KeyFactory keyFactory = KeyFactory.getInstance(publicKey.getAlgorithm());
X509EncodedKeySpec keySpec = keyFactory.getKeySpec(publicKey, X509EncodedKeySpec.class);
return keySpec.getEncoded();
} catch (NoSuchAlgorithmException e) {
Object exArgs[] = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
throw new XMLSecurityException("DEREncodedKeyValue.UnsupportedPublicKey", exArgs, e);
} catch (InvalidKeySpecException e) {
Object exArgs[] = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
throw new XMLSecurityException("DEREncodedKeyValue.UnsupportedPublicKey", exArgs, e);
}
}