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/WEB-INF/security/sso sites-details.vm
Date Tue, 04 Jan 2005 23:16:54 GMT
taylor      2005/01/04 15:16:54

  Modified:    applications/security/src/java/org/apache/jetspeed/portlets/security/sso
                        SSODetails.java SSOBrowser.java
               applications/security/src/webapp/WEB-INF/security/sso
                        sites-details.vm
  Log:
  continued work on SSO Admin -- details view is now attached to the current row of the SSO
Browser
  still under construction
  
  Revision  Changes    Path
  1.2       +41 -51    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSODetails.java	3 Jan 2005 08:14:32 -0000	1.1
  +++ SSODetails.java	4 Jan 2005 23:16:54 -0000	1.2
  @@ -15,7 +15,6 @@
   package org.apache.jetspeed.portlets.security.sso;
   
   import java.io.IOException;
  -import java.security.Principal;
   import java.sql.Types;
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -28,8 +27,12 @@
   import javax.portlet.PortletMode;
   import javax.portlet.RenderRequest;
   import javax.portlet.RenderResponse;
  +import javax.security.auth.Subject;
   
   import org.apache.jetspeed.portlets.security.SecurityResources;
  +import org.apache.jetspeed.security.SecurityException;
  +import org.apache.jetspeed.security.User;
  +import org.apache.jetspeed.security.UserManager;
   import org.apache.jetspeed.sso.SSOException;
   import org.apache.jetspeed.sso.SSOProvider;
   import org.apache.jetspeed.sso.SSOSite;
  @@ -48,6 +51,7 @@
   public class SSODetails extends BrowserPortlet
   {
       private SSOProvider sso;
  +    private UserManager userManager;
       
       public void init(PortletConfig config)
       throws PortletException 
  @@ -58,6 +62,11 @@
           {
               throw new PortletException("Failed to find the SSO Provider on portlet initialization");
           }
  +        userManager = (UserManager) getPortletContext().getAttribute(SecurityResources.CPS_USER_MANAGER_COMPONENT);
  +        if (null == userManager)
  +        {
  +            throw new PortletException("Failed to find the User Manager on portlet initialization");
  +        }        
       }
          
       
  @@ -70,7 +79,7 @@
           {
               SSOSite site = null;
               Iterator principals = null;
  -            List list = new ArrayList();
  +            List list = null;
               resultSetTypeList.add(String.valueOf(Types.VARCHAR));
               resultSetTitleList.add("Principal");
               resultSetTypeList.add(String.valueOf(Types.VARCHAR));
  @@ -80,14 +89,11 @@
               if (selectedSite != null)
               {
                   site = sso.getSite(selectedSite);
  -                principals = site.getPrincipals().iterator();
  -                        
  -                // TODO: need to try to normalize List/Collection/Iterators
  -                while (principals.hasNext())
  -                {
  -                    Principal p = (Principal)principals.next();
  -                    list.add(p.getName());
  -                }
  +                list = sso.getPrincipalsForSite(site);
  +            }
  +            else
  +            {
  +                list = new ArrayList();
               }
               BrowserIterator iterator = new DatabaseBrowserIterator(
                       list, resultSetTitleList, resultSetTypeList,
  @@ -105,14 +111,17 @@
       public void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException
       {
  +        String change = (String)PortletMessaging.consume(request, "site", "change");
  +        if (change != null)
  +        { 
  +            this.clearBrowserIterator(request);
  +        }
           String selectedSite = (String)PortletMessaging.receive(request, "site", "selected");
           if (selectedSite != null)
           {        
               Context context = this.getContext(request);
               context.put("currentSite", selectedSite);
  -            String selectedUrl = (String)PortletMessaging.receive(request, "site", "selectedUrl");
  -            context.put("currentUrl", selectedUrl);            
  -        }
  +        }        
           super.doView(request, response);
       }
       
  @@ -121,16 +130,6 @@
       {
           if (request.getPortletMode() == PortletMode.VIEW)
           {
  -            String selectedSite = request.getParameter("ssoSite");
  -            if (selectedSite != null)
  -            {
  -                SSOSite site = sso.getSite(selectedSite);
  -                if (site != null)
  -                {
  -                    PortletMessaging.publish(request, "site", "selected", selectedSite);
  -                    PortletMessaging.publish(request, "site", "selectedUrl", site.getSiteURL());
  -                }
  -            }
               String refresh = request.getParameter("sso.refresh");
               String save = request.getParameter("sso.save");
               String neue = request.getParameter("sso.new");
  @@ -140,39 +139,25 @@
               }
               else if (neue != null)
               {
  -                PortletMessaging.cancel(request, "site", "selected");
  -                PortletMessaging.cancel(request, "site", "selectedUrl");              
                 
  +                //PortletMessaging.cancel(request, "site", "selected");
  +                //PortletMessaging.cancel(request, "site", "selectedUrl");            
                   
               }
               else if (save != null)
               {
  -                String siteName = request.getParameter("site.name");                
  -                String siteUrl = request.getParameter("site.url");
  -                if (!(isEmpty(siteName) || isEmpty(siteUrl)))
  +                String portalPrincipal = request.getParameter("portal.principal");    
           
  +                String remotePrincipal = request.getParameter("remote.principal");
  +                String remoteCredential = request.getParameter("remote.credential");
  +                if (!(isEmpty(remotePrincipal) || isEmpty(remotePrincipal) || isEmpty(remoteCredential)))
                   {
                       try
                       {
  -                        SSOSite site = null;
  -                        String oldName = (String)PortletMessaging.receive(request, "site",
"selected");
  -                        if (oldName != null)
  -                        {
  -                            site = sso.getSite(oldName);
  -                        }
  -                        else
  -                        {
  -                            site = sso.getSite(siteName);
  -                        }                        
  -                        if (site != null)
  -                        {
  -                            site.setName(siteName);
  -                            site.setSiteURL(siteUrl);
  -                            sso.updateSite(site);
  -                            this.clearBrowserIterator(request);
  -                            PortletMessaging.publish(request, "site", "selected", siteName);
  -                            PortletMessaging.publish(request, "site", "selectedUrl", siteUrl);
                           
  -                        }
  -                        else
  -                        {
  -                            sso.addSite(siteName, siteUrl);
  +                        String siteName = (String)PortletMessaging.receive(request, "site",
"selected");                        
  +                        SSOSite site = sso.getSite(siteName);
  +                        User user = userManager.getUser(portalPrincipal);             
          
  +                        if (site != null && user != null)
  +                        {                            
  +                            Subject subject = user.getSubject(); 
  +                            sso.addCredentialsForSite(subject, remotePrincipal, site.getSiteURL(),
remoteCredential);
                               this.clearBrowserIterator(request);
                           }
                       }
  @@ -181,6 +166,11 @@
                           // TODO: exception handling
                           System.err.println("Exception storing site: " + e);
                       }
  +                    catch (SecurityException se)
  +                    {
  +                        // TODO: exception handling
  +                        System.err.println("Exception storing site: " + se);
  +                    }                    
                   }
               }            
           }
  
  
  
  1.3       +2 -1      jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java
  
  Index: SSOBrowser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/security/src/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SSOBrowser.java	3 Jan 2005 08:14:32 -0000	1.2
  +++ SSOBrowser.java	4 Jan 2005 23:16:54 -0000	1.3
  @@ -127,6 +127,7 @@
                   {
                       PortletMessaging.publish(request, "site", "selected", selectedSite);
                       PortletMessaging.publish(request, "site", "selectedUrl", site.getSiteURL());
  +                    PortletMessaging.publish(request, "site", "change", selectedSite);
                   }
               }
               String refresh = request.getParameter("sso.refresh");
  
  
  
  1.2       +14 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sites-details.vm	3 Jan 2005 08:14:33 -0000	1.1
  +++ sites-details.vm	4 Jan 2005 23:16:54 -0000	1.2
  @@ -23,6 +23,7 @@
   
   #set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
   
  +#if ($currentSite)
   <table cellpadding=0 cellspacing=1 border=0 width='100%' >
     <tr>
       <td width='12' class="jetdbHeadNoLink"></td>      
  @@ -52,11 +53,11 @@
   	 #end   	 
         <td class="$rowstyle" nowrap width="25%">
           #set ($action = $renderResponse.createActionURL())
  -        $action.setParameter('ssoPrincipal', $principal)
  -        <div align="center"><a href='$action'>$principal</a></div>
  +        $action.setParameter('ssoPrincipal', $principal.PortalPrincipalName)
  +        <div align="center"><a href='$action'>$principal.PortalPrincipalName</a></div>
         </td>
         <td class="$rowstyle" nowrap width="25%">
  -        <div align="center"><a href='$action'>REMOTE</a></div>
  +        <div align="center"><a href='$action'>$principal.RemotePrincipalName</a></div>
         </td>      
          <td class="$rowstyle" nowrap width='24' align='center'>
            <img src="/security/images/waste_bin.gif" width="20" height="15" border="0"/>
  @@ -82,19 +83,25 @@
     <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="site.name" size="40" value="$!currentP" class="portlet-form-label-field">
  +      <input type="text" name="portal.principal" size="40" value="$!currentP" class="portlet-form-label-field">
       </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="site.url" size="40" value="$!currentR" class="portlet-form-label-field">
  +      <input type="text" name="remote.principal" size="40" value="$!currentR" class="portlet-form-label-field">
       </td>
     </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">
  +    </td>
  +  </tr>  
   </table>
   <br/>
   <input name='sso.save' type="submit" value="$MESSAGES.getString('save')" class="portlet-form-button"/>
   <input name='sso.refresh' class="portlet-form-button" type="submit" value="$MESSAGES.getString('refresh')"
/>
   <input name='sso.new' class="portlet-form-button" type="submit" value="$MESSAGES.getString('new')"
/>
   </form>	      
  -
  +#end
  
  
  

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