gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / identitymanagement / spi / AbstractSimpleIdentity.java @ 1771
History | View | Annotate | Download (1.68 KB)
1 |
package org.gvsig.tools.identitymanagement.spi; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
import org.gvsig.tools.identitymanagement.Rule; |
5 |
import org.gvsig.tools.identitymanagement.SimpleIdentity; |
6 |
import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
7 |
|
8 |
|
9 |
public abstract class AbstractSimpleIdentity implements SimpleIdentity { |
10 |
protected final SimpleIdentityManager manager; |
11 |
|
12 |
public AbstractSimpleIdentity(SimpleIdentityManager manager) {
|
13 |
this.manager = manager;
|
14 |
} |
15 |
|
16 |
public SimpleIdentityManager getManager() {
|
17 |
return this.manager; |
18 |
} |
19 |
|
20 |
@Override
|
21 |
public String getName() { |
22 |
return this.getID(); |
23 |
} |
24 |
|
25 |
@Override
|
26 |
public String getFullName() { |
27 |
return this.getName(); |
28 |
} |
29 |
|
30 |
@Override
|
31 |
public List getAttributeNames() { |
32 |
return null; |
33 |
} |
34 |
|
35 |
@Override
|
36 |
public String getAttribute(String name) { |
37 |
return null; |
38 |
} |
39 |
|
40 |
@Override
|
41 |
public boolean isAuthorized(String actionName) { |
42 |
return this.isAuthorized(actionName, null, null); |
43 |
} |
44 |
|
45 |
@Override
|
46 |
public boolean isAuthorized(String actionName, Object resource, String resourceName) { |
47 |
for (Rule rule : this.manager.getRules()) { |
48 |
if( rule.accept(actionName) ) {
|
49 |
return rule.isAuthorized(this, actionName, resource, resourceName); |
50 |
} |
51 |
} |
52 |
return false; |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public boolean canRead(Object resource, String resourceName) { |
57 |
return this.isAuthorized(READ_AUTHORIZATION, resource, resourceName); |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public boolean canWrite(Object resource, String resourceName) { |
62 |
return this.isAuthorized(WRITE_AUTHORIZATION, resource, resourceName); |
63 |
} |
64 |
|
65 |
} |