Example usage for org.springframework.security.oauth2.common AuthenticationScheme header

List of usage examples for org.springframework.security.oauth2.common AuthenticationScheme header

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.common AuthenticationScheme header.

Prototype

AuthenticationScheme header

To view the source code for org.springframework.security.oauth2.common AuthenticationScheme header.

Click Source Link

Document

Send an Authorization header.

Usage

From source file:org.cloudfoundry.identity.uaa.api.client.test.AbstractOperationTest.java

protected static void init() throws Exception {
    try {// ww  w . jav  a  2s. c  o m
        Socket test = new Socket("localhost", 8080);
        uaaRunning = true;
        test.close();
    } catch (IOException e) {
        System.err.println("UAA is not running, skip these tests");
        uaaRunning = false;
        return;
    } finally {
        String baseUrl = "http://localhost:8080/uaa";

        ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
        credentials.setAccessTokenUri(baseUrl + "/oauth/token");
        //         credentials.setAuthenticationScheme(AuthenticationScheme.header);
        credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
        credentials.setClientId("admin");
        credentials.setClientSecret("adminsecret");

        connection = UaaConnectionFactory.getConnection(new URL(baseUrl), credentials);
    }
}

From source file:com.bcknds.demo.oauth2.util.AuthenticationUtil.java

/**
 * Gets an OAuth2RestTemplate with the password configuration setup and ready to use.
 * /*from  w w w  .  ja  va 2s.  c  o m*/
 * @return
 */
public static OAuth2RestTemplate getPasswordCredentials(final String username, final String password) {
    SSLCertificateValidation.disable();
    ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setClientId(BaseTest.PASSWORD_CLIENTID);
    resource.setScope(BaseTest.PASSWORD_SCOPE);
    resource.setId(BaseTest.PASSWORD_RESOURCEID);
    resource.setUsername(username);
    resource.setPassword(password);
    resource.setClientSecret(BaseTest.PASSWORD_SECRET);
    resource.setAccessTokenUri(BaseTest.ACCESS_TOKEN_URI);
    return new OAuth2RestTemplate(resource);
}

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

public static ClientCredentialsResourceDetails getClientCredentialsResource(String url, String[] scope,
        String clientId, String clientSecret) {
    ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
    resource.setClientId(clientId);/*from www .  jav  a2 s .c o m*/
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    if (scope != null) {
        resource.setScope(Arrays.asList(scope));
    }
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(url + "/oauth/token");
    return resource;
}

From source file:org.cloudfoundry.identity.uaa.login.feature.OpenIdTokenGrantsIT.java

private ClientCredentialsResourceDetails getClientCredentialsResource(String[] scope, String clientId,
        String clientSecret) {//from www .j  a  va2  s.c o  m
    ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
    resource.setClientId(clientId);
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    if (scope != null) {
        resource.setScope(Arrays.asList(scope));
    }
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(uaaUrl + "/oauth/token");
    return resource;
}

From source file:org.cloudfoundry.client.lib.oauth2.OauthClient.java

private OAuth2ProtectedResourceDetails getResourceDetails(String username, String password, String clientId,
        String clientSecret) {//from w w  w  . ja v  a 2 s.c o m
    ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
    resource.setUsername(username);
    resource.setPassword(password);

    resource.setClientId(clientId);
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(authorizationUrl + "/oauth/token");

    return resource;
}

From source file:org.cloudfoundry.identity.uaa.integration.OpenIdTokenAuthorizationWithApprovalIntegrationTests.java

private ClientCredentialsResourceDetails getClientCredentialsResource(String[] scope, String clientId,
        String clientSecret) {//ww w .  jav  a  2  s  . c om
    ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
    resource.setClientId(clientId);
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    if (scope != null) {
        resource.setScope(Arrays.asList(scope));
    }
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(serverRunning.getBaseUrl() + "/oauth/token");
    return resource;
}

From source file:org.cloudfoundry.identity.uaa.integration.UaaTestAccounts.java

public ClientCredentialsResourceDetails getClientCredentialsResource(String clientId, String clientSecret) {
    ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
    resource.setClientId(clientId);//from w w w .  j a v  a  2s . c o  m
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    resource.setScope(Arrays.asList("read", "write", "password"));
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(server.getAccessTokenUri());
    return resource;
}

From source file:org.cloudfoundry.identity.uaa.integration.UaaTestAccounts.java

public ImplicitResourceDetails getImplicitResource(String clientPrefix, String defaultClientId,
        String defaultRedirectUri, String username, String password) {
    ImplicitResourceDetails resource = new ImplicitResourceDetails();
    String clientId = environment.getProperty(clientPrefix + ".id", defaultClientId);
    resource.setClientId(clientId);/*from   ww  w  .ja  va 2  s  .  c  o m*/
    resource.setId(clientId);
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("credentials",
            String.format("{\"username\":\"%s\",\"password\":\"%s\"}", username, password));
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(server.getAuthorizationUri());
    resource.setScope(Arrays.asList("read", "password", "openid"));
    String redirectUri = environment.getProperty(clientPrefix + ".redirect-uri", defaultRedirectUri);
    resource.setPreEstablishedRedirectUri(redirectUri);
    return resource;
}

From source file:org.cloudfoundry.identity.uaa.integration.UaaTestAccounts.java

@Override
public ResourceOwnerPasswordResourceDetails getResourceOwnerPasswordResource(String[] scope, String clientId,
        String clientSecret, String username, String password) {

    ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
    resource.setClientId(clientId);/* ww  w .  jav a2 s. c o  m*/
    resource.setClientSecret(clientSecret);
    resource.setId(clientId);
    resource.setScope(Arrays.asList(scope));
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("username", username);
    parameters.put("password", password);
    resource.setUsername(username);
    resource.setPassword(password);
    resource.setClientAuthenticationScheme(AuthenticationScheme.header);
    resource.setAccessTokenUri(server.getAccessTokenUri());
    return resource;
}