Author: prabath
Date: Mon Mar 24 02:55:54 2008
New Revision: 15038

Log:

added xml OpenID claim mapper for mapping claims in between SReg, axschema and 
openid schema

Added:
   
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/
   
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
Modified:
   
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/AddNewClaimAction.java
   
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateClaimAction.java
   
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
   trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
   trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/ClaimsAdmin.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/ClaimDAO.java
   
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/relyingparty/openid/extensions/OpenIDAttributeExchange.java

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/AddNewClaimAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/AddNewClaimAction.java
  (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/AddNewClaimAction.java
  Mon Mar 24 02:55:54 2008
@@ -29,56 +29,63 @@
     private String claimDisplayTag;
 
     private String claimDescription;
-    
-    private String openIDTag; 
 
-       public String execute() throws Exception {
+    private String openIDTag;
+
+    public String execute() throws Exception {
 
         ClaimsAdmin admin = new ClaimsAdmin();
 
         boolean error = false;
-        
+
         if (claimUri == null
                 || (claimUri != null && claimUri.trim().length() == 0)) {
             this.addErrorMessage(getText("add_claim_uri_null"));
             error = true;
         }
 
-        if(claimUri != null && claimUri.trim().length() > 0 && 
-                claimUri.indexOf(':') < 0) {
+        if (claimUri != null && claimUri.trim().length() > 0
+                && claimUri.indexOf(':') < 0) {
             this.addErrorMessage(getText("invalid_uri",
                     new String[] { claimUri }));
             error = true;
         }
 
-        
         if (claimDisplayTag == null
-                || (claimDisplayTag != null && 
-                        claimDisplayTag.trim().length() == 0)) {
+                || (claimDisplayTag != null && claimDisplayTag.trim().length() 
== 0)) {
             this.addErrorMessage(getText("add_claim_disp_tag_null"));
             error = true;
         }
 
         if (claimDescription == null
-                || (claimDescription != null && 
-                        claimDescription.trim().length() == 0)) {
+                || (claimDescription != null && claimDescription.trim()
+                        .length() == 0)) {
             this.addErrorMessage(getText("add_claim_desc_null"));
             error = true;
         }
-        
-        if(error) {
+
+        if (error) {
             return ERROR;
         }
-        
-        if(admin.findClaimByURI(claimUri) != null) {
+
+        if (admin.findClaimByURI(claimUri) != null) {
             //Claim already  exists
             this.addErrorMessage(getText("add_claim_duplicate_claim",
                     new String[] { claimUri }));
             return ERROR;
         }
-        
+
+        if (openIDTag != null) {
+            if (!admin.isValidOpenIDTag(openIDTag)) {
+                // You can't have two supported claims with the same OpenID tag
+                this.addErrorMessage(getText("add_claim_duplicate_openid_tag",
+                        new String[] { openIDTag }));
+                return ERROR;
+            }
+        }
+
         admin.createClaim(dialectUri, claimUri, claimDisplayTag,
-                claimDescription,openIDTag);
+                claimDescription, openIDTag);
 
         return SUCCESS;
     }
@@ -98,13 +105,13 @@
     public void setClaimDescription(String claimDescription) {
         this.claimDescription = claimDescription;
     }
-    
+
     public String getOpenIDTag() {
-               return openIDTag;
-       }
+        return openIDTag;
+    }
 
-       public void setOpenIDTag(String openIDTag) {
-               this.openIDTag = openIDTag;
-       }
+    public void setOpenIDTag(String openIDTag) {
+        this.openIDTag = openIDTag;
+    }
 
 }

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateClaimAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateClaimAction.java
  (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateClaimAction.java
  Mon Mar 24 02:55:54 2008
@@ -20,9 +20,7 @@
 import org.wso2.solutions.identity.admin.ui.UIConstants;
 import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;
 
-import com.opensymphony.xwork2.ActionSupport;
-
-public class UpdateClaimAction extends ActionSupport {
+public class UpdateClaimAction extends ManagedAction {
 
     private static final long serialVersionUID = 3006810147981917457L;
 
@@ -40,7 +38,15 @@
                 claimDO.setSupported(false);
                 claimDO.setAttrId(ClaimDO.DAFAULT_ATTR_ID);
                 admin.updateClaim(claimDO);
-            } else if (operation.equals(UIConstants.CLAIM_UPDATE_ENABLE)) {
+            } else if (operation.equals(UIConstants.CLAIM_UPDATE_ENABLE)) {    
            
+                if (claimDO.getOpenIDTag() != null) {
+                    if (!admin.isValidOpenIDTag(claimDO.getOpenIDTag())) {
+                        // You can't have two supported claims with the same 
OpenID tag
+                        
this.addErrorMessage(getText("add_claim_duplicate_openid_tag",
+                                new String[] { claimDO.getOpenIDTag() }));
+                        return ERROR;
+                    }
+                }       
                 claimDO.setSupported(true);
                 admin.updateClaim(claimDO);
             }

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
 (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
 Mon Mar 24 02:55:54 2008
@@ -25,6 +25,7 @@
 invalid_user_name= Invalid characters found in the user name
 
 add_claim_duplicate_claim = Duplicate claim : {0}
+add_claim_duplicate_openid_tag = Duplicate OpenID tag : {0}
 add_claim_uri_null = Claim URI missing
 add_claim_disp_tag_null = Display Tag missing
 add_claim_desc_null = Description missing

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
==============================================================================
--- trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml     
(original)
+++ trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml     
Mon Mar 24 02:55:54 2008
@@ -74,7 +74,8 @@
                </action>
 
                <action name="UpdateClaim" 
class="org.wso2.solutions.identity.admin.ui.action.UpdateClaimAction">
-                       <result name="success" 
type="redirect">ShowClaims.action</result>
+                       <result name="success" 
type="redirect">ShowClaims.action</result>
+                       <result name="error" 
type="redirect">ShowClaims.action</result>
                </action>
 
                <action name="AddNewDialect" 
class="org.wso2.solutions.identity.admin.ui.action.AddNewDialectAction">

Added: 
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
       Mon Mar 24 02:55:54 2008
@@ -0,0 +1,97 @@
+package org.wso2.solutions.identity.openid;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+public class OpenIDClaimMapper {
+
+       public final static String LN_CLAIM_MAPPER = "ClaimMapper";
+       public final static String LN_CLAIM = "Claim";
+       public final static String LN_SREG = "SReg";
+       public final static String LN_AXSCHEMA = "AxSchema";
+       public final static String LN_OPENID_SCHEMA = "OpenIDSchema";
+
+       public final static String OPENID_CLAIM_MAPPER_FILE_PATH = 
"conf/openid-claim-mapper.xml";
+
+       private static HashMap<String, String> axMapping = new HashMap<String, 
String>();
+       private static HashMap<String, String> sregMapping = new 
HashMap<String, String>();
+
+       private static OpenIDClaimMapper instance;
+
+       private OpenIDClaimMapper() throws Exception {
+               //TODO: define a custom exception and throw it.
+               process(OPENID_CLAIM_MAPPER_FILE_PATH);
+       }
+
+       public static OpenIDClaimMapper getInstance() throws Exception {
+               if (instance == null) {
+                       instance = new OpenIDClaimMapper();
+               }
+
+               return instance;
+       }
+
+       public HashMap<String, String> getAxMapping() {
+               return axMapping;
+       }
+
+       public HashMap<String, String> getSregMapping() {
+               return sregMapping;
+       }
+
+       public void process(String filePath) throws Exception {
+               StAXOMBuilder builder = new StAXOMBuilder(filePath);
+               OMElement elem = builder.getDocumentElement();
+               process(elem);
+       }
+
+       private void process(OMElement initialClaims) throws Exception {
+
+               Iterator claims = initialClaims
+                               .getChildrenWithName(new QName(LN_CLAIM));
+
+               OMElement claimElement = null;
+               OMElement sreg = null;
+               OMElement axSchema = null;
+               OMElement openidSchema = null;
+
+               while (claims.hasNext()) {
+
+                       claimElement = (OMElement) claims.next();
+                       sreg = claimElement.getFirstChildWithName(new 
QName(LN_SREG));
+                       axSchema = claimElement
+                                       .getFirstChildWithName(new 
QName(LN_AXSCHEMA));
+                       openidSchema = claimElement.getFirstChildWithName(new 
QName(
+                                       LN_OPENID_SCHEMA));
+
+                       if (openidSchema != null && axSchema != null) {
+                               if 
(axMapping.containsKey(openidSchema.getText())) {
+                                       throw new Exception(
+                                                       "Fond duplicate key 
entries in openID claim mapper");
+                               }
+                               axMapping.put(openidSchema.getText(), 
axSchema.getText());
+                       }
+
+                       if (sreg != null && openidSchema != null) {
+                               if 
(sregMapping.containsKey(openidSchema.getText())) {
+                                       throw new Exception(
+                                                       "Fond duplicate key 
entries in openID claim mapper");
+                               }
+                               sregMapping.put(openidSchema.getText(), 
sreg.getText());
+                       }
+
+                       if (sreg != null && axSchema != null) {
+                               if 
(sregMapping.containsKey(axSchema.getText())) {
+                                       throw new Exception(
+                                                       "Fond duplicate key 
entries in openID claim mapper");
+                               }
+                               sregMapping.put(axSchema.getText(), 
sreg.getText());
+                       }
+               }
+       }
+}
\ No newline at end of file

Modified: 
trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
==============================================================================
--- trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml 
(original)
+++ trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml 
Mon Mar 24 02:55:54 2008
@@ -326,7 +326,11 @@
             
<outputDirectory>${identity.solution.home.dir}/conf</outputDirectory>
             <filtered>true</filtered>
         </file>
-
+        <file>
+            <source>../base/conf/openid-claim-mapper.xml</source>
+            
<outputDirectory>${identity.solution.home.dir}/conf</outputDirectory>
+            <filtered>true</filtered>
+        </file>
         <file>
             <source>../identity-provider/conf/wso2is.jks</source>
             
<outputDirectory>${identity.solution.home.dir}/conf</outputDirectory>

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/ClaimsAdmin.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/ClaimsAdmin.java
 (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/ClaimsAdmin.java
 Mon Mar 24 02:55:54 2008
@@ -129,6 +129,11 @@
     {
         return dbman.getMappedOpenIDTag(uri);
     }
+    
+    public boolean isValidOpenIDTag(String openIDTag)
+    {
+        return dbman.isValidOpenIDTag(openIDTag);
+    }
 
     public void resetClaimMappings() {
         ClaimDO[] claimDOs = this.getAllMappedClaims();

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
 (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
 Mon Mar 24 02:55:54 2008
@@ -17,6 +17,7 @@
 import org.wso2.solutions.identity.admin.ClaimsAdmin;
 import org.wso2.solutions.identity.openid.OpenIDAuthenticationRequest;
 import org.wso2.solutions.identity.openid.OpenIDClaim;
+import org.wso2.solutions.identity.openid.OpenIDClaimMapper;
 import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;
 
 public class OpenIDAttributeExchange extends OpenIDExtension {
@@ -25,32 +26,7 @@
 
     private static Log log = LogFactory.getLog(OpenIDAttributeExchange.class);
 
-    private static Map<String, String> axMapping = new HashMap<String, 
String>();
-
-    static {
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS);
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.DOB_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.DOB_NS);
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS);
-
-    }
+    private static Map<String, String> axMapping;
 
     /**
      * Constructed during building the response
@@ -174,8 +150,21 @@
      * http://axschema.org
      * @param val schema name-space URL
      * @return mapped value
+     * @throws IdentityProviderException
      */
-    protected String getMappedAxSchema(String val) {
+    protected String getMappedAxSchema(String val)
+            throws IdentityProviderException {
+
+        if (axMapping == null) {
+            try {
+                axMapping = OpenIDClaimMapper.getInstance().getAxMapping();
+            } catch (Exception e) {
+                throw new IdentityProviderException(
+                        
IdentityConstants.ErrorCodes.OPENID_RESP_GENERATION_FAILED,
+                        e);
+            }
+        }
+
         if (axMapping.containsKey(val)) {
             return axMapping.get(val);
         }

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
  (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/IPPersistenceManager.java
  Mon Mar 24 02:55:54 2008
@@ -189,14 +189,13 @@
         ClaimDAO dao = new ClaimDAO(hbConfig);
         return dao.getAllMappedEnabledClaims();
     }
-    
+
     /**
      * Provide the mapped OpenID tag corresponding to the provided claim uri
      * @param uri Claim uri
      * @return Mapped OpenID tag
      */
-    public String getMappedOpenIDTag(String uri)
-    {
+    public String getMappedOpenIDTag(String uri) {
         ClaimDAO dao = new ClaimDAO(hbConfig);
         return dao.getMappedOpenIDTag(uri);
     }
@@ -460,18 +459,24 @@
         return dao.getOpenIDUserRP(userName);
     }
 
-    public String getOpenIDDefaultUserProfile(String userName,String rpUrl) {
+    public String getOpenIDDefaultUserProfile(String userName, String rpUrl) {
         OpenIDUserRPDAO dao = new OpenIDUserRPDAO(hbConfig);
-        return dao.getOpenIDDefaultUserProfile(userName,rpUrl);
-    } 
-    
+        return dao.getOpenIDDefaultUserProfile(userName, rpUrl);
+    }
+
     public UserTrustedRPDO[] getPersonalRelyingPartyByHostName(String 
hostName) {
-        UserPersonalRelyingPartyDAO dao = new 
UserPersonalRelyingPartyDAO(hbConfig);
+        UserPersonalRelyingPartyDAO dao = new UserPersonalRelyingPartyDAO(
+                hbConfig);
         return dao.getPersonalRelyingPartyByHostName(hostName);
     }
-    
+
     public List<OpenIDSummaryReportData> getOpenIDsGroupedByUser() {
         OpenIDUserRPDAO dao = new OpenIDUserRPDAO(hbConfig);
         return dao.getOpenIDsGroupedByUser();
     }
+
+    public boolean isValidOpenIDTag(String openIDTag) {
+        ClaimDAO dao = new ClaimDAO(hbConfig);
+        return dao.isValidOpenIDTag(openIDTag);
+    }
 }
\ No newline at end of file

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/ClaimDAO.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/ClaimDAO.java
  (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/ClaimDAO.java
  Mon Mar 24 02:55:54 2008
@@ -164,4 +164,28 @@
             hbConfig.closeSession();
         }
     }
-}
+    
+    public boolean isValidOpenIDTag(String openIDTag) {
+        Session session = hbConfig.getCurrentSession();
+        ClaimDO[] claims = null;
+        try {
+            Criteria criteria = session.createCriteria(ClaimDO.class);
+            criteria.add(Expression.eq("openIDTag", openIDTag));
+            criteria.add(Expression.eq("supported", Boolean.TRUE));
+            List lst = criteria.list();
+            claims = (ClaimDO[]) lst.toArray(new ClaimDO[lst.size()]);
+
+            if (claims != null && claims.length > 0)
+                return false;
+            else
+                return true;
+            
+        } catch (Throwable e) {            
+            String msg = messages.getMessage("errorQuerryingClaimData");
+            log.error(msg, e);
+            throw new RuntimeException(msg, e);
+        } finally {
+            hbConfig.closeSession();
+        }
+    }
+}
\ No newline at end of file

Modified: 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/relyingparty/openid/extensions/OpenIDAttributeExchange.java
==============================================================================
--- 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/relyingparty/openid/extensions/OpenIDAttributeExchange.java
  (original)
+++ 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/relyingparty/openid/extensions/OpenIDAttributeExchange.java
  Mon Mar 24 02:55:54 2008
@@ -1,6 +1,5 @@
 package org.wso2.solutions.identity.relyingparty.openid.extensions;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -12,6 +11,7 @@
 import org.openid4java.message.ax.FetchRequest;
 import org.openid4java.message.ax.FetchResponse;
 import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.openid.OpenIDClaimMapper;
 import org.wso2.solutions.identity.relyingparty.RelyingPartyException;
 import 
org.wso2.solutions.identity.relyingparty.openid.OpenIDAuthenticationRequest;
 import org.wso2.solutions.identity.relyingparty.openid.OpenIDAxAttribute;
@@ -20,50 +20,7 @@
 
     private AuthSuccess authSuccess;
 
-    private static Map<String, String> axMapping = new HashMap<String, 
String>();
-
-    static {
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.GENDER);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.COUNTRY);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.DOB_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.DOB);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.EMAIL);
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE);
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.GENDER);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.COUNTRY);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.DOB_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.DOB);
-        axMapping.put(
-                IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE);
-        axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS2,
-                IdentityConstants.OpenId.ExchangeAttributes.EMAIL);
-    }
+    private static Map<String, String> axMapping;
 
     /**
      * Default constructor
@@ -153,7 +110,18 @@
      * @param val schema name-space URL
      * @return mapped value
      */
-    protected String getAlias(String val) {
+    protected String getAlias(String val) throws RelyingPartyException {
+
+        try {
+            if (axMapping == null) {
+                axMapping = OpenIDClaimMapper.getInstance().getSregMapping();
+            }
+        } catch (Exception e) {
+            throw new RelyingPartyException(
+                    IdentityConstants.ErrorCodes.OPENID_AUTHENTICATION_FAILED,
+                    e);
+        }
+
         if (axMapping.containsKey(val)) {
             return axMapping.get(val);
         }

_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev

Reply via email to