Java Code Examples for org.apache.wss4j.common.ext.WSSecurityException#getMessage()

The following examples show how to use org.apache.wss4j.common.ext.WSSecurityException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SamlRetrievalInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message message) throws Fault {

    // Create a SAML Token
    SAMLCallback samlCallback = new SAMLCallback();
    SAMLUtil.doSAMLCallback(new SamlCallbackHandler(), samlCallback);

    try {
        SamlAssertionWrapper assertion = new SamlAssertionWrapper(samlCallback);
        Document doc = DOMUtils.createDocument();
        Element token = assertion.toDOM(doc);
        message.put(SAMLConstants.SAML_TOKEN_ELEMENT, token);
    } catch (WSSecurityException ex) {
        StringWriter sw = new StringWriter();
        ex.printStackTrace(new PrintWriter(sw));
        throw new Fault(new RuntimeException(ex.getMessage() + ", stacktrace: " + sw.toString()));
    }

}
 
Example 2
Source File: RealmProperties.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Get the signature Crypto object
 * @return the signature Crypto object
 */
public Crypto getSignatureCrypto() {
    if (signatureCrypto == null && signatureCryptoProperties != null) {
        Properties sigProperties = SecurityUtils.loadProperties(signatureCryptoProperties);
        if (sigProperties == null) {
            LOG.fine("Cannot load signature properties using: " + signatureCryptoProperties);
            throw new STSException("Configuration error: cannot load signature properties");
        }
        try {
            signatureCrypto = CryptoFactory.getInstance(sigProperties);
        } catch (WSSecurityException ex) {
            LOG.fine("Error in loading the signature Crypto object: " + ex.getMessage());
            throw new STSException(ex.getMessage());
        }
    }

    return signatureCrypto;
}
 
Example 3
Source File: ActAsAttributeStatementProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Get an AttributeStatementBean using the given parameters.
 */
public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) {
    AttributeStatementBean attrBean = new AttributeStatementBean();

    TokenRequirements tokenRequirements = providerParameters.getTokenRequirements();
    ReceivedToken actAs = tokenRequirements.getActAs();
    try {
        if (actAs != null) {
            List<AttributeBean> attributeList = new ArrayList<>();
            String tokenType = tokenRequirements.getTokenType();

            AttributeBean parameterBean =
                handleAdditionalParameters(actAs.getToken(), tokenType);
            if (!parameterBean.getAttributeValues().isEmpty()) {
                attributeList.add(parameterBean);
            }

            attrBean.setSamlAttributes(attributeList);
        }
    } catch (WSSecurityException ex) {
        throw new STSException(ex.getMessage(), ex);
    }

    return attrBean;
}