Skip to content

Commit

Permalink
apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nenaraab committed Jan 8, 2020
1 parent 9470ad8 commit 79ab0d3
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public TokenExtractor getTokenExtractor() {

@Override
protected Validator<Token> createTokenValidator() {
return JwtValidatorBuilder
.getInstance(Environments.getCurrent().getIasConfiguration())
.withOAuth2TokenKeyService(tokenKeyService)
.withOidcConfigurationService(oidcConfigurationService)
.build();
return JwtValidatorBuilder
.getInstance(Environments.getCurrent().getIasConfiguration())
.withOAuth2TokenKeyService(tokenKeyService)
.withOidcConfigurationService(oidcConfigurationService)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ private TokenAuthenticationResult() {
// use static create methods
}


/**
* Creates an unauthenticated result with a reason.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public TokenExtractor getTokenExtractor() {

@Override
protected Validator<Token> 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 {
Expand All @@ -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<String> scopes = token.getClaimAsStringList(TokenClaims.XSUAA.SCOPES);
List<String> translatedScopes = new XsuaaScopeTranslator().translateToLocalScope(scopes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ private String convertToLocalScope(String scope) {
return matcher.group(matcher.groupCount());
}
return scope;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ private TokenAuthenticator createAuthenticator(ValidationResult validationResult
Validator<Token> tokenValidator = (TOKEN) -> validationResult;
return new AbstractTokenAuthenticator() {

@Override public TokenExtractor getTokenExtractor() {
@Override
public TokenExtractor getTokenExtractor() {
return tokenExtractor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void translateToLocalScope_doesNotTouchLocalScopedEntries() {

@Test
public void translateToLocalScope_nothingToTranslate_returnsSameScope() {
List<String> scope = newArrayList( "Display");
List<String> scope = newArrayList("Display");

List<String> translatedScope = cut.translateToLocalScope(scope);

Expand All @@ -52,6 +52,7 @@ public void translateToLocalScope_doesNotTouchNonGlobalScopedEntries() {

assertThat(translatedScope).containsSequence(scope);
}

@Test
public void translateToLocalScope_scopeContainsDotAndUnderscore() {
List<String> scope = newArrayList("my_AppId.new!t1785.Read.Context", "sub.myAppid!b13.Write.Context");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ public void toString_containsValidatorName() {
}

private class MyTokenValidator implements Validator<Token> {
@Override public ValidationResult validate(Token token) {
@Override
public ValidationResult validate(Token token) {
return ValidationResults.createValid();
}

}

private Validator<Token> validValidator() {
return (obj) -> ValidationResults.createValid();
}
Expand Down

0 comments on commit 79ab0d3

Please sign in to comment.