Example usage for org.springframework.security.oauth2.client OAuth2RestTemplate OAuth2RestTemplate

List of usage examples for org.springframework.security.oauth2.client OAuth2RestTemplate OAuth2RestTemplate

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.client OAuth2RestTemplate OAuth2RestTemplate.

Prototype

public OAuth2RestTemplate(OAuth2ProtectedResourceDetails resource) 

Source Link

Usage

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getOAuth2RestTemplateForUaaAdmin() {
    if (this.uaaAdminTemplate == null) {
        ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
        resource.setAccessTokenUri(this.uaaTokenUrl);
        resource.setClientId("admin");
        resource.setClientSecret("adminsecret");
        this.uaaAdminTemplate = new OAuth2RestTemplate(resource);
        this.uaaAdminTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
    }//from w  w w . j av a2 s  .c o  m

    return this.uaaAdminTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getOAuth2RestTemplateForClient(final String tokenUrl, final String clientId,
        final String clientSecret) {
    ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
    resource.setAccessTokenUri(tokenUrl);
    resource.setClientId(clientId);/* ww  w.  j a  v a 2s  .co m*/
    resource.setClientSecret(clientSecret);
    OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resource);
    restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());

    return restTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getACSZone2Template() {
    if (this.rocketACSTemplate == null) {
        this.rocketACSTemplate = new OAuth2RestTemplate(getZone2RocketClient());

    }//w w w .  j a  v a  2 s  .c o  m
    return this.rocketACSTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

/**
 * The client used by this template has acs.zones.admin scope from a zone specific issuer.
 * /*from  www.jav a 2s.  co  m*/
 * @return
 */
public OAuth2RestTemplate getACSZone2RogueTemplate() {
    if (this.acsZone2RogueTemplate == null) {
        this.acsZone2RogueTemplate = new OAuth2RestTemplate(getZone2RogueClient());
    }

    return this.acsZone2RogueTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getACSZone1Template() {
    if (this.apmACSTemplate == null) {
        this.apmACSTemplate = new OAuth2RestTemplate(getZone1ApmClient());
    }/*from  w w w  .j a v a 2s. co  m*/

    return this.apmACSTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getACSTemplateWithReadOnlyPolicyAccess() {
    if (this.readOnlyPolicyACSTemplate == null) {
        this.readOnlyPolicyACSTemplate = new OAuth2RestTemplate(getUserWithReadOnlyPolicyAccess());
    }/*from w  w w  . j ava 2 s  .  c  o  m*/

    return this.readOnlyPolicyACSTemplate;
}

From source file:com.ge.predix.test.utils.ACSRestTemplateFactory.java

public OAuth2RestTemplate getACSTemplateWithNoAcsScope() {
    return new OAuth2RestTemplate(getUserWithoutAnyAcsScope());
}

From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java

public static RestTemplate getClientCredentialsTemplate(ClientCredentialsResourceDetails details) {
    RestTemplate client = new OAuth2RestTemplate(details);
    client.setRequestFactory(new StatelessRequestFactory());
    client.setErrorHandler(new OAuth2ErrorHandler(details) {
        // Pass errors through in response entity for status code analysis
        @Override//ww  w  .ja v a2s.co m
        public boolean hasError(ClientHttpResponse response) throws IOException {
            return false;
        }

        @Override
        public void handleError(ClientHttpResponse response) throws IOException {
        }
    });
    return client;
}

From source file:org.opentestsystem.ap.iat.filter.AppendSessionZuulPreFilter.java

private OAuth2RestTemplate newRestTemplate() {
    return new OAuth2RestTemplate(oauth2ProtectedResourceDetails());
}