|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.servlet.MockPrincipal
public class MockPrincipal
Mock implementation of a user principal.
This class also provides convenient methods for specifying the user principal
roles.
MockContext mockContext = MockContext.initContext();
// Create a new user principal with the roles "user" and "manager"
MockPrincipal principal = new MockPrincipal("Bob", "user", "manager");
// Set the user principal on the request object
mockContext.getMockRequest().setUserPrincipal(principal);
Example usage with MockContainer:
MockContainer container = new MockContainer("c:/dev/myapp/web");
// Create a new user principal with the roles "user" and "manager"
MockPrincipal principal = new MockPrincipal("Bob", "user", "manager");
// Set the user principal on the request object
container.getRequest().setUserPrincipal(principal);
| Constructor Summary | |
|---|---|
MockPrincipal()
Constructs a new MockPrincipal instance. |
|
MockPrincipal(String name)
Constructs a new MockPrincipal instance for the given name. |
|
MockPrincipal(String name,
Set<String> roles)
Constructs a new MockPrincipal instance for the given name and roles. |
|
MockPrincipal(String name,
String... roles)
Constructs a new MockPrincipal instance for the given name and roles. |
|
| Method Summary | |
|---|---|
void |
addRoles(String... roles)
Add the roles of this principal. |
String |
getName()
Returns the name of this principal. |
Set<String> |
getRoles()
Returns the roles of this principal. |
void |
setName(String name)
Set the name of this principal. |
void |
setRoles(Set<String> roles)
Sets the roles of this principal. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.security.Principal |
|---|
equals, hashCode, toString |
| Constructor Detail |
|---|
public MockPrincipal()
public MockPrincipal(String name)
name - the name of the principal
public MockPrincipal(String name,
Set<String> roles)
name - the name of the principalroles - the principal roles
public MockPrincipal(String name,
String... roles)
name - the name of the principalroles - the principal roles| Method Detail |
|---|
public String getName()
getName in interface Principalpublic void setName(String name)
name - the name of the princpalpublic Set<String> getRoles()
public void setRoles(Set<String> roles)
roles - set the roles of this principal.public void addRoles(String... roles)
roles - set the roles of this principal.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||