private void updateKeyDescriptors(EntitiesDescriptorType entityId, KeyDescriptorType keyD){ List<Object> entities = entityId.getEntityDescriptor(); for (Object obj : entities){ updateKeyDescriptor((EntityDescriptorType) obj,keyD); } }
private EntitiesDescriptorType parseMDFile() throws ParsingException { Object spMetadata = parseSPMetadata(); Object idpMetadata = parseIdPMetadata(); EntitiesDescriptorType entities; if (EntitiesDescriptorType.class.isInstance(spMetadata)) { entities = (EntitiesDescriptorType) spMetadata; // if a IdP metadata is provided and if SP metadata provides multiple entities we search for any IDPSSODescriptor element to remove/replace it. if (idpMetadata != null) { removeIdPDescriptor(entities); } } else { entities = new EntitiesDescriptorType(); entities.addEntityDescriptor(spMetadata); } if (idpMetadata != null) { entities.addEntityDescriptor(idpMetadata); } return entities; }
private void removeIdPDescriptor(EntitiesDescriptorType entities) { for (Object descriptorType : new ArrayList<Object>(entities.getEntityDescriptor())) { for (EntityDescriptorType.EDTChoiceType choiceType : ((EntityDescriptorType) descriptorType).getChoiceType()) { for (EntityDescriptorType.EDTDescriptorChoiceType descriptorChoiceType : choiceType.getDescriptors()) { if (descriptorChoiceType.getIdpDescriptor() != null) { entities.removeEntityDescriptor(descriptorType); } } } } }
StaxParserUtil.validate(startElement, EDT); EntitiesDescriptorType entitiesDescriptorType = new EntitiesDescriptorType(); if (validUntil != null) { String validUntilValue = StaxParserUtil.getAttributeValue(validUntil); entitiesDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue)); entitiesDescriptorType.setID(StaxParserUtil.getAttributeValue(id)); entitiesDescriptorType.setName(StaxParserUtil.getAttributeValue(name)); if (cacheDuration != null) { entitiesDescriptorType .setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil.getAttributeValue(cacheDuration))); entitiesDescriptorType.addEntityDescriptor(entityParser.parse(xmlEventReader)); } else if (JBossSAMLConstants.EXTENSIONS.get().equalsIgnoreCase(localPart)) { entitiesDescriptorType.setExtensions(parseExtensions(xmlEventReader)); } else if (JBossSAMLConstants.ENTITIES_DESCRIPTOR.get().equalsIgnoreCase(localPart)) { SAMLEntitiesDescriptorParser parser = new SAMLEntitiesDescriptorParser(); entitiesDescriptorType.addEntityDescriptor(parser.parse(xmlEventReader)); } else if (localPart.equals(JBossSAMLConstants.SIGNATURE.get())) { entitiesDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader)); } else throw logger.parserUnknownTag(localPart, startElement.getLocation());
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get()); if (entities.getValidUntil() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entities.getValidUntil().toString()); if (entities.getID() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entities.getID()); if (entities.getName() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME.get(), entities.getName()); Element signature = entities.getSignature(); if (signature != null) { StaxUtil.writeDOMElement(writer, signature); ExtensionsType extensions = entities.getExtensions(); if (extensions != null) { StaxUtil.writeDOMElement(writer, extensions.getElement()); List<Object> entityDescriptors = entities.getEntityDescriptor(); for (Object ed : entityDescriptors) { if (ed instanceof EntityDescriptorType) {
StaxParserUtil.validate(startElement, EDT); EntitiesDescriptorType entitiesDescriptorType = new EntitiesDescriptorType(); if (validUntil != null) { String validUntilValue = StaxParserUtil.getAttributeValue(validUntil); entitiesDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue)); entitiesDescriptorType.setID(StaxParserUtil.getAttributeValue(id)); entitiesDescriptorType.setName(StaxParserUtil.getAttributeValue(name)); if (cacheDuration != null) { entitiesDescriptorType .setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil.getAttributeValue(cacheDuration))); entitiesDescriptorType.addEntityDescriptor(entityParser.parse(xmlEventReader)); } else if (JBossSAMLConstants.EXTENSIONS.get().equalsIgnoreCase(localPart)) { entitiesDescriptorType.setExtensions(parseExtensions(xmlEventReader)); } else if (JBossSAMLConstants.ENTITIES_DESCRIPTOR.get().equalsIgnoreCase(localPart)) { SAMLEntitiesDescriptorParser parser = new SAMLEntitiesDescriptorParser(); entitiesDescriptorType.addEntityDescriptor(parser.parse(xmlEventReader)); } else if (localPart.equals(JBossSAMLConstants.SIGNATURE.get())) { entitiesDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader)); } else throw logger.parserUnknownTag(localPart, startElement.getLocation());
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get()); if (entities.getValidUntil() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entities.getValidUntil().toString()); if (entities.getID() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entities.getID()); if (entities.getName() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME.get(), entities.getName()); Element signature = entities.getSignature(); if (signature != null) { StaxUtil.writeDOMElement(writer, signature); ExtensionsType extensions = entities.getExtensions(); if (extensions != null) { StaxUtil.writeDOMElement(writer, extensions.getElement()); List<Object> entityDescriptors = entities.getEntityDescriptor(); for (Object ed : entityDescriptors) { if (ed instanceof EntityDescriptorType) {
private void removeIdPDescriptor(EntitiesDescriptorType entities) { for (Object descriptorType : new ArrayList<Object>(entities.getEntityDescriptor())) { for (EntityDescriptorType.EDTChoiceType choiceType : ((EntityDescriptorType) descriptorType).getChoiceType()) { for (EntityDescriptorType.EDTDescriptorChoiceType descriptorChoiceType : choiceType.getDescriptors()) { if (descriptorChoiceType.getIdpDescriptor() != null) { entities.removeEntityDescriptor(descriptorType); } } } } }
StaxParserUtil.validate(startElement, EDT); EntitiesDescriptorType entitiesDescriptorType = new EntitiesDescriptorType(); if (validUntil != null) { String validUntilValue = StaxParserUtil.getAttributeValue(validUntil); entitiesDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue)); entitiesDescriptorType.setID(StaxParserUtil.getAttributeValue(id)); entitiesDescriptorType.setName(StaxParserUtil.getAttributeValue(name)); if (cacheDuration != null) { entitiesDescriptorType .setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil.getAttributeValue(cacheDuration))); entitiesDescriptorType.addEntityDescriptor(entityParser.parse(xmlEventReader)); } else if (JBossSAMLConstants.EXTENSIONS.get().equalsIgnoreCase(localPart)) { entitiesDescriptorType.setExtensions(parseExtensions(xmlEventReader)); } else if (JBossSAMLConstants.ENTITIES_DESCRIPTOR.get().equalsIgnoreCase(localPart)) { SAMLEntitiesDescriptorParser parser = new SAMLEntitiesDescriptorParser(); entitiesDescriptorType.addEntityDescriptor(parser.parse(xmlEventReader)); } else if (localPart.equals(JBossSAMLConstants.SIGNATURE.get())) { entitiesDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader)); } else throw logger.parserUnknownTag(localPart, startElement.getLocation());
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get()); if (entities.getValidUntil() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entities.getValidUntil().toString()); if (entities.getID() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entities.getID()); if (entities.getName() != null) { StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME.get(), entities.getName()); Element signature = entities.getSignature(); if (signature != null) { StaxUtil.writeDOMElement(writer, signature); ExtensionsType extensions = entities.getExtensions(); if (extensions != null) { StaxUtil.writeDOMElement(writer, extensions.getElement()); List<Object> entityDescriptors = entities.getEntityDescriptor(); for (Object ed : entityDescriptors) { if (ed instanceof EntityDescriptorType) {
private void updateKeyDescriptors(EntitiesDescriptorType entityId, KeyDescriptorType keyD){ List<Object> entities = entityId.getEntityDescriptor(); for (Object obj : entities){ updateKeyDescriptor((EntityDescriptorType) obj,keyD); } }
private EntitiesDescriptorType parseMDFile() throws ParsingException { Object spMetadata = parseSPMetadata(); Object idpMetadata = parseIdPMetadata(); EntitiesDescriptorType entities; if (EntitiesDescriptorType.class.isInstance(spMetadata)) { entities = (EntitiesDescriptorType) spMetadata; // if a IdP metadata is provided and if SP metadata provides multiple entities we search for any IDPSSODescriptor element to remove/replace it. if (idpMetadata != null) { removeIdPDescriptor(entities); } } else { entities = new EntitiesDescriptorType(); entities.addEntityDescriptor(spMetadata); } if (idpMetadata != null) { entities.addEntityDescriptor(idpMetadata); } return entities; }
StaxParserUtil.validate(startElement, EDT); EntitiesDescriptorType entitiesDescriptorType = new EntitiesDescriptorType(); entitiesDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue)); if (id != null) entitiesDescriptorType.setID(StaxParserUtil.getAttributeValue(id)); if (name != null) entitiesDescriptorType.setName(StaxParserUtil.getAttributeValue(name)); if (cacheDuration != null) entitiesDescriptorType.setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil .getAttributeValue(cacheDuration))); entitiesDescriptorType.addEntityDescriptor(entityParser.parse(xmlEventReader)); entitiesDescriptorType.setExtensions(parseExtensions(xmlEventReader)); entitiesDescriptorType.addEntityDescriptor(parser.parse(xmlEventReader)); entitiesDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader));
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get()); if (entities.getValidUntil() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entities.getValidUntil().toString()); if (entities.getID() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entities.getID()); if (entities.getName() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME.get(), entities.getName()); Element signature = entities.getSignature(); if (signature != null) ExtensionsType extensions = entities.getExtensions(); if (extensions != null) List<Object> entityDescriptors = entities.getEntityDescriptor(); for (Object ed : entityDescriptors)
private static void addAllEntityDescriptorsRecursively(List<EntityDescriptorType> resultList, EntitiesDescriptorType entitiesDescriptorType) { List<Object> entities = entitiesDescriptorType.getEntityDescriptor(); for (Object o : entities) { if (o instanceof EntitiesDescriptorType) { addAllEntityDescriptorsRecursively(resultList, (EntitiesDescriptorType) o); } else if (o instanceof EntityDescriptorType) { resultList.add((EntityDescriptorType) o); } else { throw new IllegalArgumentException("Wrong type: " + o.getClass()); } } } }
private EntitiesDescriptorType parseMDFile() throws ParsingException { InputStream is = SecurityActions.loadStream(getClass(), getIdpMetadataLocation()); if (is == null) throw logger.nullValueError(getIdpMetadataLocation()); Object idpMetadata = new SAMLParser().parse(is); EntitiesDescriptorType entities; if (EntitiesDescriptorType.class.isInstance(idpMetadata)) { entities = (EntitiesDescriptorType) idpMetadata; } else { entities = new EntitiesDescriptorType(); entities.addEntityDescriptor(idpMetadata); } return entities; }
StaxParserUtil.validate(startElement, EDT); EntitiesDescriptorType entitiesDescriptorType = new EntitiesDescriptorType(); entitiesDescriptorType.setValidUntil(XMLTimeUtil.parse(validUntilValue)); if (id != null) entitiesDescriptorType.setID(StaxParserUtil.getAttributeValue(id)); if (name != null) entitiesDescriptorType.setName(StaxParserUtil.getAttributeValue(name)); if (cacheDuration != null) entitiesDescriptorType.setCacheDuration(XMLTimeUtil.parseAsDuration(StaxParserUtil .getAttributeValue(cacheDuration))); entitiesDescriptorType.addEntityDescriptor(entityParser.parse(xmlEventReader)); entitiesDescriptorType.setExtensions(parseExtensions(xmlEventReader)); entitiesDescriptorType.addEntityDescriptor(parser.parse(xmlEventReader)); entitiesDescriptorType.setSignature(StaxParserUtil.getDOMElement(xmlEventReader));
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get()); if (entities.getValidUntil() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entities.getValidUntil().toString()); if (entities.getID() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entities.getID()); if (entities.getName() != null) StaxUtil.writeAttribute(writer, JBossSAMLConstants.NAME.get(), entities.getName()); Element signature = entities.getSignature(); if (signature != null) ExtensionsType extensions = entities.getExtensions(); if (extensions != null) List<Object> entityDescriptors = entities.getEntityDescriptor(); for (Object ed : entityDescriptors)
private static void addAllEntityDescriptorsRecursively(List<EntityDescriptorType> resultList, EntitiesDescriptorType entitiesDescriptorType) { List<Object> entities = entitiesDescriptorType.getEntityDescriptor(); for (Object o : entities) { if (o instanceof EntitiesDescriptorType) { addAllEntityDescriptorsRecursively(resultList, (EntitiesDescriptorType) o); } else if (o instanceof EntityDescriptorType) { resultList.add((EntityDescriptorType) o); } else { throw new IllegalArgumentException("Wrong type: " + o.getClass()); } } } }
private EntitiesDescriptorType parseMDFile() throws ParsingException { InputStream is = SecurityActions.loadStream(getClass(), getIdpMetadataLocation()); if (is == null) throw logger.nullValueError(getIdpMetadataLocation()); Object idpMetadata = new SAMLParser().parse(is); EntitiesDescriptorType entities; if (EntitiesDescriptorType.class.isInstance(idpMetadata)) { entities = (EntitiesDescriptorType) idpMetadata; } else { entities = new EntitiesDescriptorType(); entities.addEntityDescriptor(idpMetadata); } return entities; }