portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/web-content project.xml
Date Fri, 26 Nov 2004 18:56:34 GMT
taylor      2004/11/26 10:56:34

  Modified:    components/web-content/src/java/org/apache/jetspeed/portlet
                        IFrameGenericPortlet.java
               components/web-content project.xml
  Added:       components/web-content/src/java/org/apache/jetspeed/portlet
                        SSOIFramePortlet.java
  Log:
  Starting SSO Portlet implementation: SSOIFramePortlet
  The SSOIFramePortlet will support all SSO authentication methods
  Here we are starting on request parameter (and base64 request parameter) authentication
  
  Revision  Changes    Path
  1.4       +24 -11    jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/IFrameGenericPortlet.java
  
  Index: IFrameGenericPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/IFrameGenericPortlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IFrameGenericPortlet.java	15 Nov 2004 05:58:10 -0000	1.3
  +++ IFrameGenericPortlet.java	26 Nov 2004 18:56:34 -0000	1.4
  @@ -38,6 +38,7 @@
    */
   public class IFrameGenericPortlet extends GenericVelocityPortlet
   {
  +
       private Map attributes = new HashMap();
   
       private Map maxAttributes = new HashMap();
  @@ -83,12 +84,12 @@
       private void appendAttribute(PortletPreferences prefs, StringBuffer content, String
attribute, Map map)
       {
           String value;
  -        
  +
           if (map == maxAttributes)
               value = getMaxAttributePreference(prefs, attribute);
           else
               value = getAttributePreference(prefs, attribute);
  -        
  +
           if (value == null || value == "") { return; }
           content.append(" ").append(attribute).append("=\"").append(value).append("\"");
       }
  @@ -110,19 +111,24 @@
   
       public void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
IOException
       {
  -        response.setContentType("text/html");        
  -        doPreferencesEdit(request, response);        
  +        response.setContentType("text/html");
  +        doPreferencesEdit(request, response);
       }
  -    
  +
       /**
        * Render IFRAME content
        */
       protected void doIFrame(RenderRequest request, RenderResponse response) throws IOException
       {
           PortletPreferences prefs = request.getPreferences();
  +        String source = getURLSource(request, prefs);
           // generate HTML IFRAME content
           StringBuffer content = new StringBuffer(4096);
           content.append("<IFRAME");
  +
  +        // special case source
  +        content.append(" ").append("SRC").append("=\"").append(source).append("\"");
  +
           appendAttribute(prefs, content, "SRC");
           appendAttribute(prefs, content, "ALIGN");
           appendAttribute(prefs, content, "CLASS");
  @@ -146,8 +152,8 @@
               appendAttribute(prefs, content, "STYLE");
           }
           content.append(">");
  -        content.append("<P STYLE=\"textAlign:center\"><A HREF=\"").append(getAttributePreference(prefs,
"SRC")).append(
  -                "\">").append(getAttributePreference(prefs, "SRC")).append("</A></P>");
  +        content.append("<P STYLE=\"textAlign:center\"><A HREF=\"").append(source).append("\">").append(source).append(
  +                "</A></P>");
           content.append("</IFRAME>");
   
           // set required content type and write HTML IFRAME content
  @@ -155,13 +161,20 @@
           response.getWriter().print(content.toString());
       }
   
  +    public String getURLSource(RenderRequest request, PortletPreferences prefs)
  +    {
  +        String source = getAttributePreference(prefs, "SRC");
  +        if (source == null) source = "";
  +        return source;
  +    }
  +
       /**
        * Save the prefs
        */
  -    public void processAction(ActionRequest request, ActionResponse actionResponse)
  -    throws PortletException, IOException
  +    public void processAction(ActionRequest request, ActionResponse actionResponse) throws
PortletException,
  +            IOException
       {
           processPreferencesAction(request, actionResponse);
       }
  -    
  +
   }
  
  
  
  1.1                  jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java
  
  Index: SSOIFramePortlet.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * 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.
   */
  package org.apache.jetspeed.portlet;
  
  import java.security.AccessControlContext;
  import java.security.AccessController;
  import javax.security.auth.Subject;
  
  import javax.portlet.PortletConfig;
  import javax.portlet.PortletContext;
  import javax.portlet.PortletException;
  import javax.portlet.PortletPreferences;
  import javax.portlet.RenderRequest;
  
  import org.apache.jetspeed.sso.SSOProvider;
  
  
  /**
   * SSOIFramePortlet
   * 
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: SSOIFramePortlet.java,v 1.1 2004/11/26 18:56:34 taylor Exp $
   */
  public class SSOIFramePortlet extends IFrameGenericPortlet
  {
      public static final String SSO_TYPE = "sso.type";
      public static final String SSO_TYPE_URL = "url";
      public static final String SSO_TYPE_URL_BASE64 = "url.base64";
      public static final String SSO_TYPE_HTTP = "http";
      public static final String SSO_TYPE_CERTIFICATE = "certificate";
      
      public static final String SSO_TYPE_URL_USERNAME = "sso.url.param.username";
      public static final String SSO_TYPE_URL_PASSWORD = "sso.url.param.password";
      
  
      private PortletContext context;
      private SSOProvider sso;
  
      public void init(PortletConfig config) throws PortletException
      {
          super.init(config);
          context = getPortletContext();
          sso = (SSOProvider)context.getAttribute("cps:SSO");
          if (null == sso)
          {
             throw new PortletException("Failed to find SSO Provider on portlet initialization");
          }        
      }
          
      public String getURLSource(RenderRequest request, PortletPreferences prefs)
      {
          String baseSource = super.getURLSource(request, prefs);
          String type = prefs.getValue(SSO_TYPE, SSO_TYPE_URL);
          if (type.equals(SSO_TYPE_URL))
          {
              String userNameParam = prefs.getValue("sso.url.param.username", "");
              String passwordParam = prefs.getValue("sso.url.param.password", "");
              StringBuffer source = new StringBuffer(baseSource);
              if (baseSource.indexOf("?") == -1)
              {
                  source.append("?");
              }            
              else
              {
                  source.append("&");
              }
              AccessControlContext context = AccessController.getContext();
              Subject subject = Subject.getSubject(context); 
              System.out.println("GOT A SUBJECT " + subject);
              source.append(userNameParam);
              source.append("=");
              
              // LEFT OFF HERE: get credentials from subject, and pass into SSO component
              
              source.append("joey");
              source.append("&");
              source.append(passwordParam);
              source.append("=");
              source.append("joeys-password");
              return source.toString();
          }
          else
          {
              return baseSource;
          }
      }
      
      
      
  }
  
  
  
  1.5       +4 -0      jakarta-jetspeed-2/components/web-content/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/web-content/project.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- project.xml	12 Nov 2004 06:30:40 -0000	1.4
  +++ project.xml	26 Nov 2004 18:56:34 -0000	1.5
  @@ -43,6 +43,10 @@
         <id>jetspeed2:jetspeed-commons</id>
         <version>2.0-a1-dev</version>
       </dependency>
  +   	<dependency>
  +      <id>jetspeed2:jetspeed-api</id>
  +      <version>2.0-a1-dev</version>
  +    </dependency>	
       <dependency>
         <id>commons-httpclient</id>
         <version>2.0</version>
  
  
  

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


Mime
View raw message