Skip to content

Commit

Permalink
apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nenaraab committed Dec 20, 2019
1 parent 2164184 commit d07f9c2
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public interface XsuaaServiceConfiguration {
*
* @return certificates
*/
//@Nullable
//String getCertificates();
// @Nullable
// String getCertificates();

/**
* Private key the certificate is signed with.
*
* @return private key
*/
//@Nullable
//String getPrivateKey();
// @Nullable
// String getPrivateKey();
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,9 @@ public String getUaaDomain() {
return uaadomain;
}

/*@Override
public String getCertificates() {
return certificates;
}
@Override
public String getPrivateKey() {
return privateKey;
}*/
/*
* @Override public String getCertificates() { return certificates; }
*
* @Override public String getPrivateKey() { return privateKey; }
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static JSONObject getJSONObjectFromTag(final JSONArray jsonArray, String
JSONArray tags = (JSONArray) binding.get(TAGS);

for (int j = 0; j < tags.size(); j++) {
boolean isApiAccessPlan = binding.getAsString("plan").equals("apiaccess");
boolean isApiAccessPlan = binding.getAsString("plan").equals("apiaccess");

if (tags.get(j).equals(tag) && !isApiAccessPlan) {
if (xsuaaBinding == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
public interface Token extends UserDetails {

/**
* Use {@link com.sap.cloud.security.xsuaa.client.OAuth2TokenServiceConstants#GRANT_TYPE_CLIENT_CREDENTIALS} instead
* Use
* {@link com.sap.cloud.security.xsuaa.client.OAuth2TokenServiceConstants#GRANT_TYPE_CLIENT_CREDENTIALS}
* instead
*/
@Deprecated
static final String GRANTTYPE_CLIENTCREDENTIAL = "client_credentials";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ public String getUaaDomain() {
return uaaDomain;
}

/*@Nullable
@Override
public String getCertificates() {
return null;
}
@Nullable
@Override
public String getPrivateKey() {
return null;
}*/
/*
* @Nullable
*
* @Override public String getCertificates() { return null; }
*
* @Nullable
*
* @Override public String getPrivateKey() { return null; }
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

public class XsuaaServicesParserTest {

@Test
public void ignoreApiAccessPlan() throws IOException {
String vcapMultipleBindings = IOUtils.resourceToString("/vcap_multipleBindings.json", Charset.forName("UTF-8"));
XsuaaServicesParser cut = new XsuaaServicesParser(vcapMultipleBindings);
Properties properties = cut.parseCredentials();
assertThat(properties.getProperty("clientid")).isEqualTo("client-id");
}
@Test
public void ignoreApiAccessPlan() throws IOException {
String vcapMultipleBindings = IOUtils.resourceToString("/vcap_multipleBindings.json", Charset.forName("UTF-8"));
XsuaaServicesParser cut = new XsuaaServicesParser(vcapMultipleBindings);
Properties properties = cut.parseCredentials();
assertThat(properties.getProperty("clientid")).isEqualTo("client-id");
}

@Test(expected = IllegalStateException.class)
public void doNotAllowBrokerAndApplicationPlan() throws IOException {
String vcapMultipleBindings = IOUtils.resourceToString("/vcap_multipleBindings.json", Charset.forName("UTF-8"));
vcapMultipleBindings = vcapMultipleBindings.replace("apiaccess", "broker");
XsuaaServicesParser cut = new XsuaaServicesParser(vcapMultipleBindings);
cut.parseCredentials();
}
@Test(expected = IllegalStateException.class)
public void doNotAllowBrokerAndApplicationPlan() throws IOException {
String vcapMultipleBindings = IOUtils.resourceToString("/vcap_multipleBindings.json", Charset.forName("UTF-8"));
vcapMultipleBindings = vcapMultipleBindings.replace("apiaccess", "broker");
XsuaaServicesParser cut = new XsuaaServicesParser(vcapMultipleBindings);
cut.parseCredentials();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

public abstract class AbstractOAuth2TokenService implements OAuth2TokenService {


public AbstractOAuth2TokenService() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ OAuth2TokenResponse retrieveAccessTokenViaClientCredentialsGrant(URI tokenEndpoi
* @return the OAuth2AccessToken.
* @throws OAuth2ServiceException
* in case of an error during the http request.
* @deprecated instead use jwt bearer {{@link #retrieveAccessTokenViaJwtBearerTokenGrant(URI, ClientCredentials, String, String, Map)}}.
* @deprecated instead use jwt bearer
* {{@link #retrieveAccessTokenViaJwtBearerTokenGrant(URI, ClientCredentials, String, String, Map)}}.
*/
@Deprecated
OAuth2TokenResponse retrieveAccessTokenViaUserTokenGrant(URI tokenEndpointUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static HttpHeaders createWithAuthorizationBearerHeader(String token) {
*
* @return the HTTP headers.
*/
public static HttpHeaders createWithoutAuthorizationHeader() {
public static HttpHeaders createWithoutAuthorizationHeader() {
return createFromHeaders(createDefaultHeaders());
}

Expand All @@ -49,5 +49,4 @@ private static Map<String, String> createDefaultHeaders() {
return headers;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ public static SSLContextFactory getInstance() {
}

/**
* Creates a SSLContext which can be used to parameterize your Rest client,
* in order to support mutual TLS.
* Creates a SSLContext which can be used to parameterize your Rest client, in
* order to support mutual TLS.
*
* @param x509Certificates, you can get from your Service Configuration
* @param rsaPrivateKey, you can get from your Service Configuration
* @param x509Certificates,
* you can get from your Service Configuration
* @param rsaPrivateKey,
* you can get from your Service Configuration
* @return a new SSLContext instance
* @throws GeneralSecurityException
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ private OAuth2TokenResponse requestUserToken(XsuaaTokenFlowRequest request) thro
String refreshToken = null;
try {
boolean useJwtBearerGrant = Boolean.parseBoolean(readFromPropertyFile(FF_USE_JWT_BEARER_GRANT_TYPE));
if(useJwtBearerGrant) {
if (useJwtBearerGrant) {
/*
* As soon as JWT bearer token supports scopes, we can just use this one to get
* an user token
*/
return tokenService.retrieveAccessTokenViaJwtBearerTokenGrant(
request.getTokenEndpoint(),
new ClientCredentials(request.getClientId(), request.getClientSecret()),
token,
request.getSubdomain(),
optionalParameter);
return tokenService.retrieveAccessTokenViaJwtBearerTokenGrant(
request.getTokenEndpoint(),
new ClientCredentials(request.getClientId(), request.getClientSecret()),
token,
request.getSubdomain(),
optionalParameter);

}
OAuth2TokenResponse accessToken = tokenService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
public class HttpHeadersFactoryTest {

private static final HttpHeader ACCEPT_JSON_HEADER = new HttpHeader(ACCEPT, APPLICATION_JSON.value());
private static final HttpHeader CONTENT_TYPE_URL_ENCODED = new HttpHeader(CONTENT_TYPE, APPLICATION_FORM_URLENCODED.value());
private static final HttpHeader CONTENT_TYPE_URL_ENCODED = new HttpHeader(CONTENT_TYPE,
APPLICATION_FORM_URLENCODED.value());
private static final String TOKEN = "TOKEN CONTENT";

@Test
Expand Down

0 comments on commit d07f9c2

Please sign in to comment.