Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

200127 mitch user api v2 #41

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
<sonar.projectKey>revaturelabs_rideshare-user-service</sonar.projectKey>
<sonar.organization>revaturelabs-screenforce</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.exclusion>com/revature/beans/*.java</sonar.coverage.exclusion>
<sonar.exclusions>src/main/java/com/revature/beans/**/*.java</sonar.exclusions>
<sonar.coverage.exclusions>src/main/java/com/revature/beans/**/*.java</sonar.coverage.exclusions>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -126,6 +127,12 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<!-- <version>1.1.1</version> -->
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/revature/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import com.revature.services.DistanceService;


/**
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/revature/advice/ExceptionHandlerAdvice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.revature.advice;

import org.jboss.logging.Logger;
import org.jboss.logging.Logger.Level;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpClientErrorException;

import com.revature.exceptions.InvalidCredentialsException;

@RestControllerAdvice
public class ExceptionHandlerAdvice {
private static Logger logger = Logger.getLogger(ExceptionHandlerAdvice.class);


@ExceptionHandler(HttpClientErrorException.class)
public ResponseEntity<String> handleClientError(HttpClientErrorException e) {
logger.log(Level.TRACE, e.getMessage(), e);
return ResponseEntity
.status(e.getStatusCode())
.body(e.getMessage());
}

@ExceptionHandler(InvalidCredentialsException.class)
public ResponseEntity<String> handleInvalidCredentials(InvalidCredentialsException e) {
return ResponseEntity
.status(HttpStatus.UNAUTHORIZED)
.body("Invalid username or password");
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/revature/advice/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Package that contains all advising classes
*/

package com.revature.advice;
1 change: 0 additions & 1 deletion src/main/java/com/revature/beans/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.springframework.stereotype.Component;


import org.springframework.stereotype.Component;

@Component
@Entity
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/com/revature/beans/dtos/LoginRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.revature.beans.dtos;

import java.util.Arrays;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

public class LoginRequest {
@NotBlank(message="Username is required")
private String username;

@Size(min=1, message="Password is required.")
@NotNull
private char[] password;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public char[] getPassword() {
return password;
}

public void setPassword(char[] password) {
this.password = password;
}

@Override
public String toString() {
return "LoginRequest [username=" + username + ", password=" + Arrays.toString(password) + "]";
}

public LoginRequest(String username, char[] password) {
super();
this.username = username;
this.password = password;
}

public LoginRequest() {
super();
}

}
Loading