package org.mockejb;
import java.security.Principal;
import java.util.*;
public class MockUser implements Principal {
public final static MockUser ANONYMOUS_USER = new MockUser("anonymous");
private String name;
private List roles = new ArrayList();
public MockUser( final String name ){
this.name = name;
}
public MockUser( final String name, String role ){
this.name = name;
setRole( role );
}
public MockUser( final String name, String[] roles ){
this.name = name;
setRoles( roles );
}
public void setRoles( String[] roles ){
this.roles = Arrays.asList( roles );
}
public void setRole( String role ){
roles = new ArrayList();
roles.add(role);
}
public boolean hasRole( String role ){
return roles.contains( role );
}
public String getName() {
return this.name;
}
public String toString(){
return name;
}
}