portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r819960 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/sso/ main/webapp/WEB-INF/ main/webapp/WEB-INF/view/ main/webapp/examples/ test/ test/java/ test/java/org/ test/java/org/apache/ test/ja...
Date Tue, 29 Sep 2009 14:16:06 GMT
Author: woonsan
Date: Tue Sep 29 14:16:05 2009
New Revision: 819960

URL: http://svn.apache.org/viewvc?rev=819960&view=rev
Log:
JS2-1071: Adds best site url matching. Also adds basic/form-based authentication JSP examples
inside j2-admin to be used in the example SSO Reverse Proxy IFrame portlets.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp 
 (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/
    portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties   (with
props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/sso/DefaultSSOSiteCredentialsProviderImpl.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/sso/DefaultSSOSiteCredentialsProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/sso/DefaultSSOSiteCredentialsProviderImpl.java?rev=819960&r1=819959&r2=819960&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/sso/DefaultSSOSiteCredentialsProviderImpl.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/sso/DefaultSSOSiteCredentialsProviderImpl.java
Tue Sep 29 14:16:05 2009
@@ -19,11 +19,14 @@
 import java.io.Serializable;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.portals.applications.webcontent.proxy.SSOSiteCredentials;
 import org.apache.portals.applications.webcontent.proxy.SSOSiteCredentialsProvider;
 import org.slf4j.Logger;
@@ -35,7 +38,7 @@
     
     private static Logger log = LoggerFactory.getLogger(DefaultSSOSiteCredentialsProviderImpl.class);
 
-    public List<SSOSiteCredentials> getSSOCredentials(HttpServletRequest request, URI
siteURI)
+    public List<SSOSiteCredentials> getSSOCredentials(HttpServletRequest request, String
siteURL)
     {
         List<SSOSiteCredentials> ssoSiteCreds = new ArrayList<SSOSiteCredentials>();
         HttpSession session = request.getSession(false);
@@ -49,11 +52,15 @@
         
         if (ssoSiteCredsOfSubject != null)
         {
+            URI siteURI = URI.create(siteURL);
+            
             for (SSOSiteCredentials ssoCreds : ssoSiteCredsOfSubject)
             {
                 try
                 {
-                    if (ssoCreds.getHost().equals(siteURI.getHost()) && ssoCreds.getPort()
== siteURI.getPort())
+                    String siteBaseURL = ssoCreds.getBaseURL();
+                    
+                    if (StringUtils.startsWith(siteURL, siteBaseURL) && ssoCreds.getHost().equals(siteURI.getHost())
&& ssoCreds.getPort() == siteURI.getPort())
                     {
                         ssoSiteCreds.add(ssoCreds);
                     }
@@ -68,7 +75,46 @@
             }
         }
         
+        if (!ssoSiteCreds.isEmpty())
+        {
+            Collections.sort(ssoSiteCreds, new URLMatchDifferenceBasedComparator<SSOSiteCredentials>(siteURL));
+        }
+        
         return ssoSiteCreds;
     }
-
+    
+    private class URLMatchDifferenceBasedComparator<SSOCredentials> implements Comparator<SSOSiteCredentials>
+    {
+        private String siteURL;
+        
+        private URLMatchDifferenceBasedComparator(String siteURL)
+        {
+            this.siteURL = siteURL;
+        }
+        
+        public int compare(SSOSiteCredentials creds1, SSOSiteCredentials creds2)
+        {
+            int diff1 = StringUtils.indexOfDifference(siteURL, creds1.getBaseURL());
+            int diff2 = StringUtils.indexOfDifference(siteURL, creds2.getBaseURL());
+            
+            if (diff1 == -1)
+            {
+                return -1;
+            }
+            else if (diff2 == -1)
+            {
+                return 1;
+            }
+            else if (diff1 > diff2)
+            {
+                return -1;
+            }
+            else if (diff1 < diff2)
+            {
+                return 1;
+            }
+            
+            return 0;
+        }
+    }
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=819960&r1=819959&r2=819960&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Tue
Sep 29 14:16:05 2009
@@ -1340,15 +1340,103 @@
     <portlet-preferences>
       <preference>
         <name>SRC</name>
-        <value>http://localhost:8080/manager/list</value>
+        <value>http://localhost:${serverPort}${contextPath}/examples/basicauth.jsp</value>
       </preference>
       <preference>
         <name>PROXYREMOTEURL</name>
-        <value>http://localhost:8080/</value>
+        <value>http://localhost:${serverPort}/</value>
       </preference>
       <preference>
         <name>PROXYLOCALPATH</name>
-        <value>rproxy/localhost/</value>
+        <value>${contextPath}/rproxy/localhost/</value>
+      </preference>
+      <preference>
+        <name>AUTORESIZE</name>
+        <value>true</value>
+      </preference>
+      <preference>
+        <name>VISITLASTPAGE</name>
+        <value>true</value>
+      </preference>
+      <!--
+        Don't specify a HEIGHT if you want a normal filled out layout
+        because percentage values result in the content not to be
+        displayed on IE6. Specific values are ok though.
+      -->
+      <preference>
+        <name>HEIGHT</name>
+        <value>300</value>
+      </preference>
+      <preference>
+        <name>WIDTH</name>
+        <value>100%</value>
+      </preference>
+      <preference>
+        <name>MAX-HEIGHT</name>
+        <value>800</value>
+      </preference>
+      <preference>
+        <name>MAX-WIDTH</name>
+        <value>100%</value>
+      </preference>
+      <preference>
+        <name>SCROLLING</name>
+        <value>AUTO</value>
+      </preference>
+    </portlet-preferences>
+  </portlet>
+  
+  <portlet id="SSOFormBasedAuthReverseProxyIFramePortlet">
+    <description>Places an HTML IFrame with reverse proxied url
+      , with Jetspeed SSO enabled,
+      inside a portlet for easily
+      hosting other
+      web application within a
+      portlet. Sizes of both
+      normal and maximized
+      modes are configurable
+      in edit mode.</description>
+    <portlet-name>SSOFormBasedAuthReverseProxyIFramePortlet</portlet-name>
+    <display-name>SSO Form Based Authentication Reverse Proxy IFrame Portlet</display-name>
+    <portlet-class>
+      org.apache.jetspeed.portlets.sso.SSOReverseProxyIFramePortlet</portlet-class>
+    <init-param>
+      <name>EditPage</name>
+      <value>/WEB-INF/view/edit-prefs.vm</value>
+    </init-param>
+    <init-param>
+      <name>HelpPage</name>
+      <value>/WEB-INF/view/iframe-help.html</value>
+    </init-param>
+    <init-param>
+      <name>portlet-icon</name>
+      <value>applications-internet.png</value>
+    </init-param>
+    <expiration-cache>300</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>EDIT</portlet-mode>
+      <portlet-mode>VIEW</portlet-mode>
+      <portlet-mode>HELP</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>SSOFormBasedAuthReverseProxyIFrame</title>
+      <short-title>SSOFormBasedAuthReverseProxyIFrame</short-title>
+      <keywords>tool,sso,form,auth,reverse,proxy,iframe,web,frame,content,host</keywords>
+    </portlet-info>
+    <portlet-preferences>
+      <preference>
+        <name>SRC</name>
+        <value>http://localhost:${serverPort}${contextPath}/examples/formauth.jsp</value>
+      </preference>
+      <preference>
+        <name>PROXYREMOTEURL</name>
+        <value>http://localhost:${serverPort}/</value>
+      </preference>
+      <preference>
+        <name>PROXYLOCALPATH</name>
+        <value>${contextPath}/rproxy/localhost/</value>
       </preference>
       <preference>
         <name>AUTORESIZE</name>

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
Tue Sep 29 14:16:05 2009
@@ -0,0 +1,48 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<h1>SSO IFrame Help</h1>
+<p>
+The following preferences can be used with the SSO IFrame Portlet in addition to the standard
IFrame preferences 
+</p>
+<p>
+<table border="1" cellspacing="1" cellpadding="3">
+<tr>
+<th class="portlet-section-body">Preference</th>    
+<th class="portlet-section-body">Usage</th>
+</tr>
+<tr>
+<td class='portlet-section-body'>sso.type</td>  
+<td class='portlet-section-body'>The type of Single signon authentication. Valid values:
form | basic | basic.preemptive | url | url.base64</td>
+</tr>
+<tr>
+<td class='portlet-section-body'>sso.url.Credential</td>    
+<td class='portlet-section-body'>The name of the credential input field or parameter</td>
+</tr>
+<tr>
+<td class='portlet-section-body'>sso.url.Principal</td> 
+<td class='portlet-section-body'>The name of the user name input field or parameter</td>
+</tr>
+<tr>
+<td class='portlet-section-body'>SSO Principal</td> 
+<td class='portlet-section-body'>The actual user name</td>
+</tr>
+<tr>
+<td class='portlet-section-body'>SSO Credential</td>    
+<td class='portlet-section-body'>The actual crendential value</td>
+</tr>
+</table>    
+</p>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/iframe-help.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
Tue Sep 29 14:16:05 2009
@@ -0,0 +1,83 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+--%>
+
+<%--
+WARNING:
+
+  This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.
+  This is not for production use!
+  You should consult with other examples if you want to implement an authentication.
+
+--%>
+
+<%@ page language="java"%>
+<%@ page import="java.util.Map" %>
+<%@ page import="java.util.HashMap" %>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="javax.servlet.http.HttpServletResponse" %>
+<%@ page import="org.apache.commons.codec.binary.Base64" %>
+<%@ page import="org.apache.commons.lang.StringUtils" %>
+
+<%!
+private static final String REALM = "ExampleBasicAuthJSP";
+
+private Map userInfoMap = new HashMap();
+
+public void jspInit()
+{
+    userInfoMap.put("manager", "manager");
+    userInfoMap.put("admin", "admin");
+}
+
+private boolean authenticate(HttpServletRequest req)
+{
+    try
+    {
+		String authorization = req.getHeader("Authorization");
+		
+		if (authorization != null)
+		{
+		    Base64 base64 = new Base64();
+			String userInfo = new String(base64.decode(authorization.substring(6).getBytes()));
+			String [] userInfoArray = StringUtils.split(userInfo, ":");
+			String username = userInfoArray[0];
+			String password = userInfoArray[1];
+			
+			if (password.equals(userInfoMap.get(username)))
+			{
+			    req.getSession().setAttribute("examples.basicauth.username", username);
+			    return true;
+			}
+		}
+    }
+    catch (Exception e)
+    {
+        e.printStackTrace();
+    }
+	
+	return false;
+}
+%>
+<%
+if (authenticate(request))
+{
+	response.sendRedirect("basicauth_success.jsp");
+}
+else
+{
+	response.setHeader("WWW-Authenticate", "Basic realm=\"" + REALM + "\"");
+	response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication Failed! You can
access by manager/manager or admin/admin.");
+}
+%>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
Tue Sep 29 14:16:05 2009
@@ -0,0 +1,67 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+--%>
+
+<%--
+WARNING:
+
+  This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.
+  This is not for production use!
+  You should consult with other examples if you want to implement an authentication.
+
+--%>
+
+<%@ page language="java"%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="org.apache.commons.codec.binary.Base64" %>
+<%@ page import="org.apache.commons.lang.StringUtils" %>
+
+<%!
+private String getUsername(HttpServletRequest req)
+{
+    try
+    {
+        String authorization = req.getHeader("Authorization");
+        
+        if (authorization != null)
+        {
+            Base64 base64 = new Base64();
+            String userInfo = new String(base64.decode(authorization.substring(6).getBytes()));
+            String [] userInfoArray = StringUtils.split(userInfo, ":");
+            return userInfoArray[0];
+        }
+    }
+    catch (Exception e)
+    {
+        e.printStackTrace();
+    }
+    
+    return null;
+}
+%>
+<html>
+<head>
+<title>Authorized by Basic authentication!</title>
+</head>
+<body>
+<p>Hello, <%=session.getAttribute("examples.basicauth.username")%>. You have
been authorized by Basic authentication !!!</p>
+
+<hr/>
+<p>
+This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.<br/>
+<strong>This is not for production use! You should consult with other examples <br/>if
you want to implement an authentication.</strong> 
+</p>
+
+</body>
+</html>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/basicauth_success.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp Tue
Sep 29 14:16:05 2009
@@ -0,0 +1,99 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+--%>
+
+<%--
+WARNING:
+
+  This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.
+  This is not for production use!
+  You should consult with other examples if you want to implement an authentication.
+
+--%>
+
+<%@ page language="java"%>
+<%@ page import="java.util.Map" %>
+<%@ page import="java.util.HashMap" %>
+<%@ page import="javax.servlet.http.HttpServletResponse" %>
+<%@ page import="org.apache.commons.codec.binary.Base64" %>
+<%@ page import="org.apache.commons.lang.StringUtils" %>
+
+<%!
+private Map userInfoMap = new HashMap();
+
+public void jspInit()
+{
+    userInfoMap.put("manager", "manager");
+    userInfoMap.put("admin", "admin");
+}
+
+private boolean authenticate(HttpServletRequest req)
+{
+    try
+    {
+		String username = req.getParameter("user");
+		String password = req.getParameter("pass");
+		
+		if (username != null && password != null)
+		{
+			if (password.equals(userInfoMap.get(username)))
+			{
+			    req.getSession().setAttribute("examples.formauth.username", username);
+			    return true;
+			}
+		}
+    }
+    catch (Exception e)
+    {
+        e.printStackTrace();
+    }
+	
+	return false;
+}
+%>
+<%
+if (authenticate(request))
+{
+	response.sendRedirect("formauth_success.jsp");
+}
+else
+{
+%>
+<html>
+<head>
+<title>Form Authentication Example</title>
+</head>
+<body>
+
+<p>
+This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.<br/>
+<strong>This is not for production use! You should consult with other examples <br/>if
you want to implement an authentication.</strong> 
+</p>
+<hr/>
+
+<p>Please login.</p>
+<form method="POST">
+    Name: <input type="text" name="user" size="10"/><br/>
+    Password: <input type="password" name="pass" size="10"/><br/>
+    <input type="submit"/>
+</form>
+<hr/>
+<p>
+    <em>Note: you can log in by manager/manager or admin/admin.</em>
+</p>
+</body>
+</html>
+<%
+}
+%>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
Tue Sep 29 14:16:05 2009
@@ -0,0 +1,40 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+--%>
+
+<%--
+WARNING:
+
+  This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.
+  This is not for production use!
+  You should consult with other examples if you want to implement an authentication.
+
+--%>
+
+<%@ page language="java"%>
+<html>
+<head>
+<title>Authorized by form-based authentication!</title>
+</head>
+<body>
+<p>Hello, <%=session.getAttribute("examples.formauth.username")%>. You have been
authorized by form-based authentication !!!</p>
+
+<hr/>
+<p>
+This example is provided to demonstrate the SSO feature of SSOReverseProxyIFrame portlet.<br/>
+<strong>This is not for production use! You should consult with other examples <br/>if
you want to implement an authentication.</strong> 
+</p>
+
+</body>
+</html>

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/examples/formauth_success.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
Tue Sep 29 14:16:05 2009
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.portlets.sso;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.portals.applications.webcontent.proxy.SSOSiteCredentials;
+import org.apache.portals.applications.webcontent.proxy.impl.DefaultSSOSiteCredentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpSession;
+
+public class TestSSOSiteCredentialsProvider extends TestCase
+{
+    
+    private static Logger log = LoggerFactory.getLogger(TestSSOSiteCredentialsProvider.class);
+    
+    private MockHttpSession session;
+    private List<SSOSiteCredentials> ssoSiteCredsOfSubject;
+    
+    @Override
+    public void setUp()
+    {
+        session = new MockHttpSession();
+        
+        ssoSiteCredsOfSubject = new ArrayList<SSOSiteCredentials>();
+        
+        DefaultSSOSiteCredentials siteCreds = new DefaultSSOSiteCredentials("http://www.localhost.com",
"www.localhost.com");
+        siteCreds.setUsername("admin");
+        siteCreds.setPassword("admin");
+        ssoSiteCredsOfSubject.add(siteCreds);
+        
+        siteCreds = new DefaultSSOSiteCredentials("http://www.localhost.com/basicauth", "www.localhost.com");
+        siteCreds.setUsername("basic");
+        siteCreds.setPassword("basic");
+        ssoSiteCredsOfSubject.add(siteCreds);
+
+        siteCreds = new DefaultSSOSiteCredentials("http://www.localhost.com/formauth", "www.localhost.com");
+        siteCreds.setFormAuthentication(true);
+        siteCreds.setFormUserField("user");
+        siteCreds.setFormPwdField("pass");
+        siteCreds.setUsername("form");
+        siteCreds.setPassword("form");
+        ssoSiteCredsOfSubject.add(siteCreds);
+        
+        session.setAttribute(SSOReverseProxyIFramePortlet.SUBJECT_SSO_SITE_CREDS, ssoSiteCredsOfSubject);
+    }
+    
+    public void testBestURLMatches() throws Exception
+    {
+        DefaultSSOSiteCredentialsProviderImpl provider = new DefaultSSOSiteCredentialsProviderImpl();
+        MockHttpServletRequest request = new MockHttpServletRequest();
+        request.setSession(session);
+        
+        List<SSOSiteCredentials> siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 1);
+        assertEquals("admin", siteCreds.get(0).getUsername());
+        
+        siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com/index.html");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 1);
+        assertEquals("admin", siteCreds.get(0).getUsername());
+        
+        siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com/basicauth");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 2);
+        assertEquals("basic", siteCreds.get(0).getUsername());
+        assertEquals("admin", siteCreds.get(1).getUsername());
+        
+        siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com/basicauth/index.html");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 2);
+        assertEquals("basic", siteCreds.get(0).getUsername());
+        assertEquals("admin", siteCreds.get(1).getUsername());
+        
+        siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com/formauth");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 2);
+        assertEquals("form", siteCreds.get(0).getUsername());
+        assertEquals("admin", siteCreds.get(1).getUsername());
+        
+        siteCreds = provider.getSSOCredentials(request, "http://www.localhost.com/formauth/index.html");
+        log.info("siteCreds: " + siteCreds);
+        assertNotNull(siteCreds);
+        assertTrue(siteCreds.size() == 2);
+        assertEquals("form", siteCreds.get(0).getUsername());
+        assertEquals("admin", siteCreds.get(1).getUsername());
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/java/org/apache/jetspeed/portlets/sso/TestSSOSiteCredentialsProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties?rev=819960&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties Tue
Sep 29 14:16:05 2009
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# ------------------------------------------------------------------------
+#
+# Logging Configuration
+#
+# $Id:$
+#
+# ------------------------------------------------------------------------
+
+log4j.rootLogger = INFO, console
+
+log4j.category.org.apache.jetspeed = INFO, console
+log4j.additivity.org.apache.jetspeed = false
+
+#
+# Console
+#
+log4j.appender.console = org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout = org.apache.log4j.PatternLayout
+# Pattern to output the caller's file name and line number.
+log4j.appender.console.layout.ConversionPattern = %d [%t] %-5p %c{1}:%L - %m%n

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message