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


Java XMLCryptoContext类代码示例

本文整理汇总了Java中javax.xml.crypto.XMLCryptoContext的典型用法代码示例。如果您正苦于以下问题:Java XMLCryptoContext类的具体用法?Java XMLCryptoContext怎么用?Java XMLCryptoContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLCryptoContext类属于javax.xml.crypto包,在下文中一共展示了XMLCryptoContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)
		throws KeySelectorException {

	for (Object o : keyInfo.getContent()) {
		if (o instanceof X509Data) {
			for (Object o2 : ((X509Data) o).getContent()) {
				if (o2 instanceof X509Certificate) {
					final X509Certificate cert = (X509Certificate) o2;
					return new KeySelectorResult() {
						public Key getKey() {
							return cert.getPublicKey();
						}
					};
				}
			}
		}
	}

	return null;
}
 
开发者ID:EixoX,项目名称:jetfuel,代码行数:22,代码来源:X509CertificateKeySelector.java

示例2: marshalPGPData

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
/**
 * Marshals a {@link PGPData}
 *
 * @param xwriter
 * @param pgpData
 * @param dsPrefix
 * @param context
 * @throws MarshalException
 */
public static void marshalPGPData(XmlWriter xwriter, PGPData pgpData, String dsPrefix, XMLCryptoContext context)
throws MarshalException {
    xwriter.writeStartElement(dsPrefix, "PGPData", XMLSignature.XMLNS);

    // create and append PGPKeyID element
    byte[] keyId = pgpData.getKeyId();
    if (keyId != null) {
        xwriter.writeTextElement(dsPrefix, "PGPKeyID", XMLSignature.XMLNS, Base64.encode(keyId));
    }

    // create and append PGPKeyPacket element
    byte[] keyPacket = pgpData.getKeyPacket();
    if (keyPacket != null) {
        xwriter.writeTextElement(dsPrefix, "XMLSignature.XMLNS", XMLSignature.XMLNS, Base64.encode(keyPacket));
    }

    // create and append any elements
    @SuppressWarnings("unchecked")
    List<XMLStructure> externalElements = pgpData.getExternalElements();
    for (XMLStructure externalItem : externalElements) {
        xwriter.marshalStructure(externalItem, dsPrefix, context);
    }

    xwriter.writeEndElement(); // "PGPData"
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:35,代码来源:Marshaller.java

示例3: marshal

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context)
    throws MarshalException
{
    xwriter.writeStartElement(dsPrefix, "RetrievalMethod", XMLSignature.XMLNS);

    // TODO - see whether it is important to capture the "here" attribute as part of the
    // marshalling - do any of the tests fail?
    // add URI and Type attributes
    here = xwriter.writeAttribute("", "", "URI", uri);
    xwriter.writeAttribute("", "", "Type", type);

    // add Transforms elements
    if (!transforms.isEmpty()) {
        xwriter.writeStartElement(dsPrefix, "Transforms", XMLSignature.XMLNS);
        for (Transform transform : transforms) {
            ((DOMTransform)transform).marshal(xwriter, dsPrefix, context);
        }
        xwriter.writeEndElement(); // "Transforms"
    }
    xwriter.writeEndElement(); // "RetrievalMethod"
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:23,代码来源:DOMRetrievalMethod.java

示例4: dereferenceAsXMLStructure

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context)
    throws URIReferenceException
{
    DocumentBuilder db = null;
    boolean secVal = Utils.secureValidation(context);
    try {
        ApacheData data = (ApacheData)dereference(context);
        db = XMLUtils.createDocumentBuilder(false, secVal);
        Document doc = db.parse(new ByteArrayInputStream
            (data.getXMLSignatureInput().getBytes()));
        Element kiElem = doc.getDocumentElement();
        if (kiElem.getLocalName().equals("X509Data")
            && XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) {
            return new DOMX509Data(kiElem);
        } else {
            return null; // unsupported
        }
    } catch (Exception e) {
        throw new URIReferenceException(e);
    } finally {
        if (db != null) {
            XMLUtils.repoolDocumentBuilder(db);
        }
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:26,代码来源:DOMRetrievalMethod.java

示例5: marshalInternal

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
private static void marshalInternal(XmlWriter xwriter, KeyInfo ki,
    String dsPrefix, XMLCryptoContext context, boolean declareNamespace) throws MarshalException {

    xwriter.writeStartElement(dsPrefix, "KeyInfo", XMLSignature.XMLNS);
    if (declareNamespace) {
        xwriter.writeNamespace(dsPrefix, XMLSignature.XMLNS);
    }

    xwriter.writeIdAttribute("", "", "Id", ki.getId());
    // create and append KeyInfoType elements
    List<XMLStructure> keyInfoTypes = getContent(ki);
    for (XMLStructure kiType : keyInfoTypes) {
        xwriter.marshalStructure(kiType, dsPrefix, context);
    }

    xwriter.writeEndElement(); // "KeyInfo"
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:18,代码来源:DOMKeyInfo.java

示例6: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException {
    for (final Object object : keyInfo.getContent()) {
        final XMLStructure info = (XMLStructure) object;
        if (info instanceof X509Data) {
            final X509Data x509Data = (X509Data) info;
            for (final Object certificado : x509Data.getContent()) {
                if (certificado instanceof X509Certificate) {
                    final X509Certificate x509Certificate = (X509Certificate) certificado;
                    if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) {
                        return new KeySelectorResult() {
                            @Override
                            public Key getKey() {
                                return x509Certificate.getPublicKey();
                            }
                        };
                    }
                }
            }
        }
    }
    throw new KeySelectorException("N\u00e3o foi localizada a chave do certificado.");
}
 
开发者ID:GilbertoMattos,项目名称:nfce,代码行数:24,代码来源:X509KeySelector.java

示例7: marshalParams

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException {
	LOG.debug("marshallParams(parent,context)");
	DOMStructure domParent = (DOMStructure) parent;
	Node parentNode = domParent.getNode();
	Element parentElement = (Element) parentNode;
	parentElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi",
			"http://schemas.openxmlformats.org/package/2006/digital-signature");
	Document document = parentNode.getOwnerDocument();
	for (String sourceId : this.sourceIds) {
		Element relationshipReferenceElement = document.createElementNS(
				"http://schemas.openxmlformats.org/package/2006/digital-signature", "mdssi:RelationshipReference");
		relationshipReferenceElement.setAttribute("SourceId", sourceId);
		parentElement.appendChild(relationshipReferenceElement);
	}
	for (String sourceType : this.sourceTypes) {
		Element relationshipsGroupReferenceElement = document.createElementNS(
				"http://schemas.openxmlformats.org/package/2006/digital-signature",
				"mdssi:RelationshipsGroupReference");
		relationshipsGroupReferenceElement.setAttribute("SourceType", sourceType);
		parentElement.appendChild(relationshipsGroupReferenceElement);
	}
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:24,代码来源:RelationshipTransformService.java

示例8: dereference

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public Data dereference(URIReference arg0, XMLCryptoContext arg1)
		throws URIReferenceException {

	String partPath = arg0.getURI().toString();
	System.out.println(partPath + " in package ? "
			+ odfDoc.getPackage().contains(partPath));

	// see if our document contains this part, if not dereference using
	// default dereferencer
	if (!odfDoc.getPackage().contains(partPath)) {
		return defaultURIDereferencer.dereference(arg0, arg1);
	}

	// return part content as octet stream data
	InputStream is = odfDoc.getPackage().getInputStream(partPath);
	OctetStreamData retData = new OctetStreamData(is);

	return retData;

}
 
开发者ID:y12studio,项目名称:bkbc-premature,代码行数:22,代码来源:HelloOdfSign.java

示例9: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException {
    for (final Object object : keyInfo.getContent()) {
        final XMLStructure info = (XMLStructure) object;
        if (info instanceof X509Data) {
            final X509Data x509Data = (X509Data) info;
            for (final Object certificado : x509Data.getContent()) {
                if (certificado instanceof X509Certificate) {
                    final X509Certificate x509Certificate = (X509Certificate) certificado;
                    if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) {
                        return new KeySelectorResult() {
                            @Override
                            public Key getKey() {
                                return x509Certificate.getPublicKey();
                            }
                        };
                    }
                }
            }
        }
    }
    throw new KeySelectorException("Nao foi localizada a chave do certificado.");
}
 
开发者ID:wmixvideo,项目名称:nfe,代码行数:24,代码来源:X509KeySelector.java

示例10: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException
{
    if ( keyInfo == null )
    {
        throw new KeySelectorException ( "Null KeyInfo object!" );
    }

    final SignatureMethod sm = (SignatureMethod)method;
    final List<?> list = keyInfo.getContent ();

    for ( int i = 0; i < list.size (); i++ )
    {
        final XMLStructure xmlStructure = (XMLStructure)list.get ( i );
        if ( xmlStructure instanceof KeyValue )
        {
            try
            {
                final PublicKey pk = ( (KeyValue)xmlStructure ).getPublicKey ();
                // make sure algorithm is compatible with method
                if ( algEquals ( sm.getAlgorithm (), pk.getAlgorithm () ) )
                {
                    return new SimpleKeySelectorResult ( pk );
                }
            }
            catch ( final KeyException ke )
            {
                throw new KeySelectorException ( ke );
            }

        }
    }
    throw new KeySelectorException ( "No KeyValue element found!" );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:35,代码来源:KeyValueKeySelector.java

示例11: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException
{
    if ( keyInfo == null )
    {
        throw new KeySelectorException ( "Null KeyInfo object!" );
    }

    final SignatureMethod sm = (SignatureMethod)method;
    final List<?> list = keyInfo.getContent ();

    for ( final Object l : list )
    {
        final XMLStructure xmlStructure = (XMLStructure)l;
        if ( xmlStructure instanceof X509Data )
        {
            for ( final Object o : ( (X509Data)xmlStructure ).getContent () )
            {
                KeySelectorResult result = null;
                if ( o instanceof X509Certificate )
                {
                    result = findPublicKey ( (X509Certificate)o, sm );
                }

                if ( result != null )
                {
                    return result;
                }
            }
        }
    }
    throw new KeySelectorException ( "No KeyValue element found!" );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:34,代码来源:X509KeySelector.java

示例12: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo,
        KeySelector.Purpose purpose, AlgorithmMethod algorithmMethod,
        XMLCryptoContext context) throws KeySelectorException {

    if (keyInfo == null) {
        throw new KeySelectorException("Null KeyInfo object!");
    }

    @SuppressWarnings("unchecked")
    List<XMLStructure> list = keyInfo.getContent();
    for (XMLStructure xmlStructure : list) {
        if (xmlStructure instanceof X509Data) {
            X509Data x509Data = (X509Data) xmlStructure;
            @SuppressWarnings("rawtypes")
            List content = x509Data.getContent();
            for (int i = 0; i < content.size(); i++) {
                Object x509Content = content.get(i);
                if (x509Content instanceof X509Certificate) {
                    X509Certificate certificate = (X509Certificate) x509Content;
                    try {
                        return getPublicKeyFromKeystore(certificate,
                                (SignatureMethod) algorithmMethod);
                    } catch (KeyStoreException e) {
                        throw new KeySelectorException(e);
                    }
                }
            }
        }
    }

    throw new KeySelectorException("No X509Data element found.");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:X509KeySelector.java

示例13: select

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public KeySelectorResult select(KeyInfo keyInfo,
        KeySelector.Purpose purpose, AlgorithmMethod algorithmMethod,
        XMLCryptoContext context) throws KeySelectorException {

    if (keyInfo == null) {
        throw new KeySelectorException("Null KeyInfo object!");
    }

    @SuppressWarnings("unchecked")
    List<XMLStructure> list = keyInfo.getContent();
    for (XMLStructure xmlStructure : list) {
        if (xmlStructure instanceof KeyValue) {
            PublicKey publicKey = null;
            try {
                publicKey = ((KeyValue) xmlStructure).getPublicKey();
            } catch (KeyException ke) {
                throw new KeySelectorException(ke);
            }
            if (algorithmCompatibleWithMethod(
                    algorithmMethod.getAlgorithm(),
                    publicKey.getAlgorithm())) {
                return new SimpleKeySelectorResult(publicKey);
            }
        }
    }

    throw new KeySelectorException("No RSA/DSA KeyValue element found");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:30,代码来源:KeyValueKeySelector.java

示例14: dereference

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:ValidationTests.java

示例15: dereference

import javax.xml.crypto.XMLCryptoContext; //导入依赖的package包/类
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:ErrorHandlerPermissions.java


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