callback.setAuthenticationStatementData(Collections.singletonList(authBean));
} else if (statement == Statement.ATTR) {
AttributeStatementBean attrStateBean = new AttributeStatementBean();
if (this.roles == null) {
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
attrStateBean.setSubject(subjectBean);
attributeBean.setSimpleName("name");
attributeBean.setQualifiedName("dummy-ns");
} else {
attributeBean.setQualifiedName("dummy-ns");
}
attributeBean.setAttributeValues(Collections.singletonList("myvalue"));
attrStateBean.setSamlAttributes(Collections.singletonList(attributeBean));
callback.setAttributeStatementData(Collections.singletonList(attrStateBean));
return;
}
if (this.multiValueType.equals(MultiValue.MULTI_VALUE)
|| this.multiValueType.equals(MultiValue.ENC_VALUE)) {
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value1</saml:AttributeValue>
// <saml:AttributeValue>Value2</saml:AttributeValue>
// </saml:Attribute>
// or
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value1,Value2</saml:AttributeValue>
// </saml:Attribute>
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
attrStateBean.setSubject(subjectBean);
attributeBean.setSimpleName("role");
attributeBean.setQualifiedName(FederationConstants.DEFAULT_ROLE_URI.toString());
} else {
attributeBean.setQualifiedName(FederationConstants.DEFAULT_ROLE_URI.toString());
}
if (this.multiValueType.equals(MultiValue.MULTI_VALUE)) {
attributeBean.setAttributeValues(roles);
} else {
StringBuffer sb = new StringBuffer();
for (String role: roles) {
sb.append(role).append(this.roleSeperator);
}
String value = sb.substring(0, sb.length() - this.roleSeperator.length());
attributeBean.setAttributeValues(Collections.singletonList(value));
}
attrStateBean.setSamlAttributes(Collections.singletonList(attributeBean));
} else if (this.multiValueType.equals(MultiValue.MULTI_ATTR)) {
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value1</saml:AttributeValue>
// </saml:Attribute>
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value2</saml:AttributeValue>
// </saml:Attribute>
List<AttributeBean> attrBeans = new ArrayList<AttributeBean>();
for (String role: roles) {
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
attrStateBean.setSubject(subjectBean);
attributeBean.setSimpleName("role");
attributeBean.setQualifiedName(FederationConstants.DEFAULT_ROLE_URI.toString());
} else {
attributeBean.setQualifiedName(FederationConstants.DEFAULT_ROLE_URI.toString());
}
attributeBean.setAttributeValues(Collections.singletonList(role));
attrBeans.add(attributeBean);
}
attrStateBean.setSamlAttributes(attrBeans);
}
callback.setAttributeStatementData(Collections.singletonList(attrStateBean));