From 26c4078c6942650f6a81e348ffa5696b6f4b9908 Mon Sep 17 00:00:00 2001 From: DilshanSenarath <74205483+DilshanSenarath@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:37:03 +0530 Subject: [PATCH] add support for AttributeNameFormat config --- .../carbon/identity/core/IdentityRegistryResources.java | 1 + .../core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java | 7 +++++++ .../identity/core/model/SAMLSSOServiceProviderDO.java | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityRegistryResources.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityRegistryResources.java index aa654f6a6a36..ef016f6e8428 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityRegistryResources.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityRegistryResources.java @@ -144,6 +144,7 @@ public class IdentityRegistryResources { public static final String PROP_SAML_SSO_REQUESTED_AUDIENCES = "RequestedAudiences"; public static final String PROP_SAML_SSO_REQUESTED_RECIPIENTS = "RequestedRecipients"; public static final String PROP_SAML_SSO_ENABLE_ATTRIBUTES_BY_DEFAULT = "EnableAttributesByDefault"; + public static final String PROP_SAML_SSO_ATTRIBUTE_NAME_FORMAT = "AttributeNameFormat"; public static final String PROP_SAML_SSO_ENABLE_NAMEID_CLAIMURI = "EnableNameIDClaimUri"; public static final String PROP_SAML_SSO_NAMEID_CLAIMURI = "NameIDClaimUri"; public static final String PROP_SAML_SSO_NAMEID_FORMAT = "NameIDFormat"; diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java index fc8608eb4b1f..b59b64ca72eb 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/dao/RegistrySAMLSSOServiceProviderDAOImpl.java @@ -215,6 +215,11 @@ SAMLSSOServiceProviderDO buildSAMLSSOServiceProviderDAO (Resource resource) { .getProperty(IdentityRegistryResources.PROP_SAML_SSO_ENABLE_ATTRIBUTES_BY_DEFAULT); serviceProviderDO.setEnableAttributesByDefault(Boolean.valueOf(enableAttrByDefault)); } + if (resource + .getProperty(IdentityRegistryResources.PROP_SAML_SSO_ATTRIBUTE_NAME_FORMAT) != null) { + serviceProviderDO.setAttributeNameFormat( + resource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ATTRIBUTE_NAME_FORMAT)); + } if (resource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_IDP_INIT_SSO_ENABLED) != null) { serviceProviderDO.setIdPInitSSOEnabled(Boolean.valueOf(resource.getProperty( IdentityRegistryResources.PROP_SAML_SSO_IDP_INIT_SSO_ENABLED).trim())); @@ -418,6 +423,8 @@ private Resource createResource(SAMLSSOServiceProviderDO serviceProviderDO, Regi String enableAttributesByDefault = String.valueOf(serviceProviderDO.isEnableAttributesByDefault()); resource.addProperty(IdentityRegistryResources.PROP_SAML_SSO_ENABLE_ATTRIBUTES_BY_DEFAULT, enableAttributesByDefault); + resource.addProperty(IdentityRegistryResources.PROP_SAML_SSO_ATTRIBUTE_NAME_FORMAT, + serviceProviderDO.getAttributeNameFormat()); String idPInitSSOEnabled = String.valueOf(serviceProviderDO.isIdPInitSSOEnabled()); resource.addProperty(IdentityRegistryResources.PROP_SAML_SSO_IDP_INIT_SSO_ENABLED, idPInitSSOEnabled); diff --git a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/model/SAMLSSOServiceProviderDO.java b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/model/SAMLSSOServiceProviderDO.java index e3914c6b7f59..6450b0efc739 100644 --- a/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/model/SAMLSSOServiceProviderDO.java +++ b/components/identity-core/org.wso2.carbon.identity.core/src/main/java/org/wso2/carbon/identity/core/model/SAMLSSOServiceProviderDO.java @@ -54,6 +54,7 @@ public class SAMLSSOServiceProviderDO implements Serializable { private String[] requestedRecipients; private List requestedRecipientsList; private boolean enableAttributesByDefault; + private String attributeNameFormat; private String nameIdClaimUri; private String nameIDFormat; private boolean isIdPInitSSOEnabled; @@ -168,6 +169,14 @@ public void setEnableAttributesByDefault(boolean enableAttributesByDefault) { this.enableAttributesByDefault = enableAttributesByDefault; } + public String getAttributeNameFormat() { + return attributeNameFormat; + } + + public void setAttributeNameFormat(String attributeNameFormat) { + this.attributeNameFormat = attributeNameFormat; + } + public String getIssuer() { return issuer; }