taylor      2005/01/04 15:17:45

  Modified:    components/sso/src/java/org/apache/jetspeed/sso/impl
                        PersistenceBrokerSSOProvider.java
                        SSOContextImpl.java
               components/sso/src/test/org/apache/jetspeed/sso
                        TestSSOComponent.java
               components/web-content/src/java/org/apache/jetspeed/portlet
                        SSOIFramePortlet.java SSOWebContentPortlet.java
  Log:
  continued work on SSO Admin -- details view is now attached to the current 
row of the SSO Browser
  still under construction
  
  changed SSOContext API
  
  Revision  Changes    Path
  1.12      +61 -10    
jakarta-jetspeed-2/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java
  
  Index: PersistenceBrokerSSOProvider.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/sso/src/java/org/apache/jetspeed/sso/impl/PersistenceBrokerSSOProvider.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PersistenceBrokerSSOProvider.java 3 Jan 2005 08:13:37 -0000       1.11
  +++ PersistenceBrokerSSOProvider.java 4 Jan 2005 23:17:45 -0000       1.12
  @@ -19,6 +19,8 @@
   import java.util.Collection;
   import java.util.Hashtable;
   import java.util.Iterator;
  +import java.util.List;
  +import java.util.StringTokenizer;
   
   import org.apache.jetspeed.security.UserPrincipal;
   
  @@ -109,7 +111,7 @@
                    return false;       // no entry
                
                // Get remote Principal that matches the site and the principal
  -             if (FindRemoteMatch(remoteForPrincipals, remoteForSite) == null 
)
  +             if (findRemoteMatch(remoteForPrincipals, remoteForSite) == null 
)
                {
                    return false;       // No entry
                }
  @@ -181,7 +183,7 @@
                    Collection remoteForSite = ssoSite.getRemotePrincipals();
                    if ( remoteForSite != null)
                    {
  -                     if (FindRemoteMatch(principal.getRemotePrincipals(), 
remoteForSite) != null )
  +                     if (findRemoteMatch(principal.getRemotePrincipals(), 
remoteForSite) != null )
                        {
                            // Entry exists can't to an add has to call update
                            throw new 
SSOException(SSOException.REMOTE_PRINCIPAL_EXISTS_CALL_UPDATE);
  @@ -262,7 +264,7 @@
                            throw new 
SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
                        
                        // Get remote Principal that matches the site and the 
principal
  -                     if ((remotePrincipal = 
FindRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
  +                     if ((remotePrincipal = 
findRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
                        {
                            throw new 
SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
                        }
  @@ -339,7 +341,7 @@
                            throw new 
SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
                        
                        // Get remote Principal that matches the site and the 
principal
  -                     if ((remotePrincipal = 
FindRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
  +                     if ((remotePrincipal = 
findRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
                        {
                            throw new 
SSOException(SSOException.NO_CREDENTIALS_FOR_SITE);
                        }
  @@ -443,7 +445,7 @@
                    return null;        // no entry
                
                // Get remote Principal that matches the site and the principal
  -             if ((remotePrincipal = FindRemoteMatch(remoteForPrincipals, 
remoteForSite)) == null )
  +             if ((remotePrincipal = findRemoteMatch(remoteForPrincipals, 
remoteForSite)) == null )
                {
                    return null;        // No entry
                }
  @@ -462,16 +464,25 @@
                }
                
                //      Create new context
  -             String name = remotePrincipal.getFullPath();
  -             int ix = name.lastIndexOf('/');
  -             if ( ix != -1)
  -                     name = name.substring(ix + 1);
  +             String name = stripPrincipalName(remotePrincipal.getFullPath());
                
                SSOContext context = new 
SSOContextImpl(credential.getPrincipalId(), name, credential.getValue());
                
                return context;
        }
        
  +    private String stripPrincipalName(String fullPath)
  +    {
  +        String name;
  +        int ix = fullPath.lastIndexOf('/');
  +        if ( ix != -1)
  +            name = fullPath.substring(ix + 1);
  +        else
  +            name = new String(fullPath);
  +        
  +        return name;        
  +    }
  +
        /*
         * Get a Collection of remote Principals for the logged in principal 
identified by the full path
         */
  @@ -614,7 +625,7 @@
         * 
         * 
         */
  -     private InternalUserPrincipal FindRemoteMatch(Collection 
remoteForPrincipals, Collection remoteForSite)
  +     private InternalUserPrincipal findRemoteMatch(Collection 
remoteForPrincipals, Collection remoteForSite)
        {
            // Iterate over the lists and find match
            Iterator itRemoteForPrincipals = remoteForPrincipals.iterator();
  @@ -714,4 +725,44 @@
           }        
       }
           
  +    public List getPrincipalsForSite(SSOSite site)
  +    {
  +        List list = new ArrayList();
  +        Iterator principals = site.getRemotePrincipals().iterator();
  +        while (principals.hasNext())
  +        {
  +            InternalUserPrincipal remotePrincipal = 
(InternalUserPrincipal)principals.next();
  +            String fullpath = remotePrincipal.getFullPath();
  +            Iterator creds = remotePrincipal.getCredentials().iterator();
  +            while (creds.hasNext())
  +            {
  +                InternalCredential cred = (InternalCredential) creds.next();
  +                SSOContext context = new 
SSOContextImpl(remotePrincipal.getPrincipalId(), 
  +                                                
stripPrincipalName(remotePrincipal.getFullPath()), 
  +                                                cred.getValue(), 
  +                                                
stripPortalPrincipalName(remotePrincipal.getFullPath()));
  +                list.add(context);
  +            }
  +        }
  +        return list;
  +    }
  +
  +    
  +    private String stripPortalPrincipalName(String fullPath)
  +    {
  +        StringTokenizer tokenizer = new StringTokenizer(fullPath, "/");
  +        while (tokenizer.hasMoreTokens())
  +        {
  +            String token = tokenizer.nextToken();
  +            if (token.equals("user"))
  +            {
  +                if (tokenizer.hasMoreTokens())
  +                {
  +                    return tokenizer.nextToken();
  +                }
  +            }
  +        }
  +        return fullPath;        
  +    }
  +    
   }
  
  
  
  1.2       +40 -21    
jakarta-jetspeed-2/components/sso/src/java/org/apache/jetspeed/sso/impl/SSOContextImpl.java
  
  Index: SSOContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/sso/src/java/org/apache/jetspeed/sso/impl/SSOContextImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSOContextImpl.java       16 Nov 2004 19:08:47 -0000      1.1
  +++ SSOContextImpl.java       4 Jan 2005 23:17:45 -0000       1.2
  @@ -27,42 +27,61 @@
   */
   public class SSOContextImpl implements SSOContext {
   
  -     private long    userID;
  -     private String password;
  -     private String userName;
  +     private long    remotePrincipalId;
  +     private String remoteCredential;
  +     private String remotePrincipal;
  +    private String portalPrincipal;
        
        /**
         * Constructor takes all arguments since members can't be altered
         */
  -     public SSOContextImpl(long userID, String userName, String pwd) {
  -             super();
  -             
  -             this.userID                     =       userID;
  -             this.userName   =       userName;
  -             this.password           =       pwd;
  +     public SSOContextImpl(long remotePrincipalId, String remotePrincipal, 
String remoteCredential) 
  +    {
  +             super();                
  +             this.remotePrincipalId = remotePrincipalId;
  +             this.remotePrincipal = remotePrincipal;
  +             this.remoteCredential = remoteCredential;
        }
   
  +    public SSOContextImpl(long remotePrincipalId, String remotePrincipal, 
String remoteCredential, String portalPrincipal) 
  +    {
  +        super();        
  +        this.remotePrincipalId = remotePrincipalId;
  +        this.remotePrincipal = remotePrincipal;
  +        this.remoteCredential = remoteCredential;
  +        this.portalPrincipal = portalPrincipal;
  +    }
  +    
        /* (non-Javadoc)
  -      * @see org.apache.jetspeed.sso.SSOContext#getUserID()
  +      * @see org.apache.jetspeed.sso.SSOContext#getRemotePrincipalId()
         */
  -     public long  getUserID() {
  -             
  -             return this.userID;
  +     public long  getRemotePrincipalId() 
  +    {                
  +             return this.remotePrincipalId;
        }
   
        /* (non-Javadoc)
  -      * @see org.apache.jetspeed.sso.SSOContext#getUserName()
  +      * @see org.apache.jetspeed.sso.SSOContext#getRemotePrincipal()
         */
  -     public String getUserName() {
  -             return this.userName;
  +     public String getRemotePrincipalName() 
  +    {
  +             return this.remotePrincipal;
        }
   
        /* (non-Javadoc)
  -      * @see org.apache.jetspeed.sso.SSOContext#getPassword()
  +      * @see org.apache.jetspeed.sso.SSOContext#getRemoteCredential()
         */
  -     public String getPassword() {
  -             
  -             return this.password;
  +     public String getRemoteCredential() 
  +    {                
  +             return this.remoteCredential;
        }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.sso.SSOContext#getPortalPrincipal()
  +     */
  +    public String getPortalPrincipalName() 
  +    {
  +        return this.portalPrincipal;
  +    }
  +    
   }
  
  
  
  1.10      +3 -3      
jakarta-jetspeed-2/components/sso/src/test/org/apache/jetspeed/sso/TestSSOComponent.java
  
  Index: TestSSOComponent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/sso/src/test/org/apache/jetspeed/sso/TestSSOComponent.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestSSOComponent.java     3 Jan 2005 08:13:37 -0000       1.9
  +++ TestSSOComponent.java     4 Jan 2005 23:17:45 -0000       1.10
  @@ -174,10 +174,10 @@
        
        // Test credential update
        SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
  -     System.out.println("SSO Credential: User:" + ssocontext.getUserName() + 
" Password: " + ssocontext.getPassword()+ " for site: " + TEST_URL);
  +     System.out.println("SSO Credential: User:" + 
ssocontext.getRemotePrincipalName() + " Password: " + 
ssocontext.getRemoteCredential()+ " for site: " + TEST_URL);
        
        SSOContext ssocontext2 = ssoBroker.getCredentials(subject, TEST_URL2);
  -     System.out.println("SSO Credential: User:" + ssocontext.getUserName() + 
" Password: " + ssocontext.getPassword() + " for site: " + TEST_URL2);
  +     System.out.println("SSO Credential: User:" + 
ssocontext.getRemotePrincipalName() + " Password: " + 
ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);
        
        try
                {
  @@ -186,7 +186,7 @@
                ssoBroker.updateCredentialsForSite(subject, REMOTE_USER , 
TEST_URL, REMOTE_PWD_2);
                
                ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
  -             System.out.println("SSO Credential updated: User:" + 
ssocontext.getUserName() + " Password: " + ssocontext.getPassword());
  +             System.out.println("SSO Credential updated: User:" + 
ssocontext.getRemotePrincipalName() + " Password: " + 
ssocontext.getRemoteCredential());
                
                }
        catch(SSOException ssoex)
  
  
  
  1.6       +5 -5      
jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java
  
  Index: SSOIFramePortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SSOIFramePortlet.java     2 Dec 2004 03:14:56 -0000       1.5
  +++ SSOIFramePortlet.java     4 Jan 2005 23:17:45 -0000       1.6
  @@ -82,8 +82,8 @@
               Subject subject = getSubject();                 
               String site = request.getPreferences().getValue("SRC", "");
               SSOContext context = sso.getCredentials(subject, site);
  -            getContext(request).put(SSO_FORM_PRINCIPAL, 
context.getUserName());
  -            getContext(request).put(SSO_FORM_CREDENTIAL, 
context.getPassword());
  +            getContext(request).put(SSO_FORM_PRINCIPAL, 
context.getRemotePrincipalName());
  +            getContext(request).put(SSO_FORM_CREDENTIAL, 
context.getRemoteCredential());
           }
           catch (SSOException e)
           {
  @@ -121,8 +121,8 @@
           {
               Subject subject = getSubject();                 
               SSOContext context = sso.getCredentials(subject, site);
  -            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, 
context.getUserName());
  -            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, 
context.getPassword());
  +            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, 
context.getRemotePrincipalName());
  +            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, 
context.getRemoteCredential());
           }
           catch (SSOException e)
           {
  
  
  
  1.3       +5 -5      
jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java
  
  Index: SSOWebContentPortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/web-content/src/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SSOWebContentPortlet.java 3 Dec 2004 04:29:56 -0000       1.2
  +++ SSOWebContentPortlet.java 4 Jan 2005 23:17:45 -0000       1.3
  @@ -136,8 +136,8 @@
           {
               Subject subject = getSubject();                 
               SSOContext context = sso.getCredentials(subject, site);
  -            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, 
context.getUserName());
  -            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, 
context.getPassword());
  +            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, 
context.getRemotePrincipalName());
  +            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, 
context.getRemoteCredential());
           }
           catch (SSOException e)
           {
  @@ -166,8 +166,8 @@
               Subject subject = getSubject();                 
               String site = request.getPreferences().getValue("SRC", "");
               SSOContext context = sso.getCredentials(subject, site);
  -            getContext(request).put(SSO_FORM_PRINCIPAL, 
context.getUserName());
  -            getContext(request).put(SSO_FORM_CREDENTIAL, 
context.getPassword());
  +            getContext(request).put(SSO_FORM_PRINCIPAL, 
context.getRemotePrincipalName());
  +            getContext(request).put(SSO_FORM_CREDENTIAL, 
context.getRemoteCredential());
           }
           catch (SSOException e)
           {
  
  
  

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

Reply via email to