View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/client/src/java/org/astrogrid/community/client/security/manager/SecurityManagerCoreDelegate.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/09/16 23:18:08 $</cvs:date>
5    * <cvs:version>$Revision: 1.8 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: SecurityManagerCoreDelegate.java,v $
9    *   Revision 1.8  2004/09/16 23:18:08  dave
10   *   Replaced debug logging in Community.
11   *   Added stream close() to FileStore.
12   *
13   *   Revision 1.7.82.1  2004/09/16 09:58:48  dave
14   *   Replaced debug with commons logging ....
15   *
16   *   Revision 1.7  2004/06/18 13:45:19  dave
17   *   Merged development branch, dave-dev-200406081614, into HEAD
18   *
19   *   Revision 1.6.32.3  2004/06/17 15:10:03  dave
20   *   Removed unused imports (PMD report).
21   *
22   *   Revision 1.6.32.2  2004/06/17 13:38:58  dave
23   *   Tidied up old CVS log entries
24   *
25   * </cvs:log>
26   *
27   */
28  package org.astrogrid.community.client.security.manager ;
29  
30  import org.apache.commons.logging.Log ;
31  import org.apache.commons.logging.LogFactory ;
32  
33  import java.rmi.RemoteException ;
34  
35  import org.astrogrid.community.common.security.manager.SecurityManager ;
36  import org.astrogrid.community.client.service.CommunityServiceCoreDelegate ;
37  
38  import org.astrogrid.community.common.exception.CommunityServiceException  ;
39  import org.astrogrid.community.common.exception.CommunitySecurityException ;
40  import org.astrogrid.community.common.exception.CommunityIdentifierException  ;
41  
42  /***
43   * The core delegate code for our SecurityManager service.
44   * This acts as a wrapper for a SecurityManager service, and handles any RemoteExceptions internally.
45   *
46   */
47  public class SecurityManagerCoreDelegate
48      extends CommunityServiceCoreDelegate
49      implements SecurityManager, SecurityManagerDelegate
50      {
51      /***
52       * Our debug logger.
53       *
54       */
55      private static Log log = LogFactory.getLog(SecurityManagerCoreDelegate.class);
56  
57      /***
58       * Public constructor.
59       *
60       */
61      protected SecurityManagerCoreDelegate()
62          {
63          }
64  
65      /***
66       * Our SecurityManager service.
67       *
68       */
69      private SecurityManager manager = null ;
70  
71      /***
72       * Get a reference to our SecurityManager service.
73       *
74       */
75      protected SecurityManager getSecurityManager()
76          {
77          return this.manager ;
78          }
79  
80      /***
81       * Set our our SecurityManager service.
82       *
83       */
84      protected void setSecurityManager(SecurityManager manager)
85          {
86          this.setCommunityService(manager) ;
87          this.manager = manager ;
88          }
89  
90      /***
91       * Set an Account password.
92       * @param account  The account ident.
93       * @param password The account password.
94       * @return True if the password was set.
95       * @throws CommunitySecurityException If the password change fails.
96       * @throws CommunityServiceException If there is an internal error in service.
97       * @throws CommunityIdentifierException If the account identifier is invalid.
98       *
99       */
100     public boolean setPassword(String ident, String value)
101         throws CommunityServiceException, CommunitySecurityException, CommunityIdentifierException
102         {
103         //
104         // If we have a valid service reference.
105         if (null != this.manager)
106             {
107             //
108             // Try calling the service method.
109             try {
110                 return this.manager.setPassword(ident, value) ;
111                 }
112             //
113             // Catch anything that went BANG.
114             catch (RemoteException ouch)
115                 {
116                 //
117                 // Try converting the Exception.
118                 serviceException(ouch) ;
119                 securityException(ouch) ;
120                 identifierException(ouch) ;
121                 //
122                 // If we get this far, then we don't know what it is.
123                 throw new CommunityServiceException(
124                     "WebService call failed - " + ouch,
125                     ouch
126                     ) ;
127                 }
128             }
129         //
130         // If we don't have a valid service.
131         else {
132             throw new CommunityServiceException(
133                 "Service not initialised"
134                 ) ;
135             }
136         }
137     }