if(isSigningKey == isEncryptionKey)
throw new IllegalArgumentException("Only one of isSigningKey " +
"and isEncryptionKey should be true");
KeyDescriptorType keyDescriptor = getObjectFactory().createKeyDescriptorType();
if(algorithm != null && algorithm.length() > 0)
{
EncryptionMethodType encryptionMethod = new EncryptionMethodType();
encryptionMethod.setAlgorithm(algorithm);
encryptionMethod.getContent().add(BigInteger.valueOf(keySize));
keyDescriptor.getEncryptionMethod().add(encryptionMethod);
}
if(isSigningKey)
keyDescriptor.setUse(KeyTypes.SIGNING);
if(isEncryptionKey)
keyDescriptor.setUse(KeyTypes.ENCRYPTION);
keyDescriptor.setKeyInfo(keyInfo);
return keyDescriptor;
}