Author: prabath
Date: Thu Jan 10 02:52:20 2008
New Revision: 12106

Log:

OpenID integration

Modified:
   
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/openid/relyingparty/OpenIDConsumer.java

Modified: 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/openid/relyingparty/OpenIDConsumer.java
==============================================================================
--- 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/openid/relyingparty/OpenIDConsumer.java
      (original)
+++ 
trunk/solutions/identity/modules/token-verifier-core/src/main/java/org/wso2/solutions/identity/openid/relyingparty/OpenIDConsumer.java
      Thu Jan 10 02:52:20 2008
@@ -41,24 +41,29 @@
 
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS,
                 IdentityConstants.OpenId.ExchangeAttributes.EMAIL);
-        
attributes.put(IdentityConstants.OpenId.ExchangeAttributes.GIVEN_NAME_NS,
+        attributes.put(
+                IdentityConstants.OpenId.ExchangeAttributes.GIVEN_NAME_NS,
                 IdentityConstants.OpenId.ExchangeAttributes.GIVEN_NAME);
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.SURNAME_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.SURNAME);        
-        
attributes.put(IdentityConstants.OpenId.ExchangeAttributes.HOME_PHONE_NS,
+                IdentityConstants.OpenId.ExchangeAttributes.SURNAME);
+        attributes.put(
+                IdentityConstants.OpenId.ExchangeAttributes.HOME_PHONE_NS,
                 IdentityConstants.OpenId.ExchangeAttributes.HOME_PHONE);
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.WORK_PHONE,
                 IdentityConstants.OpenId.ExchangeAttributes.WORK_PHONE_NS);
-        
attributes.put(IdentityConstants.OpenId.ExchangeAttributes.MOBILE_PHONE,
-                IdentityConstants.OpenId.ExchangeAttributes.MOBILE_PHONE_NS);  
  
-        
attributes.put(IdentityConstants.OpenId.ExchangeAttributes.STREET_ADDRESS_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.STREET_ADDRESS);   
     
+        attributes.put(
+                IdentityConstants.OpenId.ExchangeAttributes.MOBILE_PHONE,
+                IdentityConstants.OpenId.ExchangeAttributes.MOBILE_PHONE_NS);
+        attributes.put(
+                IdentityConstants.OpenId.ExchangeAttributes.STREET_ADDRESS_NS,
+                IdentityConstants.OpenId.ExchangeAttributes.STREET_ADDRESS);
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.CITY_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.CITY);        
-        
attributes.put(IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE);      
  
+                IdentityConstants.OpenId.ExchangeAttributes.CITY);
+        attributes.put(
+                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS,
+                IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE);
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS,
-                IdentityConstants.OpenId.ExchangeAttributes.COUNTRY);        
+                IdentityConstants.OpenId.ExchangeAttributes.COUNTRY);
         attributes.put(IdentityConstants.OpenId.ExchangeAttributes.STATE_NS,
                 IdentityConstants.OpenId.ExchangeAttributes.STATE);
     }
@@ -127,23 +132,31 @@
             SRegRequest sregReq = SRegRequest.createFetchRequest();
 
             // TODO: User should be able to decide what attributes he requires.
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.NICK_NAME,
-                    true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.FULL_NAME,
-                    true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.EMAIL,
-                    true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.DOB, true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.GENDER,
-                    true);
             sregReq.addAttribute(
-                    IdentityConstants.OpenId.SimpleRegAttributes.POSTAL_CODE, 
true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.COUNTRY,
+                    IdentityConstants.OpenId.SimpleRegAttributes.NICK_NAME,
                     true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.LANGUAGE,
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.FULL_NAME,
                     true);
-            
sregReq.addAttribute(IdentityConstants.OpenId.SimpleRegAttributes.TIMEZONE,
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.EMAIL, true);
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.DOB, true);
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.GENDER, true);
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.POSTAL_CODE,
                     true);
+            sregReq.addAttribute(
+                    IdentityConstants.OpenId.SimpleRegAttributes.COUNTRY, 
true);
+            sregReq
+                    .addAttribute(
+                            
IdentityConstants.OpenId.SimpleRegAttributes.LANGUAGE,
+                            true);
+            sregReq
+                    .addAttribute(
+                            
IdentityConstants.OpenId.SimpleRegAttributes.TIMEZONE,
+                            true);
             authReq.addExtension(sregReq);
 
             // Redirect to the OpenID provider server for authentication.
@@ -199,13 +212,15 @@
                     authSuccess.getIdentity());
 
             // OpenID Attribute Exchange 1.0 - Draft 07.
-            if 
(authSuccess.hasExtension(IdentityConstants.OpenId.ExchangeAttributes.NS_AX)) {
+            if (authSuccess
+                    
.hasExtension(IdentityConstants.OpenId.ExchangeAttributes.NS_AX)) {
                 FetchResponse fetchResp = null;
                 fetchResp = (FetchResponse) authSuccess
                         
.getExtension(IdentityConstants.OpenId.ExchangeAttributes.NS_AX);
                 session.setAttribute("emailFromFetch", fetchResp
                         .getAttributeValues("email").get(0));
-            } else if 
(authSuccess.hasExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG)){
+            } else if (authSuccess
+                    
.hasExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG)) {
                 // OpenID Simple Registration Extension 1.1 - Draft 1.
                 SRegResponse sregResp = (SRegResponse) authSuccess
                         
.getExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG);
@@ -309,6 +324,24 @@
 
     /**
      * 
+     * @param xmlToken
+     * @return
+     */
+    public static boolean isOpenIDInfoCardToken(String xmlToken) {
+        try {
+            if (xmlToken != null && xmlToken.trim().length() > 0)
+                OpenIDToken.createFromXmlToken(xmlToken);
+            else
+                return false;
+        } catch (InfocardException e) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * 
      * @param request
      * @param session
      * @param openidResp
@@ -343,9 +376,9 @@
             FetchResponse fetchResp = null;
             AuthSuccess authSuccess = null;
             MessageExtension extension = null;
-          
+
             authSuccess = (AuthSuccess) authResponse;
-                    
+
             extension = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
 
             if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)

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

Reply via email to