Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gipo355 committed May 30, 2024
1 parent 4d8041a commit 7fbcf81
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
import javax.ws.rs.ApplicationPath;

/**
* @author Pavel Bucek
* Main application class.
*
* @author Pavel Bucek.
*/
@ApplicationPath("/")
public class Application extends javax.ws.rs.core.Application {
public class App extends javax.ws.rs.core.Application {

/**
* Set of classes that are root resources.
*
* @return set of classes
*/
@Override
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<Class<?>>();
final Set<Class<?>> classes = new HashSet<>();

// register root resource
classes.add(BaseService.class);
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/smi/xxx/rest/base/BaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.ws.rs.core.Response;
import org.glassfish.jersey.media.multipart.FormDataParam;

/** Base service. */
@Path("/base")
public class BaseService {

Expand All @@ -27,7 +28,7 @@ public Response get() {
public Response login(
@FormParam("username") String username, @FormParam("password") String password) {

return Response.ok("Bearer " + username + "__" + password).build();
return Response.ok(createToken(username, password)).build();
} // login

@POST
Expand All @@ -37,7 +38,7 @@ public Response login(
public Response loginFormData(
@FormDataParam("username") String username, @FormDataParam("password") String password) {

return Response.ok("Bearer " + username + "__" + password).build();
return Response.ok(createToken(username, password)).build();
} // login

@POST
Expand All @@ -46,7 +47,7 @@ public Response loginFormData(
@Path("/login")
public Response loginByModel(LoginModel datas) {

return Response.ok("Bearer " + datas.username + "__" + datas.password).build();
return Response.ok(createToken(datas.username, datas.password)).build();
} // loginByModel

@POST
Expand All @@ -55,4 +56,8 @@ public Response health() {

return Response.ok().build();
} // health

private String createToken(String username, String password) {
return "Bearer " + username + "__" + password;
}
} // LoginService
1 change: 1 addition & 0 deletions src/main/java/com/smi/xxx/rest/base/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

/** CORS Filter. */
@Provider
public class CorsFilter implements Filter, ContainerResponseFilter, ExceptionMapper<Throwable> {

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/smi/xxx/rest/base/JwtFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;

/** JWT Filter. */
public class JwtFilter implements Filter {

@Override
Expand All @@ -28,7 +29,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
} else {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

return;
// return; sonarlint
} // try - catch
} // doFilter
} // JwtFilter
1 change: 1 addition & 0 deletions src/main/java/com/smi/xxx/rest/base/LoginModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.smi.xxx.rest.base;

/** Login Model. */
public class LoginModel {
String username;
String password;
Expand Down

0 comments on commit 7fbcf81

Please sign in to comment.