当前位置: 首页>>代码示例>>Java>>正文


Java Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS属性代码示例

本文整理汇总了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;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:4,代码来源:Canonicalizer20010315ExclOmitComments.java

示例2: ExclusiveCanonicalXMLWithoutComments

public ExclusiveCanonicalXMLWithoutComments(String... inclusiveNamespacePrefixes)
{
    super(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS, inclusiveNamespacePrefixes);
}
 
开发者ID:luisgoncalves,项目名称:xades4j,代码行数:4,代码来源:ExclusiveCanonicalXMLWithoutComments.java

示例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);
        }
    }
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:46,代码来源:HostAgreement.java

示例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);
    }
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:73,代码来源:SAMLSignedObject.java


注:本文中的org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。