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 @ 1215

History | View | Annotate | Download (1.06 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("guest");
16
    }
17
    
18
    public void login(String domain, String identityid, String password) throws UnauthorizedException {
19
        this.current = new DumbIdentity(identityid);
20
    }
21

    
22
    public void logout() {
23
        this.current = null;
24
    }
25

    
26
    public SimpleIdentity getCurrentIdentity() {
27
        return this.current;
28
    }
29

    
30
    public void sudo(String domain, String identityid, Runnable acction) {
31
        SimpleIdentity save = this.current;
32
        this.current = new DumbIdentity(identityid);
33
        try {
34
            acction.run();
35
        } finally {
36
            this.current = save;
37
        }
38
    }
39

    
40

    
41
}