KeyInfo keyInfo = null;
final KeyIdentifier keyIdentifier = wef.createKeyIdentifier();
keyIdentifier.setValueType(MessageConstants.X509SubjectKeyIdentifier_NS);
keyIdentifier.updateReferenceValue(cert);
keyIdentifier.setEncodingType(MessageConstants.BASE64_ENCODING_NS);
final SecurityTokenReference str = wef.createSecurityTokenReference(keyIdentifier);
keyInfo = wef.createKeyInfo((com.sun.xml.ws.security.opt.impl.keyinfo.SecurityTokenReference) str);
return wef.createEncryptedKey(null,MessageConstants.RSA_OAEP_KEY_TRANSPORT,keyInfo,cert.getPublicKey(),key);
}