本文整理汇总了Java中org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS属性的典型用法代码示例。如果您正苦于以下问题:Java Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS属性的具体用法?Java Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS怎么用?Java Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.xml.security.c14n.Canonicalizer
的用法示例。
在下文中一共展示了Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineGetURI
/** @inheritDoc */
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
}
示例2: ExclusiveCanonicalXMLWithoutComments
public ExclusiveCanonicalXMLWithoutComments(String... inclusiveNamespacePrefixes)
{
super(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS, inclusiveNamespacePrefixes);
}
示例3: sign
public void sign(List<X509Certificate> certs, PrivateKey key, String sigalg, String digalg) throws Exception {
try {
unsign();
// Build the empty signature.
sig = new XMLSignature(this.doc, "", sigalg, Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
// Have the object place it in the proper place.
root.appendChild(sig.getElement());
Transforms transforms = new Transforms(sig.getDocument());
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
transforms.item(1).getElement().appendChild(
new InclusiveNamespaces(this.doc, PolicyConstants.INCLUSIVE_NAMESPACES).getElement());
sig.addDocument("", transforms, (digalg != null) ? digalg : MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
// Add any X.509 certificates provided.
X509Data x509 = new X509Data(root.getOwnerDocument());
if (certs != null) {
int count = 0;
for (int i = 0; i < certs.size(); i++) {
X509Certificate cert = certs.get(i);
if (((i + 1) < certs.size()) && count > 0) {
// Last (but not only) cert in chain. Only add if
// it's not self-signed.
if (((X509Certificate) cert).getSubjectDN().equals(((X509Certificate) cert).getIssuerDN()))
break;
}
x509.addCertificate((X509Certificate) cert);
count++;
}
}
if (x509.lengthCertificate() > 0) {
KeyInfo keyinfo = new KeyInfo(root.getOwnerDocument());
keyinfo.add(x509);
sig.getElement().appendChild(keyinfo.getElement());
}
// Finally, sign the thing.
sig.sign(key);
} catch (XMLSecurityException e) {
unsign();
throw new Exception("XML security exception: " + e.getMessage(), e);
}
}
示例4: sign
/**
* Sign the SAML object according to the input parameters
*
* @param sigalg The XML signature algorithm to apply
* @param digalg The digest algorithm to apply
* @param k The secret or private key to sign the resulting digest
* @param certs The public key certificate(s) to embed in the object, if any
* @throws SAMLException Thrown if an error occurs while constructing the signature
*/
public void sign(String sigalg, String digalg, Key k, Collection certs)
throws SAMLException
{
unsign();
// Generate the DOM if not already built, and anchor the DOM in the document.
toDOM();
plantRoot();
try
{
// Build the empty signature.
sig=new XMLSignature(root.getOwnerDocument(),"",sigalg,Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
// Have the object place it in the proper place.
insertSignature();
Transforms transforms = new Transforms(sig.getDocument());
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
transforms.item(1).getElement().appendChild(
new InclusiveNamespaces(root.getOwnerDocument(),config.getProperty("gov.nih.nci.cagrid.opensaml.inclusive-namespace-prefixes")).getElement()
);
if (config.getBooleanProperty("gov.nih.nci.cagrid.opensaml.compatibility-mode"))
sig.addDocument("",transforms,(digalg!=null) ? digalg : MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
else
sig.addDocument("#" + getId(),transforms,(digalg!=null) ? digalg : MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
// Add any X.509 certificates provided.
X509Data x509 = new X509Data(root.getOwnerDocument());
if (certs!=null)
{
int count = 0;
Iterator i=certs.iterator();
while (i.hasNext())
{
Object cert=i.next();
if (cert instanceof X509Certificate) {
if (!i.hasNext() && count > 0) {
// Last (but not only) cert in chain. Only add if it's not self-signed.
if (((X509Certificate)cert).getSubjectDN().equals(((X509Certificate)cert).getIssuerDN()))
break;
}
x509.addCertificate((X509Certificate)cert);
}
count++;
}
}
if (x509.lengthCertificate()>0)
{
KeyInfo keyinfo = new KeyInfo(root.getOwnerDocument());
keyinfo.add(x509);
sig.getElement().appendChild(keyinfo.getElement());
}
// Finally, sign the thing.
sig.sign(k);
}
catch (XMLSecurityException e)
{
unsign();
throw new InvalidCryptoException("SAMLSignedObject.sign() detected an XML security exception: " + e.getMessage(),e);
}
}