WSSEncryptionProvider.java revision 272ac8a1a482b3baeff7293aac5de828cfd1ee69
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: WSSEncryptionProvider.java,v 1.7 2009/08/29 03:06:01 mallas Exp $
*
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* <code>WSSEncryptionProvider</code> is a class for encrypting and
* decrypting WSS XML Documents which implements
* <code>AMEncryptionProvider</code>.
*/
public class WSSEncryptionProvider extends AMEncryptionProvider {
/** Creates a new instance of WSSEncryptionProvider */
public WSSEncryptionProvider() {
super();
}
/**
* Encrypts the given WSS XML element in a given XML Context document.
* @param doc the context XML Document.
* @param elmMap Map of (Element, wsu_id) to be encrypted.
* @param encDataEncAlg Encryption Key Algorithm.
* @param encDataEncAlgStrength Encryption Key Strength.
* @param certAlias Key Encryption Key cert alias.
* @param kekStrength Key Encryption Key Strength.
* @param tokenType Security token type.
* @param providerID Provider ID.
* @return org.w3c.dom.Document XML Document replaced with encrypted data
* for a given XML element.
*/
int kekStrength,
throws EncryptionException {
"ReplaceWSSElements: Null values for doc or elements map or public key");
"nullValues"));
}
"AndReplaceWSSElements: DOC input = "
}
}
} else {
}
} else {
}
if(secretKeyEncData == null) {
"generateKeyError"));
}
try {
// ENCRYPTED KEY
} else if(kekStrength == 192) {
} else if(kekStrength == 256) {
} else {
throw new EncryptionException(
}
} else {
throw new EncryptionException(
}
// Encrypt the key with key encryption key
// SecurityTokenReference
}
+tokenId);
}
if (wsu_ids_set != null) {
}
}
}
// ENCRYPTED KEY END
// ENCRYPTED DATA
}
// ENCRYPTED DATA END
"AndReplaceWSSElements: Encrypted DOC = "
}
"ReplaceWSSElements: XML Encryption error : ", xe);
throw new EncryptionException(xe);
}
return resultDoc;
}
/**
* Decrypt the given encrypted key.
* @param encryptedKey the encrypted key element
* @param certAlias the private key alias
* @return the key associated with the decrypted key.
*/
if(encryptedElem == null) {
return null;
}
try {
} catch (XMLEncryptionException xe) {
return null;
}
}
}