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


Java X509Data.getContent方法代码示例

本文整理汇总了Java中javax.xml.crypto.dsig.keyinfo.X509Data.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java X509Data.getContent方法的具体用法?Java X509Data.getContent怎么用?Java X509Data.getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.crypto.dsig.keyinfo.X509Data的用法示例。


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

示例1: marshal

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
public static void marshal(XmlWriter xwriter, X509Data x509Data, String dsPrefix, XMLCryptoContext context)
    throws MarshalException
{
    xwriter.writeStartElement(dsPrefix, "X509Data", XMLSignature.XMLNS);

    @SuppressWarnings("unchecked")
    List<Object> content = x509Data.getContent();
    // append children and preserve order
    for (int i = 0, size = content.size(); i < size; i++) {
        Object object = content.get(i);
        if (object instanceof X509Certificate) {
            marshalCert(xwriter, (X509Certificate) object,dsPrefix);
        } else if (object instanceof XMLStructure) {
            xwriter.marshalStructure((XMLStructure) object, dsPrefix, context);
        } else if (object instanceof byte[]) {
            marshalSKI(xwriter, (byte[]) object, dsPrefix);
        } else if (object instanceof String) {
            marshalSubjectName(xwriter, (String) object, dsPrefix);
        } else if (object instanceof X509CRL) {
            marshalCRL(xwriter, (X509CRL) object, dsPrefix);
        }
    }
    xwriter.writeEndElement(); // "X509Data"
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:25,代码来源:DOMX509Data.java

示例2: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的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

示例3: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的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

示例4: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的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

示例5: equals

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof X509Data)) {
        return false;
    }
    X509Data oxd = (X509Data)o;

    @SuppressWarnings("unchecked") List<Object> ocontent = oxd.getContent();
    int size = content.size();
    if (size != ocontent.size()) {
        return false;
    }

    for (int i = 0; i < size; i++) {
        Object x = content.get(i);
        Object ox = ocontent.get(i);
        if (x instanceof byte[]) {
            if (!(ox instanceof byte[]) ||
                !Arrays.equals((byte[])x, (byte[])ox)) {
                return false;
            }
        } else {
            if (!(x.equals(ox))) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:DOMX509Data.java

示例6: equals

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof X509Data)) {
        return false;
    }
    X509Data oxd = (X509Data)o;

    List<?> ocontent = oxd.getContent();
    int size = content.size();
    if (size != ocontent.size()) {
        return false;
    }

    for (int i = 0; i < size; i++) {
        Object x = content.get(i);
        Object ox = ocontent.get(i);
        if (x instanceof byte[]) {
            if (!(ox instanceof byte[]) ||
                !Arrays.equals((byte[])x, (byte[])ox)) {
                return false;
            }
        } else {
            if (!(x.equals(ox))) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:DOMX509Data.java

示例7: extractCertificate

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
private static X509Certificate extractCertificate(XMLSignature signature) {

        LOG.debug("Extracting certificate from XML signature...");

        X509Certificate certificate = null;

        for (Object o1 : signature.getKeyInfo().getContent()) {
            XMLStructure info = (XMLStructure) o1;
            if (!(info instanceof X509Data)) {
                continue;
            }

            X509Data x509Data = (X509Data) info;

            for (Object o : x509Data.getContent()) {
                if (o instanceof X509Certificate) {
                    certificate = (X509Certificate) o;
                    break;
                }
            }

            // Do not keep on searching if the certificate has been found
            if (certificate != null) {
                break;
            }
        }

        LOG.debug("Certificate found in XML signature: {}", certificate);

        return certificate;
    }
 
开发者ID:identio,项目名称:identio-saml,代码行数:32,代码来源:Validator.java

示例8: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
/**
 * Attempts to find a key that satisfies the specified constraints. it's the
 * first public key contained in X509 certificate that match the authorized
 * signature methods.
 *
 * @param keyInfo KeyInfo of the document
 * @param context Crypto context
 * @param method  Algorithm
 * @param purpose Purpose
 * @return A key that satisfies the constraints
 * @throws KeySelectorException Thrown when no keys are found in the document
 */
@SuppressWarnings("rawtypes")
@Override
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method,
                                XMLCryptoContext context) throws KeySelectorException {

    for (Object o1 : keyInfo.getContent()) {

        XMLStructure info = (XMLStructure) o1;

        if (!(info instanceof X509Data)) {
            continue;
        }

        X509Data x509Data = (X509Data) info;

        for (Object o : x509Data.getContent()) {

            if (!(o instanceof X509Certificate)) {
                continue;
            }

            final PublicKey publicKey = ((X509Certificate) o).getPublicKey();

            return () -> publicKey;
        }
    }

    throw new KeySelectorException("No key found!");
}
 
开发者ID:identio,项目名称:identio-saml,代码行数:42,代码来源:X509KeySelector.java

示例9: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, 
		AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException {
	if (keyInfo == null)
		throw new KeySelectorException("Null KeyInfo");
	List<?> list = keyInfo.getContent();
	PublicKey pk = null;

	for (int i = 0; i < list.size(); i++) {
		XMLStructure xmlStructure = (XMLStructure) list.get(i);
		if (xmlStructure instanceof KeyValue) {
			try {
				pk = ((KeyValue)xmlStructure).getPublicKey();
			} catch(KeyException ke) {
				throw new KeySelectorException(ke.getMessage());
			}
			break;
		} else if (xmlStructure instanceof X509Data) {
			X509Data x509data = (X509Data)xmlStructure;
			List<?> x509datalist = x509data.getContent();
			for (int j = 0; j < x509datalist.size(); j++) {
				if (x509datalist.get(j) instanceof X509Certificate) {
					X509Certificate cert = (X509Certificate)x509datalist.get(j);
					pk = cert.getPublicKey();
					break;
				}
			}
		}
	}
	if (pk != null) {
		final PublicKey retpk = pk;
		logger.debug("PublicKey from XML=" + pk);
		return new KeySelectorResult() {public Key getKey(){return retpk;}};
	}
	throw new KeySelectorException("Missing KeyValue");
}
 
开发者ID:IRSgov,项目名称:IDES-Data-Preparation-Java,代码行数:36,代码来源:UtilShared.java

示例10: equals

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }

    if (!(o instanceof X509Data)) {
        return false;
    }
    X509Data oxd = (X509Data) o;

    List ocontent = oxd.getContent();
    int size = content.size();
    if (size != ocontent.size()) {
        return false;
    }

    for (int i = 0; i < size; i++) {
        Object x = content.get(i);
        Object ox = ocontent.get(i);
        if (x instanceof byte[]) {
            if (!(ox instanceof byte[]) ||
                !Arrays.equals((byte[]) x, (byte[]) ox)) {
                return false;
            }
        } else {
            if (!(x.equals(ox))) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:34,代码来源:DOMX509Data.java

示例11: select

import javax.xml.crypto.dsig.keyinfo.X509Data; //导入方法依赖的package包/类
@Override
@Nonnull
public KeySelectorResult select (@Nonnull final KeyInfo aKeyInfo,
                                 final KeySelector.Purpose aPurpose,
                                 @Nonnull final AlgorithmMethod aMethod,
                                 final XMLCryptoContext aContext) throws KeySelectorException
{
  for (final Object aKeyInfoElement : aKeyInfo.getContent ())
  {
    final XMLStructure aXMLStructure = (XMLStructure) aKeyInfoElement;
    if (aXMLStructure instanceof X509Data)
    {
      // We found a certificate
      final X509Data x509Data = (X509Data) aXMLStructure;
      for (final Object aX509Element : x509Data.getContent ())
      {
        if (aX509Element instanceof X509Certificate)
        {
          final X509Certificate aCert = (X509Certificate) aX509Element;
          final PublicKey aPublicKey = aCert.getPublicKey ();
          // Make sure the algorithm is compatible
          // with the method.
          if (algorithmEquals (aMethod.getAlgorithm (), aPublicKey.getAlgorithm ()))
            return new ConstantKeySelectorResult (aPublicKey);
        }
      }
    }
  }
  throw new KeySelectorException ("No key found!");
}
 
开发者ID:phax,项目名称:ph-xmldsig,代码行数:31,代码来源:X509KeySelector.java


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