Search in sources :

Example 6 with GuestAuthenticationToken

use of org.codice.ddf.security.handler.api.GuestAuthenticationToken in project alliance by codice.

the class NsiliEndpoint method getGuestSubject.

public static synchronized Subject getGuestSubject() throws SecurityServiceException {
    if (guestSubject == null || Security.getInstance().tokenAboutToExpire(guestSubject)) {
        String ip = DEFAULT_IP_ADDRESS;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
            LOGGER.debug("Guest token ip: {}", ip);
        } catch (UnknownHostException e) {
            LOGGER.info("Could not get IP address for localhost", e);
        }
        String guestTokenId = ip;
        GuestAuthenticationToken guestToken = new GuestAuthenticationToken(BaseAuthenticationToken.ALL_REALM, guestTokenId);
        guestSubject = securityManager.getSubject(guestToken);
    }
    return guestSubject;
}
Also used : GuestAuthenticationToken(org.codice.ddf.security.handler.api.GuestAuthenticationToken) UnknownHostException(java.net.UnknownHostException)

Example 7 with GuestAuthenticationToken

use of org.codice.ddf.security.handler.api.GuestAuthenticationToken in project ddf by codice.

the class Security method getGuestSubject.

/**
     * Gets the guest {@link Subject} associated with the specified IP. Uses a cached subject when possible since the subject
     * will not change between calls.
     *
     * @return system's {@link Subject}
     */
public Subject getGuestSubject(String ipAddress) {
    Subject subject = null;
    GuestAuthenticationToken token = new GuestAuthenticationToken(BaseAuthenticationToken.DEFAULT_REALM, ipAddress);
    LOGGER.debug("Getting new Guest user token for {}", ipAddress);
    try {
        SecurityManager securityManager = getSecurityManager();
        if (securityManager != null) {
            subject = securityManager.getSubject(token);
        }
    } catch (SecurityServiceException sse) {
        LOGGER.info("Unable to request subject for guest user.", sse);
    }
    return subject;
}
Also used : SecurityServiceException(ddf.security.service.SecurityServiceException) GuestAuthenticationToken(org.codice.ddf.security.handler.api.GuestAuthenticationToken) SecurityManager(ddf.security.service.SecurityManager) Subject(ddf.security.Subject)

Aggregations

GuestAuthenticationToken (org.codice.ddf.security.handler.api.GuestAuthenticationToken)7 HandlerResult (org.codice.ddf.security.handler.api.HandlerResult)3 Subject (ddf.security.Subject)2 SecurityServiceException (ddf.security.service.SecurityServiceException)2 ServletException (javax.servlet.ServletException)2 ReceivedToken (org.apache.cxf.sts.request.ReceivedToken)2 BasicAuthenticationHandler (org.codice.ddf.security.handler.basic.BasicAuthenticationHandler)2 PKIHandler (org.codice.ddf.security.handler.pki.PKIHandler)2 SecurityAssertion (ddf.security.assertion.SecurityAssertion)1 GuestPrincipal (ddf.security.principal.GuestPrincipal)1 SecurityManager (ddf.security.service.SecurityManager)1 UnknownHostException (java.net.UnknownHostException)1 FilterChain (javax.servlet.FilterChain)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 TokenValidatorParameters (org.apache.cxf.sts.token.validator.TokenValidatorParameters)1 TokenValidatorResponse (org.apache.cxf.sts.token.validator.TokenValidatorResponse)1 BinarySecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType)1