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

The following examples show how to use org.opensaml.core.xml.schema.XSString. 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 File: SamlAuthSsoHandler.java    From centraldogma with 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
Source File: SimpleMetadataUIInfo.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * 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
Source File: AbstractSamlObjectBuilder.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * 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
Source File: ConsumerServlet.java    From OpenSAML-ref-project-demo-v3 with Apache License 2.0 5 votes vote down vote up
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 File: TokenMgtUtil.java    From carbon-apimgt with 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 File: SAMLGroupIDExtractorImpl.java    From carbon-apimgt with 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 File: APIKeyMgtUtil.java    From carbon-apimgt with 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 File: Saml2User.java    From sling-whiteboard with 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 File: TokenMgtUtil.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
private static String getStringAttributeValue(XSString attributeValue) {
    return attributeValue.getValue();
}
 
Example #10
Source File: APIKeyMgtUtil.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
private static String getStringAttributeValue(XSString attributeValue) {
    return attributeValue.getValue();
}
 
Example #11
Source File: SAMLGroupIDExtractorImpl.java    From carbon-apimgt with 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();
}