Package org.springframework.security.oauth2.common

Examples of org.springframework.security.oauth2.common.OAuth2RefreshToken


   * Retrieve Token from ~/.cf/tokens.yml
   *
   * @return token (String)
   */
  protected OAuth2AccessToken retrieveToken() throws MojoExecutionException {
    final OAuth2AccessToken token = tokensFile.retrieveToken(getTarget());

    if (token == null) {
      throw new MojoExecutionException(String.format("Can not authenticate to target '%s'. " +
          "Configure a username and password, or use the login goal.", getTarget().toString()));
    }
View Full Code Here


    super.execute();
  }

  @Override
  protected void doExecute() throws MojoExecutionException {
    final OAuth2AccessToken token = getClient().login();
    final CloudInfo cloudInfo = getClient().getCloudInfo();
    final CloudSpace space = getCurrentSpace();

    tokensFile.saveToken(getTarget(), token, cloudInfo, space);
View Full Code Here

    return token;
  }

  public String getAuthorizationHeader() {
    OAuth2AccessToken accessToken = getToken();
    if (accessToken != null) {
      return accessToken.getTokenType() + " " + accessToken.getValue();
    }
    return null;
  }
View Full Code Here

    this.allowRefresh = allowRefresh;
  }

  @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);
View Full Code Here

        new SqlLobValue(serializeAuthentication(authentication)) }, new int[] { Types.VARCHAR, Types.BLOB,
        Types.BLOB });
  }

  public OAuth2RefreshToken readRefreshToken(String token) {
    OAuth2RefreshToken refreshToken = null;

    try {
      refreshToken = jdbcTemplate.queryForObject(selectRefreshTokenSql, new RowMapper<OAuth2RefreshToken>() {
        public OAuth2RefreshToken mapRow(ResultSet rs, int rowNum) throws SQLException {
          return deserializeRefreshToken(rs.getBytes(2));
View Full Code Here

      if (existingToken != null) {
        if (existingToken.isExpired()) {
          if (clientTokenServices != null) {
            clientTokenServices.removeAccessToken(resource, auth);
          }
          OAuth2RefreshToken refreshToken = existingToken.getRefreshToken();
          if (refreshToken != null) {
            accessToken = refreshAccessToken(resource, refreshToken, request);
          }
        }
        else {
View Full Code Here

  protected JaxbOAuth2AccessToken convertToInternal(OAuth2AccessToken accessToken) {
    JaxbOAuth2AccessToken jaxbAccessToken = new JaxbOAuth2AccessToken();
    jaxbAccessToken.setAccessToken(accessToken.getValue());
    jaxbAccessToken.setExpriation(accessToken.getExpiration());
    OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
    if(refreshToken != null) {
      jaxbAccessToken.setRefreshToken(refreshToken.getValue());
    }
    return jaxbAccessToken;
  }
View Full Code Here

    if (!info.containsKey(TOKEN_ID)) {
      info.put(TOKEN_ID, tokenId);
    }
    result.setAdditionalInformation(info);
    result.setValue(encode(result, authentication));
    OAuth2RefreshToken refreshToken = result.getRefreshToken();
    if (refreshToken != null) {
      DefaultOAuth2AccessToken encodedRefreshToken = new DefaultOAuth2AccessToken(accessToken);
      encodedRefreshToken.setValue(refreshToken.getValue());
      Map<String, Object> refreshTokenInfo = new LinkedHashMap<String, Object>(accessToken.getAdditionalInformation());
      refreshTokenInfo.put(TOKEN_ID, encodedRefreshToken.getValue());
      encodedRefreshToken.setAdditionalInformation(refreshTokenInfo);
      DefaultOAuth2RefreshToken token = new DefaultOAuth2RefreshToken(encode(encodedRefreshToken, authentication));
      if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
View Full Code Here

  }

  public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication) throws AuthenticationException {

    OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
    OAuth2RefreshToken refreshToken = null;
    if (existingAccessToken != null) {
      if (existingAccessToken.isExpired()) {
        if (existingAccessToken.getRefreshToken() != null) {
          refreshToken = existingAccessToken.getRefreshToken();
          // The token store could remove the refresh token when the
View Full Code Here

    if (!supportRefreshToken) {
      throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
    }

    OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue);
    if (refreshToken == null) {
      throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
    }

    OAuth2Authentication authentication = tokenStore.readAuthenticationForRefreshToken(refreshToken);
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.common.OAuth2RefreshToken

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.