Package org.springframework.security.oauth2.config.annotation.web.configuration

Examples of org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter


    OAuth2AccessTokenEntity incomingToken = tokenServices.readAccessToken(incomingTokenValue);

    if (incomingToken.getScope().contains(SystemScopeService.ID_TOKEN_SCOPE)) {

      if (!client.getClientId().equals(tokenRequest.getClientId())) {
        throw new InvalidClientException("Not the right client for this token");
      }

      // it's an ID token, process it accordingly

      try {
View Full Code Here


        JWSAlgorithm alg = jws.getHeader().getAlgorithm();

        if (client.getTokenEndpointAuthSigningAlg() != null &&
            !client.getTokenEndpointAuthSigningAlg().equals(alg)) {
          throw new InvalidClientException("Client's registered request object signing algorithm (" + client.getRequestObjectSigningAlg() + ") does not match request object's actual algorithm (" + alg.getName() + ")");
        }

        if (client.getTokenEndpointAuthMethod() == null ||
            client.getTokenEndpointAuthMethod().equals(AuthMethod.NONE) ||
            client.getTokenEndpointAuthMethod().equals(AuthMethod.SECRET_BASIC) ||
View Full Code Here

      OAuth2Request clientAuth = authentication.getOAuth2Request();

      ClientDetailsEntity client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());

      if (client == null) {
        throw new InvalidClientException("Client not found: " + clientAuth.getClientId());
      }

      OAuth2AccessTokenEntity token = new OAuth2AccessTokenEntity();//accessTokenFactory.createNewAccessToken();

      // attach the client
View Full Code Here

    AuthenticationHolderEntity authHolder = refreshToken.getAuthenticationHolder();

    //Make sure this client allows access token refreshing
    if (!client.isAllowRefresh()) {
      throw new InvalidClientException("Client does not allow refreshing access token!");
    }

    // clear out any access tokens
    // TODO: make this a configurable option
    tokenRepository.clearAccessTokensForRefreshToken(refreshToken);
View Full Code Here

  @Override
  public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception, InvalidClientException, IllegalArgumentException {
    if (!Strings.isNullOrEmpty(clientId)) {
      ClientDetailsEntity client = clientRepository.getClientByClientId(clientId);
      if (client == null) {
        throw new InvalidClientException("Client with id " + clientId + " was not found");
      }
      else {
        return client;
      }
    }
View Full Code Here

   */
  @Override
  public void deleteClient(ClientDetailsEntity client) throws InvalidClientException {

    if (clientRepository.getById(client.getId()) == null) {
      throw new InvalidClientException("Client with id " + client.getClientId() + " was not found");
    }

    // clean out any tokens that this client had issued
    tokenRepository.clearTokensForClient(client);

View Full Code Here

    query.setParameter("code", code);

    AuthorizationCodeEntity result = JpaUtil.getSingleResult(query.getResultList());

    if (result == null) {
      throw new InvalidGrantException("JpaAuthorizationCodeRepository: no authorization code found for value " + code);
    }

    OAuth2Authentication authRequest = result.getAuthentication();

    manager.remove(result);
View Full Code Here

  public String resolveRedirect(String requestedRedirect, ClientDetails client) throws OAuth2Exception {

    Set<String> authorizedGrantTypes = client.getAuthorizedGrantTypes();
    if (authorizedGrantTypes.isEmpty()) {
      throw new InvalidGrantException("A client must have at least one authorized grant type.");
    }
    if (!containsRedirectGrantType(authorizedGrantTypes)) {
      throw new InvalidGrantException(
          "A redirect_uri can only be used by implicit or authorization_code grant types.");
    }

    Set<String> redirectUris = client.getRegisteredRedirectUri();
View Full Code Here

  @Override
  public String resolveRedirect(String requestedRedirect, ClientDetails client) throws OAuth2Exception {
    String redirect = super.resolveRedirect(requestedRedirect, client);
    if (blacklistService.isBlacklisted(redirect)) {
      // don't let it go through
      throw new InvalidRequestException("The supplied redirect_uri is not allowed on this server.");
    } else {
      // not blacklisted, passed the parent test, we're fine
      return redirect;
    }
  }
View Full Code Here

    }
    else if (StringUtils.hasText(requestedRedirect)) {
      return requestedRedirect;
    }
    else {
      throw new InvalidRequestException("A redirect_uri must be supplied.");
    }

  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter

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.