Author: channa
Date: Thu May  1 22:52:13 2008
New Revision: 16455

Log:

Adding OpenID support. Validations and testing TBD.


Modified:
   trunk/mashup/java/modules/core/conf/web_root.xml
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
   trunk/mashup/java/modules/distribution/src/assemble/bin-release-assembly.xml
   trunk/mashup/java/modules/www/openidsubmit.jsp

Modified: trunk/mashup/java/modules/core/conf/web_root.xml
==============================================================================
--- trunk/mashup/java/modules/core/conf/web_root.xml    (original)
+++ trunk/mashup/java/modules/core/conf/web_root.xml    Thu May  1 22:52:13 2008
@@ -107,7 +107,7 @@
         <!-- Upadate with full URL to validate.jsp page -->
         <init-param>
             <param-name>webapp_url</param-name>
-            <param-value>http://localhost:7443/</param-value>
+            <param-value>https://localhost:7443/</param-value>
         </init-param>
         <init-param>
             <param-name>email_from_address</param-name>

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Thu May  1 22:52:13 2008
@@ -69,6 +69,8 @@
     public static final String EMAIL_BODY = "email_body";
     public static final String EMAIL_FOOTER = "email_footer";
     public static final String EMAIL_GREETING = "email_greeting";
+
+    // Page in web application sent as link in e-mail for verifying 
self-registrations. 
     public static final String EMAIL_VALIDATION_PAGE = "validate.jsp";
 
     public static final String USER_REGISTRY = "user_registry";

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
     (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/InfoCardHandler.java
     Thu May  1 22:52:13 2008
@@ -31,11 +31,16 @@
 import org.wso2.registry.users.UserStoreException;
 import org.wso2.registry.users.UserStoreReader;
 import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.relyingparty.RelyingPartyException;
 import org.wso2.solutions.identity.relyingparty.TokenVerifierConstants;
+import 
org.wso2.solutions.identity.relyingparty.openid.OpenIDAuthenticationRequest;
+import org.wso2.solutions.identity.relyingparty.openid.OpenIDConsumer;
+import org.wso2.solutions.identity.relyingparty.openid.OpenIDRequestType;
 import org.wso2.solutions.identity.util.IdentityUtil;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.util.Map;
 
@@ -113,7 +118,7 @@
                 } else {
                     identifier = (String) 
request.getAttribute(IdentityConstants.OpenId.OPENID_IDENTIFIER);
                 }
-                
+
                 // Add only if this identifier has not been associated with a 
user.
                 if (!InfoCardHandler.isIdentifierRegistered(request, 
identifier)) {
                     int regCardCount = 0;
@@ -225,4 +230,53 @@
         }
         return isRegistered;
     }
+
+    /**
+     *  
+     * @param request
+     * @param response
+     */
+    public static void openIDSubmit(HttpServletRequest request, 
HttpServletResponse response) {
+        String calledFrom = request.getParameter("calledfrom");
+        try {
+            OpenIDAuthenticationRequest openIDAuthRequest = null;
+
+            openIDAuthRequest = new OpenIDAuthenticationRequest(request, 
response);
+
+            openIDAuthRequest.setOpenIDUrl((String) 
request.getParameter("openIdUrl"));
+
+            // you need to set an absolute url as the return url.
+            // once the user authenticated successfully or failed at the OpenID
+            // Provider, the browser will be redirected to this url
+            StringBuffer returnUrl = new StringBuffer();
+            
returnUrl.append(request.getSession().getServletContext().getAttribute(
+                    MashupConstants.WEBAPP_URL));
+            returnUrl.append("registration".equals(calledFrom) ? 
"register_self_infocard.jsp" : "infocardaccept.jsp");
+            returnUrl.append("?calledfrom=" + calledFrom + "&" + 
MashupConstants.AUTHENTICATION_METHOD +
+                    "=openid&FromIdentityProvider=true");
+            openIDAuthRequest.setReturnUrl(returnUrl.toString());
+
+            // Use Simple Attribute Registration 1.1
+            
openIDAuthRequest.addRequestType(OpenIDRequestType.SIMPLE_REGISTRATION);
+
+            // Set the required claims - I need these claims from the OpenID
+            // Provider.
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.NICK_NAME);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.FULL_NAME);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.EMAIL);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.DOB);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.GENDER);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.POSTAL_CODE);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.COUNTRY);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.LANGUAGE);
+            
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.TIMEZONE);
+
+            // Performs authentication : this will redirect you to OpenID 
Provider for authentication
+            
OpenIDConsumer.getInstance().doOpenIDAuthentication(openIDAuthRequest);
+        }
+        catch (RelyingPartyException e) {
+            // handle exceptions
+            log.error("Error getting open ID information", e);
+        }
+    }
 }

Modified: 
trunk/mashup/java/modules/distribution/src/assemble/bin-release-assembly.xml
==============================================================================
--- 
trunk/mashup/java/modules/distribution/src/assemble/bin-release-assembly.xml    
    (original)
+++ 
trunk/mashup/java/modules/distribution/src/assemble/bin-release-assembly.xml    
    Thu May  1 22:52:13 2008
@@ -70,6 +70,12 @@
                 <include>commons-dbcp:commons-dbcp:jar</include>
                 <include>commons-pool:commons-pool:jar</include>
                 <include>org.wso2.commons:authenticator:jar</include>
+                <include>org.openid4java:openid4java-nodeps:jar</include>
+                <include>com.ibm.icu:icu4j:jar</include>
+                <include>org.openxri:openxri-syntax:jar</include>
+                <include>org.openxri:openxri-client:jar</include>
+                <include>org.htmlparser:htmlparser:jar</include>
+                <include>opensaml:openws:jar</include>
            </includes>
         </dependencySet>
     </dependencySets>

Modified: trunk/mashup/java/modules/www/openidsubmit.jsp
==============================================================================
--- trunk/mashup/java/modules/www/openidsubmit.jsp      (original)
+++ trunk/mashup/java/modules/www/openidsubmit.jsp      Thu May  1 22:52:13 2008
@@ -13,57 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 --%>
-<[EMAIL PROTECTED] import="org.wso2.mashup.MashupConstants"%>
-<%@ page import="org.wso2.solutions.identity.IdentityConstants" %>
-<%@ page 
import="org.wso2.solutions.identity.relyingparty.RelyingPartyException" %>
-<%@ page 
import="org.wso2.solutions.identity.relyingparty.openid.OpenIDAuthenticationRequest"
 %>
-<%@ page 
import="org.wso2.solutions.identity.relyingparty.openid.OpenIDConsumer" %>
-<%@ page 
import="org.wso2.solutions.identity.relyingparty.openid.OpenIDRequestType" %>
-
+<%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler" %>
 <%
-    String calledFrom = request.getParameter("calledfrom");
-try
-{
-   OpenIDAuthenticationRequest openIDAuthRequest = null;
-
-   openIDAuthRequest = new OpenIDAuthenticationRequest(request,response);
-
-   openIDAuthRequest.setOpenIDUrl((String)request.getParameter("openIdUrl"));
-
-   // you need to set an absolute url as the return url.
-   // once the user authenticated successfully or failed at the OpenID
-   // Provider, the browser will be redirected to this url
-    StringBuffer returnUrl = new StringBuffer();
-    returnUrl.append(request.getSession().getServletContext().getAttribute(
-            MashupConstants.WEBAPP_URL));
-    returnUrl.append("registration".equals(calledFrom) ? 
"register_self_infocard.jsp" : "infocardaccept.jsp");
-    returnUrl.append("?calledfrom=" + calledFrom + "&" + 
MashupConstants.AUTHENTICATION_METHOD +
-            "=openid&FromIdentityProvider=true");
-    openIDAuthRequest.setReturnUrl(returnUrl.toString());
-
-   // Use Simple Attribute Registration 1.1
-   openIDAuthRequest.addRequestType(OpenIDRequestType.SIMPLE_REGISTRATION);
-
-   // Set the required claims - I need these claims from the OpenID
-   // Provider.
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.NICK_NAME);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.FULL_NAME);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.EMAIL);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.DOB);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.GENDER);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.POSTAL_CODE);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.COUNTRY);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.LANGUAGE);
-   
openIDAuthRequest.addRequiredClaims(IdentityConstants.OpenId.SimpleRegAttributes.TIMEZONE);
-
-   // Performs authentication : this will redirect you to OpenID Provider for 
authentication
-   OpenIDConsumer.getInstance().doOpenIDAuthentication(openIDAuthRequest);
-
-}
-catch(RelyingPartyException e)
-{
-   // handle exceptions
-   out.println(e.getMessage());
-}
-
+    InfoCardHandler.openIDSubmit(request, response);
 %>
\ No newline at end of file

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to