Statistics
| Revision:

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

    
2
package org.gvsig.tools.identitymanagement.impl;
3

    
4
import org.gvsig.tools.identitymanagement.SimpleIdentity;
5
import org.gvsig.tools.identitymanagement.UnauthorizedException;
6
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
        super();
15
        this.current = new DumbIdentity(this, "guest");
16
    }
17

    
18
    @Override
19
    public SimpleIdentity getIdentity(String identityid) {
20
        return new DumbIdentity(this, identityid);
21
    }
22
    
23
    
24
    @Override
25
    public void login(String domain, String identityid, String password) throws UnauthorizedException {
26
        this.current = getIdentity(identityid);
27
    }
28

    
29
    @Override
30
    public void logout() {
31
        this.current = null;
32
    }
33

    
34
    @Override
35
    public SimpleIdentity getCurrentIdentity() {
36
        return this.current;
37
    }
38

    
39
    @Override
40
    public void sudo(String domain, String identityid, Runnable acction) {
41
        SimpleIdentity save = this.current;
42
        this.current = getIdentity(identityid);
43
        try {
44
            acction.run();
45
        } finally {
46
            this.current = save;
47
        }
48
    }
49

    
50

    
51
}