Author: prabath
Date: Tue Mar 25 01:39:40 2008
New Revision: 15067

Log:

added comments

Modified:
   
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java

Modified: 
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
==============================================================================
--- 
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
       (original)
+++ 
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/openid/OpenIDClaimMapper.java
       Tue Mar 25 01:39:40 2008
@@ -8,6 +8,11 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 
+/**
+ * This class manages mapping of OpenID Simple Registration[SReg] to two 
schemas
+ * used in OpenID Attribute Exchanged [AxSchema & OpenID schema]
+ * 
+ */
 public class OpenIDClaimMapper {
 
        public final static String LN_CLAIM_MAPPER = "ClaimMapper";
@@ -16,6 +21,7 @@
        public final static String LN_AXSCHEMA = "AxSchema";
        public final static String LN_OPENID_SCHEMA = "OpenIDSchema";
 
+       // If you want to add a new mapping - need to edit this file
        public final static String OPENID_CLAIM_MAPPER_FILE_PATH = 
"conf/openid-claim-mapper.xml";
 
        private static HashMap<String, String> axMapping = new HashMap<String, 
String>();
@@ -23,16 +29,25 @@
 
        private static OpenIDClaimMapper instance;
 
+       /**
+        * Private constructor, makes the class singleton
+        * 
+        * @throws Exception TODO: Define a custom exception
+        */
        private OpenIDClaimMapper() throws Exception {
-               //TODO: define a custom exception and throw it.
                process(OPENID_CLAIM_MAPPER_FILE_PATH);
        }
 
+       /**
+        * Creates and maintains a singleton instance of OpenIDClaimMapper
+        * 
+        * @return An instance of OpenIDClaimMapper
+        * @throws Exception
+        */
        public static OpenIDClaimMapper getInstance() throws Exception {
                if (instance == null) {
                        instance = new OpenIDClaimMapper();
                }
-
                return instance;
        }
 
@@ -44,12 +59,23 @@
                return sregMapping;
        }
 
-       public void process(String filePath) throws Exception {
+       /**
+        * Process the OpenID mapping file
+        * 
+        * @param filePath Path to the OpenID attribute mapping file
+        * @throws Exception
+        */
+       private void process(String filePath) throws Exception {
                StAXOMBuilder builder = new StAXOMBuilder(filePath);
                OMElement elem = builder.getDocumentElement();
                process(elem);
        }
 
+       /**
+        * Populate attribute mapping HashMaps
+        * @param initialClaims Root element
+        * @throws Exception
+        */
        private void process(OMElement initialClaims) throws Exception {
 
                Iterator claims = initialClaims
@@ -61,7 +87,6 @@
                OMElement openidSchema = null;
 
                while (claims.hasNext()) {
-
                        claimElement = (OMElement) claims.next();
                        sreg = claimElement.getFirstChildWithName(new 
QName(LN_SREG));
                        axSchema = claimElement

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

Reply via email to