Search in sources :

Example 1 with SecurityAssertionPrincipalDefault

use of ddf.security.assertion.impl.SecurityAssertionPrincipalDefault in project ddf by codice.

the class GuestInterceptor method handleMessage.

@Override
public void handleMessage(SoapMessage message) throws Fault {
    if (message != null) {
        HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);
        LOGGER.debug("Getting new Guest user token");
        Principal principal = null;
        Subject subject = null;
        try {
            subject = getSubject(request.getRemoteAddr());
        } catch (AuthenticationException e) {
            throw new Fault(e);
        }
        if (subject != null) {
            PrincipalCollection principals = subject.getPrincipals();
            SecurityAssertion securityAssertion = principals.oneByType(SecurityAssertion.class);
            if (securityAssertion != null) {
                principal = new SecurityAssertionPrincipalDefault(securityAssertion);
            } else {
                LOGGER.debug("Subject did not contain a security assertion");
            }
            message.put(SecurityContext.class, new DefaultSecurityContext(principal, null));
            message.put(WSS4J_CHECK_STRING, Boolean.TRUE);
        }
    } else {
        LOGGER.debug("Incoming SOAP message is null - guest interceptor makes no sense.");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) DefaultSecurityContext(org.apache.cxf.interceptor.security.DefaultSecurityContext) AuthenticationException(org.codice.ddf.platform.filter.AuthenticationException) SecurityAssertionPrincipalDefault(ddf.security.assertion.impl.SecurityAssertionPrincipalDefault) PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) Fault(org.apache.cxf.interceptor.Fault) SecurityAssertion(ddf.security.assertion.SecurityAssertion) Principal(java.security.Principal) Subject(ddf.security.Subject)

Aggregations

Subject (ddf.security.Subject)1 SecurityAssertion (ddf.security.assertion.SecurityAssertion)1 SecurityAssertionPrincipalDefault (ddf.security.assertion.impl.SecurityAssertionPrincipalDefault)1 Principal (java.security.Principal)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Fault (org.apache.cxf.interceptor.Fault)1 DefaultSecurityContext (org.apache.cxf.interceptor.security.DefaultSecurityContext)1 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)1 AuthenticationException (org.codice.ddf.platform.filter.AuthenticationException)1