KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > interceptor > ClientInterceptor


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * ClientInterceptor.java
20  *
21  * This object is responsible for supplying the authentication information on
22  * the client side of a connection for the request onto a server.
23  */

24
25 // package path
26
package com.rift.coad.lib.interceptor;
27
28 // the thread permission container
29
import com.rift.coad.lib.security.ThreadsPermissionContainer;
30 import com.rift.coad.lib.security.ThreadPermissionSession;
31 import com.rift.coad.lib.interceptor.credentials.Credential;
32 import com.rift.coad.lib.interceptor.credentials.Session;
33
34 /**
35  * This object is responsible for supplying the authentication information on
36  * the client side of a connection for the request onto a server.
37  *
38  * @author Brett Chaldecott
39  */

40 public class ClientInterceptor {
41     
42     // the classes private member variables
43
private ThreadsPermissionContainer permissionContainer = null;
44     
45     /**
46      * Creates a new instance of ClientInterceptor
47      */

48     protected ClientInterceptor(ThreadsPermissionContainer permissionContainer) {
49         this.permissionContainer = permissionContainer;
50     }
51     
52     
53     /**
54      * This method retrieves the threads session credentials.
55      *
56      * @return The credentials for this session.
57      * @exception InterceptorException
58      */

59     public Credential getSessionCredential() throws InterceptorException {
60         try {
61             ThreadPermissionSession permission = permissionContainer.
62                     getSession();
63             Session session = new Session(permission.getUser().getName(),
64                     permission.getUser().getSessionId(),
65                     permission.getPrincipals());
66             return session;
67         } catch (Exception JavaDoc ex) {
68             throw new InterceptorException(
69                     "Failed to retrieve the session credentials : " +
70                     ex.getMessage(),ex);
71         }
72     }
73     
74 }
75
Popular Tags