Example usage for org.springframework.security.web FilterInvocation getFullRequestUrl

List of usage examples for org.springframework.security.web FilterInvocation getFullRequestUrl

Introduction

In this page you can find the example usage for org.springframework.security.web FilterInvocation getFullRequestUrl.

Prototype

public String getFullRequestUrl() 

Source Link

Document

Indicates the URL that the user agent used for this request.

Usage

From source file:com.sun.identity.provider.springsecurity.OpenSSOObjectDefinitionSource.java

/**
 * @inheritDoc/*from  w ww .  ja v a2 s .  c  o m*/
 */
public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
    FilterInvocation filterInvocation = (FilterInvocation) object;
    HttpServletRequest request = filterInvocation.getRequest();
    if (isAnonymousUrl(request)) {
        return null;
    }

    SSOToken token = OpenSSOProcessingFilter.getToken(filterInvocation.getHttpRequest());
    if (token == null) {
        throw new InsufficientAuthenticationException("SSOToken does not exist");
    }

    Set actions = new HashSet();
    actions.add(filterInvocation.getHttpRequest().getMethod());
    String fullResourceUrl = filterInvocation.getFullRequestUrl();

    try {
        PolicyEvaluator policyEvaluator = PolicyEvaluatorFactory.getInstance()
                .getPolicyEvaluator("iPlanetAMWebAgentService");
        if (debug.messageEnabled()) {
            debug.message("getPolicy for resource=" + fullResourceUrl + " actions=" + actions);
        }
        PolicyDecision policyDecision = policyEvaluator.getPolicyDecision(token, fullResourceUrl, actions,
                envParams);
        Map actionDecisions = policyDecision.getActionDecisions();
        if (debug.messageEnabled()) {
            debug.message("action decisions =" + actionDecisions);
        }

        // If OpenSSO has a NULL policy decision we return
        // and Empty list. This results in a Spring "ABSTAIN" vote
        if (actionDecisions == null || actionDecisions.isEmpty()) {
            return Collections.emptyList();
        } else {
            ActionDecision actionDecision = (ActionDecision) actionDecisions.values().iterator().next();
            List<ConfigAttribute> configAtributes = new ArrayList<ConfigAttribute>();
            for (Iterator it = actionDecision.getValues().iterator(); it.hasNext();) {
                String s = (String) it.next();
                debug.message("configAttributes.add(" + s);
                configAtributes.add(new SecurityConfig(s));
            }
            return configAtributes;
        }
    } catch (Exception e) {
        debug.error("Exception while evaling policy", e);
        throw new AccessDeniedException("Error accessing to Opensso", e);
    }
}