Package org.opensaml.saml2.metadata.provider

Examples of org.opensaml.saml2.metadata.provider.AbstractMetadataProvider


                }
            }
        }

        log.trace("Checking to see if any of the child entities descriptors contains the entity descriptor requested");
        EntityDescriptor entityDescriptor;
        List<EntitiesDescriptor> entitiesDescriptors = descriptor.getEntitiesDescriptors();
        if (entitiesDescriptors != null && !entitiesDescriptors.isEmpty()) {
            for (EntitiesDescriptor entitiesDescriptor : descriptor.getEntitiesDescriptors()) {
                entityDescriptor = getEntityDescriptorById(entityID, entitiesDescriptor);
                if (entityDescriptor != null) {
View Full Code Here


        if (DatatypeHelper.isEmpty(supportedProtocol)) {
            log.debug("Supported protocol was null, skipping search for role.");
            return null;
        }

        RoleDescriptor role = doGetRole(entityID, roleName, supportedProtocol);
        if (role == null) {
            log.debug("Metadata document does not contain a role of type {} supporting protocol {} for entity {}",
                    new Object[] { roleName, supportedProtocol, entityID });
            return null;
        }
View Full Code Here

                    entityID);
            return null;
        }

        Iterator<RoleDescriptor> rolesItr = roles.iterator();
        RoleDescriptor role = null;
        while (rolesItr.hasNext()) {
            role = rolesItr.next();
            if (role != null && role.isSupportedProtocol(supportedProtocol)) {
                return role;
            }
        }

        return null;
View Full Code Here

        Saml2Client client = new Saml2Client();
        InputStream metaDataInputStream = getClass().getClassLoader().getResourceAsStream("testshib-providers.xml");
        String metadata = IOUtils.toString(metaDataInputStream, "UTF-8");
        client.setIdpMetadata(metadata);
        StaticBasicParserPool parserPool = client.newStaticBasicParserPool();
        AbstractMetadataProvider provider = client.idpMetadataProvider(parserPool);
        XMLObject md = client.getXmlObject(provider);
        String id = client.getIdpEntityId(md);
        assertEquals("https://idp.testshib.org/idp/shibboleth", id);
    }
View Full Code Here

    @Test
    public void testIdpMetadataParsing_fromFile() {
        Saml2Client client = new Saml2Client();
        client.setIdpMetadataPath("resource:testshib-providers.xml");
        StaticBasicParserPool parserPool = client.newStaticBasicParserPool();
        AbstractMetadataProvider provider = client.idpMetadataProvider(parserPool);
        XMLObject md = client.getXmlObject(provider);
        String id = client.getIdpEntityId(md);
        assertEquals("https://idp.testshib.org/idp/shibboleth", id);
    }
View Full Code Here

            throw new SamlException("Error bootstrapping OpenSAML", e);
        }

        // required parserPool for XML processing
        final StaticBasicParserPool parserPool = newStaticBasicParserPool();
        final AbstractMetadataProvider idpMetadataProvider = idpMetadataProvider(parserPool);

        final XMLObject md;
        try {
            md = idpMetadataProvider.getMetadata();
        } catch (MetadataProviderException e) {
            throw new SamlException("Error initializing idpMetadataProvider", e);
        }

        // If no idpEntityId declared, select first EntityDescriptor entityId as our IDP entityId
        if (this.idpEntityId == null) {
            this.idpEntityId = getIdpEntityId(md);
        }

        // Generate our Service Provider metadata
        Saml2MetadataGenerator metadataGenerator = new Saml2MetadataGenerator();
        if (this.credentialProvider != null) {
            metadataGenerator.setCredentialProvider(this.credentialProvider);
            metadataGenerator.setAuthnRequestSigned(true);
        }
        // If the spEntityId is blank, use the callback url
        if (CommonHelper.isBlank(this.spEntityId)) {
            this.spEntityId = getCallbackUrl();
        }
        metadataGenerator.setEntityId(this.spEntityId);
        // Assertion consumer service url is the callback url
        metadataGenerator.setAssertionConsumerServiceUrl(getCallbackUrl());
        // for now same for logout url
        metadataGenerator.setSingleLogoutServiceUrl(getCallbackUrl());
        AbstractMetadataProvider spMetadataProvider = metadataGenerator.buildMetadataProvider();

        // Initialize metadata provider for our SP and get the XML as a String
        try {
            spMetadataProvider.initialize();
            this.spMetadata = metadataGenerator.printMetadata();
        } catch (MetadataProviderException e) {
            throw new TechnicalException("Error initializing spMetadataProvider", e);
        } catch (MarshallingException e) {
            logger.warn("Unable to print SP metadata", e);
View Full Code Here

        }
        return parserPool;
    }

    protected AbstractMetadataProvider idpMetadataProvider(ParserPool parserPool) {
        AbstractMetadataProvider idpMetadataProvider;
        try {
            if (idpMetadataPath != null) {
                Resource resource = null;
                if (this.idpMetadataPath.startsWith(CommonHelper.RESOURCE_PREFIX)) {
                    String path = this.idpMetadataPath.substring(CommonHelper.RESOURCE_PREFIX.length());
                    if (!path.startsWith("/")) {
                        path = "/" + path;
                    }
                    resource = new ClasspathResource(path);
                } else {
                    resource = new FilesystemResource(this.idpMetadataPath);
                }
                idpMetadataProvider = new ResourceBackedMetadataProvider(new Timer(true), resource);
            } else {
                InputStream in = new ByteArrayInputStream(idpMetadata.getBytes());
                Document inCommonMDDoc = parserPool.parse(in);
                Element metadataRoot = inCommonMDDoc.getDocumentElement();
                idpMetadataProvider = new DOMMetadataProvider(metadataRoot);
            }
            idpMetadataProvider.setParserPool(parserPool);
            idpMetadataProvider.initialize();
        } catch (MetadataProviderException e) {
            throw new SamlException("Error initializing idpMetadataProvider", e);
        } catch (XMLParserException e) {
            throw new TechnicalException("Error parsing idp Metadata", e);
        } catch (ResourceException e) {
View Full Code Here

    protected int defaultACSIndex = 0;

    public AbstractMetadataProvider buildMetadataProvider() {
        final EntityDescriptor md = buildMetadata();
        return new AbstractMetadataProvider() {

            @Override
            protected XMLObject doGetMetadata() throws MetadataProviderException {
                return md;
            }
View Full Code Here

     * @throws MetadataProviderException in case initialization fails
     */
    public void initialize() throws MetadataProviderException {
        if (getDelegate() instanceof AbstractMetadataProvider) {
            log.debug("Initializing delegate");
            AbstractMetadataProvider provider = (AbstractMetadataProvider) getDelegate();
            provider.initialize();
        } else {
            log.debug("Cannot initialize delegate, doesn't extend AbstractMetadataProvider");
        }
    }
View Full Code Here

     * Method destroys the metadata delegate.
     */
    public void destroy() {
        if (getDelegate() instanceof AbstractMetadataProvider) {
            log.debug("Destroying delegate");
            AbstractMetadataProvider provider = (AbstractMetadataProvider) getDelegate();
            provider.destroy();
        } else {
            log.debug("Cannot destroy delegate, doesn't extend AbstractMetadataProvider");
        }
    }
View Full Code Here

TOP

Related Classes of org.opensaml.saml2.metadata.provider.AbstractMetadataProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.