是否有人用Java创建了ADFS的Claims Trust Provider?

时间:2019-06-07 14:27:42

标签: java saml opensaml

在OpenSAML中,有一个MetadataServiceResponse,它似乎可以用作WS-Fed ADFS设置(/FederationMetadata3/2007-06/FederationMetadata.xml)的一部分。

但是,我无法创建通用RoleDescriptor或找到任何执行此操作的示例。

是否有人让Java充当ADFS的Claims Trust Provider,如果有的话,是否有示例?进行了广泛的浏览,似乎很少见。

谢谢!

        MetadataServiceResponse mdResponse = metadataService.execute(new MetadataServiceRequest());


        KeyInfo keyInfo = new KeyInfoBuilder().buildObject();

        List<X509Data> x509datas = keyInfo.getX509Datas();
        X509Data x509Data = new X509DataBuilder().buildObject();
        List<X509Certificate> x509certs = x509Data.getX509Certificates();

        X509Certificate x509Cert = new X509CertificateBuilder().buildObject();
        x509Cert.setValue(Base64.getEncoder().encodeToString(mdResponse.getSigningKey().getEntityCertificate().getEncoded()));
        x509certs.add(x509Cert);
        x509datas.add(x509Data);

        Signature signature = buildSAMLObject(Signature.class, Signature.DEFAULT_ELEMENT_NAME);

        signature.setSigningCredential(mdResponse.getSigningKey());
        signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
        signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS);
        signature.setKeyInfo(keyInfo);

        EntityDescriptor ed = new EntityDescriptorBuilder().buildObject();
        ed.setEntityID("https://myserver:8443/adfs/services/trust");
        ed.setID(UUID.randomUUID().toString());
        ed.setSignature(signature);

        EntityDescriptorMarshaller aMarsh = new EntityDescriptorMarshaller();

        try {
            aMarsh.marshall(ed);
        } catch (MarshallingException ex){
            LOGGER.error("marshalling exception", ex);
        }

        Signer.signObject(signature); //Generates SignatureValue

0 个答案:

没有答案