Author: rogerrut
Date: Thu Dec  8 00:55:51 2005
New Revision: 355043

URL: http://svn.apache.org/viewcvs?rev=355043&view=rev
Log:
Added SSO Proxy Portlet to demo package
Moved SSO ProxyPortlet to web content page

Added:
    
portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/view/edit-sso-proxy.vm
    
portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/
      - copied from r354990, 
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/portlet/sso/
Removed:
    
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/portlet/sso/
Modified:
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
    
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java
    
portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
    
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java

Modified: 
portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml?rev=355043&r1=355042&r2=355043&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml 
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/portlet.xml 
Thu Dec  8 00:55:51 2005
@@ -727,5 +727,36 @@
     </portlet-preferences>                                     
 </portlet> 
 
+<portlet id="SSOProxyPortlet">
+    <portlet-name>SSOProxyPortletPortlet</portlet-name>
+    <display-name>SSOProxyPortlet</display-name>
+    <description>
+            SSO Proxy Portlet
+        </description>
+               <init-param>
+               <name>EditPage</name>
+                 <value>/WEB-INF/view/edit-sso-proxy.vm</value>
+               </init-param>
+    
<portlet-class>org.apache.jetspeed.portlet.sso.SSOProxyPortlet</portlet-class>
+    <expiration-cache>-1</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+      <portlet-mode>EDIT</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>SSOProxyPortlet</title>
+      <short-title>SSOProxyPortlet</short-title>
+      <keywords>SSO,Proxy,Security</keywords>
+    </portlet-info>
+    <portlet-preferences>
+       <preference>
+         <name>ForceSSORefresh</name>
+         <value>false</value>
+        </preference>
+    </portlet-preferences>
+  </portlet>
+
 </portlet-app>
 

Added: 
portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/view/edit-sso-proxy.vm
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/view/edit-sso-proxy.vm?rev=355043&view=auto
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/view/edit-sso-proxy.vm
 (added)
+++ 
portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/view/edit-sso-proxy.vm
 Thu Dec  8 00:55:51 2005
@@ -0,0 +1,16 @@
+
+<h2 class="portlet-section-header">Edit Preferences</h2>
+
+<form action="$renderResponse.createActionURL()" method="post">
+<table>
+#foreach ($pref in $prefs)
+#prefField($pref.Key $pref.Value "40")
+#end
+<hr/>
+#form4ColumnCell("Destination URL" $DestinationURL 30 "DestinationURL")
+#form4ColumnCell("SSO Site (empty for all)" $SSOSite 30 "SSOSite")
+</table>
+<input type="submit" name="Save" value="Save" />
+</form>
+
+

Modified: 
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java?rev=355043&r1=355042&r2=355043&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java
 Thu Dec  8 00:55:51 2005
@@ -118,7 +118,7 @@
      *  (non-Javadoc)
      * @see org.apache.jetspeed.sso.SSOProvider#useSSO(java.lang.String, 
java.lang.String, java.lang.String)
      */
-    public BufferedInputStream useSSO(Subject subject, String url, String 
SSOSite, boolean bRefresh) throws SSOException
+    public String useSSO(Subject subject, String url, String SSOSite, boolean 
bRefresh) throws SSOException
     {
        // Get the principal from the subject
                BasePrincipal principal = 
(BasePrincipal)SecurityHelper.getBestPrincipal(subject, UserPrincipal.class);
@@ -155,7 +155,7 @@
      *  (non-Javadoc)
      * @see org.apache.jetspeed.sso.SSOProvider#useSSO(java.lang.String, 
java.lang.String)
      */
-    public BufferedInputStream useSSO(Subject subject, String url, boolean 
bRefresh) throws SSOException
+    public String useSSO(Subject subject, String url, boolean bRefresh) throws 
SSOException
     {
        String content = null;
                // Get the principal from the subject
@@ -1234,12 +1234,13 @@
         return  (SSOSite) 
getPersistenceBrokerTemplate().getObjectByQuery(query);
     }
     
-    private BufferedInputStream getContentFromURL(String proxyID, String 
destUrl, SSOSite[] sites, boolean bRefresh ) throws SSOException
+    private String getContentFromURL(String proxyID, String destUrl, SSOSite[] 
sites, boolean bRefresh ) throws SSOException
     {
        URL urlObj = null;
        
        // Result Buffer
-       BufferedInputStream bis = null;
+       //BufferedInputStream bis = null;
+       String resultPage;
        
        String strErrorMessage = "SSO Component Error. Failed to get content 
for URL " + destUrl;
        
@@ -1333,22 +1334,24 @@
                                                if (log.isInfoEnabled() )
                                                        log.info("SSO Component 
--SSO Site and destination URL match. Go and get the content." );
                                                
-                                               try
-                                               {
-                                                       bis = new 
BufferedInputStream(get.getResponseBodyAsStream());
-                                               }
-                                               catch(IOException ioe)
-                                               {
-                                                       
log.error(strErrorMessage, ioe);
-                                                       throw new SSOException 
(strErrorMessage, ioe);  
-                                               }
+                                               //try
+                                               //{
+                                                       //bis = new 
BufferedInputStream(get.getResponseBodyAsStream());
+                                                       resultPage = 
get.getResponseBodyAsString();
+                                               //}
+                                               //catch(IOException ioe)
+                                               //{
+                                               //      
log.error(strErrorMessage, ioe);
+                                               //      throw new SSOException 
(strErrorMessage, ioe);  
+                                               //}
 
                                                get.releaseConnection();
                                                
                                                //      Add the client object 
to the cache
                                                this.clientProxy.put(proxyID, 
client);
                                                
-                                               return bis;
+                                               //return bis;
+                                               return resultPage;
                                        }
                                
                                                } catch (Exception e) {
@@ -1384,26 +1387,28 @@
         }
                
                
-               try
-               {
-                       bis = new 
BufferedInputStream(get.getResponseBodyAsStream());
-               }
-               catch(IOException ioe)
-               {
-                       log.error(strErrorMessage, ioe);
-                       throw new SSOException (strErrorMessage, ioe);
-                       
-               }
-               catch (Exception e)
-               {
-                       log.error(strErrorMessage, e);
-                       throw new SSOException (strErrorMessage, e);
-                       
-               }
+               //try
+               //{
+                       //bis = new 
BufferedInputStream(get.getResponseBodyAsStream());
+                       resultPage = get.getResponseBodyAsString();
+               //}
+               //catch(IOException ioe)
+               //{
+               //      log.error(strErrorMessage, ioe);
+               //      throw new SSOException (strErrorMessage, ioe);
+               //      
+               //}
+               //catch (Exception e)
+               //{
+               //      log.error(strErrorMessage, e);
+               //      throw new SSOException (strErrorMessage, e);
+               //      
+               //}
                
                get.releaseConnection();
                
-               return bis;
+               //return bis;
+               return resultPage;
     }
     
     /*

Modified: 
portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java?rev=355043&r1=354990&r2=355043&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/web-content/src/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
 Thu Dec  8 00:55:51 2005
@@ -69,7 +69,6 @@
     
     /** ACTION_PARAMETER_SSOPROXY*/
     static final String ACTION_PARAMETER_SSOPROXY = "SSOProxy";
-
     
     /** Preference values */
     /** DestinationURL */
@@ -83,6 +82,10 @@
     
     /** Encoding*/
     static final String ENCODING = "Encoding";
+    
+    private String destinationURL;
+    private String ssoSite;
+    private String encoding;
 
     public void init(PortletConfig config) throws PortletException
     {
@@ -92,12 +95,27 @@
         if (null == sso)
         {
            throw new PortletException("Failed to find SSO Provider on portlet 
initialization");
-        }        
+        }
+        
     }
     
     public void processAction(ActionRequest request, ActionResponse 
actionResponse)
     throws PortletException, IOException
     {
+               String ssoProxyAction = 
request.getParameter(ACTION_PARAMETER_SSOPROXY); 
+               System.out.println("SSOProxy Action value [" + ssoProxyAction + 
"]");
+               
+       if ( ssoProxyAction != null && ssoProxyAction.length() > 0)
+               this.destinationURL = ssoProxyAction;
+       else
+               this.destinationURL = 
request.getParameter(this.DESTINATION_URL);
+       
+       
+        this.ssoSite = request.getParameter(SSO_SITE);
+        this.encoding = request.getParameter(ENCODING);
+        if (this.encoding == null)
+               this.encoding =  this.defaultEncoding;
+
         // save the prefs
         super.processAction(request, actionResponse);
     }
@@ -105,12 +123,9 @@
     public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        String destinationURL = 
request.getPreferences().getValue(DESTINATION_URL, "");
-        String ssoSite = request.getPreferences().getValue(SSO_SITE, "");
         String forceRefresh = 
request.getPreferences().getValue(FORCE_SSO_REFRESH, "false");
-        String encoding = request.getPreferences().getValue(ENCODING, 
this.defaultEncoding);
 
-        if (destinationURL == null)
+        if (destinationURL == null || destinationURL.length() == 0)
         {
             // No destination configured Switch to configure View
              request.setAttribute(PARAM_VIEW_PAGE, 
this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
@@ -119,6 +134,9 @@
             return;
         }
         
+//      Set the content type
+        response.setContentType("text/html");
+        
         /*
          * Call into the SSO Proxy and process the result page
          */
@@ -130,15 +148,16 @@
        
         try
         {
+               StringBuffer page= new StringBuffer();
             Subject subject = getSubject(); 
             if (ssoSite == null || ssoSite.length() ==0)
-               bis = sso.useSSO(subject, destinationURL,doRefresh);
+               page.append(sso.useSSO(subject, destinationURL,doRefresh));
             else
-               bis = sso.useSSO(subject, destinationURL,ssoSite, doRefresh);
+               page.append(sso.useSSO(subject, destinationURL,ssoSite, 
doRefresh));
             
             // Authentication done at least once
             this.isAuthenticated = true;
-            
+            /*
             bis.mark(BLOCK_SIZE);
             String pageEncoding = getContentCharSet(bis);
             if (pageEncoding == null)
@@ -147,7 +166,7 @@
             }
             
             Reader read = new InputStreamReader(bis, encoding);
-            StringBuffer page= new StringBuffer();
+            
             
                        char[] bytes = new char[BLOCK_SIZE];
                        
@@ -160,7 +179,7 @@
                        
             //Done
             read.close();
-            
+            */
             // Rewrite
                        // Post Process for generated page              
                        PortletURL actionURL = response.createActionURL();
@@ -175,17 +194,9 @@
         }
         catch (SSOException e)
         {
-            if (e.getMessage().equals(SSOException.NO_CREDENTIALS_FOR_SITE))
-            {
-                // no credentials configured in SSO store
-                // switch to SSO Configure View
-                request.setAttribute(PARAM_VIEW_PAGE, 
this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
-                setupPreferencesEdit(request, response);    
-            }
-            else
-            {
-                throw new PortletException(e);
-            }
+               response.getWriter().println("<P>Error rendering page. Error 
message<BR>" + e.getMessage() + "</P>");
+               
+               this.destinationURL ="";   
         }          
     }
     

Modified: 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java?rev=355043&r1=355042&r2=355043&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java
 (original)
+++ 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java
 Thu Dec  8 00:55:51 2005
@@ -49,7 +49,7 @@
     * @return
     * @throws SSOException
     */
-   public BufferedInputStream useSSO(Subject subject, String url, String 
SSOSite, boolean bRefresh) throws SSOException;
+   public String useSSO(Subject subject, String url, String SSOSite, boolean 
bRefresh) throws SSOException;
    
    /**
     * Same as the method above except that the user will be authenticated 
against all
@@ -61,7 +61,7 @@
     * @return
     * @throws SSOException
     */
-   public BufferedInputStream useSSO(Subject subject, String url, boolean 
bRefresh) throws SSOException;
+   public String useSSO(Subject subject, String url, boolean bRefresh) throws 
SSOException;
    
     
    /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to