mark security context as deprecated and use shiro apis instead

This commit is contained in:
Sebastian Sdorra
2012-08-30 13:20:26 +02:00
parent 7d0980605e
commit 4a9d14b708
24 changed files with 277 additions and 298 deletions

View File

@@ -38,6 +38,7 @@ package sonia.scm.util;
import com.google.inject.Provider;
import org.apache.shiro.authz.Permission;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.mockito.invocation.InvocationOnMock;
@@ -67,6 +68,12 @@ import javax.servlet.http.HttpServletResponse;
public class MockUtil
{
/** Field description */
private static final User ADMIN = new User("scmadmin", "SCM Admin",
"scmadmin@scm.org");
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -101,6 +108,14 @@ public class MockUtil
when(subject.isPermittedAll()).thenReturn(Boolean.TRUE);
when(subject.hasRole("admin")).thenReturn(Boolean.TRUE);
PrincipalCollection collection = mock(PrincipalCollection.class);
when(collection.getPrimaryPrincipal()).thenReturn(ADMIN.getId());
when(collection.oneByType(User.class)).thenReturn(ADMIN);
when(subject.getPrincipal()).thenReturn(ADMIN.getId());
when(subject.getPrincipals()).thenReturn(collection);
return subject;
}