Author: channa
Date: Sat Jun 21 07:43:13 2008
New Revision: 18534
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18534

Log:
Changed identity based login error handling, to accomodate prompt for self 
registration as required by MASHUP-853. Also improved error handling as per 
MASHUP-804. Also included http:// prefix for openid field by default.


Added:
   trunk/mashup/java/modules/www/openid_field.jsp
Modified:
   
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceIC.java
   trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/IdentityHandler.java
   trunk/mashup/java/modules/www/identityaccept.jsp
   trunk/mashup/java/modules/www/openidsubmit.jsp
   trunk/mashup/java/modules/www/register_self.jsp
   trunk/mashup/java/modules/www/signin.jsp
   trunk/mashup/java/modules/www/taskbar.jsp

Modified: 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceIC.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceIC.java?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceIC.java
 (original)
+++ 
trunk/mashup/java/modules/admin/service/src/org/wso2/mashup/admin/service/MashupLoginServiceIC.java
 Sat Jun 21 07:43:13 2008
@@ -48,7 +48,7 @@
         UserRealm realm = (UserRealm) 
configuration.getParameterValue(RegistryConstants.REGISTRY_REALM);
         try {
             UserStoreReader storeReader = realm.getUserStoreReader();
-            // Null for key gets all users with the PPID - there can be only 
one.
+            // Null for key gets all users with the identifier - there can be 
only one.
             String[] userNames = 
storeReader.getUserNamesWithPropertyValue(null, identifier);
 
             // If a name is returned, instantiate a secure registry for user.
@@ -59,13 +59,12 @@
             throw new MashupFault("Exception while processing identifier : " + 
identifier, e);
         }
 
-        if (username == null) {
-            throw new MashupFault("User cannot be found for the identifier : " 
+ identifier);
+        if (username != null) {
+            LoginUtil.updateDB(msgCtx, username);
+            sgCtx.setProperty(MashupConstants.USER_LOGGED_IN, "true");
+            sgCtx.setProperty(MashupConstants.LOGGED_IN_USER_NAME, username);
         }
 
-        LoginUtil.updateDB(msgCtx, username);
-        sgCtx.setProperty(MashupConstants.USER_LOGGED_IN, "true");
-        sgCtx.setProperty(MashupConstants.LOGGED_IN_USER_NAME, username);
         return username;
     }
 }

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java     
Sat Jun 21 07:43:13 2008
@@ -279,4 +279,6 @@
     public static final String MASHUP_AUTHOR_NAME = "mashupAuthorName";
 
     public static final int BUFFER_SIZE = 40960;
+
+    public static final String OPENID_URL_PREFIX = "http://";;
 }

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/IdentityHandler.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/IdentityHandler.java?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/IdentityHandler.java
     (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/IdentityHandler.java
     Sat Jun 21 07:43:13 2008
@@ -75,12 +75,18 @@
                 String identifier = (String) 
(MashupConstants.INFOCARD.equals(authMethod) ?
                         request.getAttribute(IdentityConstants.CLAIM_PPID) :
                         
request.getAttribute(IdentityConstants.OpenId.OPENID_IDENTIFIER));
-                String userName = MashupUtils.login(identifier, 
session.getId(), 
+                String userName = MashupUtils.login(identifier, 
session.getId(),
                                                     request.getContextPath());
-                UserRegistry userRegistry = 
RegistryUtils.createUserRegistry(userName,
-                        embeddedRegistry);
-                
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
-                success = true;
+
+                // if the username is empty, the identifier has not been 
registered.
+                if (!"".equals(userName)) {
+                    UserRegistry userRegistry = 
RegistryUtils.createUserRegistry(userName,
+                                                                               
  embeddedRegistry);
+                    
request.getSession().setAttribute(MashupConstants.USER_REGISTRY, userRegistry);
+                    success = true;
+                } else {
+                    log.info("Identity not registered.");
+                }
             } catch (MashupFault e) {
                 log.error("Identity login failed.", e);
             }

Modified: trunk/mashup/java/modules/www/identityaccept.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/identityaccept.jsp?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/identityaccept.jsp    (original)
+++ trunk/mashup/java/modules/www/identityaccept.jsp    Sat Jun 21 07:43:13 2008
@@ -19,6 +19,9 @@
 <%@ page import="org.wso2.registry.session.UserRegistry" %>
 <%@ page import="java.net.URLDecoder" %>
 <%@ page import="java.util.ResourceBundle" %>
+<%@ page import="org.wso2.mashup.webapp.identity.RegistrationBean" %>
+<%@ page import="org.wso2.solutions.identity.IdentityConstants" %>
+<%@ page import="org.wso2.mashup.MashupConstants" %>
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
 
 <!--Required to keep a user logged in if 'Remember Me' option is selected-->
@@ -52,7 +55,7 @@
     // Check if user is logged in already; if so, this is to associate the 
user with the identity.
     if (isLoggedIn) {
         title = "Associate Identifier with user profile";
-       if 
(org.wso2.mashup.webapp.identity.IdentityHandler.associateIdentifierWithUser(request))
 {
+       if (IdentityHandler.associateIdentifierWithUser(request)) {
            // Send the user back to the caling page on success - it'll show 
the added identifier.
             response.sendRedirect(bounceback);
        } else {
@@ -61,17 +64,17 @@
     } else {
         // Unauthenticated users are trying to sign in.
          title = "Sign-in to " + bundle.getString("main.title");
-        if (org.wso2.mashup.webapp.identity.IdentityHandler.signIn(request)) {
+        if (IdentityHandler.signIn(request)) {
                response.sendRedirect(bounceback);
             return;
         } else {
             message = "Identifier based login failed." +
                     "<br/><strong>Please make sure you have registered your 
Identifier</strong>.";
+            System.out.println("Login failed, so displaying page.");
         }
     }
 %>
 <div id="page">
-    <%@ include file="header.jsp" %>
 <div id="search"></div>
     <div id="simple-content">
        <div class="page_title"><%= title %></div>
@@ -79,9 +82,26 @@
 
             <tr>
                 <td align="center">
-                    <div class="login-error"><img src="images/error.gif" 
align="absmiddle">&nbsp; <%= message %></div>
-                                       <br/><br/><br/>
-                    Return to <a href="<%= bounceback %>">calling page</a> to 
try again. 
+                    <div class="login-error"><img src="images/error.gif"
+                                                  align="absmiddle">&nbsp; <%= 
message %>
+                    </div>
+                    <br/><br/><br/>
+                    You can return to the <a href="<%= bounceback %>">page you 
were on</a> and try to sign in again.
+                    <br/><br/>
+                    <% if (RegistrationBean.isSelfRegistrationEnabled()) {%>
+                    If you have not registered yourself yet,
+                    <% if (MashupConstants.OPENID
+                            .equals(request.getParameter(
+                                    MashupConstants.AUTHENTICATION_METHOD))) { 
%>
+                    you can sign-up with this OpenID.
+                    <jsp:include page="openid_field.jsp">
+                        <jsp:param name="submitted_openid"
+                                   value="<%= 
request.getAttribute(IdentityConstants.OpenId.OPENID_IDENTIFIER) %>"/>
+                    </jsp:include>
+                    <% } else { %>
+                    You can <a href="register_self.jsp?firstcall=true">Sign 
up</a> here.
+                    <% }
+                    }%>
                 </td>
             </tr>
         </table>

Added: trunk/mashup/java/modules/www/openid_field.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/openid_field.jsp?pathrev=18534
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/www/openid_field.jsp      Sat Jun 21 07:43:13 2008
@@ -0,0 +1,28 @@
+<%--
+ * Copyright 2006,2007 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+--%>
+<%@ page import="org.wso2.mashup.MashupConstants" %>
+<%
+    String prePopulate = request.getParameter("submitted_openid");
+    if (prePopulate == null || "".equals(prePopulate)) {
+        prePopulate = MashupConstants.OPENID_URL_PREFIX;
+    }
+%>
+<form name="openidsignin" id="openidsignin" method="post" 
action="openidsubmit.jsp">
+    <img src="images/openid-logo.jpg" border="0"><br/>    
+    <input type="text" name="openid_identifier" value="<%= prePopulate %>"/>
+    <input type="hidden" name="calledfrom" value="registration"/>
+    <input type="submit" name="submit" value="Register"/>
+</form>
\ No newline at end of file

Modified: trunk/mashup/java/modules/www/openidsubmit.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/openidsubmit.jsp?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/openidsubmit.jsp      (original)
+++ trunk/mashup/java/modules/www/openidsubmit.jsp      Sat Jun 21 07:43:13 2008
@@ -15,5 +15,5 @@
 --%>
 <%@ page import="org.wso2.mashup.webapp.identity.IdentityHandler" %>
 <%
-    org.wso2.mashup.webapp.identity.IdentityHandler.openIDSubmit(request, 
response);
+    IdentityHandler.openIDSubmit(request, response);
 %>
\ No newline at end of file

Modified: trunk/mashup/java/modules/www/register_self.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/register_self.jsp?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/register_self.jsp     (original)
+++ trunk/mashup/java/modules/www/register_self.jsp     Sat Jun 21 07:43:13 2008
@@ -216,13 +216,8 @@
         <br/>
     </td>
     <td align="center" valign="top" height="175">
-        <form name="openidsignin" id="openidsignin" method="post" 
action="openidsubmit.jsp">
-            <img src="images/openid-logo.jpg" border="0"><br/>
-            Get details from my OpenID:<br/>
-            <input type="text" name="openid_identifier"/>
-            <input type="hidden" name="calledfrom" value="registration"/>
-            <input type="submit" name="submit" value="Register"/>
-        </form>
+        Get details from my OpenID:<br/>
+        <%@ include file="openid_field.jsp" %>
     </td>
 </tr>
 <tr>

Modified: trunk/mashup/java/modules/www/signin.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/signin.jsp?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/signin.jsp    (original)
+++ trunk/mashup/java/modules/www/signin.jsp    Sat Jun 21 07:43:13 2008
@@ -262,7 +262,7 @@
                     <td height="175" valign="top">
                         <form name="openidsignin" id="openidsignin" 
method="post" action="openidsubmit.jsp">
                             <img src="images/openid-logo.jpg" border="0"><br/>
-                            Enter Your OpenID Url:<input type="text" 
name="openid_identifier"/>
+                            Enter Your OpenID Url:<input type="text" 
name="openid_identifier" value="<%= MashupConstants.OPENID_URL_PREFIX %>"/>
                             <input type="hidden" name="calledfrom" 
value="signin"/>
                             <input type="submit" name="submit" value="Login" />
                         </form>

Modified: trunk/mashup/java/modules/www/taskbar.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/taskbar.jsp?rev=18534&r1=18533&r2=18534&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/taskbar.jsp   (original)
+++ trunk/mashup/java/modules/www/taskbar.jsp   Sat Jun 21 07:43:13 2008
@@ -224,7 +224,7 @@
 </li>
 <div id="openIdPrompt" style="display:none;">
     <form name="openidsignin" id="openidsignin" method="post" 
action="openidsubmit.jsp">
-        Enter Your OpenID Url:<input type="text" name="openid_identifier"/>
+        Enter Your OpenID Url:<input type="text" name="openid_identifier" 
value="<%= MashupConstants.OPENID_URL_PREFIX %>"/>
         <input type="hidden" name="calledfrom" value="signin"/>
         <input type="submit" name="submit" value="Add"/>
     </form>

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

Reply via email to