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;
}