Package org.springframework.security.oauth.provider

Examples of org.springframework.security.oauth.provider.OAuthAuthenticationDetails


   */
  public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) {
    int result = ACCESS_ABSTAIN;

    if (authentication.getDetails() instanceof OAuthAuthenticationDetails) {
      OAuthAuthenticationDetails details = (OAuthAuthenticationDetails) authentication.getDetails();
      for (Object configAttribute : configAttributes) {
        ConfigAttribute attribute = (ConfigAttribute) configAttribute;

        if (ConsumerSecurityConfig.PERMIT_ALL_ATTRIBUTE.equals(attribute)) {
          return ACCESS_GRANTED;
        }
        else if (ConsumerSecurityConfig.DENY_ALL_ATTRIBUTE.equals(attribute)) {
          return ACCESS_DENIED;
        }
        else if (supports(attribute)) {
          ConsumerSecurityConfig config = (ConsumerSecurityConfig) attribute;
          if ((config.getSecurityType() == ConsumerSecurityConfig.ConsumerSecurityType.CONSUMER_KEY)
            && (config.getAttribute().equals(details.getConsumerDetails().getConsumerKey()))) {
            return ACCESS_GRANTED;
          }
          else if (config.getSecurityType() == ConsumerSecurityConfig.ConsumerSecurityType.CONSUMER_ROLE) {
            List<GrantedAuthority> authorities = details.getConsumerDetails().getAuthorities();
            if (authorities != null) {
              for (GrantedAuthority authority : authorities) {
                if (authority.getAuthority().equals(config.getAttribute())) {
                  return ACCESS_GRANTED;
                }
View Full Code Here


  }

  public static boolean consumerHasAnyRole(SecurityExpressionRoot root, String... roles) {
    Authentication authentication = root.getAuthentication();
    if (authentication.getDetails() instanceof OAuthAuthenticationDetails) {
      OAuthAuthenticationDetails details = (OAuthAuthenticationDetails) authentication.getDetails();
      List<GrantedAuthority> consumerAuthorities = details.getConsumerDetails().getAuthorities();
      if (consumerAuthorities != null) {
        Set<String> roleSet = AuthorityUtils.authorityListToSet(consumerAuthorities);
        for (String role : roles) {
          if (roleSet.contains(role)) {
            return true;
View Full Code Here

   * @param request The request.
   * @param consumerDetails The consumer details.
   * @return The authentication details.
   */
  protected Object createDetails(HttpServletRequest request, ConsumerDetails consumerDetails) {
    return new OAuthAuthenticationDetails(request, consumerDetails);
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.oauth.provider.OAuthAuthenticationDetails

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.