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/jetspeed-api/src/java/org/apache/jetspeed/sso SSOProvider.java
Date Mon, 03 Jan 2005 08:13:37 GMT
taylor      2005/01/03 00:13:37

  Modified:    components/sso/src/java/org/apache/jetspeed/sso/impl
                        PersistenceBrokerSSOProvider.java
               components/sso/src/test/org/apache/jetspeed/sso
                        TestSSOComponent.java
               jetspeed-api/src/java/org/apache/jetspeed/sso
                        SSOProvider.java
  Log:
  http://issues.apache.org/jira/browse/JS2-178
  
  add a few apis to maintain sso sites
  
  Revision  Changes    Path
  1.11      +70 -14    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PersistenceBrokerSSOProvider.java	1 Jan 2005 00:00:05 -0000	1.10
  +++ PersistenceBrokerSSOProvider.java	3 Jan 2005 08:13:37 -0000	1.11
  @@ -15,13 +15,10 @@
    */
   package org.apache.jetspeed.sso.impl;
   
  -import java.security.Principal;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Hashtable;
   import java.util.Iterator;
  -import java.util.LinkedList;
  -import java.util.List;
   
   import org.apache.jetspeed.security.UserPrincipal;
   
  @@ -41,7 +38,6 @@
   
   import org.apache.jetspeed.security.SecurityHelper;
   import org.apache.jetspeed.security.BasePrincipal;
  -import org.apache.jetspeed.security.User;
   import org.apache.jetspeed.security.om.InternalCredential;
   import org.apache.jetspeed.security.om.InternalUserPrincipal;
   import org.apache.jetspeed.security.om.impl.InternalCredentialImpl;
  @@ -59,10 +55,10 @@
   * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
   */
   public class PersistenceBrokerSSOProvider extends
  -		InitablePersistenceBrokerDaoSupport implements SSOProvider {
  -	
  +		InitablePersistenceBrokerDaoSupport implements SSOProvider 
  +{	
   	private Hashtable mapSite = new Hashtable();	
  -    	/**
  +  	/**
        * PersitenceBrokerSSOProvider()
        * @param repository Location of repository mapping file.  Must be available within
the classpath.
        * @param prefsFactoryImpl <code>java.util.prefs.PreferencesFactory</code>
implementation to use.
  @@ -79,8 +75,8 @@
       {
           Criteria queryCriteria = new Criteria();
           Query query = QueryFactory.newQuery(SSOSiteImpl.class, queryCriteria);
  -        Iterator result = getPersistenceBrokerTemplate().getIteratorByQuery(query);
  -        return result;
  +        Collection c = getPersistenceBrokerTemplate().getCollectionByQuery(query);
  +        return c.iterator();        
       }
       
   	/* (non-Javadoc)
  @@ -228,8 +224,6 @@
            }
            // Add to site
            this.mapSite.put(site, ssoSite);
  -         // Clear cache
  -         //this.mapSite.clear();
   	}
   
   	/* (non-Javadoc)
  @@ -302,8 +296,6 @@
               throw new SSOException(SSOException.FAILED_STORING_SITE_INFO_IN_DB + e.toString()
);
            }
            
  -         // Clear cache
  -       //  this.mapSite.clear();
   	}
   	
   	/**
  @@ -594,7 +586,7 @@
   			while (itPrincipals.hasNext())
   			{
   				SSOPrincipal tmp = (SSOPrincipal)itPrincipals.next();
  -				if (         tmp.getFullPath().compareToIgnoreCase(fullPath) == 0
  +				if (tmp.getFullPath().compareToIgnoreCase(fullPath) == 0
   				        && tmp.getSiteID() == site.getSiteId())
   				{
   					// Found -- get the remotePrincipal
  @@ -658,4 +650,68 @@
   	    }
   	    return null;
   	}
  +    
  +    public SSOSite getSite(String siteName)
  +    {
  +        Criteria filter = new Criteria();
  +        filter.addEqualTo("name", siteName);
  +        Query query = QueryFactory.newQuery(SSOSiteImpl.class, filter);
  +        SSOSite site = (SSOSite) getPersistenceBrokerTemplate().getObjectByQuery(query);
  +        return site;       
  +    }
  +    
  +    public void updateSite(SSOSite site)
  +    throws SSOException
  +    {
  +        try
  +        {
  +            getPersistenceBrokerTemplate().store(site);
  +            this.mapSite.put(site.getName(), site);                        
  +        }
  +        catch (Exception e)
  +        {
  +            String msg = "Unable to remove SSO Site: " + site.getName();
  +            logger.error(msg, e);
  +            throw new SSOException(msg, e);
  +        }        
  +    }
  +    
  +    public void addSite(String siteName, String siteUrl)
  +    throws SSOException
  +    {
  +        try
  +        {
  +            SSOSite ssoSite = new SSOSiteImpl();
  +            ssoSite.setSiteURL(siteUrl);
  +            ssoSite.setName(siteName);
  +            ssoSite.setCertificateRequired(false);
  +            ssoSite.setAllowUserSet(true);            
  +            getPersistenceBrokerTemplate().store(ssoSite);
  +            this.mapSite.put(siteName, ssoSite);            
  +        }
  +        catch (Exception e)
  +        {
  +            String msg = "Unable to remove SSO Site: " + siteName;
  +            logger.error(msg, e);
  +            throw new SSOException(msg, e);
  +        }                
  +    }
  +    
  +    public void removeSite(SSOSite site)
  +    throws SSOException
  +    {
  +        try
  +        {
  +            getPersistenceBrokerTemplate().delete(site);
  +            this.mapSite.remove(site);
  +
  +        }
  +        catch (Exception e)
  +        {
  +            String msg = "Unable to remove SSO Site: " + site.getName();
  +            logger.error(msg, e);
  +            throw new SSOException(msg, e);
  +        }        
  +    }
  +        
   }
  
  
  
  1.9       +9 -0      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestSSOComponent.java	5 Dec 2004 00:46:38 -0000	1.8
  +++ TestSSOComponent.java	3 Jan 2005 08:13:37 -0000	1.9
  @@ -27,6 +27,7 @@
   
   import java.security.Principal;
   import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.Set;
   
   
  @@ -211,6 +212,14 @@
       		throw new Exception(ssoex.getMessage());
   		}
   		*/
  +        
  +        Iterator sites = ssoBroker.getSites("");
  +        while (sites.hasNext())
  +        {
  +            SSOSite site = (SSOSite)sites.next();
  +            System.out.println("Site = " + site.getName());
  +        }
  +        
       }
   
       /**
  
  
  
  1.6       +9 -0      jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java
  
  Index: SSOProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/sso/SSOProvider.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SSOProvider.java	1 Jan 2005 00:00:05 -0000	1.5
  +++ SSOProvider.java	3 Jan 2005 08:13:37 -0000	1.6
  @@ -52,4 +52,13 @@
           throws SSOException;
       
       Iterator getSites(String filter);
  +    
  +    SSOSite getSite(String siteName);
  +    
  +    void updateSite(SSOSite site) throws SSOException;
  +    
  +    void addSite(String siteName, String siteUrl) throws SSOException; 
  +    
  +    void removeSite(SSOSite site) throws SSOException;
  +    
   }
  
  
  

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