Java Code Examples for io.pivotal.cfenv.core.CfCredentials#getString()

The following examples show how to use io.pivotal.cfenv.core.CfCredentials#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CfSingleSignOnProcessor.java    From java-cfenv with Apache License 2.0 6 votes vote down vote up
@Override
public void process(CfCredentials cfCredentials, Map<String, Object> properties) {
    String clientId = cfCredentials.getString("client_id");
    String clientSecret = cfCredentials.getString("client_secret");
    String authDomain = cfCredentials.getString("auth_domain");
    String issuer = fromAuthDomain(authDomain);

    properties.put(SSO_SERVICE, authDomain);
    properties.put(SPRING_SECURITY_CLIENT + ".provider." + PROVIDER_ID + ".issuer-uri", issuer + "/oauth/token");
    properties.put(SPRING_SECURITY_CLIENT + ".provider." + PROVIDER_ID + ".authorization-uri", authDomain + "/oauth/authorize");

    ArrayList<String> grantTypes = (ArrayList<String>) cfCredentials.getMap().get("grant_types");
    if (grantTypes != null && isAuthCodeAndClientCreds(grantTypes)) {
        mapBasicClientProperties(properties, AUTHCODE_CLIENT_REGISTRATION_ID, clientId, clientSecret);
        properties.put(SPRING_SECURITY_CLIENT + ".registration." + AUTHCODE_CLIENT_REGISTRATION_ID + ".authorization-grant-type", AUTHORIZATION_CODE);

        mapBasicClientProperties(properties, CLIENTCRED_CLIENT_REGISTRATION_ID, clientId, clientSecret);
        properties.put(SPRING_SECURITY_CLIENT + ".registration." + CLIENTCRED_CLIENT_REGISTRATION_ID + ".authorization-grant-type", CLIENT_CREDENTIALS);
    } else if (grantTypes != null && grantTypes.size() == 1) { // if one grant type
        mapBasicClientProperties(properties, BASE_CLIENT_REGISTRATION_ID, clientId, clientSecret);
        String grantType = grantTypes.get(0);
        properties.put(SPRING_SECURITY_CLIENT + ".registration." + BASE_CLIENT_REGISTRATION_ID + ".authorization-grant-type", grantType);
    } else { // if grant type is empty, invalid combo, or more than 2 grant types
        mapBasicClientProperties(properties, BASE_CLIENT_REGISTRATION_ID, clientId, clientSecret);
    }
}
 
Example 2
Source File: CfSingleSignOnLegacyProcessor.java    From java-cfenv with Apache License 2.0 6 votes vote down vote up
@Override
public void process(CfCredentials cfCredentials, Map<String, Object> properties) {
	String clientId = cfCredentials.getString("client_id");
	String clientSecret = cfCredentials.getString("client_secret");
	String authDomain = cfCredentials.getString("auth_domain");

	properties.put("security.oauth2.client.clientId", clientId);
	properties.put("security.oauth2.client.clientSecret", clientSecret);
	properties.put("security.oauth2.client.accessTokenUri",
			authDomain + "/oauth/token");
	properties.put("security.oauth2.client.userAuthorizationUri",
			authDomain + "/oauth/authorize");
	properties.put("ssoServiceUrl", authDomain);
	properties.put("security.oauth2.resource.userInfoUri",
			authDomain + "/userinfo");
	properties.put("security.oauth2.resource.tokenInfoUri",
			authDomain + "/check_token");
	properties.put("security.oauth2.resource.jwk.key-set-uri",
			authDomain + "/token_keys");
}
 
Example 3
Source File: CfSpringCloudConfigClientProcessor.java    From java-cfenv with Apache License 2.0 5 votes vote down vote up
@Override
public void process(CfCredentials cfCredentials, Map<String, Object> properties) {
	String uri = cfCredentials.getUri();
	String clientId = cfCredentials.getString("client_id");
	String clientSecret = cfCredentials.getString("client_secret");
	String accessTokenUri = cfCredentials.getString("access_token_uri");

	properties.put("spring.cloud.config.uri", uri);
	properties.put("spring.cloud.config.client.oauth2.clientId", clientId);
	properties.put("spring.cloud.config.client.oauth2.clientSecret", clientSecret);
	properties.put("spring.cloud.config.client.oauth2.accessTokenUri", accessTokenUri);
}
 
Example 4
Source File: CfEurekaClientProcessor.java    From java-cfenv with Apache License 2.0 5 votes vote down vote up
@Override
public void process(CfCredentials cfCredentials, Map<String, Object> properties) {
    String uri = cfCredentials.getUri();
    String clientId = cfCredentials.getString("client_id");
    String clientSecret = cfCredentials.getString("client_secret");
    String accessTokenUri = cfCredentials.getString("access_token_uri");

    properties.put("eureka.client.serviceUrl.defaultZone", uri + "/eureka/");
    properties.put("eureka.client.region", "default");
    properties.put("eureka.client.oauth2.client-id", clientId);
    properties.put("eureka.client.oauth2.client-secret", clientSecret);
    properties.put("eureka.client.oauth2.access-token-uri", accessTokenUri);
}