Search in sources :

Example 21 with KeyInfoBean

use of org.apache.wss4j.common.saml.bean.KeyInfoBean in project cxf by apache.

the class SamlCallbackHandler method createKeyInfo.

protected KeyInfoBean createKeyInfo() throws Exception {
    Crypto crypto = CryptoFactory.getInstance(cryptoPropertiesFile);
    CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
    cryptoType.setAlias(cryptoAlias);
    X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
    KeyInfoBean keyInfo = new KeyInfoBean();
    keyInfo.setCertIdentifer(keyInfoIdentifier);
    if (keyInfoIdentifier == CERT_IDENTIFIER.X509_CERT) {
        keyInfo.setCertificate(certs[0]);
    } else if (keyInfoIdentifier == CERT_IDENTIFIER.KEY_VALUE) {
        keyInfo.setPublicKey(certs[0].getPublicKey());
    }
    return keyInfo;
}
Also used : Crypto(org.apache.wss4j.common.crypto.Crypto) KeyInfoBean(org.apache.wss4j.common.saml.bean.KeyInfoBean) CryptoType(org.apache.wss4j.common.crypto.CryptoType) X509Certificate(java.security.cert.X509Certificate)

Example 22 with KeyInfoBean

use of org.apache.wss4j.common.saml.bean.KeyInfoBean in project jbossws-cxf by jbossws.

the class SamlCallbackHandler method createKeyInfo.

protected KeyInfoBean createKeyInfo() throws Exception {
    InputStream is = Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties").openStream();
    Properties props = new Properties();
    try {
        props.load(is);
    } finally {
        is.close();
    }
    Crypto crypto = CryptoFactory.getInstance(props);
    CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
    cryptoType.setAlias("alice");
    X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
    KeyInfoBean keyInfo = new KeyInfoBean();
    keyInfo.setCertificate(certs[0]);
    keyInfo.setCertIdentifer(CERT_IDENTIFIER.X509_CERT);
    return keyInfo;
}
Also used : Crypto(org.apache.wss4j.common.crypto.Crypto) KeyInfoBean(org.apache.wss4j.common.saml.bean.KeyInfoBean) InputStream(java.io.InputStream) CryptoType(org.apache.wss4j.common.crypto.CryptoType) Properties(java.util.Properties) X509Certificate(java.security.cert.X509Certificate)

Aggregations

KeyInfoBean (org.apache.wss4j.common.saml.bean.KeyInfoBean)22 Crypto (org.apache.wss4j.common.crypto.Crypto)15 SubjectBean (org.apache.wss4j.common.saml.bean.SubjectBean)12 SAMLCallback (org.apache.wss4j.common.saml.SAMLCallback)11 IOException (java.io.IOException)10 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)10 X509Certificate (java.security.cert.X509Certificate)7 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)7 AttributeBean (org.apache.wss4j.common.saml.bean.AttributeBean)7 AttributeStatementBean (org.apache.wss4j.common.saml.bean.AttributeStatementBean)7 CryptoType (org.apache.wss4j.common.crypto.CryptoType)6 Element (org.w3c.dom.Element)4 KeyGenerator (javax.crypto.KeyGenerator)3 SecretKey (javax.crypto.SecretKey)3 WSSecEncryptedKey (org.apache.wss4j.dom.message.WSSecEncryptedKey)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 Document (org.w3c.dom.Document)2 InputStream (java.io.InputStream)1 Principal (java.security.Principal)1