1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
105 if (null != this.manager)
106 {
107
108
109 try {
110 return this.manager.setPassword(ident, value) ;
111 }
112
113
114 catch (RemoteException ouch)
115 {
116
117
118 serviceException(ouch) ;
119 securityException(ouch) ;
120 identifierException(ouch) ;
121
122
123 throw new CommunityServiceException(
124 "WebService call failed - " + ouch,
125 ouch
126 ) ;
127 }
128 }
129
130
131 else {
132 throw new CommunityServiceException(
133 "Service not initialised"
134 ) ;
135 }
136 }
137 }