I am trying to encrypt a SAML assertion. Get certificate correctly.
Code snips as below:
private static EncryptedAssertion encryptAssertion(Assertion assertion) throws NoSuchAlgorithmException, NoSuchProviderException, Exception {
X509Certificate cert =(X509Certificate) PublicKeyUtil.getEncryptionCertificate(jksFile, publicKeyAlias, keyStorePassword);
BasicX509Credential cred = new BasicX509Credential();
cred.setEntityCertificate(cert);
cred.setPrivateKey(null);
EncryptionParameters encParams = new EncryptionParameters();
encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128);
encParams.setEncryptionCredential(cred);
KeyEncryptionParameters kek = new KeyEncryptionParameters();
kek.setAlgorithm(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15);
kek.setEncryptionCredential(cred);
Encrypter encrypter = new Encrypter(encParams, kek);
encrypter.setKeyPlacement(Encrypter.KeyPlacement.INLINE);
EncryptedAssertion encrypted = encrypter.encrypt(assertion);
return encrypted;
}
Выдает исключение, когда encrypter.encrypt (утверждение)
Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.xml.security.encryption.XMLCipher.<init>(XMLCipher.java:341)
at org.apache.xml.security.encryption.XMLCipher.getInstance(XMLCipher.java:457)
at org.opensaml.xml.encryption.Encrypter.encryptElement(Encrypter.java:442)
at org.opensaml.saml2.encryption.Encrypter.encrypt(Encrypter.java:344)
at org.opensaml.saml2.encryption.Encrypter.encrypt(Encrypter.java:258)
Кто-нибудь знает, что является причиной?