Skip to content

Commit

Permalink
Fix format and add missing final
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Mar 15, 2024
1 parent adb71f8 commit f68fb13
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ public class LdapConfiguration
private Integer poolMinIdle;
private boolean poolTestOnBorrow;

public LdapConfiguration(String ldapHost, Integer ldapPort, boolean useTls, boolean useSsl, String ldapAdminBindDn,
String ldapUserBaseDn, String ldapUserSearch, String ldapGroupMemberAttribute,
String ldapAdminPassword, String ldapTrustStorePath, String ldapTrustStorePassword,
Integer poolMaxIdle, Integer poolMaxTotal, Integer poolMinIdle, boolean poolTestOnBorrow)
public LdapConfiguration(
String ldapHost,
Integer ldapPort,
boolean useTls,
boolean useSsl,
String ldapAdminBindDn,
String ldapUserBaseDn,
String ldapUserSearch,
String ldapGroupMemberAttribute,
String ldapAdminPassword,
String ldapTrustStorePath,
String ldapTrustStorePassword,
Integer poolMaxIdle,
Integer poolMaxTotal,
Integer poolMinIdle,
boolean poolTestOnBorrow)
{
this.ldapHost = ldapHost;
this.ldapPort = ldapPort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public class GatewayWebAppResource
private final ResourceGroupsManager resourceGroupsManager;

@Inject
public GatewayWebAppResource(GatewayBackendManager gatewayBackendManager, QueryHistoryManager queryHistoryManager,
BackendStateManager backendStateManager, ResourceGroupsManager resourceGroupsManager)
public GatewayWebAppResource(
GatewayBackendManager gatewayBackendManager,
QueryHistoryManager queryHistoryManager,
BackendStateManager backendStateManager,
ResourceGroupsManager resourceGroupsManager)
{
this.gatewayBackendManager = requireNonNull(gatewayBackendManager, "gatewayBackendManager is null");
this.queryHistoryManager = requireNonNull(queryHistoryManager, "queryHistoryManager is null");
Expand Down Expand Up @@ -105,8 +108,7 @@ public Response getAllBackends()
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/findQueryHistory")
public Response findQueryHistory(QueryHistoryRequest query,
@Context SecurityContext securityContext)
public Response findQueryHistory(QueryHistoryRequest query, @Context SecurityContext securityContext)
{
LbPrincipal principal = (LbPrincipal) securityContext.getUserPrincipal();
String[] roles = principal.getMemberOf().orElse("").split("_");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public List<String> processPagePermissions(List<String> roles)
}
}
return roles.stream()
.flatMap(role -> Stream.of(pagePermissions.get(role).split("_")))
.distinct().toList();
.flatMap(role -> Stream.of(pagePermissions.get(role).split("_")))
.distinct().toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public final class LbTokenUtil
* Cookie key to pass the token.
*/

private LbTokenUtil()
{
}
private LbTokenUtil() {}

public static boolean validateToken(String idToken, RSAPublicKey publicKey, String issuer, Optional<List<String>> audiences)
{
Expand All @@ -45,9 +43,7 @@ public static boolean validateToken(String idToken, RSAPublicKey publicKey, Stri
}

Algorithm algorithm = Algorithm.RSA256(publicKey, null);
Verification verification =
JWT.require(algorithm)
.withIssuer(issuer);
Verification verification = JWT.require(algorithm).withIssuer(issuer);

audiences.ifPresent(auds -> verification.withAnyOfAudience(auds.toArray(new String[0])));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class MultiReadHttpServletRequest
extends HttpServletRequestWrapper
{
private byte[] content;
private final byte[] content;
private final Map<String, String> headerMap = new HashMap<>();

public static void copy(InputStream in, OutputStream out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void main(String[] args)
mysql.setPortBindings(List.of("3306:3306"));
mysql.start();

HaGatewayLauncher.main(new String[]{"server", "gateway-ha/gateway-ha-config.yml"});
HaGatewayLauncher.main(new String[] {"server", "gateway-ha/gateway-ha-config.yml"});

log.info("======== SERVER STARTED ========");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ public class TestLbTokenUtil
public void setup()
{
lbKeyProvider = new LbKeyProvider(new SelfSignKeyPairConfiguration(
requireNonNull(getClass().getClassLoader().getResource(rsaPrivateKey)).getFile(),
requireNonNull(getClass().getClassLoader().getResource(rsaPublicKey)).getFile()));
requireNonNull(getClass().getClassLoader().getResource(rsaPrivateKey)).getFile(),
requireNonNull(getClass().getClassLoader().getResource(rsaPublicKey)).getFile()));
Map<String, Object> headers = java.util.Map.of("alg", "RS256");
Algorithm algorithm = Algorithm.RSA256(lbKeyProvider.getRsaPublicKey(),
lbKeyProvider.getRsaPrivateKey());
idToken = JWT.create()
.withHeader(headers)
.withIssuer(SessionCookie.SELF_ISSUER_ID)
.withSubject("test")
.withAudience("test.com")
.sign(algorithm);
.withHeader(headers)
.withIssuer(SessionCookie.SELF_ISSUER_ID)
.withSubject("test")
.withAudience("test.com")
.sign(algorithm);
jwt = JWT.decode(idToken);
}

Expand Down

0 comments on commit f68fb13

Please sign in to comment.