@ThreadSafe public class XMLSignatureSigningStage extends BaseIteratingStage<Element>
DOMElementItem
collection.
This stage requires the following properties be set prior to initialization:
privateKey| Modifier and Type | Class and Description |
|---|---|
static class |
XMLSignatureSigningStage.ShaVariant
The variant of SHA to use in the various signature algorithms.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ALGO_ID_C14N_EXCL_OMIT_COMMENTS
Exclusive canonicalization, WITHOUT comments, algorithm ID: "http://www.w3.org/2001/10/xml-exc-c14n#" .
|
static String |
ALGO_ID_C14N_EXCL_WITH_COMMENTS
Exclusive canonicalization, WITH comments, algorithm ID: "http://www.w3.org/2001/10/xml-exc-c14n#WithComments" .
|
static String |
ALGO_ID_C14N_OMIT_COMMENTS
Inclusive canonicalization, WITHOUT comments, algorithm ID: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" .
|
static String |
ALGO_ID_C14N_WITH_COMMENTS
Inclusive canonicalization, WITH comments, algorithm ID: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" .
|
static String |
ALGO_ID_DIGEST_SHA1
SHA1 digest algorithm ID: "http://www.w3.org/2000/09/xmldsig#sha1" .
|
static String |
ALGO_ID_DIGEST_SHA256
SHA256 digest algorithm ID: "http://www.w3.org/2001/04/xmlenc#sha256" .
|
static String |
ALGO_ID_DIGEST_SHA384
SHA384 digest algorithm ID: "http://www.w3.org/2001/04/xmldsig-more#sha384" .
|
static String |
ALGO_ID_DIGEST_SHA512
SHA512 digest algorithm ID: "http://www.w3.org/2001/04/xmlenc#sha512" .
|
static String |
ALGO_ID_SIGNATURE_RSA_SHA1
RSA-SHA1 signature algorithm ID: "http://www.w3.org/2000/09/xmldsig#rsa-sha1" .
|
static String |
ALGO_ID_SIGNATURE_RSA_SHA256
RSA-SHA256 signature algorithm ID: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" .
|
static String |
ALGO_ID_SIGNATURE_RSA_SHA384
RSA-SHA384 signature algorithm ID: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384" .
|
static String |
ALGO_ID_SIGNATURE_RSA_SHA512
RSA-SHA512 signature algorithm ID: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" .
|
private String |
c14nAlgo
Canonicalization algorithm to use.
|
private boolean |
c14nExclusive
Whether to use exclusive canonicalization.
|
private boolean |
c14nWithComments
Whether to include comments in the canonicalized data.
|
private List<X509Certificate> |
certificates
Certificate chain, with end entity certificate as element 0, to be included with the signature.
|
private List<X509CRL> |
crls
CRLs to be included with the signature.
|
private boolean |
debugPreDigest
Whether to debug digest operations by logging the pre-digest data stream.
|
private String |
digestAlgo
Digest algorithm used.
|
private List<QName> |
idAttributeNames
Names of attributes to treat as ID attributes for signature referencing.
|
private boolean |
includeKeyNames
Whether key names should be included in the signature's KeyInfo.
|
private boolean |
includeKeyValue
Whether the public key should be included in the signature's KeyInfo.
|
private boolean |
includeX509Certificates
Whether the certificates chain should be included in the signature's KeyInfo.
|
private boolean |
includeX509Crls
Whether the CRLs should be included in the signature's KeyInfo.
|
private boolean |
includeX509IssuerSerial
Whether the end-entity certificate's issuer and serial number should be included in the signature's KeyInfo.
|
private boolean |
includeX509SubjectName
Whether the end-entity certificate's subject name should be included in the signature's KeyInfo.
|
private List<String> |
inclusivePrefixList
Inclusive prefix list used with exclusive canonicalization.
|
private KeyInfoFactory |
keyInfoFactory
Factory used to create KeyInfo objects.
|
private List<String> |
keyNames
Explicit names to associate with the given signing key.
|
private Logger |
log
Class logger.
|
private PrivateKey |
privKey
Private key used to sign data.
|
private PublicKey |
pubKey
Public key associated with the given private key.
|
static String |
RFC4501_BASE_URI
RFC4501 base URI: "http://www.w3.org/2001/04/xmldsig-more" .
|
private XMLSignatureSigningStage.ShaVariant |
shaVariant
SHA algorithm variant used in signature and digest algorithms.
|
private String |
sigAlgo
Signature algorithm used.
|
static QName |
SIGNATURE_NAME
QName of the Signature element.
|
static String |
TRANSFORM_ENVELOPED_SIGNATURE
Enveloped signature transform ID: "http://www.w3.org/2000/09/xmldsig#enveloped-signature" .
|
static String |
XML_ENC_NS_URI
XML Encryption base URI: "http://www.w3.org/2001/04/xmlenc#" .
|
static String |
XML_SIG_NS_URI
XML Signature base URI: "http://www.w3.org/2000/09/xmldsig#" .
|
private XMLSignatureFactory |
xmlSigFactory
Factory used to create XML signature objects.
|
| Constructor and Description |
|---|
XMLSignatureSigningStage()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addKeyNames(ArrayList<Object> keyInfoItems)
Adds key names to the KeyInfo, if key names are to be included.
|
protected void |
addKeyValue(ArrayList<Object> keyInfoItems)
Adds raw key values to the KeyInfo if key values are to be included.
|
protected void |
addX509Data(ArrayList<Object> keyInfoItems)
Adds X509 data (subject names, certificates, CRLs, and Issuer/Serial) set to be included, into the key info.
|
protected KeyInfo |
buildKeyInfo()
Builds the KeyInfo element to be included in the signature.
|
protected Reference |
buildSignatureReference(Element target)
Builds the references to the signed content.
|
protected SignedInfo |
buildSignedInfo(Element target)
Gets the descriptor of signed content.
|
protected void |
doDestroy() |
protected boolean |
doExecute(Item<Element> item)
Processes a given Item.
|
protected void |
doInitialize() |
List<X509Certificate> |
getCertificates()
Gets the certificates associated with the key used to sign the content.
|
List<X509CRL> |
getCrls()
Gets the CRLs associated with certificates.
|
String |
getDigestAlgo()
Gets the digest algorithm used when signing.
|
protected String |
getElementId(Element target)
Determines the ID for the element to be signed.
|
List<QName> |
getIdAttributeNames()
Gets the names of the attributes treated as reference IDs.
|
List<String> |
getInclusivePrefixList()
Gets the inclusive prefix list used during exclusive canonicalization.
|
List<String> |
getKeyNames()
Gets the explicit key names added to the KeyInfo.
|
PrivateKey |
getPrivateKey()
Gets the private key used to sign the content.
|
PublicKey |
getPublicKey()
Gets the public key associated with private key used to sign the content.
|
XMLSignatureSigningStage.ShaVariant |
getShaVariant()
Gets the SHA algorithm variant used when computing the signature and digest.
|
String |
getSigAlgo()
Gets the signature algorithm used when signing.
|
boolean |
isC14nExclusive()
Gets whether exclusive canonicalization will be used.
|
boolean |
isC14nWithComments()
Gets whether comments are canonicalized.
|
boolean |
isDebugPreDigest()
Gets whether logging of the pre-digest data stream is enabled.
|
boolean |
isIncludeKeyNames()
Gets whether key names are included in the KeyInfo.
|
boolean |
isIncludeKeyValue()
Gets whether key values are included in the KeyInfo.
|
boolean |
isIncludeX509Certificates()
Gets whether X509 certificates are included in the KeyInfo.
|
boolean |
isIncludeX509Crls()
Gets whether CRLs are included in the KeyInfo.
|
boolean |
isIncludeX509IssuerSerial()
Gets whether the end-entity certificate's issuer and serial number are included in the KeyInfo.
|
boolean |
isIncludeX509SubjectName()
Gets whether end-entity certifcate's subject name is included in the KeyInfo.
|
void |
setC14nExclusive(boolean isExclusive)
Sets whether exclusive canonicalization will be used.
|
void |
setC14nWithComments(boolean withComments)
Sets whether comments are canonicalized.
|
void |
setCertificates(List<X509Certificate> certs)
Sets the certificates associated with the key used to sign the content.
|
void |
setCrls(List<X509CRL> revocationLists)
Sets the CRLs associated with certificates.
|
void |
setDebugPreDigest(boolean debug)
Sets whether logging of the pre-digest data stream is enabled.
|
void |
setIdAttributeNames(List<QName> names)
Sets the names of the attributes treated as reference IDs.
|
void |
setIncludeKeyNames(boolean include)
Sets whether key names are included in the KeyInfo.
|
void |
setIncludeKeyValue(boolean included)
Sets whether key values are included in the KeyInfo.
|
void |
setIncludeX509Certificates(boolean include)
Sets whether X509 certificates are included in the KeyInfo.
|
void |
setIncludeX509Crls(boolean include)
Sets whether CRLs are included in the KeyInfo.
|
void |
setIncludeX509IssuerSerial(boolean include)
Sets whether the end-entity certificate's issuer and serial number are included in the KeyInfo.
|
void |
setIncludeX509SubjectName(boolean include)
Sets whether end-entity certifcate's subject name is included in the KeyInfo.
|
void |
setInclusivePrefixList(List<String> prefixList)
Sets the inclusive prefix list used during exclusive canonicalization.
|
void |
setKeyNames(List<String> names)
Sets the explicit key names added to the KeyInfo.
|
void |
setPrivateKey(PrivateKey key)
Sets the private key used to sign the content.
|
void |
setPublicKey(PublicKey key)
Sets public key associated with private key used to sign the content.
|
void |
setShaVariant(XMLSignatureSigningStage.ShaVariant variant)
Sets the SHA algorithm variant used when computing the signature and digest.
|
doExecuteexecute, getCollectionPredicate, setCollectionPredicatesetIdgetIddestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdestroy, isDestroyedpublic static final String XML_SIG_NS_URI
public static final QName SIGNATURE_NAME
public static final String XML_ENC_NS_URI
public static final String RFC4501_BASE_URI
public static final String ALGO_ID_SIGNATURE_RSA_SHA1
public static final String ALGO_ID_SIGNATURE_RSA_SHA256
public static final String ALGO_ID_SIGNATURE_RSA_SHA384
public static final String ALGO_ID_SIGNATURE_RSA_SHA512
public static final String ALGO_ID_DIGEST_SHA1
public static final String ALGO_ID_DIGEST_SHA256
public static final String ALGO_ID_DIGEST_SHA384
public static final String ALGO_ID_DIGEST_SHA512
public static final String ALGO_ID_C14N_OMIT_COMMENTS
public static final String ALGO_ID_C14N_WITH_COMMENTS
public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS
public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS
public static final String TRANSFORM_ENVELOPED_SIGNATURE
private final Logger log
private XMLSignatureFactory xmlSigFactory
private KeyInfoFactory keyInfoFactory
private XMLSignatureSigningStage.ShaVariant shaVariant
ShaVariant.SHA256private PrivateKey privKey
private PublicKey pubKey
private List<X509Certificate> certificates
private String sigAlgo
private String digestAlgo
private boolean c14nExclusive
trueprivate boolean c14nWithComments
falseprivate String c14nAlgo
c14nExclusive and
c14nWithComments properties.private List<String> inclusivePrefixList
private List<QName> idAttributeNames
private List<String> keyNames
private boolean includeKeyNames
trueprivate boolean includeKeyValue
falseprivate boolean includeX509SubjectName
falseprivate boolean includeX509Certificates
trueprivate boolean includeX509Crls
falseprivate boolean includeX509IssuerSerial
falseprivate boolean debugPreDigest
false@Nonnull public XMLSignatureSigningStage.ShaVariant getShaVariant()
public void setShaVariant(@Nonnull XMLSignatureSigningStage.ShaVariant variant)
variant - SHA algorithm variant used when computing the signature and digest@Nullable public PrivateKey getPrivateKey()
public void setPrivateKey(@Nonnull PrivateKey key)
key - private key used to sign the content@Nullable public PublicKey getPublicKey()
public void setPublicKey(@Nullable PublicKey key)
key - public key associated with private key used to sign the content@Nonnull @NonnullElements @Unmodifiable public List<X509Certificate> getCertificates()
public void setCertificates(@Nullable@NullableElements List<X509Certificate> certs)
certs - certificates associated with the key used to sign the content@Nonnull @NonnullElements @Unmodifiable public List<X509CRL> getCrls()
public void setCrls(@Nullable@NullableElements List<X509CRL> revocationLists)
revocationLists - CRLs associated with certificatespublic boolean isC14nExclusive()
public void setC14nExclusive(boolean isExclusive)
isExclusive - whether exclusive canonicalization will be usedpublic boolean isC14nWithComments()
public void setC14nWithComments(boolean withComments)
withComments - whether comments are canonicalized@Nonnull @NonnullElements @Unmodifiable public List<String> getInclusivePrefixList()
public void setInclusivePrefixList(@Nullable@NullableElements List<String> prefixList)
prefixList - inclusive prefix list used during exclusive canonicalization@Nonnull @NonnullElements @Unmodifiable public List<QName> getIdAttributeNames()
public void setIdAttributeNames(@Nonnull@NullableElements List<QName> names)
names - names of the attributes treated as reference IDs@Nonnull @NonnullElements public List<String> getKeyNames()
public void setKeyNames(@Nullable@NullableElements List<String> names)
names - explicit key names added to the KeyInfopublic boolean isIncludeKeyNames()
public void setIncludeKeyNames(boolean include)
include - whether key names are included in the KeyInfopublic boolean isIncludeKeyValue()
public void setIncludeKeyValue(boolean included)
included - whether key values are included in the KeyInfopublic boolean isIncludeX509SubjectName()
public void setIncludeX509SubjectName(boolean include)
include - whether end-entity certifcate's subject name is included in the KeyInfopublic boolean isIncludeX509Certificates()
public void setIncludeX509Certificates(boolean include)
include - whether X509 certificates are included in the KeyInfopublic boolean isIncludeX509Crls()
public void setIncludeX509Crls(boolean include)
include - whether CRLs are included in the KeyInfopublic boolean isIncludeX509IssuerSerial()
public void setIncludeX509IssuerSerial(boolean include)
include - whether the end-entity certificate's issuer and serial number are included in the KeyInfopublic boolean isDebugPreDigest()
public void setDebugPreDigest(boolean debug)
debug - whether logging of the pre-digest data stream is enabledpublic String getSigAlgo()
public String getDigestAlgo()
protected boolean doExecute(@Nonnull Item<Element> item) throws StageProcessingException
doExecute in class BaseIteratingStage<Element>item - Item on which to operateStageProcessingException - thrown if there is a problem with the stage processing@Nonnull protected SignedInfo buildSignedInfo(@Nonnull Element target) throws StageProcessingException
target - the element that will be signedStageProcessingException - thrown if there is a problem create the signed content descriptor@Nonnull protected Reference buildSignatureReference(@Nonnull Element target) throws StageProcessingException
target - the element to be signedStageProcessingException - thrown if there is a problem creating the reference to the element@Nullable protected String getElementId(@Nonnull Element target)
idAttributeNames then the value of the attribute is used as the
ID value. If no ID attribute names are given, or none of the given ones match, and one or more of the attributes
is marked as an ID attribute (i.e. Attr.isId() is true), then the value of one of those attributes is
used.target - an element to be referenced by the signature@Nonnull protected KeyInfo buildKeyInfo() throws StageProcessingException
StageProcessingException - thrown if there is a problem creating the KeyInfo descriptorprotected void addKeyNames(@Nonnull@NonnullElements@Live ArrayList<Object> keyInfoItems) throws StageProcessingException
keyInfoItems - collector for KeyInfo childrenStageProcessingException - thrown if there is a problem creating the KeyName contentprotected void addKeyValue(@Nonnull@NonnullElements@Live ArrayList<Object> keyInfoItems) throws StageProcessingException
keyInfoItems - collector for KeyInfo childrenStageProcessingException - thrown if there is a problem creating the KeyValue contentprotected void addX509Data(@Nonnull@NonnullElements@Live ArrayList<Object> keyInfoItems) throws StageProcessingException
keyInfoItems - collector for KeyInfo childrenStageProcessingException - thrown if there is a problem creating the X509Data contentprotected void doDestroy()
doDestroy in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponentprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponentnet.shibboleth.utilities.java.support.component.ComponentInitializationExceptionCopyright © 1999–2016. All rights reserved.