portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r734959 - in /portals/jetspeed-2/applications/j2-admin/trunk: ./ src/main/java/org/apache/jetspeed/portlets/security/sso/ src/webapp/WEB-INF/security/sso/
Date Fri, 16 Jan 2009 10:17:07 GMT
Author: ddam
Date: Fri Jan 16 02:17:03 2009
New Revision: 734959

URL: http://svn.apache.org/viewvc?rev=734959&view=rev
Log:
JS2-907 : Changes to SSO browser and detail portlets

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/pom.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-details.vm
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-view.vm

Modified: portals/jetspeed-2/applications/j2-admin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/pom.xml?rev=734959&r1=734958&r2=734959&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/pom.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/pom.xml Fri Jan 16 02:17:03 2009
@@ -198,9 +198,9 @@
             <version>${jetspeed-2.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.portals.jetspeed-2</groupId>
+            <groupId>org.apache.portals.applications</groupId>
             <artifactId>portals-gems</artifactId>
-            <version>2.1.3</version>
+            <version>2.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>velocity</groupId>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java?rev=734959&r1=734958&r2=734959&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSOBrowser.java
Fri Jan 16 02:17:03 2009
@@ -19,7 +19,7 @@
 import java.io.IOException;
 import java.sql.Types;
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Collection;
 import java.util.List;
 
 import javax.portlet.ActionRequest;
@@ -27,16 +27,19 @@
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
 import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.sso.SSOException;
-import org.apache.jetspeed.sso.SSOProvider;
+import org.apache.jetspeed.sso.SSOManager;
 import org.apache.jetspeed.sso.SSOSite;
 import org.apache.portals.gems.browser.BrowserIterator;
-import org.apache.portals.gems.browser.DatabaseBrowserIterator;
 import org.apache.portals.gems.browser.BrowserPortlet;
+import org.apache.portals.gems.browser.DatabaseBrowserIterator;
 import org.apache.portals.gems.util.StatusMessage;
 import org.apache.portals.messaging.PortletMessaging;
 import org.apache.velocity.context.Context;
@@ -49,13 +52,13 @@
  */
 public class SSOBrowser extends BrowserPortlet
 {
-    private SSOProvider sso;
+    private SSOManager sso;
     
     public void init(PortletConfig config)
     throws PortletException 
     {
         super.init(config);
-        sso = (SSOProvider)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
+        sso = (SSOManager)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
         if (null == sso)
         {
             throw new PortletException("Failed to find the SSO Provider on portlet initialization");
@@ -70,13 +73,7 @@
         List resultSetTypeList = new ArrayList();
         try
         {
-            Iterator sites = sso.getSites("");
-            
-            // List userObjectList = (List)getParameterFromTemp(portlet, rundata, USER_OBJECTS);
-
-            //
-            // Add MetaData headers, types
-            //
+            Collection<SSOSite> sites = sso.getSites("");
             
             resultSetTypeList.add(String.valueOf(Types.VARCHAR));
             resultSetTypeList.add(String.valueOf(Types.VARCHAR));
@@ -84,16 +81,15 @@
             resultSetTitleList.add(1, "Site");
 
             //subPopulate(rundata, qResult, repo, folder, null);
-
             List list = new ArrayList();
-            while (sites.hasNext())
-            {
-                List row = new ArrayList(2);
-                SSOSite site = (SSOSite)sites.next();
-                row.add(0, site.getSiteURL());                     
-                row.add(1, site.getName());
-                list.add(row);
-            }            
+            if (sites != null){
+                for (SSOSite site : sites ){
+                	List row = new ArrayList(2);
+                    row.add(0, site.getURL());                     
+                    row.add(1, site.getName());
+                    list.add(row);
+                }
+            }
             BrowserIterator iterator = new DatabaseBrowserIterator(
                     list, resultSetTitleList, resultSetTypeList,
                     windowSize);
@@ -111,13 +107,12 @@
     public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedUrl");
-        if (selectedSite != null)
+        String selectedSiteName = (String)PortletMessaging.receive(request, "site", "selectedName");
+        if (selectedSiteName != null)
         {        
             Context context = this.getContext(request);
-            context.put("currentUrl", selectedSite);
-            String selectedName = (String)PortletMessaging.receive(request, "site", "selectedName");
-            context.put("currentName", selectedName);  
+            context.put("currentName", selectedSiteName);  
+            context.put("currentUrl", (String)PortletMessaging.receive(request, "site", "selectedUrl"));
             
             String realm = (String)PortletMessaging.receive(request, "site", "realm");
             context.put("currentRealm", realm);  
@@ -139,6 +134,22 @@
         super.doView(request, response);
     }
     
+    protected void clearPortletMessages(PortletRequest request, PortletResponse response){
+    	PortletMessaging.cancel(request, "site", "selectedName");
+        PortletMessaging.cancel(request, "site", "selectedUrl");      
+        PortletMessaging.cancel(request, "site", "realm");
+        PortletMessaging.cancel(request, "site", "idField");
+        PortletMessaging.cancel(request, "site", "pwdField");	
+    }
+    
+    protected void setPortletMessage(PortletRequest request, String key, String msg) throws
IOException{
+    	if (StringUtils.isNotEmpty(msg)){
+    		PortletMessaging.publish(request, "site", key, msg);
+    	} else {
+    		 PortletMessaging.cancel(request, "site", key);	
+    	}
+    }
+    
     public void processAction(ActionRequest request, ActionResponse response)
     throws PortletException, IOException
     {
@@ -147,15 +158,15 @@
             String selectedSite = request.getParameter("ssoSite");
             if (selectedSite != null)
             {
-                SSOSite site = sso.getSite(selectedSite);
+            	SSOSite site = sso.getSiteByName(selectedSite);
                 if (site != null)
                 {
-                    PortletMessaging.publish(request, "site", "selectedUrl", selectedSite);
-                    PortletMessaging.publish(request, "site", "selectedName", site.getName());
-                    PortletMessaging.publish(request, "site", "change", selectedSite);
-                    PortletMessaging.publish(request, "site", "realm", site.getRealm());
-                    PortletMessaging.publish(request, "site", "idField", site.getFormUserField());
-                    PortletMessaging.publish(request, "site", "pwdField", site.getFormPwdField());
+                    setPortletMessage(request, "selectedUrl", site.getURL());
+                    setPortletMessage(request, "selectedName", site.getName());
+                    setPortletMessage(request, "change", selectedSite);
+                    setPortletMessage(request, "realm", site.getRealm());
+                    setPortletMessage(request, "idField", site.getFormUserField());
+                    setPortletMessage(request, "pwdField", site.getFormPwdField());
                 }
             }
             String refresh = request.getParameter("sso.refresh");
@@ -169,33 +180,26 @@
             }
             else if (neue != null)
             {
-                PortletMessaging.cancel(request, "site", "selected");
-                PortletMessaging.cancel(request, "site", "selectedUrl");      
-                PortletMessaging.cancel(request, "site", "realm");
-                PortletMessaging.cancel(request, "site", "idField");
-                PortletMessaging.cancel(request, "site", "pwdField");
+            	clearPortletMessages(request,response);
             }
             else if (delete != null && (!(isEmpty(delete))))
             {
-                try
+            	try
                 {
                     SSOSite site = null;
-                    site = sso.getSite(delete);
+                    site = sso.getSiteByName(delete);
                     if (site != null)
                     {
                         sso.removeSite(site);
                         this.clearBrowserIterator(request);
-                        PortletMessaging.cancel(request, "site", "selected");
-                        PortletMessaging.cancel(request, "site", "selectedUrl");   
-                        PortletMessaging.cancel(request, "site", "realm");
-                        PortletMessaging.cancel(request, "site", "idField");
-                        PortletMessaging.cancel(request, "site", "pwdField");
+                        clearPortletMessages(request,response);
                     }
                 }
                 catch (SSOException e)
                 {
                     publishStatusMessage(request, "SSOBrowser", "status", e, "Could not remove
site");
                 }
+            	
             }
             else if (save != null)
             {
@@ -211,64 +215,47 @@
                     try
                     {
                         SSOSite site = null;
-                        String old = (String)PortletMessaging.receive(request, "site", "selectedUrl");
+                        String old = (String)PortletMessaging.receive(request, "site", "selectedName");
                         if (old != null)
                         {
-                            site = sso.getSite(old);
-                        }
-                        else
-                        {
-                            site = sso.getSite(siteUrl);
-                        }                        
-                        if (site != null)
-                        {
-                            site.setName(siteName);
-                            site.setSiteURL(siteUrl);
-                            site.setRealm(siteRealm);
-                            if (siteFormID != null && siteFormID.length() > 0
-                            	&& siteFormPWD != null && siteFormPWD.length()
> 0	)
-                            {
-                            	// Form authentication
-                            	site.setFormAuthentication(true);
-                            	site.setFormUserField(siteFormID);
-                            	site.setFormPwdField(siteFormPWD);
-                            }
-                            else
-                            {
-                            	//Challenge response authentication
-                            	site.setChallengeResponseAuthentication(true);
-                            }
-                            
-                            sso.updateSite(site);
-                            this.clearBrowserIterator(request);
-                            PortletMessaging.publish(request, "site", "selectedName", siteName);
-                            PortletMessaging.publish(request, "site", "selectedUrl", siteUrl);
   
-                            PortletMessaging.publish(request, "site", "realm", siteRealm);
-                            PortletMessaging.publish(request, "site", "idField",siteFormID);
-                            PortletMessaging.publish(request, "site", "pwdField", siteFormPWD);
-
+                            site = sso.getSiteByName(old);
                         }
                         else
                         {
-                        	if (siteFormID != null && siteFormID.length() > 0
-                                	&& siteFormPWD != null && siteFormPWD.length()
> 0	)
-                            {
-                    			sso.addSiteFormAuthenticated(siteName, siteUrl, siteRealm, siteFormID,siteFormPWD);
-                    		
-                            }
-                        	else
-                        	{
-                        		sso.addSiteChallengeResponse(siteName, siteUrl, siteRealm);
-                        	}
-                            this.clearBrowserIterator(request);
+                            site = sso.getSiteByName(siteName);
+                        } 
+                        boolean isNewSite = false;
+                        if (site == null){
+                        	isNewSite = true;
+                        	site = sso.newSite(siteName, siteUrl);
                         }
+                        
+                        site.setName(siteName);
+                        site.setURL(siteUrl);
+                        site.setRealm(siteRealm);
+                        site.setFormUserField(siteFormID);
+                    	site.setFormPwdField(siteFormPWD);
+                    	site.setFormAuthentication(StringUtils.isNotEmpty(siteFormID) &&
StringUtils.isNotEmpty(siteFormPWD));
+                    	site.setChallengeResponseAuthentication(!site.isFormAuthentication());
+                    	
+                    	if (isNewSite){
+                    		sso.addSite(site);
+                    	} else {
+                    		sso.updateSite(site);
+                    	}
+                    	this.clearBrowserIterator(request);
+                        PortletMessaging.publish(request, "site", "selectedName", siteName);
+                        PortletMessaging.publish(request, "site", "selectedUrl", siteUrl);
   
+                        PortletMessaging.publish(request, "site", "realm", siteRealm);
+                        PortletMessaging.publish(request, "site", "idField",siteFormID);
+                        PortletMessaging.publish(request, "site", "pwdField", siteFormPWD);
                     }
                     catch (SSOException e)
                     {
                         publishStatusMessage(request, "SSOBrowser", "status", e, "Could not
store site");
                     }
                 }
-            }            
+            }   
         }
         super.processAction(request, response);
             

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java?rev=734959&r1=734958&r2=734959&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/sso/SSODetails.java
Fri Jan 16 02:17:03 2009
@@ -19,7 +19,10 @@
 import java.io.IOException;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -28,20 +31,22 @@
 import javax.portlet.PortletMode;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.security.auth.Subject;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.portlets.security.SecurityUtil;
 import org.apache.jetspeed.security.GroupManager;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
 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.SSOManager;
 import org.apache.jetspeed.sso.SSOSite;
+import org.apache.jetspeed.sso.SSOUser;
 import org.apache.portals.gems.browser.BrowserIterator;
-import org.apache.portals.gems.browser.DatabaseBrowserIterator;
 import org.apache.portals.gems.browser.BrowserPortlet;
+import org.apache.portals.gems.browser.DatabaseBrowserIterator;
 import org.apache.portals.gems.util.StatusMessage;
 import org.apache.portals.messaging.PortletMessaging;
 import org.apache.velocity.context.Context;
@@ -54,7 +59,7 @@
  */
 public class SSODetails extends BrowserPortlet
 {
-    private SSOProvider sso;
+    private SSOManager sso;
     private UserManager userManager;
     private GroupManager groupManager;
         
@@ -62,10 +67,10 @@
     throws PortletException 
     {
         super.init(config);
-        sso = (SSOProvider)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
+        sso = (SSOManager)getPortletContext().getAttribute(CommonPortletServices.CPS_SSO_COMPONENT);
         if (null == sso)
         {
-            throw new PortletException("Failed to find the SSO Provider on portlet initialization");
+            throw new PortletException("Failed to find the SSO Manager on portlet initialization");
         }
         userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
         if (null == userManager)
@@ -88,22 +93,27 @@
         try
         {
             SSOSite site = null;
-            List list = null;
+            
+            List<RemoteAndLocalPrincipalPair> list = new ArrayList<RemoteAndLocalPrincipalPair>();
+
             resultSetTypeList.add(String.valueOf(Types.VARCHAR));
             resultSetTitleList.add("Principal");
             resultSetTypeList.add(String.valueOf(Types.VARCHAR));
             resultSetTitleList.add("Remote");
             
-            String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedUrl");
+            String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedName");
             if (selectedSite != null)
             {
-                site = sso.getSite(selectedSite);
-                list = sso.getPrincipalsForSite(site);
-            }
-            else
-            {
-                list = new ArrayList();
-            }
+                site = sso.getSiteByName(selectedSite);
+                Collection<SSOUser> ssoUsers = sso.getUsersForSite(site);
+                for (SSOUser user : ssoUsers) {
+                	Collection<JetspeedPrincipal> principals = sso.getPortalPrincipals(user);
+                	// keep 1-on-n relation for now. Later portlet needs to be refactored to
support n-to-n
+                	if (principals.size() == 1){
+                		list.add(new RemoteAndLocalPrincipalPair(user,principals.iterator().next()));
+                	}                	
+				}
+            }           
             BrowserIterator iterator = new DatabaseBrowserIterator(
                     list, resultSetTitleList, resultSetTypeList,
                     windowSize);
@@ -126,13 +136,13 @@
             this.clearBrowserIterator(request);
         }
         Context context = this.getContext(request);        
-        String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedUrl");
+        String selectedSite = (String)PortletMessaging.receive(request, "site", "selectedName");
         if (selectedSite != null)
         {        
             context.put("currentSite", selectedSite);
         }        
         
-        // get relative link, TODO: encapsulate Jetspeed links access into component
+        // get relative link, TOremoveCredentialsForSiteDO: encapsulate Jetspeed links access
into component
         String userChooser = SecurityUtil.getAbsoluteUrl(request, "/Administrative/choosers/users.psml");
         String groupChooser = SecurityUtil.getAbsoluteUrl(request, "/Administrative/choosers/groups.psml");
         
@@ -148,6 +158,16 @@
         super.doView(request, response);
     }
         
+    protected JetspeedPrincipal getJetspeedPrincipal(String principalType, String principalName)
throws SecurityException {
+    	JetspeedPrincipal foundPrincipal = null;
+    	if (principalType.equals(JetspeedPrincipalType.USER)){
+    		foundPrincipal = userManager.getUser(principalName);	
+    	} else if (principalType.equals(JetspeedPrincipalType.GROUP)){
+    		foundPrincipal = groupManager.getGroup(principalName);
+    	}
+    	return foundPrincipal;
+    }
+    
     public void processAction(ActionRequest request, ActionResponse response)
     throws PortletException, IOException
     {
@@ -155,48 +175,47 @@
         {
             String refresh = request.getParameter("sso.refresh");
             String add = request.getParameter("sso.add");
-            String delete = request.getParameter("ssoDelete");
-           
+            String deleteUser = request.getParameter("ssoDelete.user");
+            String deleteGroup = request.getParameter("ssoDelete.group");
+            
             if (refresh != null)
             {
                 this.clearBrowserIterator(request);
             }
-            else if (delete != null && !(isEmpty(delete)))
+            else if (StringUtils.isNotEmpty(deleteUser) || StringUtils.isNotEmpty(deleteGroup)
)
             {
-                try
-                {
-                    String siteName = (String)PortletMessaging.receive(request, "site", "selectedUrl");
                                           
-                    SSOSite site = sso.getSite(siteName);
-                    User user = null;
-                    try
-                    {
-                        user = userManager.getUser(delete);   
-                    }
-                    catch(SecurityException se)
-                    {
-                        // User doesn't exist -- maybe a group
-                        user =null;
+            	String principalType = null;
+            	String principalName = null;
+            	if (StringUtils.isNotEmpty(deleteUser)){
+            		principalType = JetspeedPrincipalType.USER;
+                	principalName=deleteUser;
+                } else {                    
+                    if (StringUtils.isNotEmpty(deleteGroup)){                	
+                    	principalName = deleteGroup;
+                    	principalType = JetspeedPrincipalType.GROUP;
                     }
+                }
+            	try
+                {
+                    String siteName = (String)PortletMessaging.receive(request, "site", "selectedName");
                                           
+                    SSOSite site = sso.getSiteByName(siteName);
                     
                     if ( site != null )
                     {
-                        /*
-	                     * If the user is null try to remove a group
-	                     */
-	                    if ( user != null)
-	                    {
-	                        // Remove USER
-	                        Subject subject = userManager.getSubject(user); 
-	                        sso.removeCredentialsForSite(subject, site.getSiteURL());
-	                        this.clearBrowserIterator(request);
-	                    }
-	                    else
-	                    {
-	                        // Try group removal
-	                        String fullPath = "/group/" + delete;
-	                        sso.removeCredentialsForSite(fullPath, site.getSiteURL());
-	                        this.clearBrowserIterator(request);
-	                    }  
+                        
+                    	JetspeedPrincipal principal = getJetspeedPrincipal(principalType,principalName);
+                    	if (principal != null){
+                    		Collection<SSOUser> ssoUsers = sso.getRemoteUsers(site, principal);
+                    		if (ssoUsers != null && ssoUsers.size() == 1){
+                    			sso.removeUser(ssoUsers.iterator().next());
+                    		} else {
+                        		// TODO: provide feedback, sso user not found
+                        	}		
+                    	} else {
+                    		// TODO: provide feedback, user not found
+                    	}	
+                    	
+                        this.clearBrowserIterator(request);
 	                 }
                 }
                 catch (SSOException e)
@@ -222,34 +241,31 @@
                 if (principalType == null || principalType.length() == 0 )
                     principalType = "user";
                 
-                if (!(isEmpty(remotePrincipal) || isEmpty(remotePrincipal) || isEmpty(remoteCredential)))
+                if (!(StringUtils.isEmpty(remotePrincipal) || StringUtils.isEmpty(remotePrincipal)
|| StringUtils.isEmpty(remoteCredential)))
                 {
                     try
                     {
-                        String siteName = (String)PortletMessaging.receive(request, "site",
"selectedUrl");                        
-                        SSOSite site = sso.getSite(siteName);
-                        Subject subject = null;
-                        String groupFullPath = null;
-                        
-                        if (principalType.compareTo("user") == 0)
-                        {
-                            User user = userManager.getUser(portalPrincipal);    
-                            subject = userManager.getSubject(user);
-                        }
-                        else
-                        {
-                            // Create fullPath
-                            groupFullPath = "/group/" + portalPrincipal;
-                          }
+                        String siteName = (String)PortletMessaging.receive(request, "site",
"selectedName");                        
+                        SSOSite site = sso.getSiteByName(siteName);
+
+                        JetspeedPrincipal localPrincipal = getJetspeedPrincipal(principalType,
portalPrincipal);
                         
-                        if (site != null && (subject != null || groupFullPath !=
null) )
+                        if (site != null && localPrincipal != null )
                         {
-                            if (subject != null )
-                                sso.addCredentialsForSite(subject, remotePrincipal, site.getSiteURL(),
remoteCredential);
-                            else
-                                sso.addCredentialsForSite(groupFullPath, remotePrincipal,
site.getSiteURL(), remoteCredential);
-                            
-                            this.clearBrowserIterator(request);
+                        	if (sso.getRemoteUsers(site, localPrincipal).size() > 0){
+                                try
+                                {
+                                    // TODO: fixme, bug in Pluto on portlet session
+                                    PortletMessaging.publish(request, "SSODetails", "status",
new StatusMessage("Could not add remote user: portal principal "+localPrincipal.getName()+"
is already associated with a remote user for this site!", StatusMessage.ERROR));
+                                }
+                                catch (Exception e)
+                                {
+                                    System.err.println("Failed to publish message: " + e);
+                                }
+                        	} else {
+                            	sso.addUser(site, localPrincipal, remotePrincipal, remoteCredential);
                           
+                                this.clearBrowserIterator(request);
+                        	}
                         }
                     }
                     catch (SSOException e)
@@ -266,14 +282,24 @@
         super.processAction(request, response);
             
     }
+    
+    public static class RemoteAndLocalPrincipalPair {
+    	SSOUser remotePrincipal;
+    	JetspeedPrincipal portalPrincipal;
+    	
+    	RemoteAndLocalPrincipalPair(SSOUser remoteUser, JetspeedPrincipal portalPrincipal){
+    		this.remotePrincipal=remoteUser;
+    		this.portalPrincipal=portalPrincipal;
+    	}
 
-    private boolean isEmpty(String s)
-    {
-        if (s == null) return true;
-        
-        if (s.trim().equals("")) return true;
-        
-        return false;
+		public SSOUser getRemotePrincipal() {
+			return remotePrincipal;
+		}
+
+		public JetspeedPrincipal getPortalPrincipal() {			
+			return portalPrincipal;
+		}
+    	
     }
-    
+
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-details.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-details.vm?rev=734959&r1=734958&r2=734959&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-details.vm
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-details.vm
Fri Jan 16 02:17:03 2009
@@ -54,14 +54,14 @@
     <td width='24' class="portlet-section-header">&nbsp;</td>    
     <td class=""></td>        
   </tr>
-  #foreach ( $principal in $table )
+  #foreach ( $pair in $table )
   <tr>
     #if ($velocityCount % 2 == 0)
        #set($rowstyle = "portlet-section-body")
     #else
        #set($rowstyle = "portlet-section-alternate")
     #end    
-     #if ($currentP == $principal)
+     #if ($currentP == $pair.portalPrincipal.name)
        <td class="$rowstyle" nowrap width='12'>
          <img src="/j2-admin/images/selected.gif" width="7" height="12" border="0" vspace="2"/>
        </td>
@@ -72,14 +72,14 @@
 	 #end   	 
       <td class="$rowstyle" nowrap width="25%">
         #set ($action = $renderResponse.createActionURL())
-        $action.setParameter('ssoPrincipal', $principal.PortalPrincipalName)
-        <div align="center">$principal.PortalPrincipalName</div>
+        $action.setParameter('ssoPrincipal', $pair.portalPrincipal.name)
+        <div align="center">$pair.portalPrincipal.name</div>
       </td>
       <td class="$rowstyle" nowrap width="25%">
-        <div align="center">$principal.RemotePrincipalName</div>
+        <div align="center">$pair.remotePrincipal.name</div>
       </td>      
        <td class="$rowstyle" nowrap width='24' align='center'>
-         <a href="javascript:YesNoPopup('$MESSAGES.getString('confirmToDeleteRemote')','$MESSAGES.getString('confirmDelete')','securityform','ssoDelete','$principal.PortalPrincipalName','YesNoReturnMethod()');">
+         <a href="javascript:YesNoPopup('$MESSAGES.getString('confirmToDeleteRemote')','$MESSAGES.getString('confirmDelete')','securityform','ssoDelete.${pair.portalPrincipal.type.name}','$pair.portalPrincipal.name','YesNoReturnMethod()');">
            <img src="/j2-admin/images/waste_bin.gif" width="20" height="15" border="0"/>
           
          </a>
        </td>      
@@ -90,7 +90,8 @@
 <br/>
 <form name='securityform' action="$renderResponse.createActionURL()" method="post">
 <input type='hidden' name='principal.type' value='user'/>
-<input name='ssoDelete' type='hidden' value=''/>
+<input name='ssoDelete.user' type='hidden' value=''/>
+<input name='ssoDelete.group' type='hidden' value=''/>
 <table>
   <tr colspan="2" align="right">
     <td nowrap class="portlet-section-alternate" align="right">$MESSAGES.getString('portalPrincipal')&nbsp;</td>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-view.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-view.vm?rev=734959&r1=734958&r2=734959&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-view.vm
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/security/sso/sites-view.vm
Fri Jan 16 02:17:03 2009
@@ -64,11 +64,11 @@
      
       <td class="$rowstyle" nowrap width="40%">
         #set ($action = $renderResponse.createActionURL())
-        $action.setParameter('ssoSite', $ssoUrl)
+        $action.setParameter('ssoSite', $ssoName)
         <div align="center"><a href='$action'>$ssoName</a></div>
       </td>
        <td class="$rowstyle" nowrap width='24' align='center'>
-         <a href="javascript:YesNoPopup('$MESSAGES.getString('confirmtodeletesite')','$MESSAGES.getString('confirmdelete')','ssoForm','ssoDelete','$ssoUrl','YesNoReturnMethod()');">
+         <a href="javascript:YesNoPopup('$MESSAGES.getString('confirmtodeletesite')','$MESSAGES.getString('confirmdelete')','ssoForm','ssoDelete','$ssoName','YesNoReturnMethod()');">
            <img src="/j2-admin/images/waste_bin.gif" width="20" height="14" border="0"/>
           
          </a>
        </td>      



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