Search in sources :

Example 1 with LogoType

use of org.keycloak.dom.saml.v2.mdui.LogoType in project keycloak by keycloak.

the class SAMLUIInfoParser method processSubElement.

@Override
protected void processSubElement(XMLEventReader xmlEventReader, UIInfoType target, SAMLMetadataQNames element, StartElement elementDetail) throws ParsingException {
    switch(element) {
        case DISPLAY_NAME:
            LocalizedNameType displayName = new LocalizedNameType(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            displayName.setValue(StaxParserUtil.getElementText(xmlEventReader));
            target.addDisplayName(displayName);
            break;
        case DESCRIPTION:
            LocalizedNameType description = new LocalizedNameType(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            description.setValue(StaxParserUtil.getElementText(xmlEventReader));
            target.addDescription(description);
            break;
        case KEYWORDS:
            KeywordsType keywords = new KeywordsType(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_LANG));
            target.addKeywords(keywords);
            break;
        case INFORMATION_URL:
            LocalizedURIType informationURL = new LocalizedURIType(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            informationURL.setValue(URI.create(StaxParserUtil.getElementText(xmlEventReader)));
            target.addInformationURL(informationURL);
            break;
        case PRIVACY_STATEMENT_URL:
            LocalizedURIType privacyStatementURL = new LocalizedURIType(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_LANG));
            StaxParserUtil.advance(xmlEventReader);
            privacyStatementURL.setValue(URI.create(StaxParserUtil.getElementText(xmlEventReader)));
            target.addPrivacyStatementURL(privacyStatementURL);
            break;
        case LOGO:
            LogoType logo = new LogoType(Integer.parseInt(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_HEIGHT)), Integer.parseInt(StaxParserUtil.getRequiredAttributeValue(elementDetail, ATTR_WIDTH)));
            String lang = StaxParserUtil.getAttributeValue(elementDetail, ATTR_LANG);
            if (lang != null)
                logo.setLang(lang);
            StaxParserUtil.advance(xmlEventReader);
            try {
                String logoValue = StaxParserUtil.getElementText(xmlEventReader).replaceAll("\\s+", "");
                logo.setValue(new URI(logoValue));
            } catch (URISyntaxException ex) {
                throw new ParsingException(ex);
            }
            target.addLogo(logo);
            break;
        default:
            throw LOGGER.parserUnknownTag(StaxParserUtil.getElementName(elementDetail), elementDetail.getLocation());
    }
}
Also used : LocalizedURIType(org.keycloak.dom.saml.v2.metadata.LocalizedURIType) LogoType(org.keycloak.dom.saml.v2.mdui.LogoType) KeywordsType(org.keycloak.dom.saml.v2.mdui.KeywordsType) LocalizedNameType(org.keycloak.dom.saml.v2.metadata.LocalizedNameType) ParsingException(org.keycloak.saml.common.exceptions.ParsingException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 KeywordsType (org.keycloak.dom.saml.v2.mdui.KeywordsType)1 LogoType (org.keycloak.dom.saml.v2.mdui.LogoType)1 LocalizedNameType (org.keycloak.dom.saml.v2.metadata.LocalizedNameType)1 LocalizedURIType (org.keycloak.dom.saml.v2.metadata.LocalizedURIType)1 ParsingException (org.keycloak.saml.common.exceptions.ParsingException)1