Package org.picketlink.identity.federation.saml.v2.metadata

Examples of org.picketlink.identity.federation.saml.v2.metadata.EntityDescriptorType


        try {
            metadata = new SAMLParser().parse(is);
        } catch (ParsingException e) {
            throw new RuntimeException(e);
        }
        EntitiesDescriptorType entities;

        if (EntitiesDescriptorType.class.isInstance(metadata)) {
            entities = (EntitiesDescriptorType) metadata;
        } else {
            entities = new EntitiesDescriptorType();
            entities.addEntityDescriptor(metadata);
        }

        for (Object o : entities.getEntityDescriptor()) {
            EntityDescriptorType entity = (EntityDescriptorType)o;
            String entityId = entity.getEntityID();
            ApplicationModel app = realm.addApplication(entityId);
            app.setFullScopeAllowed(true);
            app.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
View Full Code Here


        assertEquals(spSSODescriptor.getSingleLogoutService().size(), 4);
    }

    public void testFileBasedEntitiesMetadataProvider() {
        FileBasedEntitiesMetadataProvider metadataProvider = new FileBasedEntitiesMetadataProvider();
        EntitiesDescriptorType metadata = getMetadata(metadataProvider, "saml2/metadata/sp-two-salesforce-googleapps.xml");

        List<Object> descriptors = metadata.getEntityDescriptor();
        for (Object descriptorType : descriptors) {
            if (!(descriptorType instanceof EntityDescriptorType)) {
                fail("Wrong type: " + descriptorType.getClass());
            }
View Full Code Here

            entities = new EntitiesDescriptorType();
            entities.addEntityDescriptor(metadata);
        }

        for (Object o : entities.getEntityDescriptor()) {
            EntityDescriptorType entity = (EntityDescriptorType)o;
            String entityId = entity.getEntityID();
            ApplicationModel app = realm.addApplication(entityId);
            app.setFullScopeAllowed(true);
            app.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
            app.setAttribute(SamlProtocol.SAML_SERVER_SIGNATURE, SamlProtocol.ATTRIBUTE_TRUE_VALUE); // default to true
            app.setAttribute(SamlProtocol.SAML_SIGNATURE_ALGORITHM, SignatureAlgorithm.RSA_SHA256.toString());
View Full Code Here

*/
public class FileBasedMetadataProviderUnitTestCase extends TestCase {

    public void testFileBasedEntityMetadataProvider() {
        FileBasedEntityMetadataProvider metadataProvider = new FileBasedEntityMetadataProvider();
        EntityDescriptorType metadata = getMetadata(metadataProvider, "saml2/metadata/sp-entitydescriptor.xml");

        assertEquals(metadata.getEntityID(), "https://service.example.org/shibboleth");
        SPSSODescriptorType spSSODescriptor = CoreConfigUtil.getSPDescriptor(metadata);
        assertNull(spSSODescriptor.isAuthnRequestsSigned());
        assertEquals(spSSODescriptor.getSingleLogoutService().size(), 4);
    }
View Full Code Here

        for (Object descriptorType : descriptors) {
            if (!(descriptorType instanceof EntityDescriptorType)) {
                fail("Wrong type: " + descriptorType.getClass());
            }

            EntityDescriptorType entDescriptorType = (EntityDescriptorType)descriptorType;

            if ("https://saml.salesforce.com".equals(entDescriptorType.getEntityID())) {
                SPSSODescriptorType spDescriptor = CoreConfigUtil.getSPDescriptor(entDescriptorType);

                assertTrue(spDescriptor.isAuthnRequestsSigned());
                List<EndpointType> logoutEndpoints = spDescriptor.getSingleLogoutService();
                assertNotNull(logoutEndpoints);
                assertEquals(logoutEndpoints.size(), 1);
                EndpointType endpoint = logoutEndpoints.get(0);
                assertEquals("https://login.salesforce.com/saml/logout-request.jsp?saml=MgoTx78aEPkEM4eGV5ZzptlliwIVkRkOWYKlqXQq2StV_sLo0EiRqKYtIc",
                      endpoint.getLocation().toASCIIString());
                assertEquals("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST", endpoint.getBinding().toASCIIString());
            }
            else if ("google.com/a/somedomain.com".equals(entDescriptorType.getEntityID())) {
                SPSSODescriptorType spDescriptor = CoreConfigUtil.getSPDescriptor(entDescriptorType);

                assertFalse(spDescriptor.isAuthnRequestsSigned());
                List<EndpointType> logoutEndpoints = spDescriptor.getSingleLogoutService();
                assertNotNull(logoutEndpoints);
                assertEquals(logoutEndpoints.size(), 0);
            }
            else {
                fail("Wrong entityID: " + entDescriptorType.getEntityID());
            }
        }
    }
View Full Code Here

    }

    @Test
    public void testCreateEntityDescriptor() {
        IDPSSODescriptorType idp = this.createIDPSSODescriptor();
        EntityDescriptorType idpEntity = MetaDataBuilder.createEntityDescriptor(idp);
        assertNotNull("IDP Entity Descriptor not null", idpEntity);

        SPSSODescriptorType sp = this.createSPSSODescriptor();
        EntityDescriptorType spEntity = MetaDataBuilder.createEntityDescriptor(sp);
        assertNotNull("SP Entity Descriptor not null", spEntity);
    }
View Full Code Here

        List<EDTDescriptorChoiceType> edtList = new ArrayList<EntityDescriptorType.EDTDescriptorChoiceType>();
        edtList.add(edtDescriptorChoiceType);

        EDTChoiceType choiceType = new EDTChoiceType(edtList);

        EntityDescriptorType entity = new EntityDescriptorType(" ");
        entity.addChoiceType(choiceType);
        return entity;
    }
View Full Code Here

        List<EntityDescriptorType> resultList = new ArrayList<EntityDescriptorType>();
        if (metadataProvider.isMultiple()) {
            EntitiesDescriptorType metadatas = (EntitiesDescriptorType) metadataProvider.getMetaData();
            addAllEntityDescriptorsRecursively(resultList, metadatas);
        } else {
            EntityDescriptorType metadata = (EntityDescriptorType) metadataProvider.getMetaData();
            resultList.add(metadata);
        }
        return resultList;
    }
View Full Code Here

        StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
        StaxParserUtil.validate(startElement, EDT);

        Attribute entityID = startElement.getAttributeByName(new QName(JBossSAMLConstants.ENTITY_ID.get()));
        String entityIDValue = StaxParserUtil.getAttributeValue(entityID);
        EntityDescriptorType entityDescriptorType = new EntityDescriptorType(entityIDValue);

        Attribute validUntil = startElement.getAttributeByName(new QName(JBossSAMLConstants.VALID_UNTIL.get()));
        if (validUntil != null) {
            String validUntilValue = StaxParserUtil.getAttributeValue(validUntil);
            entityDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue));
        }

        Attribute id = startElement.getAttributeByName(new QName(JBossSAMLConstants.ID.get()));
        if (id != null) {
            entityDescriptorType.setID(StaxParserUtil.getAttributeValue(id));
        }

        Attribute cacheDuration = startElement.getAttributeByName(new QName(JBossSAMLConstants.CACHE_DURATION.get()));
        if (cacheDuration != null) {
            entityDescriptorType.setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil.getAttributeValue(cacheDuration)));
        }

        // Get the Child Elements
        while (xmlEventReader.hasNext()) {
            XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
            if (xmlEvent instanceof EndElement) {
                StaxParserUtil.validate((EndElement) xmlEvent, EDT);
                StaxParserUtil.getNextEndElement(xmlEventReader);
                break;
            }
            startElement = (StartElement) xmlEvent;
            String localPart = startElement.getName().getLocalPart();

            if (JBossSAMLConstants.IDP_SSO_DESCRIPTOR.get().equals(localPart)) {
                IDPSSODescriptorType idpSSO = parseIDPSSODescriptor(xmlEventReader);

                EDTDescriptorChoiceType edtDescChoice = new EDTDescriptorChoiceType(idpSSO);
                EDTChoiceType edtChoice = EDTChoiceType.oneValue(edtDescChoice);
                entityDescriptorType.addChoiceType(edtChoice);
            } else if (JBossSAMLConstants.SP_SSO_DESCRIPTOR.get().equals(localPart)) {
                SPSSODescriptorType spSSO = parseSPSSODescriptor(xmlEventReader);

                EDTDescriptorChoiceType edtDescChoice = new EDTDescriptorChoiceType(spSSO);
                EDTChoiceType edtChoice = EDTChoiceType.oneValue(edtDescChoice);
                entityDescriptorType.addChoiceType(edtChoice);
            } else if (JBossSAMLConstants.ATTRIBUTE_AUTHORITY_DESCRIPTOR.get().equals(localPart)) {
                AttributeAuthorityDescriptorType attrAuthority = parseAttributeAuthorityDescriptor(xmlEventReader);

                EDTDescriptorChoiceType edtDescChoice = new EDTDescriptorChoiceType(attrAuthority);
                EDTChoiceType edtChoice = EDTChoiceType.oneValue(edtDescChoice);
                entityDescriptorType.addChoiceType(edtChoice);
            } else if (JBossSAMLConstants.AUTHN_AUTHORITY_DESCRIPTOR.get().equals(localPart)) {
                throw logger.unsupportedType("AuthnAuthorityDescriptor");
            } else if (JBossSAMLConstants.AFFILIATION_DESCRIPTOR.get().equals(localPart)) {
                throw logger.unsupportedType(" AffiliationDescriptor");
            } else if (JBossSAMLConstants.PDP_DESCRIPTOR.get().equals(localPart)) {
                throw logger.unsupportedType(" PDPDescriptor");
            } else if (localPart.equals(JBossSAMLConstants.SIGNATURE.get())) {
                entityDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader));
            } else if (JBossSAMLConstants.ORGANIZATION.get().equals(localPart)) {
                OrganizationType organization = parseOrganization(xmlEventReader);

                entityDescriptorType.setOrganization(organization);
            } else if (JBossSAMLConstants.CONTACT_PERSON.get().equals(localPart)) {
                entityDescriptorType.addContactPerson(parseContactPerson(xmlEventReader));
            } else if (JBossSAMLConstants.ADDITIONAL_METADATA_LOCATION.get().equals(localPart)) {
                throw logger.unsupportedType("AdditionalMetadataLocation");
            } else if (JBossSAMLConstants.EXTENSIONS.get().equalsIgnoreCase(localPart)) {
                entityDescriptorType.setExtensions(parseExtensions(xmlEventReader));
            } else
                throw logger.parserUnknownStartElement(localPart, startElement.getLocation());
        }
        return entityDescriptorType;
    }
View Full Code Here

                Object metadata = parseMDFile();
                if (metadata instanceof EntitiesDescriptorType) {
                    EntitiesDescriptorType entities = (EntitiesDescriptorType) metadata;
                    spType = CoreConfigUtil.getSPConfiguration(entities, bindingURI);
                } else if (metadata instanceof EntityDescriptorType) {
                    EntityDescriptorType entity = (EntityDescriptorType) metadata;
                    spType = (SPType) CoreConfigUtil.getSPConfiguration(entity, bindingURI);
                } else {
                    throw logger.wrongMetadataRootElement();
                }
            } catch (ParsingException e) {
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.saml.v2.metadata.EntityDescriptorType

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.