fix code smells

This commit is contained in:
verboomp
2026-01-21 09:40:43 +01:00
parent 2c14caa6ca
commit 47ee7c3c25
5 changed files with 12 additions and 29 deletions

View File

@@ -2,7 +2,6 @@ package marketing.heyday.hartmann.fotodocumentation.core.utils;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.Principal; import java.security.Principal;
import java.util.Optional; import java.util.Optional;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
@@ -42,14 +41,6 @@ public class LoginUtils {
return authenticate(userPass._1, userPass._2); return authenticate(userPass._1, userPass._2);
} }
public Optional<String> getSecurityToken(HttpServletRequest httpServletRequest) {
Optional<String[]> headerOpt = extractAuthHeader(httpServletRequest);
if (headerOpt.isPresent() && headerOpt.get().length > 2) {
return Optional.ofNullable(headerOpt.get()[2]);
}
return Optional.empty();
}
private Optional<SecurityIdentity> authenticate(String username, String password) { private Optional<SecurityIdentity> authenticate(String username, String password) {
try { try {
Principal principal = new NamePrincipal(username); Principal principal = new NamePrincipal(username);

View File

@@ -55,7 +55,7 @@ public class CustomerPictureResource {
Optional<SecurityIdentity> identity = loginUtils.authenticate(httpServletRequest); Optional<SecurityIdentity> identity = loginUtils.authenticate(httpServletRequest);
if (identity.isEmpty()) { if (identity.isEmpty()) {
LOG.debug("identity empty login invalid"); LOG.debug("identity empty login invalid");
return Response.status(401).build(); return Response.status(Status.UNAUTHORIZED).build();
} }

View File

@@ -41,8 +41,7 @@ public abstract class AbstractRestTest extends AbstractTest {
protected String getAuthorization(String user, String pass) { protected String getAuthorization(String user, String pass) {
String auth = user + ":" + pass; String auth = user + ":" + pass;
String encoded = Base64.getEncoder().encodeToString(auth.getBytes()); String encoded = Base64.getEncoder().encodeToString(auth.getBytes());
String authorization = "Basic " + encoded; return "Basic " + encoded;
return authorization;
} }
protected String getBearerToken(String authorization) { protected String getBearerToken(String authorization) {

View File

@@ -31,7 +31,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
* created: 13 Nov 2024 * created: 13 Nov 2024
*/ */
public class AbstractTest { public abstract class AbstractTest {
private static final Log LOG = LogFactory.getLog(AbstractTest.class); private static final Log LOG = LogFactory.getLog(AbstractTest.class);
public String deploymentURL = "http://localhost:8180/"; public String deploymentURL = "http://localhost:8180/";
@@ -179,11 +179,4 @@ public class AbstractTest {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
/*
public static void main(String[] args) throws SQLException {
try (var connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/skillmatrix", "skillmatrix", "skillmatrix")) {
initDb(connection, "dataset.xml");
}
}*/
} }