Search in sources :

Example 21 with AuthenticationException

use of org.apache.shiro.authc.AuthenticationException in project ddf by codice.

the class AbstractStsRealm method requestSecurityToken.

/**
     * Request a security token (SAML assertion) from the STS.
     *
     * @param authToken The subject the security token is being request for.
     * @return security token (SAML assertion)
     */
protected SecurityToken requestSecurityToken(Object authToken) {
    SecurityToken token = null;
    String stsAddress = getAddress();
    try {
        LOGGER.debug("Requesting security token from STS at: {}.", stsAddress);
        if (authToken != null) {
            LOGGER.debug("Telling the STS to request a security token on behalf of the auth token");
            STSClient stsClient = configureStsClient();
            stsClient.setWsdlLocation(stsAddress);
            stsClient.setOnBehalfOf(authToken);
            stsClient.setTokenType(getAssertionType());
            stsClient.setKeyType(getKeyType());
            stsClient.setKeySize(Integer.parseInt(getKeySize()));
            token = stsClient.requestSecurityToken(stsAddress);
            LOGGER.debug("Finished requesting security token.");
        }
    } catch (Exception e) {
        String msg = "Error requesting the security token from STS at: " + stsAddress + ".";
        LOGGER.debug(msg, e);
        throw new AuthenticationException(msg, e);
    }
    return token;
}
Also used : SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) STSClient(org.apache.cxf.ws.security.trust.STSClient) AuthenticationException(org.apache.shiro.authc.AuthenticationException) XMLStreamException(javax.xml.stream.XMLStreamException) AuthenticationException(org.apache.shiro.authc.AuthenticationException)

Aggregations

AuthenticationException (org.apache.shiro.authc.AuthenticationException)21 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)9 Subject (org.apache.shiro.subject.Subject)6 AuthenticationToken (org.apache.shiro.authc.AuthenticationToken)4 LockedAccountException (org.apache.shiro.authc.LockedAccountException)4 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)3 IncorrectCredentialsException (org.apache.shiro.authc.IncorrectCredentialsException)3 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)3 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)3 Session (org.apache.shiro.session.Session)3 Serializable (java.io.Serializable)2 NotAuthorizedException (javax.ws.rs.NotAuthorizedException)2 SecurityContext (javax.ws.rs.core.SecurityContext)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 STSClient (org.apache.cxf.ws.security.trust.STSClient)2 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)2 DelegatingSubject (org.apache.shiro.subject.support.DelegatingSubject)2 Test (org.junit.Test)2