From 79ab0d3b9f72a9f31f62a83936ff0a823b41e779 Mon Sep 17 00:00:00 2001 From: Nena Raab Date: Wed, 8 Jan 2020 11:04:06 +0100 Subject: [PATCH] apply formatting rules --- .../sap/cloud/security/test/SecurityTestRule.java | 13 ++++++------- .../sap/cloud/security/config/Environments.java | 3 ++- .../cloud/security/config/cf/CFEnvironment.java | 3 ++- .../security/servlet/IasTokenAuthenticator.java | 10 +++++----- .../servlet/TokenAuthenticationResult.java | 1 - .../security/servlet/XsuaaTokenAuthenticator.java | 14 +++++++------- .../cloud/security/token/XsuaaScopeTranslator.java | 2 +- .../security/config/cf/CFEnvironmentTest.java | 4 ++-- .../servlet/AbstractTokenAuthenticatorTest.java | 3 ++- .../cloud/security/token/ScopeTranslatorTest.java | 3 ++- .../token/validation/CombiningValidatorTest.java | 4 +++- 11 files changed, 32 insertions(+), 28 deletions(-) diff --git a/java-security-test/src/main/java/com/sap/cloud/security/test/SecurityTestRule.java b/java-security-test/src/main/java/com/sap/cloud/security/test/SecurityTestRule.java index 1bc5f1a8a..dd5f62ae4 100644 --- a/java-security-test/src/main/java/com/sap/cloud/security/test/SecurityTestRule.java +++ b/java-security-test/src/main/java/com/sap/cloud/security/test/SecurityTestRule.java @@ -75,13 +75,12 @@ public static SecurityTestRule getInstance(Service service) { /** * Specifies an embedded jetty as servlet server. It needs to be configured * before the {@link #before()} method. The application server will be started - * with default options for the given {@link Service}, - * see {@link ApplicationServerOptions#forService(Service)} for - * details. By default the servlet server will listen on a free random port. - * Use - * {@link SecurityTestRule#useApplicationServer(ApplicationServerOptions)} - * to overwrite default settings. Use {@link #getApplicationServerUri()} to - * obtain the actual port used at runtime. + * with default options for the given {@link Service}, see + * {@link ApplicationServerOptions#forService(Service)} for details. By default + * the servlet server will listen on a free random port. Use + * {@link SecurityTestRule#useApplicationServer(ApplicationServerOptions)} to + * overwrite default settings. Use {@link #getApplicationServerUri()} to obtain + * the actual port used at runtime. * * @return the rule itself. */ diff --git a/java-security/src/main/java/com/sap/cloud/security/config/Environments.java b/java-security/src/main/java/com/sap/cloud/security/config/Environments.java index 8c431e812..d3cb8739a 100644 --- a/java-security/src/main/java/com/sap/cloud/security/config/Environments.java +++ b/java-security/src/main/java/com/sap/cloud/security/config/Environments.java @@ -11,7 +11,8 @@ private Environments() { } public static Environment getCurrent() { - // TODO Kubernetes: probe in which environemt it runs currently: CF or Kubernetes, e.g. + // TODO Kubernetes: probe in which environemt it runs currently: CF or + // Kubernetes, e.g. // if(System.getenv("VCAP_SERVICES") != null) { return cfEnvironment; } diff --git a/java-security/src/main/java/com/sap/cloud/security/config/cf/CFEnvironment.java b/java-security/src/main/java/com/sap/cloud/security/config/cf/CFEnvironment.java index e17df4bce..ff73363e3 100644 --- a/java-security/src/main/java/com/sap/cloud/security/config/cf/CFEnvironment.java +++ b/java-security/src/main/java/com/sap/cloud/security/config/cf/CFEnvironment.java @@ -46,7 +46,8 @@ public OAuth2ServiceConfiguration getXsuaaConfiguration() { @Override public OAuth2ServiceConfiguration getIasConfiguration() { // TODO IAS - // return loadAll(IAS).stream().filter(Objects::nonNull).findFirst().orElse(null); + // return + // loadAll(IAS).stream().filter(Objects::nonNull).findFirst().orElse(null); throw new UnsupportedOperationException("Bindings of IAS Identity Service is not yet supported."); } diff --git a/java-security/src/main/java/com/sap/cloud/security/servlet/IasTokenAuthenticator.java b/java-security/src/main/java/com/sap/cloud/security/servlet/IasTokenAuthenticator.java index b6bc091ed..034c571e8 100644 --- a/java-security/src/main/java/com/sap/cloud/security/servlet/IasTokenAuthenticator.java +++ b/java-security/src/main/java/com/sap/cloud/security/servlet/IasTokenAuthenticator.java @@ -22,11 +22,11 @@ public TokenExtractor getTokenExtractor() { @Override protected Validator createTokenValidator() { - return JwtValidatorBuilder - .getInstance(Environments.getCurrent().getIasConfiguration()) - .withOAuth2TokenKeyService(tokenKeyService) - .withOidcConfigurationService(oidcConfigurationService) - .build(); + return JwtValidatorBuilder + .getInstance(Environments.getCurrent().getIasConfiguration()) + .withOAuth2TokenKeyService(tokenKeyService) + .withOidcConfigurationService(oidcConfigurationService) + .build(); } } diff --git a/java-security/src/main/java/com/sap/cloud/security/servlet/TokenAuthenticationResult.java b/java-security/src/main/java/com/sap/cloud/security/servlet/TokenAuthenticationResult.java index a60c185f6..8ac295d5e 100644 --- a/java-security/src/main/java/com/sap/cloud/security/servlet/TokenAuthenticationResult.java +++ b/java-security/src/main/java/com/sap/cloud/security/servlet/TokenAuthenticationResult.java @@ -22,7 +22,6 @@ private TokenAuthenticationResult() { // use static create methods } - /** * Creates an unauthenticated result with a reason. * diff --git a/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java b/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java index e10e7d367..36abd4d97 100644 --- a/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java +++ b/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java @@ -29,12 +29,12 @@ public TokenExtractor getTokenExtractor() { @Override protected Validator createTokenValidator() { - return JwtValidatorBuilder - .getInstance(Environments.getCurrent().getXsuaaConfiguration()) - .withOAuth2TokenKeyService(tokenKeyService) - .withOidcConfigurationService(oidcConfigurationService) - .configureAnotherServiceInstance(getOtherXsuaaServiceConfiguration()) - .build(); + return JwtValidatorBuilder + .getInstance(Environments.getCurrent().getXsuaaConfiguration()) + .withOAuth2TokenKeyService(tokenKeyService) + .withOidcConfigurationService(oidcConfigurationService) + .configureAnotherServiceInstance(getOtherXsuaaServiceConfiguration()) + .build(); } private class XsuaaTokenExtractor implements TokenExtractor { @@ -59,7 +59,7 @@ private OAuth2ServiceConfiguration getOtherXsuaaServiceConfiguration() { @Override protected TokenAuthenticationResult authenticated(Token token) { if (token.getService() != Service.XSUAA) { - return super.authenticated(token); + return super.authenticated(token); } List scopes = token.getClaimAsStringList(TokenClaims.XSUAA.SCOPES); List translatedScopes = new XsuaaScopeTranslator().translateToLocalScope(scopes); diff --git a/java-security/src/main/java/com/sap/cloud/security/token/XsuaaScopeTranslator.java b/java-security/src/main/java/com/sap/cloud/security/token/XsuaaScopeTranslator.java index 8d7745a8a..16d4274b8 100644 --- a/java-security/src/main/java/com/sap/cloud/security/token/XsuaaScopeTranslator.java +++ b/java-security/src/main/java/com/sap/cloud/security/token/XsuaaScopeTranslator.java @@ -26,6 +26,6 @@ private String convertToLocalScope(String scope) { return matcher.group(matcher.groupCount()); } return scope; - } + } } diff --git a/java-security/src/test/java/com/sap/cloud/security/config/cf/CFEnvironmentTest.java b/java-security/src/test/java/com/sap/cloud/security/config/cf/CFEnvironmentTest.java index 21350de77..a2ea99c52 100644 --- a/java-security/src/test/java/com/sap/cloud/security/config/cf/CFEnvironmentTest.java +++ b/java-security/src/test/java/com/sap/cloud/security/config/cf/CFEnvironmentTest.java @@ -82,7 +82,7 @@ public void getConfigurationOfOneXsuaaInstance() { assertThat(cut.getNumberOfXsuaaConfigurations()).isEqualTo(1); assertThat(cut.getXsuaaConfigurationForTokenExchange()).isSameAs(cut.getXsuaaConfiguration()); - //assertThat(cut.getIasConfiguration()).isNull(); // TODO IAS + // assertThat(cut.getIasConfiguration()).isNull(); // TODO IAS } @Test @@ -135,6 +135,6 @@ public void getServiceConfiguration_vcapServicesNotAvailable_returnsNull() { assertThat(cut.getXsuaaConfiguration()).isNull(); assertThat(CFEnvironment.getInstance().getXsuaaConfiguration()).isNull(); - //assertThat(cut.getIasConfiguration()).isNull(); // TODO IAS + // assertThat(cut.getIasConfiguration()).isNull(); // TODO IAS } } \ No newline at end of file diff --git a/java-security/src/test/java/com/sap/cloud/security/servlet/AbstractTokenAuthenticatorTest.java b/java-security/src/test/java/com/sap/cloud/security/servlet/AbstractTokenAuthenticatorTest.java index 0351cad57..1b78692a2 100644 --- a/java-security/src/test/java/com/sap/cloud/security/servlet/AbstractTokenAuthenticatorTest.java +++ b/java-security/src/test/java/com/sap/cloud/security/servlet/AbstractTokenAuthenticatorTest.java @@ -80,7 +80,8 @@ private TokenAuthenticator createAuthenticator(ValidationResult validationResult Validator tokenValidator = (TOKEN) -> validationResult; return new AbstractTokenAuthenticator() { - @Override public TokenExtractor getTokenExtractor() { + @Override + public TokenExtractor getTokenExtractor() { return tokenExtractor; } diff --git a/java-security/src/test/java/com/sap/cloud/security/token/ScopeTranslatorTest.java b/java-security/src/test/java/com/sap/cloud/security/token/ScopeTranslatorTest.java index 5b643edf5..8820377d9 100644 --- a/java-security/src/test/java/com/sap/cloud/security/token/ScopeTranslatorTest.java +++ b/java-security/src/test/java/com/sap/cloud/security/token/ScopeTranslatorTest.java @@ -37,7 +37,7 @@ public void translateToLocalScope_doesNotTouchLocalScopedEntries() { @Test public void translateToLocalScope_nothingToTranslate_returnsSameScope() { - List scope = newArrayList( "Display"); + List scope = newArrayList("Display"); List translatedScope = cut.translateToLocalScope(scope); @@ -52,6 +52,7 @@ public void translateToLocalScope_doesNotTouchNonGlobalScopedEntries() { assertThat(translatedScope).containsSequence(scope); } + @Test public void translateToLocalScope_scopeContainsDotAndUnderscore() { List scope = newArrayList("my_AppId.new!t1785.Read.Context", "sub.myAppid!b13.Write.Context"); diff --git a/java-security/src/test/java/com/sap/cloud/security/token/validation/CombiningValidatorTest.java b/java-security/src/test/java/com/sap/cloud/security/token/validation/CombiningValidatorTest.java index 3d81b4a6d..2074ff84c 100644 --- a/java-security/src/test/java/com/sap/cloud/security/token/validation/CombiningValidatorTest.java +++ b/java-security/src/test/java/com/sap/cloud/security/token/validation/CombiningValidatorTest.java @@ -103,11 +103,13 @@ public void toString_containsValidatorName() { } private class MyTokenValidator implements Validator { - @Override public ValidationResult validate(Token token) { + @Override + public ValidationResult validate(Token token) { return ValidationResults.createValid(); } } + private Validator validValidator() { return (obj) -> ValidationResults.createValid(); }