public class WSSecEncrypt extends WSSecEncryptedKey
Modifier and Type | Field and Description |
---|---|
protected byte[] |
embeddedKey |
protected String |
embeddedKeyName |
protected SecurityTokenReference |
securityTokenReference
SecurityTokenReference to be inserted into EncryptedData/keyInfo element.
|
bstToken, customEKTokenId, customEKTokenValueType, digestAlgo, document, encKeyId, encrUser, encryptedEphemeralKey, encryptedKeyElement, envelope, ephemeralKey, keyEncAlgo, symEncAlgo, symmetricKey, useThisCert
callbackLookup, doDebug, keyIdentifierType, parts, password, user
Constructor and Description |
---|
WSSecEncrypt() |
WSSecEncrypt(WSSConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
addExternalRefElement(Element dataRef,
WSSecHeader secHeader)
Adds (prepends) the external Reference element to the Security header.
|
void |
addInternalRefElement(Element dataRef)
Adds the internal Reference element to this Encrypt data.
|
Document |
build(Document doc,
Crypto crypto,
WSSecHeader secHeader)
Builds the SOAP envelope with encrypted Body and adds encrypted key.
|
static Element |
createDataRefList(Document doc,
Element referenceList,
List<String> encDataRefs)
Create DOM subtree for
xenc:EncryptedKey |
static List<String> |
doEncryption(Document doc,
WSSConfig config,
org.apache.xml.security.keys.KeyInfo keyInfo,
SecretKey secretKey,
String encryptionAlgorithm,
List<WSEncryptionPart> references,
CallbackLookup callbackLookup)
Perform encryption on the SOAP envelope.
|
Element |
encryptForExternalRef(Element dataRef,
List<WSEncryptionPart> references)
Deprecated.
Use encryptForRef(dataRef, references) instead
|
Element |
encryptForInternalRef(Element dataRef,
List<WSEncryptionPart> references)
Deprecated.
Use encryptForRef(dataRef, references) instead
|
Element |
encryptForRef(Element dataRef,
List<WSEncryptionPart> references)
Encrypt one or more parts or elements of the message.
|
SecurityTokenReference |
getSecurityTokenReference() |
boolean |
isEmbedEncryptedKey() |
boolean |
isEncryptSymmKey() |
void |
prepare(Document doc,
Crypto crypto)
Initialize a WSSec Encrypt.
|
void |
setCustomReferenceValue(String customReferenceValue) |
void |
setEmbeddedKeyName(String embeddedKeyName)
Set the key name for EMBEDDED_KEYNAME
|
void |
setEmbedEncryptedKey(boolean embedEncryptedKey) |
void |
setEncKeyIdDirectId(boolean b) |
void |
setEncryptSymmKey(boolean encryptSymmKey) |
void |
setKey(byte[] key)
Sets the key to use during embedded encryption.
|
void |
setKeyEnc(String keyEnc)
Sets the algorithm to encode the symmetric key.
|
void |
setSecurityTokenReference(SecurityTokenReference reference) |
appendBSTElementToHeader, appendToHeader, createCipherValue, createEncryptedKey, getBinarySecurityTokenElement, getBSTTokenId, getDigestAlgorithm, getEncryptedEphemeralKey, getEncryptedKeyElement, getEphemeralKey, getId, getKeyGenerator, getSymmetricEncAlgorithm, getSymmetricKey, isCertSet, prepareInternal, prependBSTElementToHeader, prependToHeader, setCustomEKTokenId, setCustomEKTokenValueType, setDigestAlgorithm, setDocument, setEncKeyId, setEncryptedKeyElement, setEphemeralKey, setKeyEncAlgo, setSymmetricEncAlgorithm, setSymmetricKey, setUserInfo, setUseThisCert
getKeyIdentifierType, getWsConfig, setBodyID, setCallbackLookup, setKeyIdentifierType, setParts, setUserInfo, setWsConfig, setWsuId
protected byte[] embeddedKey
protected String embeddedKeyName
protected SecurityTokenReference securityTokenReference
public WSSecEncrypt()
public WSSecEncrypt(WSSConfig config)
public void setKey(byte[] key)
key
- to use during encryption. The key must fit the selected
symmetrical encryption algorithmpublic void setKeyEnc(String keyEnc)
WSConstants.KEYTRANSPORT_RSAOEP
algorithm.keyEnc
- specifies the key encoding algorithm.WSConstants.KEYTRANSPORT_RSA15
,
WSConstants.KEYTRANSPORT_RSAOEP
public void setEmbeddedKeyName(String embeddedKeyName)
embeddedKeyName
- public void prepare(Document doc, Crypto crypto) throws WSSecurityException
prepare
in class WSSecEncryptedKey
doc
- The SOAP envelope as Document
crypto
- An instance of the Crypto API to handle keystore and certificatesWSSecurityException
public Document build(Document doc, Crypto crypto, WSSecHeader secHeader) throws WSSecurityException
doc
- the SOAP envelope as Document
with plain text Bodycrypto
- an instance of the Crypto API to handle keystore and CertificatessecHeader
- the security header element to hold the encrypted key element.Document
WSSecurityException
public Element encryptForRef(Element dataRef, List<WSEncryptionPart> references) throws WSSecurityException
WSEncryptionPart
object that
contain information about the elements to encrypt. The method call the
encryption method, takes the reference information generated during
encryption and add this to the xenc:Reference
element.
This method can be called after prepare()
and can be
called multiple times to encrypt a number of parts or elements.
The method generates a xenc:Reference
element that must
be added to this token. See addInternalRefElement()
.
If the dataRef
parameter is null
the method
creates and initializes a new Reference element.dataRef
- A xenc:Reference
element or null
references
- A list containing WSEncryptionPart objectsxenc:Reference
elementWSSecurityException
public Element encryptForInternalRef(Element dataRef, List<WSEncryptionPart> references) throws WSSecurityException
WSSecurityException
public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references) throws WSSecurityException
WSSecurityException
public void addInternalRefElement(Element dataRef)
encryptForInternalRef()
method. The reference element is
added to the EncryptedKey
element of this encrypt block.dataRef
- The internal enc:Reference
elementpublic void addExternalRefElement(Element dataRef, WSSecHeader secHeader)
encryptForExternalRef()
method. The method prepends the
reference element in the SecurityHeader.dataRef
- The external enc:Reference
elementsecHeader
- The security header.public static List<String> doEncryption(Document doc, WSSConfig config, org.apache.xml.security.keys.KeyInfo keyInfo, SecretKey secretKey, String encryptionAlgorithm, List<WSEncryptionPart> references, CallbackLookup callbackLookup) throws WSSecurityException
doc
- The document containing the SOAP envelope as document elementconfig
- The WSSConfig from which to generate wsu:ID'skeyInfo
- The KeyInfo object to set in EncryptedDatasecretKey
- The SecretKey object with which to encrypt dataencryptionAlgorithm
- The encryption algorithm URI to usereferences
- The list of references to encryptWSSecurityException
public static Element createDataRefList(Document doc, Element referenceList, List<String> encDataRefs)
xenc:EncryptedKey
doc
- the SOAP envelope parent documentreferenceList
- encDataRefs
- xenc:EncryptedKey
elementpublic SecurityTokenReference getSecurityTokenReference()
public void setSecurityTokenReference(SecurityTokenReference reference)
reference
- public boolean isEncryptSymmKey()
public void setEncryptSymmKey(boolean encryptSymmKey)
public void setCustomReferenceValue(String customReferenceValue)
public void setEncKeyIdDirectId(boolean b)
public void setEmbedEncryptedKey(boolean embedEncryptedKey)
public boolean isEmbedEncryptedKey()
Copyright © 2018 JBoss by Red Hat. All rights reserved.