Java Code Examples for org.opensaml.core.xml.schema.XSString

The following examples show how to use org.opensaml.core.xml.schema.XSString. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: centraldogma   Source File: SamlAuthSsoHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
private String findLoginNameFromAttributes(Response response) {
    if (Strings.isNullOrEmpty(attributeLoginName)) {
        return null;
    }
    return response.getAssertions()
                   .stream()
                   .flatMap(s -> s.getAttributeStatements().stream())
                   .flatMap(s -> s.getAttributes().stream())
                   .filter(attr -> attr.getName().equals(attributeLoginName))
                   .findFirst()
                   .map(attr -> {
                       final XMLObject v = attr.getAttributeValues().get(0);
                       if (v instanceof XSString) {
                           return ((XSString) v).getValue();
                       } else {
                           return null;
                       }
                   })
                   .orElse(null);
}
 
Example 2
/**
 * Gets string values from the list of mdui objects.
 *
 * @param items the items
 * @return the string values
 */
private Collection<String> getStringValues(final List<?> items) {
    final List<String> list = new ArrayList<>();
    for (final Object d : items) {
        if (d instanceof XSURI) {
            list.add(((XSURI) d).getValue());
        } else if (d instanceof XSString) {
            list.add(((XSString) d).getValue());
        }
    }
    return list;
}
 
Example 3
/**
 * New attribute value.
 *
 * @param value the value
 * @param elementName the element name
 * @return the xS string
 */
protected final XSString newAttributeValue(final Object value, final QName elementName) {
    final XSStringBuilder attrValueBuilder = new XSStringBuilder();
    final XSString stringValue = attrValueBuilder.buildObject(elementName, XSString.TYPE_NAME);
    if (value instanceof String) {
        stringValue.setValue((String) value);
    } else {
        stringValue.setValue(value.toString());
    }
    return stringValue;
}
 
Example 4
private void logAssertionAttributes(Assertion assertion) {
    for (Attribute attribute : assertion.getAttributeStatements().get(0).getAttributes()) {
        logger.info("Attribute name: " + attribute.getName());
        for (XMLObject attributeValue : attribute.getAttributeValues()) {
            logger.info("Attribute value: " + ((XSString) attributeValue).getValue());
        }
    }
}
 
Example 5
Source Project: carbon-apimgt   Source File: TokenMgtUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static String getAttributeValue(XMLObject attributeValue) {
    if (attributeValue == null){
        return null;
    } else if (attributeValue instanceof XSString){
        return getStringAttributeValue((XSString) attributeValue);
    } else if(attributeValue instanceof XSAnyImpl){
        return getAnyAttributeValue((XSAnyImpl) attributeValue);
    } else {
        return attributeValue.toString();
    }
}
 
Example 6
Source Project: carbon-apimgt   Source File: SAMLGroupIDExtractorImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the String value from XMLObject
 *
 * @param attributeValue XMLObject of attribute value recived in SAML Assertion     *
 * @return attribute value as a String
 */
private String getAttributeValue(XMLObject attributeValue) {
    if (attributeValue == null){
        return null;
    } else if (attributeValue instanceof XSString){
        return getStringAttributeValue((XSString) attributeValue);
    } else if(attributeValue instanceof XSAnyImpl){
        return getAnyAttributeValue((XSAnyImpl) attributeValue);
    } else {
        return attributeValue.toString();
    }
}
 
Example 7
Source Project: carbon-apimgt   Source File: APIKeyMgtUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static String getAttributeValue(XMLObject attributeValue) {
    if (attributeValue == null){
        return null;
    } else if (attributeValue instanceof XSString){
        return getStringAttributeValue((XSString) attributeValue);
    } else if(attributeValue instanceof XSAnyImpl){
        return getAnyAttributeValue((XSAnyImpl) attributeValue);
    } else {
        return attributeValue.toString();
    }
}
 
Example 8
Source Project: sling-whiteboard   Source File: Saml2User.java    License: Apache License 2.0 4 votes vote down vote up
public void addUserProperty(String key, XMLObject attributeValue) {
    this.userProperties.put(key, ((XSString) attributeValue).getValue());
}
 
Example 9
Source Project: carbon-apimgt   Source File: TokenMgtUtil.java    License: Apache License 2.0 4 votes vote down vote up
private static String getStringAttributeValue(XSString attributeValue) {
    return attributeValue.getValue();
}
 
Example 10
Source Project: carbon-apimgt   Source File: APIKeyMgtUtil.java    License: Apache License 2.0 4 votes vote down vote up
private static String getStringAttributeValue(XSString attributeValue) {
    return attributeValue.getValue();
}
 
Example 11
Source Project: carbon-apimgt   Source File: SAMLGroupIDExtractorImpl.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Get the String value from XSString object
 *
 * @param attributeValue XSString Object instance of attribute value received in SAML Assertion
 * @return attribute value as a String
 */
private String getStringAttributeValue(XSString attributeValue) {
    return attributeValue.getValue();
}