org.opensaml.xmlsec.signature.X509Data Java Examples

The following examples show how to use org.opensaml.xmlsec.signature.X509Data. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Saml2SettingsProvider.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
private void initIdpCerts(IDPSSODescriptor idpSsoDescriptor, HashMap<String, Object> configProperties) {
    int i = 0;

    for (KeyDescriptor keyDescriptor : idpSsoDescriptor.getKeyDescriptors()) {
        if (UsageType.SIGNING.equals(keyDescriptor.getUse())
                || UsageType.UNSPECIFIED.equals(keyDescriptor.getUse())) {
            for (X509Data x509data : keyDescriptor.getKeyInfo().getX509Datas()) {
                for (X509Certificate x509Certificate : x509data.getX509Certificates()) {
                    configProperties.put(SettingsBuilder.IDP_X509CERTMULTI_PROPERTY_KEY + "." + (i++),
                            x509Certificate.getValue());
                }
            }
        }
    }
}
 
Example #2
Source File: SamlClient.java    From saml-client with MIT License 5 votes vote down vote up
private static Stream<X509Data> getDatasWithCertificates(KeyDescriptor descriptor) {
  return descriptor
      .getKeyInfo()
      .getX509Datas()
      .stream()
      .filter(d -> d.getX509Certificates().size() > 0);
}
 
Example #3
Source File: SamlClient.java    From saml-client with MIT License 5 votes vote down vote up
private static X509Certificate getFirstCertificate(X509Data data) {
  try {
    org.opensaml.xmlsec.signature.X509Certificate cert =
        data.getX509Certificates().stream().findFirst().orElse(null);
    if (cert != null) {
      return KeyInfoSupport.getCertificate(cert);
    }
  } catch (CertificateException e) {
    logger.error("Exception in getFirstCertificate", e);
  }

  return null;
}