Search in sources :

Example 1 with SignatureAlgorithm

use of org.apache.syncope.common.lib.types.SignatureAlgorithm in project syncope by apache.

the class SAML2ReaderWriter method init.

public void init() {
    X509KeyInfoGeneratorFactory keyInfoGeneratorFactory = new X509KeyInfoGeneratorFactory();
    keyInfoGeneratorFactory.setEmitEntityCertificate(true);
    keyInfoGenerator = keyInfoGeneratorFactory.newInstance();
    // Try to load a signature algorithm
    if (loader.getSignatureAlgorithm() != null) {
        SignatureAlgorithm loadedSignatureAlgorithm = SignatureAlgorithm.valueOf(loader.getSignatureAlgorithm());
        if (loadedSignatureAlgorithm != null) {
            sigAlgo = loadedSignatureAlgorithm.getAlgorithm();
            jceSigAlgo = JCEMapper.translateURItoJCEID(sigAlgo);
        }
        if (jceSigAlgo == null) {
            LOG.warn("Signature algorithm {} is not valid. Using default algorithm instead.", loader.getSignatureAlgorithm());
            sigAlgo = null;
        }
    }
    if (sigAlgo == null) {
        sigAlgo = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1;
        String pubKeyAlgo = loader.getCredential().getPublicKey().getAlgorithm();
        if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
            sigAlgo = SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA1;
        } else if (pubKeyAlgo.equalsIgnoreCase("EC")) {
            sigAlgo = SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA1;
        }
        jceSigAlgo = JCEMapper.translateURItoJCEID(sigAlgo);
    }
    callbackHandler = new SAMLSPCallbackHandler(loader.getKeyPass());
}
Also used : SignatureAlgorithm(org.apache.syncope.common.lib.types.SignatureAlgorithm) X509KeyInfoGeneratorFactory(org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory)

Aggregations

SignatureAlgorithm (org.apache.syncope.common.lib.types.SignatureAlgorithm)1 X509KeyInfoGeneratorFactory (org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory)1