use of org.keycloak.dom.saml.v2.metadata.AttributeConsumingServiceType in project keycloak by keycloak.
the class SAMLAttributeConsumingServiceParser method processSubElement.
@Override
protected void processSubElement(XMLEventReader xmlEventReader, AttributeConsumingServiceType target, SAMLMetadataQNames element, StartElement elementDetail) throws ParsingException {
switch(element) {
case SERVICE_NAME:
LocalizedNameType serviceName = new LocalizedNameType(StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG));
StaxParserUtil.advance(xmlEventReader);
serviceName.setValue(StaxParserUtil.getElementText(xmlEventReader));
target.addServiceName(serviceName);
break;
case SERVICE_DESCRIPTION:
LocalizedNameType serviceDescription = new LocalizedNameType(StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG));
StaxParserUtil.advance(xmlEventReader);
serviceDescription.setValue(StaxParserUtil.getElementText(xmlEventReader));
target.addServiceDescription(serviceDescription);
break;
case REQUESTED_ATTRIBUTE:
target.addRequestedAttribute(SAMLRequestedAttributeParser.getInstance().parse(xmlEventReader));
break;
default:
throw LOGGER.parserUnknownTag(StaxParserUtil.getElementName(elementDetail), elementDetail.getLocation());
}
}
use of org.keycloak.dom.saml.v2.metadata.AttributeConsumingServiceType in project keycloak by keycloak.
the class SAMLMetadataWriter method write.
public void write(SPSSODescriptorType spSSODescriptor) throws ProcessingException {
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.SP_SSO_DESCRIPTOR.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
writeProtocolSupportEnumeration(spSSODescriptor.getProtocolSupportEnumeration());
// Write the attributes
Boolean authnSigned = spSSODescriptor.isAuthnRequestsSigned();
if (authnSigned != null) {
StaxUtil.writeAttribute(writer, new QName(JBossSAMLConstants.AUTHN_REQUESTS_SIGNED.get()), authnSigned.toString());
}
Boolean wantAssertionsSigned = spSSODescriptor.isWantAssertionsSigned();
if (wantAssertionsSigned != null) {
StaxUtil.writeAttribute(writer, new QName(JBossSAMLConstants.WANT_ASSERTIONS_SIGNED.get()), wantAssertionsSigned.toString());
}
// Get the key descriptors
List<KeyDescriptorType> keyDescriptors = spSSODescriptor.getKeyDescriptor();
for (KeyDescriptorType keyDescriptor : keyDescriptors) {
writeKeyDescriptor(keyDescriptor);
}
List<EndpointType> sloServices = spSSODescriptor.getSingleLogoutService();
for (EndpointType endpoint : sloServices) {
writeSingleLogoutService(endpoint);
}
List<IndexedEndpointType> artifactResolutions = spSSODescriptor.getArtifactResolutionService();
for (IndexedEndpointType artifactResolution : artifactResolutions) {
writeArtifactResolutionService(artifactResolution);
}
List<String> nameIDFormats = spSSODescriptor.getNameIDFormat();
for (String nameIDFormat : nameIDFormats) {
writeNameIDFormat(nameIDFormat);
}
List<IndexedEndpointType> assertionConsumers = spSSODescriptor.getAssertionConsumerService();
for (IndexedEndpointType assertionConsumer : assertionConsumers) {
writeAssertionConsumerService(assertionConsumer);
}
List<AttributeConsumingServiceType> attributeConsumers = spSSODescriptor.getAttributeConsumingService();
for (AttributeConsumingServiceType attributeConsumer : attributeConsumers) {
writeAttributeConsumingService(attributeConsumer);
}
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
}
use of org.keycloak.dom.saml.v2.metadata.AttributeConsumingServiceType in project keycloak by keycloak.
the class SAMLMetadataWriter method writeAttributeConsumingService.
public void writeAttributeConsumingService(AttributeConsumingServiceType attributeConsumer) throws ProcessingException {
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ATTRIBUTE_CONSUMING_SERVICE.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
if (attributeConsumer.isIsDefault() != null)
StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISDEFAULT.get(), "" + attributeConsumer.isIsDefault());
StaxUtil.writeAttribute(writer, JBossSAMLConstants.INDEX.get(), "" + attributeConsumer.getIndex());
// Service Name
List<LocalizedNameType> serviceNames = attributeConsumer.getServiceName();
for (LocalizedNameType serviceName : serviceNames) {
writeLocalizedNameType(serviceName, new QName(JBossSAMLURIConstants.METADATA_NSURI.get(), JBossSAMLConstants.SERVICE_NAME.get(), METADATA_PREFIX));
}
List<LocalizedNameType> serviceDescriptions = attributeConsumer.getServiceDescription();
for (LocalizedNameType serviceDescription : serviceDescriptions) {
writeLocalizedNameType(serviceDescription, new QName(JBossSAMLURIConstants.METADATA_NSURI.get(), JBossSAMLConstants.SERVICE_DESCRIPTION.get(), METADATA_PREFIX));
}
List<RequestedAttributeType> requestedAttributes = attributeConsumer.getRequestedAttribute();
for (RequestedAttributeType requestedAttribute : requestedAttributes) {
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.REQUESTED_ATTRIBUTE.get(), JBossSAMLURIConstants.METADATA_NSURI.get());
Boolean isRequired = requestedAttribute.isIsRequired();
if (isRequired != null) {
StaxUtil.writeAttribute(writer, new QName(JBossSAMLConstants.IS_REQUIRED.get()), isRequired.toString());
}
writeAttributeTypeWithoutRootTag(requestedAttribute);
StaxUtil.writeEndElement(writer);
}
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
}
Aggregations