Examples of InvalidTokenException


Examples of org.naturalcli.InvalidTokenException

    public void setText(String text) throws InvalidTokenException {
        this.text = text;
        // Determine if it is optional
        optional = Pattern.matches("^\\[.*\\]$", text);
        if (Pattern.matches("^\\[.*$", text))
            throw new InvalidTokenException("Bad optional token: missing ']' char at end.");
        if (Pattern.matches("^.*\\]$", text))
            throw new InvalidTokenException("Bad optional token: missing '[' char at begin.");
        // Fill text_without_optional
        if (this.isOptional())
            text_without_optional = text.substring(1, text.length()-2);
        else
            text_without_optional = text;
View Full Code Here

Examples of org.naturalcli.InvalidTokenException

       String error;
       if (def.matches(text))
           return new ParameterToken(text);
       error = def.incompatibleMessage(text);
       if (error != null)
           throw new InvalidTokenException(error);
       return null;
   }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

  public OAuth2AccessTokenEntity refreshAccessToken(String refreshTokenValue, TokenRequest authRequest) throws AuthenticationException {

    OAuth2RefreshTokenEntity refreshToken = tokenRepository.getRefreshTokenByValue(refreshTokenValue);

    if (refreshToken == null) {
      throw new InvalidTokenException("Invalid refresh token: " + refreshTokenValue);
    }

    ClientDetailsEntity client = refreshToken.getClient();

    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);

    if (refreshToken.isExpired()) {
      tokenRepository.removeRefreshToken(refreshToken);
      throw new InvalidTokenException("Expired refresh token: " + refreshTokenValue);
    }

    // TODO: have the option to recycle the refresh token here, too
    // for now, we just reuse it as long as it's valid, which is the original intent
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

  public OAuth2Authentication loadAuthentication(String accessTokenValue) throws AuthenticationException {

    OAuth2AccessTokenEntity accessToken = tokenRepository.getAccessTokenByValue(accessTokenValue);

    if (accessToken == null) {
      throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
    }

    if (accessToken.isExpired()) {
      //tokenRepository.removeAccessToken(accessToken);
      revokeAccessToken(accessToken);
      throw new InvalidTokenException("Expired access token: " + accessTokenValue);
    }

    return accessToken.getAuthenticationHolder().getAuthentication();
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

   */
  @Override
  public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue) throws AuthenticationException {
    OAuth2AccessTokenEntity accessToken = tokenRepository.getAccessTokenByValue(accessTokenValue);
    if (accessToken == null) {
      throw new InvalidTokenException("Access token for value " + accessTokenValue + " was not found");
    }
    else {
      return accessToken;
    }
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

   */
  @Override
  public OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue) throws AuthenticationException {
    OAuth2RefreshTokenEntity refreshToken = tokenRepository.getRefreshTokenByValue(refreshTokenValue);
    if (refreshToken == null) {
      throw new InvalidTokenException("Refresh token for value " + refreshTokenValue + " was not found");
    }
    else {
      return refreshToken;
    }
  }
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

  public Authentication authenticate(Authentication authentication) throws AuthenticationException {

    String token = (String) authentication.getPrincipal();
    OAuth2Authentication auth = tokenServices.loadAuthentication(token);
    if (auth == null) {
      throw new InvalidTokenException("Invalid token: " + token);
    }

    Collection<String> resourceIds = auth.getOAuth2Request().getResourceIds();
    if (resourceId != null && resourceIds != null && !resourceIds.isEmpty() && !resourceIds.contains(resourceId)) {
      throw new OAuth2AccessDeniedException("Invalid token does not contain resource id (" + resourceId + ")");
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

  @ResponseBody
  public Map<String, ?> checkToken(@RequestParam("token") String value) {

    OAuth2AccessToken token = resourceServerTokenServices.readAccessToken(value);
    if (token == null) {
      throw new InvalidTokenException("Token was not recognised");
    }

    if (token.isExpired()) {
      throw new InvalidTokenException("Token has expired");
    }

    OAuth2Authentication authentication = resourceServerTokenServices.loadAuthentication(token.getValue());

    Map<String, ?> response = accessTokenConverter.convertAccessToken(token, authentication);
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

    logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
    // This isn't an oauth resource, so we don't want to send an
    // unauthorized code here. The client has already authenticated
    // successfully with basic auth and should just
    // get back the invalid token error.
    @SuppressWarnings("serial")
    InvalidTokenException e400 = new InvalidTokenException(e.getMessage()) {
      @Override
      public int getHttpErrorCode() {
        return 400;
      }
    };
View Full Code Here

Examples of org.springframework.security.oauth2.common.exceptions.InvalidTokenException

        map.put(EXP, new Long(intValue));
      }
      return map;
    }
    catch (Exception e) {
      throw new InvalidTokenException("Cannot convert access token to JSON", e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.