View Javadoc

1   /* 
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8   *
9   *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17  package org.apache.jetspeed.sso;
18  
19  import java.util.Collection;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import javax.security.auth.Subject;
24  
25  
26  /***
27  * <p>Utility component to handle SSO requests</p>
28  * 
29  * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
30  */
31  public interface SSOProvider
32  {   
33  	/***
34  	 * Init
35  	 * Called from the Spring Framework to initialize SSO Provider component
36  	 * @throws Exception
37  	 */
38     void init() throws Exception;
39     
40     /***
41      * This method first authenticates the the SSOSite and then forwards the request
42      * to the destination URL. The content will be returned as a string.
43      * If the SSOSite and the url match only one call will be executed since the
44      * authentication will be done while getting the result page.
45      * 
46      * @param userID
47      * @param url
48      * @param SSOSite
49      * @param bRefresh if true it refreshes the proxy connection if false a cached proxy will be used
50      * @return
51      * @throws SSOException
52      */
53     public String useSSO(Subject subject, String url, String SSOSite, boolean bRefresh) throws SSOException;
54     
55     /***
56      * Same as the method above except that the user will be authenticated against all
57      * SSOSites defined for the user before going to the destination site.
58      * 
59      * @param userID
60      * @param url
61      * @param bRefresh if true it refreshes the proxy connection if false a cached proxy will be used
62      * @return
63      * @throws SSOException
64      */
65     public String useSSO(Subject subject, String url, boolean bRefresh) throws SSOException;
66     
67      
68     /***
69      * Retrive cookies for an user by User full path
70      * @param fullPath
71      * @return
72      */
73     Collection getCookiesForUser(String fullPath);
74     
75     /***
76      * Retrive Cookies by Subject
77      * @param user
78      * @return
79      */
80     Collection getCookiesForUser(Subject user);
81     
82     
83     /***
84      * Public API's for SSO functinality
85      * @return
86      */
87  	boolean	hasSSOCredentials(Subject subject, String site);
88          
89  	SSOContext getCredentials(Subject subject, String site)  
90          throws SSOException;
91      
92  	void  addCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)  
93          throws SSOException;
94      
95      void  updateCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)  
96      throws SSOException;
97      
98  	void removeCredentialsForSite(Subject subject, String site)  
99          throws SSOException;
100     
101     /***
102      * return a list of SSOContext objects containing 
103      * both the portal principal, remote principal, and credentials
104      * 
105      * @param site
106      * @return list SSOContext objects 
107      */
108     List getPrincipalsForSite(SSOSite site);
109     
110     Iterator getSites(String filter);
111     
112     SSOSite getSite(String siteUrl);
113     
114     void updateSite(SSOSite site) throws SSOException;
115     
116     void addSite(String siteName, String siteUrl) throws SSOException; 
117     
118     void removeSite(SSOSite site) throws SSOException;
119     
120     /***
121      * addCredentialsForSite()
122      * @param fullPath
123      * @param remoteUser
124      * @param site
125      * @param pwd
126      * @throws SSOException
127      */
128     void addCredentialsForSite(String fullPath, String remoteUser, String site, String pwd) throws SSOException;
129     
130     /***
131      * removeCredentialsForSite()
132      * @param fullPath
133      * @param site
134      * @throws SSOException
135      */
136     void removeCredentialsForSite(String fullPath, String site) throws SSOException;
137 
138     /* Retrive site information */
139     String getSiteURL(String site);
140     String getSiteName(String site); 
141     
142     void	setRealmForSite(String site, String realm) throws SSOException;
143     String	getRealmForSite(String site) throws SSOException;
144     
145     /***
146      * Get all SSOSites that the principal has access to
147      * @param userId
148      * @return
149      */
150     public Collection getSitesForPrincipal(String userId);
151     
152     /***
153      * Add a new site that uses Challenge / Response Authentication
154      * @param siteName
155      * @param siteUrl
156      * @param realm
157      * @throws SSOException
158      */
159     public void addSiteChallengeResponse(String siteName, String siteUrl, String realm) throws SSOException;
160     
161     /***
162      * Add a new site that uses Form Authentication
163      * @param siteName
164      * @param siteUrl
165      * @param realm
166      * @param userField
167      * @param pwdField
168      * @throws SSOException
169      */
170     public void addSiteFormAuthenticated(String siteName, String siteUrl, String realm, String userField, String pwdField) throws SSOException;
171     
172 }