Package org.springframework.security.oauth2.provider.approval

Examples of org.springframework.security.oauth2.provider.approval.UserApprovalHandler


    HttpEntity<Map> httpEntity = new HttpEntity<Map>(body, headers);
    restTemplate.put(authorizationUrl + "/User/{id}/password", httpEntity, userId);
  }

  protected ResourceOwnerPasswordAccessTokenProvider createResourceOwnerPasswordAccessTokenProvider() {
    ResourceOwnerPasswordAccessTokenProvider resourceOwnerPasswordAccessTokenProvider = new ResourceOwnerPasswordAccessTokenProvider();
    resourceOwnerPasswordAccessTokenProvider.setRequestFactory(restTemplate.getRequestFactory()); //copy the http proxy along
    return resourceOwnerPasswordAccessTokenProvider;
  }
View Full Code Here


    return request;
  }

  private OAuth2ProtectedResourceDetails getResourceDetails(String username, String password, String clientId, String clientSecret) {
    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;
  }
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

  }

  public DefaultOAuth2AccessToken getToken(HashMap<String, String> target) {
    final String token = target.get(ACCESS_TOKEN_KEY);
    final String[] tokens = token.split(" ");
    return new DefaultOAuth2AccessToken(tokens[1]);
  }
View Full Code Here

    if (targetInfo == null) {
      return null;
    }

    DefaultOAuth2RefreshToken refreshToken = targetInfos.getRefreshToken(targetInfo);
    DefaultOAuth2AccessToken token = targetInfos.getToken(targetInfo);
    token.setRefreshToken(refreshToken);

    return token;
  }
View Full Code Here

  @Override
  public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
    OAuth2AccessToken token = super.grant(grantType, tokenRequest);
    if (token != null) {
      DefaultOAuth2AccessToken norefresh = new DefaultOAuth2AccessToken(token);
      // The spec says that client credentials should not be allowed to get a refresh token
      if (!allowRefresh) {
        norefresh.setRefreshToken(null);
      }
      token = norefresh;
    }
    return token;
  }
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

    target.put(ACCESS_TOKEN_KEY, String.format("%s %s", token.getTokenType().toLowerCase(), token.getValue()));
  }

  public DefaultOAuth2RefreshToken getRefreshToken(HashMap<String, String> target) {
    final String token = target.get(REFRESH_TOKEN_KEY);
    return new DefaultOAuth2RefreshToken(token);
  }
View Full Code Here

    if (targetInfo == null) {
      return null;
    }

    DefaultOAuth2RefreshToken refreshToken = targetInfos.getRefreshToken(targetInfo);
    DefaultOAuth2AccessToken token = targetInfos.getToken(targetInfo);
    token.setRefreshToken(refreshToken);

    return token;
  }
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

TOP

Related Classes of org.springframework.security.oauth2.provider.approval.UserApprovalHandler

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.