Skip to content

Commit

Permalink
Merge pull request #8 from gipo999/fix-lint-issues
Browse files Browse the repository at this point in the history
Fix lint issues
  • Loading branch information
gipo355 authored May 30, 2024
2 parents 26c601e + 7fbcf81 commit bb4284f
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 31 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
# tags: ghcr.io/${{ github.repository_owner }}/its-battistar-express:latest
# TODO: tag with release version
# tags: ${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
# TODO: add latest tag
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
Expand Down
7 changes: 0 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

FROM eclipse-temurin:21 as BUILD_IMAGE

# TODO: fix label
# LABEL org.opencontainers.image.source https://github.com/gipo355/template-fastify

# TODO: provide watch mode for development
# the cmd is ./gradlew war on file change
# which outputs to build/libs/*.war

# VULN: should probably not run as root

# VULN: should probably move to alpine, preferably embedding tomcat in the app
Expand Down
10 changes: 4 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ dependencies {

rewrite("org.openrewrite.recipe:rewrite-java-security:2.8.1")

// app
implementation(group: 'org.slf4j', name: 'slf4j-api', version: '2+')

// NOTE: why require tomcat 9? why is this a dependency if it's a war to be deployed on an external tomcat?
compileOnly(group: 'org.apache.tomcat', name: 'tomcat-catalina', version: "${TOMCAT_VERSION}")

implementation('javax.xml.bind:jaxb-api:2.3.1')
Expand Down Expand Up @@ -225,10 +223,10 @@ jacocoTestReport {
}
}


// war {
// dependsOn 'test'
// }
war {
dependsOn 'check'
dependsOn 'test'
}

task cleanEclipse(type: Delete, overwrite: true) {
delete '.project'
Expand Down
9 changes: 9 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## MULTI STAGE

FROM tomcat:9-jdk21-temurin-jammy

COPY build/libs/* /usr/local/tomcat/webapps

EXPOSE ${PORT}

CMD ["catalina.sh", "run"]
7 changes: 0 additions & 7 deletions docker/builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ FROM eclipse-temurin:21

# TODO: must provide gradle otherwise it downloads every restart??

# TODO: fix label
# LABEL org.opencontainers.image.source https://github.com/gipo355/template-fastify

# TODO: provide watch mode for development
# the cmd is ./gradlew war on file change
# which outputs to build/libs/*.war

# VULN: should probably not run as root

# initialize defaults for overriding through --env
Expand Down
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 bb4284f

Please sign in to comment.