|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The interface of the object that is able to create XML Signature for a given source represented by a tokenizer.
To create a signature we need data source to sign and
Example of the mostly used case - creating signature with private key and X509 certificate:
java.security.cert.X509Certificate certificate; Tokenizer source; java.security.PrivateKey privateKey; ... // obtain source, privateKey and certificate ... SignatureCreator creator = SignatureFactory.getInstance().getSignatureCreator(); Tokenizer sign = creator.createSignature(source, privateKey, certificate);
During signing, data source may be transformed by some algorithms.
If method addTransformAlgorithm
is not used, the only
canonicalization transformation is applied for data source. Application may implement
other transformation (see Transform
)
and then apply it to data source using addTransformAlgorithm
.
The KeyInfo
element is derived from type of the given key resp.
certificate. The common types of the KeyInfo
element, specified
by W3C, are DSAKeyValue
, RSAKeyValue
and X509Data
.
The user defined KeyInfo
element may be also generated. Just issue
setKeyContentData
to declare that the KeyContent with the given
name should be used.
Method Summary | |
void |
addAncestorNamespace(java.lang.String prefix,
java.lang.String value)
Adds namespace defined by the ancestor of the signature. |
void |
addAncestorNamespaces(java.util.Map namespaces)
Adds namespace defined by the ancestor of the signature. |
void |
addTransformAlgorithm(java.lang.String transformAlgorithm)
Adds transformation parameter for the signature. |
Tokenizer |
createSignature(Tokenizer source,
java.security.PrivateKey privateKey,
java.security.PublicKey publicKey)
Creates Signature for the given source with PrivateKey and PublicKey. |
Tokenizer |
createSignature(Tokenizer source,
java.security.PrivateKey privateKey,
java.security.cert.X509Certificate certificate)
Creates Signature for the given source with PrivateKey and PublicKey. |
Tokenizer |
createSignature(Tokenizer source,
javax.crypto.SecretKey secretKey)
Creates Signature for the given source with PrivateKey and PublicKey. |
void |
setCanonicalizationMethod(java.lang.String canonicalizationMethod)
Sets Canonicalization for the signature. |
void |
setDigestMethod(java.lang.String digestMethod)
Sets digestMethod for the signature |
void |
setKeyContentData(QName keyContentName,
java.util.Map keyContentData)
Adds KeyContent associates with a given keyContentName to the KeyInfo element that will be created by some of createSignature method. |
void |
setKeyName(java.lang.String keyName)
Sets KeyName for the signature. |
void |
setPrefix(java.lang.String prefix)
Sets prefix of the signature to the given value. |
void |
setReferenceURI(java.lang.String referenceURI)
Set uri attribute of the refencence element in the SignedInfo structure to the given URI. |
void |
setSignatureMethod(java.lang.String signatureMethod)
Sets SignatureMethod to a given string. |
Method Detail |
public void addTransformAlgorithm(java.lang.String transformAlgorithm)
transformAlgorithm
- to be added to.public void setDigestMethod(java.lang.String digestMethod)
digestMethod
- The new DigestMethod valuepublic void setCanonicalizationMethod(java.lang.String canonicalizationMethod)
canonicalizationMethod
- The new CanonicalizationMethod valuepublic void setSignatureMethod(java.lang.String signatureMethod)
signatureMethod
- The new SignatureMethod valuepublic void setKeyName(java.lang.String keyName)
keyName
- The new KeyName valuepublic void setReferenceURI(java.lang.String referenceURI)
referenceURI
- the given URI to set.public void setPrefix(java.lang.String prefix)
prefix
- the string to set to.public void addAncestorNamespace(java.lang.String prefix, java.lang.String value)
SignedInfo
element.
prefix
- namespace prefixvalue
- value of the namespacepublic void addAncestorNamespaces(java.util.Map namespaces)
SignedInfo
element.
namespaces
- map of the namespaces defined by ancestorpublic Tokenizer createSignature(Tokenizer source, java.security.PrivateKey privateKey, java.security.PublicKey publicKey) throws SignatureException
source
- the given data sourceprivateKey
- private key (DSA or RSA algorithm)publicKey
- public key (DSA or RSA algorithm)
SignatureException
- thrown when error occurspublic Tokenizer createSignature(Tokenizer source, java.security.PrivateKey privateKey, java.security.cert.X509Certificate certificate) throws SignatureException
source
- the given data sourceprivateKey
- private key (DSA or RSA algorithm)certificate
- X509 certificate
SignatureException
- thrown when error occurspublic Tokenizer createSignature(Tokenizer source, javax.crypto.SecretKey secretKey) throws SignatureException
source
- the given data sourcesecretKey
- secret key (HMAC-SHA1 algorithm)
SignatureException
- thrown when error occurspublic void setKeyContentData(QName keyContentName, java.util.Map keyContentData)
keyContentName
- name of the keyContentkeyContentData
- an additional information for constructing KeyContent
object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |