org.opensaml.xml.signature.X509Certificate.setValue()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(14.4k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.opensaml.xml.signature.X509Certificate.setValue()方法的一些代码示例,展示了X509Certificate.setValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509Certificate.setValue()方法的具体详情如下:
包路径:org.opensaml.xml.signature.X509Certificate
类名称:X509Certificate
方法名:setValue

X509Certificate.setValue介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

KeyInfo keyInfo=(KeyInfo)Configuration.getBuilderFactory().getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME).buildObject(KeyInfo.DEFAULT_ELEMENT_NAME);
   X509Data data=(X509Data)Configuration.getBuilderFactory().getBuilder(X509Data.DEFAULT_ELEMENT_NAME).buildObject(X509Data.DEFAULT_ELEMENT_NAME);
   X509Certificate cert=(X509Certificate)Configuration.getBuilderFactory().getBuilder(X509Certificate.DEFAULT_ELEMENT_NAME).buildObject(X509Certificate.DEFAULT_ELEMENT_NAME);
   signature.setSigningCredential(signingCredential);
   value=org.apache.xml.security.utils.Base64.encode(signingCredential.getEntityCertificate().getEncoded());
   cert.setValue(value);
   data.getX509Certificates().add(cert);
   keyInfo.getX509Datas().add(data);
   signature.setKeyInfo(keyInfo);

代码示例来源:origin: io.apigee.opensaml/xmltooling

/**
 * Builds an {@link org.opensaml.xml.signature.X509Certificate} XMLObject from a native 
 * Java {@link java.security.cert.X509Certificate}.
 * 
 * @param cert the Java {@link java.security.cert.X509Certificate} to convert
 * @return a {@link org.opensaml.xml.signature.X509Certificate} XMLObject
 * @throws CertificateEncodingException thrown when there is an error converting the Java 
 *           certificate representation to the XMLObject representation
 */
public static org.opensaml.xml.signature.X509Certificate 
buildX509Certificate(X509Certificate cert) throws CertificateEncodingException {
  org.opensaml.xml.signature.X509Certificate xmlCert =
    (org.opensaml.xml.signature.X509Certificate) Configuration.getBuilderFactory()
    .getBuilder(org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME)
    .buildObject(org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME);
  
  xmlCert.setValue(Base64.encodeBytes(cert.getEncoded()));
  
  return xmlCert;
}

代码示例来源:origin: org.opensaml/xmltooling

/**
 * Builds an {@link org.opensaml.xml.signature.X509Certificate} XMLObject from a native 
 * Java {@link java.security.cert.X509Certificate}.
 * 
 * @param cert the Java {@link java.security.cert.X509Certificate} to convert
 * @return a {@link org.opensaml.xml.signature.X509Certificate} XMLObject
 * @throws CertificateEncodingException thrown when there is an error converting the Java 
 *           certificate representation to the XMLObject representation
 */
public static org.opensaml.xml.signature.X509Certificate 
buildX509Certificate(X509Certificate cert) throws CertificateEncodingException {
  org.opensaml.xml.signature.X509Certificate xmlCert =
    (org.opensaml.xml.signature.X509Certificate) Configuration.getBuilderFactory()
    .getBuilder(org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME)
    .buildObject(org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME);
  
  xmlCert.setValue(Base64.encodeBytes(cert.getEncoded()));
  
  return xmlCert;
}

代码示例来源:origin: org.wso2.carbon.identity.metadata.saml2/org.wso2.carbon.identity.outbound.metadata.saml2

/**
 * Creates the KeyInfo from the provided Credential.
 *
 * @throws MetadataException
 */
private KeyInfo createKeyInfo() throws MetadataException {
  if (log.isDebugEnabled()) {
    log.debug("Creating the KeyInfo element");
  }
  KeyInfo keyInfo = BuilderUtil.createSAMLObject(ConfigElements.XMLSIGNATURE_NS, "KeyInfo", "");
  X509Data data = BuilderUtil.createSAMLObject(ConfigElements.XMLSIGNATURE_NS, "X509Data", "");
  X509Certificate cert = BuilderUtil.createSAMLObject(ConfigElements.XMLSIGNATURE_NS, "X509Certificate", "");
  String value;
  try {
    value = org.apache.xml.security.utils.Base64.encode(credential.getEntityCertificate().getEncoded());
  } catch (CertificateEncodingException e) {
    throw new MetadataException("Error while encoding the certificate.", e);
  }
  cert.setValue(value);
  data.getX509Certificates().add(cert);
  keyInfo.getX509Datas().add(data);
  if (log.isDebugEnabled()) {
    log.debug("Completed KeyInfo element creation");
  }
  return keyInfo;
}

代码示例来源:origin: org.apache.rampart/rampart-trust

/**
 * Creates the X509 data element in a SAML issuer token. Should create an element similar to following,
 * <X509Data xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
 *                         xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
 *   <X509Certificate>
 *       MIICNTCCAZ6gAwIB...
 *   </X509Certificate>
 * </X509Data>
 * @param clientCert Client certificate to be used when generating X509 data
 * @return  SAML X509Data representation.
 * @throws TrustException If an error occurred while creating X509Data and X509Certificate.
 */
static X509Data createX509Data(X509Certificate clientCert) throws TrustException {
  byte[] clientCertBytes;
  try {
    clientCertBytes = clientCert.getEncoded();
  } catch (CertificateEncodingException e) {
    log.error("An error occurred while encoding certificate.", e);
    throw new TrustException("An error occurred while encoding certificate.", e);
  }
  String base64Cert = Base64.encode(clientCertBytes);
  org.opensaml.xml.signature.X509Certificate x509Certificate
      = (org.opensaml.xml.signature.X509Certificate)CommonUtil.buildXMLObject
      (org.opensaml.xml.signature.X509Certificate.DEFAULT_ELEMENT_NAME);
  x509Certificate.setValue(base64Cert);
  X509Data x509Data = (X509Data)CommonUtil.buildXMLObject(X509Data.DEFAULT_ELEMENT_NAME);
  x509Data.getX509Certificates().add(x509Certificate);
  return x509Data;
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider

@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);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider

@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);
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider

@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);
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider

@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);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.authenticator.saml2.sso.common

String value = org.apache.xml.security.utils.Base64.encode(cred
    .getEntityCertificate().getEncoded());
cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity.carbon.auth.saml2/org.wso2.carbon.identity.authenticator.saml2.sso.common

String value = org.apache.xml.security.utils.Base64.encode(cred
    .getEntityCertificate().getEncoded());
cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sso.agent

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);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.agent.sso.java/org.wso2.carbon.identity.sso.agent

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);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.carbon.auth.saml2/org.wso2.carbon.identity.authenticator.saml2.sso.common

String value = org.apache.xml.security.utils.Base64.encode(cred
    .getEntityCertificate().getEncoded());
cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.authenticator.saml2.sso.common

String value = org.apache.xml.security.utils.Base64.encode(cred
    .getEntityCertificate().getEncoded());
cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sso.saml

cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.saml.cloud/org.wso2.carbon.identity.sso.saml.cloud

cert.setValue(value);
data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(data);

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement

X509Certificate cert = (X509Certificate) buildXMLObject(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);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement

X509Certificate cert = (X509Certificate) buildXMLObject(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);

代码示例来源:origin: org.apache.rampart/rampart-trust

= org.apache.xml.security.utils.Base64.encode(signKeyHolder.getEntityCertificate().getEncoded());
cert.setValue(value);
x509Data.getX509Certificates().add(cert);
keyInfo.getX509Datas().add(x509Data);

相关文章