}
protected ProtectionDomain getProtectionDomain(String username, String role) throws Exception
{
Group gp = new SimpleGroup("Roles");
gp.addMember(new SimplePrincipal(role));
Principal sp = new SimplePrincipal(username);
prepareAndSetAuthenticatedSubject(sp,gp);
return new ProtectionDomain(null,null,null,new Principal[] { sp,gp} );
}