Bug 280367 Move jetty-specific Scope use into jetty specific UserIdentity implementation

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@399 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
David Jencks 2009-06-16 00:12:05 +00:00
parent 5ad86fc8a8
commit e68d8ba98f
4 changed files with 9 additions and 10 deletions

View File

@ -335,7 +335,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
String[] roles = roleInfo.getRoles();
for (String role : roles)
{
if (userIdentity.isUserInRole(role))
if (userIdentity.isUserInRole(role, null))
return true;
}
return false;

View File

@ -47,8 +47,11 @@ public class DefaultUserIdentity implements UserIdentity
return _userPrincipal;
}
public boolean isUserInRole(String role)
public boolean isUserInRole(String role, Scope scope)
{
if (scope!=null && scope.getRoleRefMap()!=null)
role=scope.getRoleRefMap().get(role);
for (String r :_roles)
if (r.equals(role))
return true;

View File

@ -46,10 +46,7 @@ public class UserAuthentication implements Authentication.User
public boolean isUserInRole(Scope scope, String role)
{
if (scope!=null && scope.getRoleRefMap()!=null)
role=scope.getRoleRefMap().get(role);
return _userIdentity.isUserInRole(role);
return _userIdentity.isUserInRole(role, scope);
}
public void logout()

View File

@ -16,8 +16,6 @@ import java.security.Principal;
import java.util.Map;
import javax.security.auth.Subject;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/* ------------------------------------------------------------ */
/** User object that encapsulates user identity and operations such as run-as-role actions,
@ -46,9 +44,10 @@ public interface UserIdentity
* This call is used to satisfy authorization calls from
* container code which will be using translated role names.
* @param role A role name.
* @param scope
* @return True if the user can act in that role.
*/
boolean isUserInRole(String role);
boolean isUserInRole(String role, Scope scope);
/* ------------------------------------------------------------ */
@ -105,7 +104,7 @@ public interface UserIdentity
return null;
}
public boolean isUserInRole(String role)
public boolean isUserInRole(String role, Scope scope)
{
return false;
}