Search in sources :

Example 1 with IDPSSODescriptorImpl

use of org.opensaml.saml2.metadata.impl.IDPSSODescriptorImpl in project MaxKey by dromara.

the class MetadataDescriptorUtil method main.

/**
 * @param args
 * @throws Exception
 * @throws ConfigurationException
 * @throws FileNotFoundException
 */
public static void main(String[] args) throws Exception, ConfigurationException, FileNotFoundException {
    // 
    File file = new File("d:\\SAMLSP-00D90000000hf9n.xml");
    org.opensaml.DefaultBootstrap.bootstrap();
    EntityDescriptor entityDescriptor = MetadataDescriptorUtil.getInstance().getEntityDescriptor(file);
    // System.out.println("2 : "+entityDescriptor.getRoleDescriptors());
    // System.out.println("3 : "+idpEntityDescriptor.);
    // System.out.println("+"+ entityDescriptor.getOrganization());
    List<RoleDescriptor> listRoleDescriptor = entityDescriptor.getRoleDescriptors();
    for (RoleDescriptor roleDescriptor : listRoleDescriptor) {
        // sPSSODescriptor1=idpEntityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
        if (roleDescriptor instanceof IDPSSODescriptorImpl) {
            IDPSSODescriptor iDPSSODescriptor = (IDPSSODescriptorImpl) roleDescriptor;
            System.out.println("3 : " + iDPSSODescriptor.getSingleSignOnServices().get(0).getLocation());
        // System.out.println("- : "+iDPSSODescriptor.getNameIDFormats().get(0).getFormat());
        // System.out.println("- : "+iDPSSODescriptor.getKeyDescriptors().get(0).getKeyInfo().getX509Datas().get(0));
        } else {
            SPSSODescriptor sPSSODescriptor = (SPSSODescriptorImpl) roleDescriptor;
            System.out.println("- : " + sPSSODescriptor.getAssertionConsumerServices().get(0).getLocation());
        // System.out.println("- : "+sPSSODescriptor.getAssertionConsumerServices().get(0).getBinding());
        }
    // System.out.println("===============================================");
    }
    // //two
    InputStream in = new FileInputStream(file);
    EntityDescriptor entityDescriptor1 = MetadataDescriptorUtil.getInstance().getEntityDescriptor(in);
    SPSSODescriptor sPSSODescriptor = entityDescriptor1.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
    System.out.println("ok :" + sPSSODescriptor.getAssertionConsumerServices().get(0).getLocation());
// System.out.println("ok :"+sPSSODescriptor.getAssertionConsumerServices().get(0).getBinding());
// System.out.println("ok :"+sPSSODescriptor.getNameIDFormats().get(0).getFormat());
// System.out.println("ok :"+sPSSODescriptor.getKeyDescriptors().get(0).getKeyInfo().getX509Datas().get(0));
}
Also used : SPSSODescriptorImpl(org.opensaml.saml2.metadata.impl.SPSSODescriptorImpl) EntityDescriptor(org.opensaml.saml2.metadata.EntityDescriptor) SPSSODescriptor(org.opensaml.saml2.metadata.SPSSODescriptor) IDPSSODescriptorImpl(org.opensaml.saml2.metadata.impl.IDPSSODescriptorImpl) IDPSSODescriptor(org.opensaml.saml2.metadata.IDPSSODescriptor) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) RoleDescriptor(org.opensaml.saml2.metadata.RoleDescriptor) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 EntityDescriptor (org.opensaml.saml2.metadata.EntityDescriptor)1 IDPSSODescriptor (org.opensaml.saml2.metadata.IDPSSODescriptor)1 RoleDescriptor (org.opensaml.saml2.metadata.RoleDescriptor)1 SPSSODescriptor (org.opensaml.saml2.metadata.SPSSODescriptor)1 IDPSSODescriptorImpl (org.opensaml.saml2.metadata.impl.IDPSSODescriptorImpl)1 SPSSODescriptorImpl (org.opensaml.saml2.metadata.impl.SPSSODescriptorImpl)1