Search in sources :

Example 1 with EncryptionException

use of org.opensaml.xmlsec.encryption.support.EncryptionException in project spring-security by spring-projects.

the class TestOpenSamlObjects method encrypted.

static EncryptedID encrypted(NameID nameId, Saml2X509Credential credential) {
    X509Certificate certificate = credential.getCertificate();
    Encrypter encrypter = getEncrypter(certificate);
    try {
        return encrypter.encrypt(nameId);
    } catch (EncryptionException ex) {
        throw new Saml2Exception("Unable to encrypt nameID.", ex);
    }
}
Also used : Encrypter(org.opensaml.saml.saml2.encryption.Encrypter) EncryptionException(org.opensaml.xmlsec.encryption.support.EncryptionException) Saml2Exception(org.springframework.security.saml2.Saml2Exception) X509Certificate(java.security.cert.X509Certificate)

Example 2 with EncryptionException

use of org.opensaml.xmlsec.encryption.support.EncryptionException in project spring-security by spring-projects.

the class TestOpenSamlObjects method encrypted.

static EncryptedAssertion encrypted(Assertion assertion, Saml2X509Credential credential) {
    X509Certificate certificate = credential.getCertificate();
    Encrypter encrypter = getEncrypter(certificate);
    try {
        return encrypter.encrypt(assertion);
    } catch (EncryptionException ex) {
        throw new Saml2Exception("Unable to encrypt assertion.", ex);
    }
}
Also used : Encrypter(org.opensaml.saml.saml2.encryption.Encrypter) EncryptionException(org.opensaml.xmlsec.encryption.support.EncryptionException) Saml2Exception(org.springframework.security.saml2.Saml2Exception) X509Certificate(java.security.cert.X509Certificate)

Example 3 with EncryptionException

use of org.opensaml.xmlsec.encryption.support.EncryptionException in project spring-security by spring-projects.

the class TestOpenSamlObjects method encrypted.

static EncryptedAttribute encrypted(String name, String value, Saml2X509Credential credential) {
    Attribute attribute = attribute(name, value);
    X509Certificate certificate = credential.getCertificate();
    Encrypter encrypter = getEncrypter(certificate);
    try {
        return encrypter.encrypt(attribute);
    } catch (EncryptionException ex) {
        throw new Saml2Exception("Unable to encrypt nameID.", ex);
    }
}
Also used : Encrypter(org.opensaml.saml.saml2.encryption.Encrypter) Attribute(org.opensaml.saml.saml2.core.Attribute) EncryptedAttribute(org.opensaml.saml.saml2.core.EncryptedAttribute) EncryptionException(org.opensaml.xmlsec.encryption.support.EncryptionException) Saml2Exception(org.springframework.security.saml2.Saml2Exception) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)3 Encrypter (org.opensaml.saml.saml2.encryption.Encrypter)3 EncryptionException (org.opensaml.xmlsec.encryption.support.EncryptionException)3 Saml2Exception (org.springframework.security.saml2.Saml2Exception)3 Attribute (org.opensaml.saml.saml2.core.Attribute)1 EncryptedAttribute (org.opensaml.saml.saml2.core.EncryptedAttribute)1