Search in sources :

Example 1 with SecurityTokenManager

use of com.sun.identity.liberty.ws.security.SecurityTokenManager in project OpenAM by OpenRock.

the class MessageProcessor method addBinaryToken.

/**
     * Adds binary token to the security header.
     */
private BinarySecurityToken addBinaryToken(SOAPMessage msg) throws SOAPBindingException {
    try {
        SOAPHeader header = msg.getSOAPPart().getEnvelope().getHeader();
        if (header == null) {
            header = msg.getSOAPPart().getEnvelope().addHeader();
        }
        SecurityTokenManager manager = new SecurityTokenManager(null);
        BinarySecurityToken binaryToken = manager.getX509CertificateToken();
        binaryToken.setWSFVersion(SOAPBindingConstants.WSF_11_VERSION);
        binaryToken.addToParent(header);
        return binaryToken;
    } catch (Exception ex) {
        Utils.debug.error("MessageProcessor.addBinaryToken: " + "Could not add binary security token", ex);
        throw new SOAPBindingException(Utils.bundle.getString("cannotAddCorrelationHeader"));
    }
}
Also used : BinarySecurityToken(com.sun.identity.liberty.ws.common.wsse.BinarySecurityToken) SecurityTokenManager(com.sun.identity.liberty.ws.security.SecurityTokenManager) SOAPHeader(javax.xml.soap.SOAPHeader) SOAPException(javax.xml.soap.SOAPException)

Example 2 with SecurityTokenManager

use of com.sun.identity.liberty.ws.security.SecurityTokenManager in project OpenAM by OpenRock.

the class DSTRequestHandler method generateBinarySecurityToken.

/**
     * Generates the binary security token if the security profile is X509.
     * @param msg Request Message. 
     * @return BinarySecurityToken.
     * @exception DSTException.
     */
private BinarySecurityToken generateBinarySecurityToken(Message msg) throws DSTException {
    try {
        SecurityTokenManager manager = new SecurityTokenManager(msg.getToken());
        BinarySecurityToken binaryToken = manager.getX509CertificateToken();
        binaryToken.setWSFVersion(msg.getWSFVersion());
        return binaryToken;
    } catch (Exception e) {
        DSTUtils.debug.error("DSTRequestHandler:generateBinary" + "SecurityToken: Error in generating binary security token.", e);
        throw new DSTException(e);
    }
}
Also used : BinarySecurityToken(com.sun.identity.liberty.ws.common.wsse.BinarySecurityToken) SecurityTokenManager(com.sun.identity.liberty.ws.security.SecurityTokenManager) DSTException(com.sun.identity.liberty.ws.dst.DSTException) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException) DSTException(com.sun.identity.liberty.ws.dst.DSTException)

Aggregations

BinarySecurityToken (com.sun.identity.liberty.ws.common.wsse.BinarySecurityToken)2 SecurityTokenManager (com.sun.identity.liberty.ws.security.SecurityTokenManager)2 DSTException (com.sun.identity.liberty.ws.dst.DSTException)1 SOAPFaultException (com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)1 SOAPException (javax.xml.soap.SOAPException)1 SOAPHeader (javax.xml.soap.SOAPHeader)1