Examples of OAuthSecurityContext


Examples of com.sun.jersey.oauth.server.OAuthSecurityContext

        // do not filter if the request path matches pattern to ignore
        if (match(ignorePathPattern, request.getPath())) {
            return request;
        }

        OAuthSecurityContext sc = null;

        try {
            sc = getSecurityContext(request);
        } catch (OAuthException e) {
            if (optional) {
View Full Code Here

Examples of com.sun.jersey.oauth.server.OAuthSecurityContext

        if (consumer == null) {
            throw newUnauthorizedException();
        }

        OAuthSecrets secrets = new OAuthSecrets().consumerSecret(consumer.getSecret());
        OAuthSecurityContext sc;
        String nonceKey;

        if (token == null) {
            if (consumer.getPrincipal() == null) {
                throw newUnauthorizedException();
            }
            nonceKey = "c:" + consumerKey;
            sc = new OAuthSecurityContext(consumer, request.isSecure());
        } else {
            OAuthToken accessToken = provider.getAccessToken(token);
            if (accessToken == null) {
                throw newUnauthorizedException();
            }

            OAuthConsumer atConsumer = accessToken.getConsumer();
            if (atConsumer == null || !consumerKey.equals(atConsumer.getKey())) {
                throw newUnauthorizedException();
            }

            nonceKey = "t:" + token;
            secrets.tokenSecret(accessToken.getSecret());
            sc = new OAuthSecurityContext(accessToken, request.isSecure());
        }

        if (!verifySignature(osr, params, secrets)) {
            throw newUnauthorizedException();
        }
View Full Code Here

Examples of org.springframework.security.oauth.consumer.OAuthSecurityContext

      throw new IllegalArgumentException("A resource must be supplied for an OAuth2ClientHttpRequestFactory.");
    }
  }

  public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
    OAuthSecurityContext context = OAuthSecurityContextHolder.getContext();
    if (context == null) {
      context = new OAuthSecurityContextImpl();
    }

    Map<String, OAuthConsumerToken> accessTokens = context.getAccessTokens();
    OAuthConsumerToken accessToken = accessTokens == null ? null : accessTokens.get(this.resource.getId());

    boolean useAuthHeader = this.resource.isAcceptsAuthorizationHeader();
    if (!useAuthHeader) {
      String queryString = this.support.getOAuthQueryString(this.resource, accessToken, uri.toURL(), httpMethod.name(), this.additionalOAuthParameters);
View Full Code Here

Examples of org.springframework.security.oauth.consumer.OAuthSecurityContext

  public void removeToken(String resourceId) {
    getSession().removeAttribute(KEY_PREFIX + "#" + resourceId);
  }

  protected HttpSession getSession() {
    OAuthSecurityContext context = OAuthSecurityContextHolder.getContext();
    if (context == null) {
      throw new IllegalStateException("A security context must be established.");
    }

    HttpServletRequest request;
    try {
      request = (HttpServletRequest) context.getDetails();
    }
    catch (ClassCastException e) {
      throw new IllegalStateException("The security context must have the HTTP servlet request as its details.");
    }
View Full Code Here

Examples of org.springframework.security.oauth.consumer.OAuthSecurityContext

      Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
      if (isRequireAuthenticated() && !authentication.isAuthenticated()) {
        throw new InsufficientAuthenticationException("An authenticated principal must be present.");
      }

      OAuthSecurityContext context = OAuthSecurityContextHolder.getContext();
      if (context == null) {
        throw new IllegalStateException("No OAuth security context has been established. Unable to access resources.");
      }

      Map<String, OAuthConsumerToken> accessTokens = context.getAccessTokens();

      for (String dependency : accessTokenDeps) {
        if (!accessTokens.containsKey(dependency)) {
          throw new AccessTokenRequiredException(getProtectedResourceDetailsService().loadProtectedResourceDetailsById(dependency));
        }
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.