if (subjectBean != null) {
attrStateBean.setSubject(subjectBean);
}
if (this.roles == null) {
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
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;
}
List<AttributeBean> attributeList = new ArrayList<AttributeBean>();
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) {
// SAML 1.1
if (this.isUseNameFormatAsNamespace()) {
//Workaround for CXF-4484
attributeBean.setSimpleName(this.roleAttributeName);
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(ClaimTypes.URI_BASE.toString());
} else {
attributeBean.setSimpleName(getNameOfClaimType(this.roleAttributeName));
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(getNamespaceOfClaimType(this.roleAttributeName));
}
} else {
// SAML 2.0
attributeBean.setQualifiedName(this.roleAttributeName);
attributeBean.setNameFormat(this.getAttributeNameFormat());
}
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));
}
attributeList.add(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) {
// SAML 1.1
if (this.isUseNameFormatAsNamespace()) {
//Workaround for CXF-4484
attributeBean.setSimpleName(this.roleAttributeName);
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(ClaimTypes.URI_BASE.toString());
} else {
attributeBean.setSimpleName(getNameOfClaimType(this.roleAttributeName));
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(getNamespaceOfClaimType(this.roleAttributeName));
}
} else {
// SAML 2.0
attributeBean.setQualifiedName(this.roleAttributeName);
attributeBean.setNameFormat(this.getAttributeNameFormat());
}
attributeBean.setAttributeValues(Collections.singletonList(role));
attributeList.add(attributeBean);
}
}
//ClaimTypes.COUNTRY
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
//SAML 1.1
attributeBean.setSimpleName(getNameOfClaimType(this.countryClaimName));
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(getNamespaceOfClaimType(this.countryClaimName));
} else {
//SAML 2.0
attributeBean.setQualifiedName(this.countryClaimName);
attributeBean.setNameFormat(this.getAttributeNameFormat());
}
attributeBean.setAttributeValues(Collections.singletonList("CH"));
attributeList.add(attributeBean);
//custom claim language
AttributeBean attributeBean2 = new AttributeBean();
if (subjectBean != null) {
// SAML 1.1
if (this.isUseNameFormatAsNamespace()) {
//Workaround for CXF-4484
attributeBean2.setSimpleName(this.customClaimName);
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean2.setQualifiedName(ClaimTypes.URI_BASE.toString());
} else {
attributeBean2.setSimpleName(getNameOfClaimType(this.customClaimName));
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean2.setQualifiedName(getNamespaceOfClaimType(this.customClaimName));
}
} else {
// SAML 2
attributeBean2.setQualifiedName(this.customClaimName);
attributeBean2.setNameFormat(this.getAttributeNameFormat());
}
attributeBean2.setAttributeValues(Collections.singletonList("CH"));
attributeList.add(attributeBean2);
attrStateBean.setSamlAttributes(attributeList);
callback.setAttributeStatementData(Collections.singletonList(attrStateBean));