throw new IllegalStateException("Unable to handle encryption as SP url is null");
try
{
URL spurl = new URL(sp);
PublicKey publicKey = keyManager.getValidatingKey(spurl.getHost());
EncryptionType enc = idpConfiguration.getEncryption();
if(enc == null)
throw new IllegalStateException("EncryptionType not configured");
String encAlgo = enc.getEncAlgo().value();
int keyLength = enc.getKeySize();
//Generate a key on the fly
SecretKey sk = keyManager.getEncryptionKey(spurl.getHost(), encAlgo, keyLength);
StringWriter sw = new StringWriter();
saml2Response.marshall(responseType, sw);