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/applications/security/src/webapp/images user-chooser.gif
Date Wed, 05 Jan 2005 04:24:49 GMT
taylor      2005/01/04 20:24:49

  Modified:    applications/security/src/java/org/apache/jetspeed/portlets/security/sso
                        SSODetails.java
               applications/security/src/webapp/WEB-INF/security/sso
                        sites-details.vm
               applications/security/src/java/org/apache/jetspeed/portlets/security
                        SecurityResources.java
               applications/security/src/webapp/WEB-INF portlet.xml
                        jetspeed-portlet.xml
  Added:       applications/security/src/webapp/WEB-INF/security/users
                        user-chooser.vm
               applications/security/src/java/org/apache/jetspeed/portlets/security/users
                        UserChooserPortlet.java
               applications/security/src/webapp/images user-chooser.gif
  Log:
  - implemented a basic user selector popup
    this needs some work still and im considering reimplementing it with a page
    instead of a pipeline since im getting no css provided by the aggregated pipeline
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/users/user-chooser.vm
  
  Index: user-chooser.vm
  ===================================================================
  #*
  Copyright 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.
  *#
  
  #**
  
  @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  @version $Id: sites-details.vm,v 1.2 2005/01/04 23:16:54 taylor Exp $
  
  *#
  
  <script language="JavaScript" type="text/javascript">
      <!--
      function select(value)
      {
          var openerForm = opener.document.forms['securityform'];
          var openerEl = openerForm.elements['portal.principal'];
          openerEl.value = value;
          window.close();
      }
  	function rowHover(row)
  	{
  	    row.oldClassName = row.className;
  	    row.className = 'jetdbLight';
  	    row.onmouseout = function()
  	    {
  	        this.className = this.oldClassName;
  	    }
  	}    
      //-->
  </script>
  
  
  #set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
  
  <table cellpadding=0 cellspacing=1 border=0 width='100%' >
    <tr>
      <td width='12' class="jetdbHeadNoLink"></td>      
      #foreach ($column in $title)
  	  #set ($columnLink = $renderResponse.createRenderURL())
  	  $columnLink.setParameter("js_dbcolumn",$column)
  ##      <td align='center' class="jetdbHeadNoLink" width="40%" nowrap onClick="window.location.href='$columnLink'">
        <td align='center' class="jetdbHeadNoLink" width="40%" nowrap>
          $column
        </td>
      #end
      <td width='24' class="jetdbHeadNoLink">&nbsp;</td>    
      <td class=""></td>        
    </tr>
    #foreach ( $user in $table )
    <tr>
        #set ($rowstyle = "jetdbOdd")
         <td class="$rowstyle" nowrap width='12'>
           &nbsp;
         </td>      
        <td class="$rowstyle" nowrap width="25%" onclick="select('$user');" onmouseover="rowHover(this)">
          <div align="center">$user</div>
        </td>
      <td class="">&nbsp;</td>               
     </tr>
    #end
    <tr>
      <td width='12' class="jetdbHeadNoLink"></td>      
      #foreach ($column in $title)
  	  #set ($columnLink = $renderResponse.createRenderURL())
  	  $columnLink.setParameter("js_dbcolumn",$column)
        <td align='center' class="jetdbHeadNoLink" width="40%" nowrap>
        </td>
      #end
      <td width='24' class="jetdbHeadNoLink">&nbsp;</td>    
      <td class=""></td>        
    </tr>
  </table>
  
  
  
  1.3       +48 -3     jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java
  
  Index: SSODetails.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SSODetails.java	4 Jan 2005 23:16:54 -0000	1.2
  +++ SSODetails.java	5 Jan 2005 04:24:49 -0000	1.3
  @@ -29,6 +29,8 @@
   import javax.portlet.RenderResponse;
   import javax.security.auth.Subject;
   
  +import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
  +import org.apache.jetspeed.components.portletregistry.PortletRegistry;
   import org.apache.jetspeed.portlets.security.SecurityResources;
   import org.apache.jetspeed.security.SecurityException;
   import org.apache.jetspeed.security.User;
  @@ -36,6 +38,8 @@
   import org.apache.jetspeed.sso.SSOException;
   import org.apache.jetspeed.sso.SSOProvider;
   import org.apache.jetspeed.sso.SSOSite;
  +import org.apache.pluto.om.entity.PortletEntity;
  +import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.portals.gems.browser.BrowserIterator;
   import org.apache.portals.gems.browser.DatabaseBrowserIterator;
   import org.apache.portals.gems.browser.BrowserPortlet;
  @@ -52,6 +56,12 @@
   {
       private SSOProvider sso;
       private UserManager userManager;
  +    private PortletEntityAccessComponent entityAccess;
  +    private PortletRegistry registry;
  +    private PortletEntity chooserEntity = null;
  +    
  +    private static final String USER_CHOOSER_ENTITY_KEY = "_js2-security-714";
  +    private static final String PORTLET_NAME = "security::UserChooser";
       
       public void init(PortletConfig config)
       throws PortletException 
  @@ -66,7 +76,41 @@
           if (null == userManager)
           {
               throw new PortletException("Failed to find the User Manager on portlet initialization");
  -        }        
  +        }
  +
  +        registry = (PortletRegistry) 
  +            getPortletContext().getAttribute(SecurityResources.CPS_REGISTRY_COMPONENT);
  +        if (null == registry)
  +        {
  +            throw new PortletException("Failed to find the Registry on portlet initialization");
  +        }      
  +        entityAccess = (PortletEntityAccessComponent) 
  +            getPortletContext().getAttribute(SecurityResources.CPS_ENTITY_ACCESS_COMPONENT);
  +        if (null == entityAccess)
  +        {
  +            throw new PortletException("Failed to find the Entity Accessor on portlet initialization");
  +        }      
  +        
  +        PortletDefinition portletDef = registry.getPortletDefinitionByUniqueName(PORTLET_NAME);
  +        if (null == portletDef)
  +        {
  +            throw new PortletException("Could not find portlet definition in registry for
" + PORTLET_NAME);
  +        }
  +        
  +        PortletEntity entity = entityAccess.getPortletEntity(USER_CHOOSER_ENTITY_KEY);
  +        if (entity == null)
  +        {            
  +            entity = entityAccess.newPortletEntityInstance(portletDef, USER_CHOOSER_ENTITY_KEY);
  +            try
  +            {
  +                entityAccess.storePortletEntity(entity);
  +            }
  +            catch (Exception e)
  +            {
  +                throw new PortletException("Could not create entity for " + PORTLET_NAME);
  +            }
  +        }
  +        chooserEntity = entity;
       }
          
       
  @@ -116,12 +160,13 @@
           { 
               this.clearBrowserIterator(request);
           }
  +        Context context = this.getContext(request);        
           String selectedSite = (String)PortletMessaging.receive(request, "site", "selected");
           if (selectedSite != null)
           {        
  -            Context context = this.getContext(request);
               context.put("currentSite", selectedSite);
           }        
  +        context.put("chooser", chooserEntity);        
           super.doView(request, response);
       }
       
  
  
  
  1.3       +23 -6     jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/sso/sites-details.vm
  
  Index: sites-details.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/security/sso/sites-details.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sites-details.vm	4 Jan 2005 23:16:54 -0000	1.2
  +++ sites-details.vm	5 Jan 2005 04:24:49 -0000	1.3
  @@ -21,6 +21,18 @@
   
   *#
   
  +#set ($pipeline = $renderResponse.createRenderURL())
  +#set ($pipeline = "$pipeline?pipeline=portlet-pipeline&entity=$chooser.Id")
  +
  +<script>
  +function openWindow(element)
  +{	
  +    var vWinUsers = window.open('$pipeline', 'UserPicker', 'status=no,resizable=yes,top=100,left=200,width=100,height=250,scrollbars=yes');
  +    vWinUsers.opener = self;
  +	vWinUsers.focus();
  +}
  +</script>
  +
   #set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
   
   #if ($currentSite)
  @@ -78,24 +90,28 @@
     </tr>
   </table>
   <br/>
  -<form action="$renderResponse.createActionURL()" method="post">
  +<form name='securityform' action="$renderResponse.createActionURL()" method="post">
   <table>
     <tr colspan="2" align="right">
       <td nowrap class="portlet-section-alternate" align="right">Portal Principal:&nbsp;</td>
       <td class="portlet-section-body" align="left">
  -      <input type="text" name="portal.principal" size="40" value="$!currentP" class="portlet-form-label-field">
  +      <input type="text" name="portal.principal" size="30" value="$!currentP" class="portlet-form-label-field">
  +	 <a href="javascript:openWindow('portal.principal');">
  +        <img title="Select a user"
  +             name="assigneeImage" 
  +             src="/security/images/user-chooser.gif" hspace=0 height=16 width=16 border=0
align=absmiddle></a>      
  +    </td>      
       </td>
     </tr>
     <tr colspan="2" align="right">
       <td nowrap class="portlet-section-alternate" align="right">Remote Principal:&nbsp;</td>
       <td class="portlet-section-body" align="left">
  -      <input type="text" name="remote.principal" size="40" value="$!currentR" class="portlet-form-label-field">
  -    </td>
  +      <input type="text" name="remote.principal" size="30" value="$!currentR" class="portlet-form-label-field">
     </tr>
     <tr colspan="2" align="right">
       <td nowrap class="portlet-section-alternate" align="right">Remote Credential:&nbsp;</td>
       <td class="portlet-section-body" align="left">
  -      <input type="password" name="remote.credential" size="40" value="$!remoteCredential"
class="portlet-form-label-field">
  +      <input type="password" name="remote.credential" size="30" value="$!remoteCredential"
class="portlet-form-label-field">      
       </td>
     </tr>  
   </table>
  @@ -105,3 +121,4 @@
   <input name='sso.new' class="portlet-form-button" type="submit" value="$MESSAGES.getString('new')"
/>
   </form>	      
   #end
  +
  
  
  
  1.2       +2 -1      jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java
  
  Index: SecurityResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SecurityResources.java	22 Dec 2004 17:50:10 -0000	1.1
  +++ SecurityResources.java	5 Jan 2005 04:24:49 -0000	1.2
  @@ -31,6 +31,7 @@
       public final static String CPS_GROUP_MANAGER_COMPONENT = "cps:GroupManager";
       public final static String CPS_PROFILER_COMPONENT = "cps:Profiler";
       public final static String CPS_SSO_COMPONENT = "cps:SSO";    
  +    public final static String CPS_ENTITY_ACCESS_COMPONENT = "cps:EntityAccessor";
   
       public final static String CURRENT_USER = "current_user";
       public final static String PAM_CURRENT_USER = "org.apache.jetspeed.pam.user";
  
  
  
  1.10      +26 -0     jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/portlet.xml
  
  Index: portlet.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/portlet.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- portlet.xml	3 Jan 2005 08:14:32 -0000	1.9
  +++ portlet.xml	5 Jan 2005 04:24:49 -0000	1.10
  @@ -216,5 +216,31 @@
       </portlet-info>
   </portlet>
   
  +<portlet id="UserChooser">
  +    <init-param>
  +    	<description>This parameter sets the template used in view mode.</description>
  +		<name>ViewPage</name>
  +			<value>/WEB-INF/security/users/user-chooser.vm</value>
  +     </init-param>   
  +    <portlet-name>UserChooser</portlet-name>
  +    <display-name>Users</display-name>
  +    <description>User Chooser Portlet</description>
  +    <portlet-class>org.apache.jetspeed.portlets.security.users.UserChooserPortlet</portlet-class>
  +    <expiration-cache>-1</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>
  +    <resource-bundle>org.apache.jetspeed.portlets.security.resources.SecurityResources</resource-bundle>
           
  +    <portlet-info>
  +      <title>User Select</title>
  +      <short-title>Users</short-title>
  +      <keywords>admin,security,users</keywords>
  +    </portlet-info>
  +</portlet>
  +
   </portlet-app>
   
  
  
  
  1.6       +2 -0      jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/jetspeed-portlet.xml
  
  Index: jetspeed-portlet.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/webapp/WEB-INF/jetspeed-portlet.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jetspeed-portlet.xml	3 Jan 2005 08:14:32 -0000	1.5
  +++ jetspeed-portlet.xml	5 Jan 2005 04:24:49 -0000	1.6
  @@ -35,6 +35,8 @@
       <js:service name='GroupManager'/>    
       <js:service name="Profiler" /> 
       <js:service name="SSO" />         
  +	<js:service name='PortletRegistryComponent'/>
  +	<js:service name='EntityAccessor'/>    
     </js:services>
   
   </portlet-app>
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/users/UserChooserPortlet.java
  
  Index: UserChooserPortlet.java
  ===================================================================
  /* Copyright 2004 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.portlets.security.users;
  
  import java.security.Principal;
  import java.sql.Types;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import javax.portlet.PortletConfig;
  import javax.portlet.PortletException;
  import javax.portlet.RenderRequest;
  import javax.security.auth.Subject;
  
  import org.apache.jetspeed.portlets.security.SecurityResources;
  import org.apache.jetspeed.security.User;
  import org.apache.jetspeed.security.UserManager;
  import org.apache.jetspeed.security.UserPrincipal;
  import org.apache.portals.gems.browser.BrowserIterator;
  import org.apache.portals.gems.browser.DatabaseBrowserIterator;
  import org.apache.portals.gems.browser.BrowserPortlet;
  
  /**
   * SSOBrowser
   * 
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: UserChooserPortlet.java,v 1.1 2005/01/05 04:24:49 taylor Exp $
   */
  public class UserChooserPortlet extends BrowserPortlet
  {
      private UserManager userManager;
      
      public void init(PortletConfig config)
      throws PortletException 
      {
          super.init(config);
          userManager = (UserManager) 
              getPortletContext().getAttribute(SecurityResources.CPS_USER_MANAGER_COMPONENT);
          if (null == userManager)
          {
              throw new PortletException("Failed to find the User Manager on portlet initialization");
          }
      }
             
      public void getRows(RenderRequest request, String sql, int windowSize)
      throws Exception
      {
          List resultSetTitleList = new ArrayList();
          List resultSetTypeList = new ArrayList();
          try
          {
              Iterator users = userManager.getUsers("");
                          
              
              resultSetTypeList.add(String.valueOf(Types.VARCHAR));
              resultSetTitleList.add("User");
  
              // TODO: need to try to normalize List/Collection/Iterators
              List list = new ArrayList();
              while (users.hasNext())
              {
                  User user = (User)users.next();
                  Principal principal = getPrincipal(user.getSubject(),
                          UserPrincipal.class);                
                  list.add(principal.getName());
              }            
              BrowserIterator iterator = new DatabaseBrowserIterator(
                      list, resultSetTitleList, resultSetTypeList,
                      windowSize);
              setBrowserIterator(request, iterator);
          }
          catch (Exception e)
          {
              //log.error("Exception in CMSBrowserAction.getRows: ", e);
              e.printStackTrace();
              throw e;
          }        
      }
     
      public Principal getPrincipal(Subject subject, Class classe) {
          Principal principal = null;
          Iterator principals = subject.getPrincipals().iterator();
          while (principals.hasNext()) {
              Principal p = (Principal) principals.next();
              if (classe.isInstance(p)) {
                  principal = p;
                  break;
              }
          }
          return principal;
      }
      
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/security/src/webapp/images/user-chooser.gif
  
  	<<Binary file>>
  
  

---------------------------------------------------------------------
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