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


Java X509Data类代码示例

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


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

示例1: setSignatureRaw

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
private static Signature setSignatureRaw(String signatureAlgorithm, X509Credential cred) throws SSOAgentException {
    Signature signature = (Signature) buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
    signature.setSigningCredential(cred);
    signature.setSignatureAlgorithm(signatureAlgorithm);
    signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);

    try {
        KeyInfo keyInfo = (KeyInfo) buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
        X509Data data = (X509Data) buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
        org.opensaml.xml.signature.X509Certificate cert =
                (org.opensaml.xml.signature.X509Certificate) buildXMLObject(org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME);
        String value =
                org.apache.xml.security.utils.Base64.encode(cred.getEntityCertificate().getEncoded());
        cert.setValue(value);
        data.getX509Certificates().add(cert);
        keyInfo.getX509Datas().add(data);
        signature.setKeyInfo(keyInfo);
        return signature;

    } catch (CertificateEncodingException e) {
        throw new SSOAgentException("Error getting certificate", e);
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:24,代码来源:SSOAgentUtils.java

示例2: processEntityCertificate

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/** Process the value of {@link X509Credential#getEntityCertificate()}.
 * 
 * @param keyInfo the KeyInfo that is being built
 * @param x509Data the X509Data that is being built
 * @param credential the Credential that is being processed
 * @throws SecurityException thrown if the certificate data can not be encoded from the Java certificate object
 */
protected void processEntityCertificate(KeyInfo keyInfo, X509Data x509Data, X509Credential credential) 
        throws SecurityException {
    
    if (credential.getEntityCertificate() == null) {
        return;
    }
    
    java.security.cert.X509Certificate javaCert = credential.getEntityCertificate();
    
    processCertX509DataOptions(x509Data, javaCert);
    processCertKeyNameOptions(keyInfo, javaCert);
    
    // The cert chain includes the entity cert, so don't add a duplicate
    if (options.emitEntityCertificate && ! options.emitEntityCertificateChain) {
        try {
            X509Certificate xmlCert = KeyInfoHelper.buildX509Certificate(javaCert);
            x509Data.getX509Certificates().add(xmlCert);
        } catch (CertificateEncodingException e) {
            throw new SecurityException("Error generating X509Certificate element " 
                    + "from credential's end-entity certificate", e);
        }
    }
    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:X509KeyInfoGeneratorFactory.java

示例3: processEntityCertificateChain

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/** Process the value of {@link X509Credential#getEntityCertificateChain()}.
 * 
 * @param keyInfo the KeyInfo that is being built
 * @param x509Data the X509Data that is being built
 * @param credential the Credential that is being processed
 * @throws SecurityException thrown if the certificate data can not be encoded from the Java certificate object
 */
protected void processEntityCertificateChain(KeyInfo keyInfo, X509Data x509Data, X509Credential credential) 
        throws SecurityException {
    
    if (options.emitEntityCertificateChain && credential.getEntityCertificateChain() != null) {
        for (java.security.cert.X509Certificate javaCert : credential.getEntityCertificateChain()) {
            try {
                X509Certificate xmlCert = KeyInfoHelper.buildX509Certificate(javaCert);
                x509Data.getX509Certificates().add(xmlCert);
            } catch (CertificateEncodingException e) {
                throw new SecurityException("Error generating X509Certificate element " 
                        + "from a certificate in credential's certificate chain", e);
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:X509KeyInfoGeneratorFactory.java

示例4: processCRLs

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/** Process the value of {@link X509Credential#getCRLs()}.
 * 
 * @param keyInfo the KeyInfo that is being built
 * @param x509Data the X509Data that is being built
 * @param credential the Credential that is being processed
 * @throws SecurityException thrown if the CRL data can not be encoded from the Java certificate object
 */
protected void processCRLs(KeyInfo keyInfo, X509Data x509Data, X509Credential credential) 
        throws SecurityException {
    
    if (options.emitCRLs && credential.getCRLs() != null) {
        for (java.security.cert.X509CRL javaCRL : credential.getCRLs()) {
            try {
                X509CRL xmlCRL = KeyInfoHelper.buildX509CRL(javaCRL);
                x509Data.getX509CRLs().add(xmlCRL);
            } catch (CRLException e) {
                throw new SecurityException("Error generating X509CRL element " 
                        + "from a CRL in credential's CRL list", e);
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:X509KeyInfoGeneratorFactory.java

示例5: getCertificates

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Get a list of the Java {@link java.security.cert.X509Certificate} within the given KeyInfo.
 * 
 * @param keyInfo key info to extract the certificates from
 * 
 * @return a list of Java {@link java.security.cert.X509Certificate}s
 * 
 * @throws CertificateException thrown if there is a problem converting the 
 *          X509 data into {@link java.security.cert.X509Certificate}s.
 */
public static List<X509Certificate> getCertificates(KeyInfo keyInfo) throws CertificateException {
    List<X509Certificate> certList = new LinkedList<X509Certificate>();

    if (keyInfo == null) {
        return certList;
    }

    List<X509Data> x509Datas = keyInfo.getX509Datas();
    for (X509Data x509Data : x509Datas) {
        if (x509Data != null) {
            certList.addAll(getCertificates(x509Data));
        }
    }

    return certList;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:KeyInfoHelper.java

示例6: getCRLs

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Get a list of the Java {@link java.security.cert.X509CRL}s within the given {@link KeyInfo}.
 * 
 * @param keyInfo the {@link KeyInfo} to extract the CRL's from
 * 
 * @return a list of Java {@link java.security.cert.X509CRL}s
 * 
 * @throws CRLException thrown if there is a problem converting the 
 *          CRL data into {@link java.security.cert.X509CRL}s
 */
public static List<X509CRL> getCRLs(KeyInfo keyInfo) throws CRLException {
    List<X509CRL> crlList = new LinkedList<X509CRL>();

    if (keyInfo == null) {
        return crlList;
    }

    List<X509Data> x509Datas = keyInfo.getX509Datas();
    for (X509Data x509Data : x509Datas) {
        if (x509Data != null) {
            crlList.addAll(getCRLs(x509Data));
        }
    }

    return crlList;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:KeyInfoHelper.java

示例7: getMetadata

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Get a string representation of the signed metadata.
 * 
 * This method replaces the KeyInfo elements in the SPMetadata.xml file with
 * the actual certificate passed in the credentials parameter.
 * 
 * @param signingCredential
 *            Credential to use for signing. If <code>null</code>, the
 *            metadata is not signed.
 * @return The signed metadata as a string.
 */
public String getMetadata(Credential signingCredential, boolean sign) {
	X509Credential c = (X509Credential) signingCredential;
	EntityDescriptor e = SAMLUtil.clone(entityDescriptor);
	for (RoleDescriptor rd : e.getRoleDescriptors()) {
		for (KeyDescriptor k : rd.getKeyDescriptors()) {
			for (X509Data data : k.getKeyInfo().getX509Datas()) {
				for (X509Certificate cert : data.getX509Certificates()) {
					try {
						cert.setValue(Base64.encodeBytes(c.getEntityCertificate().getEncoded()));
					} catch (CertificateEncodingException e1) {
						throw new RuntimeException(e1);
					}
				}
			}
		}
	}
	OIOSamlObject obj = new OIOSamlObject(e);
	if (sign) {
		obj.sign(signingCredential);
	}
	return obj.toXML();
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:34,代码来源:SPMetadata.java

示例8: buildEntityDescriptor

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
public static EntityDescriptor buildEntityDescriptor(Credential cred) {
	EntityDescriptor data = (EntityDescriptor) SAMLUtil.unmarshallElement(TestHelper.class.getResourceAsStream("IdPMetadata.xml"));
       IDPSSODescriptor idpSSODescriptor = data.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
       
       org.opensaml.xml.signature.X509Certificate cert = SAMLUtil.buildXMLObject(org.opensaml.xml.signature.X509Certificate.class);
       try {
		cert.setValue(Base64.encodeBytes(getCertificate(cred).getEncoded()));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
       
	if (idpSSODescriptor.getKeyDescriptors().size() > 0) {
		KeyDescriptor keyDescriptor = (KeyDescriptor) idpSSODescriptor.getKeyDescriptors().get(0);
		if (keyDescriptor.getKeyInfo().getX509Datas().size() > 0) {
			X509Data x509Data = (X509Data) keyDescriptor.getKeyInfo().getX509Datas().get(0);
			x509Data.getX509Certificates().clear();
			x509Data.getX509Certificates().add(cert);
		}
	}
	return data;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:22,代码来源:TestHelper.java

示例9: setSignature

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
@Override
public void setSignature(String signatureAlgorithm, X509Credential cred) throws IdentityProviderException {
    Signature signature = (Signature) buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
    signature.setSigningCredential(cred);
    signature.setSignatureAlgorithm(signatureAlgorithm);
    signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);

    try {
        KeyInfo keyInfo = (KeyInfo) buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
        X509Data data = (X509Data) buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
        X509Certificate cert = (X509Certificate) buildXMLObject(X509Certificate.DEFAULT_ELEMENT_NAME);
        String value = Base64.encode(cred.getEntityCertificate().getEncoded());
        cert.setValue(value);
        data.getX509Certificates().add(cert);
        keyInfo.getX509Datas().add(data);
        signature.setKeyInfo(keyInfo);
    } catch (CertificateEncodingException e) {
        log.error("Failed to get encoded certificate", e);
        throw new IdentityProviderException("Error while getting encoded certificate");
    }

    assertion.setSignature(signature);
    signatureList.add(signature);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:25,代码来源:SAML2TokenBuilder.java

示例10: setSignature

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
@Override
public void setSignature(String signatureAlgorithm, X509Credential cred) throws IdentityProviderException {
    Signature signature = (Signature) buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
    signature.setSigningCredential(cred);
    signature.setSignatureAlgorithm(signatureAlgorithm);
    signature.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);

    try {
        KeyInfo keyInfo = (KeyInfo) buildXMLObject(KeyInfo.DEFAULT_ELEMENT_NAME);
        X509Data data = (X509Data) buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
        X509Certificate cert = (X509Certificate) buildXMLObject(X509Certificate.DEFAULT_ELEMENT_NAME);
        String value = Base64.encode(cred.getEntityCertificate().getEncoded());
        cert.setValue(value);
        data.getX509Certificates().add(cert);
        keyInfo.getX509Datas().add(data);
        signature.setKeyInfo(keyInfo);
    } catch (CertificateEncodingException e) {
        log.error("Error while getting the encoded certificate", e);
        throw new IdentityProviderException("Error while getting the encoded certificate");
    }

    assertion.setSignature(signature);
    signatureList.add(signature);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:25,代码来源:SAML1TokenBuilder.java

示例11: X509KeyInfoGenerator

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param newOptions the options to be used by the generator
 */
protected X509KeyInfoGenerator(X509Options newOptions) {
    super(newOptions);
    options = newOptions;
    
    keyInfoBuilder = 
        (KeyInfoBuilder) Configuration.getBuilderFactory().getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
    x509DataBuilder = 
        (X509DataBuilder) Configuration.getBuilderFactory().getBuilder(X509Data.DEFAULT_ELEMENT_NAME);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:X509KeyInfoGeneratorFactory.java

示例12: generate

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/** {@inheritDoc} */
public KeyInfo generate(Credential credential) throws SecurityException {
    if ( ! (credential instanceof X509Credential) ) {
        log.warn("X509KeyInfoGenerator was passed a credential that was not an instance of X509Credential: {}",
                credential.getClass().getName());
        return null;
    }
    X509Credential x509Credential = (X509Credential) credential;
    
    KeyInfo keyInfo =  super.generate(credential);
    if (keyInfo == null) {
        keyInfo = keyInfoBuilder.buildObject();
    }
    X509Data x509Data = x509DataBuilder.buildObject();
    
    processEntityCertificate(keyInfo, x509Data, x509Credential);
    processEntityCertificateChain(keyInfo, x509Data, x509Credential);
    processCRLs(keyInfo, x509Data, x509Credential);
    
    List<XMLObject> x509DataChildren = x509Data.getOrderedChildren();
    if (x509DataChildren != null && x509DataChildren.size() > 0) {
        keyInfo.getX509Datas().add(x509Data);
    }
    
    List<XMLObject> keyInfoChildren = keyInfo.getOrderedChildren();
    if (keyInfoChildren != null && keyInfoChildren.size() > 0) {
        return keyInfo;
    } else {
        return null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:X509KeyInfoGeneratorFactory.java

示例13: processCertX509DataOptions

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Process the options related to generation of child elements of X509Data based on certificate data.
 * 
 * @param x509Data the X509Data element being processed.
 * @param cert the certificate being processed
 */
protected void processCertX509DataOptions(X509Data x509Data, java.security.cert.X509Certificate cert) {
    processCertX509SubjectName(x509Data, cert);
    processCertX509IssuerSerial(x509Data, cert);
    processCertX509SKI(x509Data, cert);
    processCertX509Digest(x509Data, cert);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:X509KeyInfoGeneratorFactory.java

示例14: processCertX509SubjectName

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Process the options related to generation of the X509SubjectDN child element of X509Data 
 * based on certificate data.
 * 
 * @param x509Data the X509Data element being processed.
 * @param cert the certificate being processed
 */
protected void processCertX509SubjectName(X509Data x509Data, java.security.cert.X509Certificate cert) {
    if (options.emitX509SubjectName) {
        String subjectNameValue = getSubjectName(cert);
        if (! DatatypeHelper.isEmpty(subjectNameValue)) {
            x509Data.getX509SubjectNames().add( KeyInfoHelper.buildX509SubjectName(subjectNameValue));
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:X509KeyInfoGeneratorFactory.java

示例15: processCertX509IssuerSerial

import org.opensaml.xml.signature.X509Data; //导入依赖的package包/类
/**
 * Process the options related to generation of the X509IssuerSerial child element of X509Data 
 * based on certificate data.
 * 
 * @param x509Data the X509Data element being processed.
 * @param cert the certificate being processed
 */ 
protected void processCertX509IssuerSerial(X509Data x509Data, java.security.cert.X509Certificate cert) {
    if (options.emitX509IssuerSerial) {
        String issuerNameValue = getIssuerName(cert);
        if (! DatatypeHelper.isEmpty(issuerNameValue)) {
            x509Data.getX509IssuerSerials().add( 
                    KeyInfoHelper.buildX509IssuerSerial(issuerNameValue, cert.getSerialNumber()) );
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:X509KeyInfoGeneratorFactory.java


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