* @throws RampartException
*/
private String setupEncryptedKey(RampartMessageData rmd, Token sigToken)
throws RampartException {
try {
WSSecEncryptedKey encrKey = this.getEncryptedKeyBuilder(rmd, sigToken);
String id = encrKey.getId();
byte[] secret = encrKey.getEphemeralKey();
// Create a rahas token from this info and store it so we can use
// it in the next steps
Date created = new Date();
Date expires = new Date();
// TODO make this lifetime configurable ???
expires.setTime(System.currentTimeMillis() + 300000);
org.apache.rahas.EncryptedKeyToken tempTok = new org.apache.rahas.EncryptedKeyToken(id,
(OMElement) encrKey.getEncryptedKeyElement(), created, expires);
tempTok.setSecret(secret);
// Set the SHA1 value of the encrypted key, this is used when the encrypted
// key is referenced via a key identifier of type EncryptedKeySHA1
tempTok.setSHA1(getSHA1(encrKey.getEncryptedEphemeralKey()));
rmd.getTokenStorage().add(tempTok);
String bstTokenId = encrKey.getBSTTokenId();
// If direct ref is used to refer to the cert
// then add the cert to the sec header now
if (bstTokenId != null && bstTokenId.length() > 0) {
RampartUtil.appendChildToSecHeader(rmd, encrKey.getBinarySecurityTokenElement());
}
return id;
} catch (TrustException e) {