Package org.springframework.security.oauth2.provider

Examples of org.springframework.security.oauth2.provider.ClientDetails


    }
    return null;
  }

  private OAuth2AccessToken createToken(String username, String password, String clientId, String clientSecret) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();
    try {
      return provider.obtainAccessToken(resource, request);
View Full Code Here


      throw cfEx;
    }
  }

  private OAuth2AccessToken refreshToken(OAuth2AccessToken currentToken, String username, String password, String clientId, String clientSecret) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();

    return provider.refreshAccessToken(resource, currentToken.getRefreshToken(), request);
View Full Code Here

    return null;
  }

  private OAuth2AccessToken createToken(String username, String password, String clientId, String clientSecret) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();
    try {
      return provider.obtainAccessToken(resource, request);
    }
View Full Code Here

    }
  }

  private OAuth2AccessToken refreshToken(OAuth2AccessToken currentToken, String username, String password, String clientId, String clientSecret) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();

    return provider.refreshAccessToken(resource, currentToken.getRefreshToken(), request);
  }
View Full Code Here

  }

  private AccessTokenRequest createAccessTokenRequest(String username, String password) {
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("credentials", String.format("{\"username\":\"%s\",\"password\":\"%s\"}", username, password));
    AccessTokenRequest request = new DefaultAccessTokenRequest();
    request.setAll(parameters);

    return request;
  }
View Full Code Here

  }

  private AccessTokenRequest createAccessTokenRequest(String username, String password) {
    Map<String, String> parameters = new LinkedHashMap<String, String>();
    parameters.put("credentials", String.format("{\"username\":\"%s\",\"password\":\"%s\"}", username, password));
    AccessTokenRequest request = new DefaultAccessTokenRequest();
    request.setAll(parameters);

    return request;
  }
View Full Code Here

  }

  @Test
  public void tokenSavedOnLogin() throws MojoExecutionException, IOException, URISyntaxException {
    DefaultOAuth2RefreshToken refreshToken = new DefaultOAuth2RefreshToken("refreshtoken");
    DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken("accesstoken");
    accessToken.setRefreshToken(refreshToken);
    when(client.login()).thenReturn(accessToken);

    HashMap<String, Object> info = new HashMap<String, Object>(1);
    info.put("version", "2");
    when(client.getCloudInfo()).thenReturn(new CloudInfo(info));
View Full Code Here

    logout = new TestableLogout(authTokens);
  }

  @Test
  public void tokenSavedOnLogin() throws MojoExecutionException, IOException, URISyntaxException {
    DefaultOAuth2RefreshToken refreshToken = new DefaultOAuth2RefreshToken("refreshtoken");
    DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken("accesstoken");
    accessToken.setRefreshToken(refreshToken);
    when(client.login()).thenReturn(accessToken);

    HashMap<String, Object> info = new HashMap<String, Object>(1);
View Full Code Here

  private Authentication createAuthentication(JsonObject token) {
    return new PreAuthenticatedAuthenticationToken(token.get("sub").getAsString(), token, introspectionAuthorityGranter.getAuthorities(token));
  }

  private OAuth2AccessToken createAccessToken(final JsonObject token, final String tokenString) {
    OAuth2AccessToken accessToken = new OAuth2AccessTokenImpl(token, tokenString);
    return accessToken;
  }
View Full Code Here

        return false;
      }
      // create an OAuth2Authentication
      OAuth2Authentication auth = new OAuth2Authentication(createStoredRequest(tokenResponse), createAuthentication(tokenResponse));
      // create an OAuth2AccessToken
      OAuth2AccessToken token = createAccessToken(tokenResponse, accessToken);

      if (token.getExpiration().after(new Date())) {
        // Store them in the cache
        authCache.put(accessToken, new TokenCacheObject(token, auth));

        return true;
      }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.provider.ClientDetails

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.