gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / identitymanagement / impl / DumbIdentityManager.java @ 1771
History | View | Annotate | Download (1.24 KB)
1 | 1160 | jjdelcerro | |
---|---|---|---|
2 | package org.gvsig.tools.identitymanagement.impl; |
||
3 | |||
4 | import org.gvsig.tools.identitymanagement.SimpleIdentity; |
||
5 | 1215 | jjdelcerro | import org.gvsig.tools.identitymanagement.UnauthorizedException; |
6 | 1160 | jjdelcerro | import org.gvsig.tools.identitymanagement.spi.AbstractSimpleIdentityManager; |
7 | |||
8 | |||
9 | public class DumbIdentityManager extends AbstractSimpleIdentityManager { |
||
10 | |||
11 | private SimpleIdentity current = null; |
||
12 | |||
13 | public DumbIdentityManager() {
|
||
14 | 1211 | jjdelcerro | super();
|
15 | 1771 | jjdelcerro | this.current = new DumbIdentity(this, "guest"); |
16 | 1160 | jjdelcerro | } |
17 | 1771 | jjdelcerro | |
18 | @Override
|
||
19 | public SimpleIdentity getIdentity(String identityid) { |
||
20 | return new DumbIdentity(this, identityid); |
||
21 | } |
||
22 | 1160 | jjdelcerro | |
23 | 1771 | jjdelcerro | |
24 | @Override
|
||
25 | 1215 | jjdelcerro | public void login(String domain, String identityid, String password) throws UnauthorizedException { |
26 | 1771 | jjdelcerro | this.current = getIdentity(identityid);
|
27 | 1160 | jjdelcerro | } |
28 | |||
29 | 1771 | jjdelcerro | @Override
|
30 | 1160 | jjdelcerro | public void logout() { |
31 | this.current = null; |
||
32 | } |
||
33 | |||
34 | 1771 | jjdelcerro | @Override
|
35 | 1160 | jjdelcerro | public SimpleIdentity getCurrentIdentity() {
|
36 | return this.current; |
||
37 | } |
||
38 | |||
39 | 1771 | jjdelcerro | @Override
|
40 | 1215 | jjdelcerro | public void sudo(String domain, String identityid, Runnable acction) { |
41 | 1164 | jjdelcerro | SimpleIdentity save = this.current;
|
42 | 1771 | jjdelcerro | this.current = getIdentity(identityid);
|
43 | 1164 | jjdelcerro | try {
|
44 | acction.run(); |
||
45 | } finally {
|
||
46 | this.current = save;
|
||
47 | } |
||
48 | } |
||
49 | |||
50 | |||
51 | 1160 | jjdelcerro | } |