Skip to content
Snippets Groups Projects
Commit e00017cd authored by Adrian Damian's avatar Adrian Damian
Browse files

Accommodate the use of DNPrincipal in proxy user login

parent 5336a1cc
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ import ca.nrc.cadc.ac.server.GroupDetailSelector;
import ca.nrc.cadc.ac.server.UserPersistence;
import ca.nrc.cadc.ac.server.ldap.LdapGroupPersistence;
import ca.nrc.cadc.ac.server.ldap.LdapUserPersistence;
import ca.nrc.cadc.auth.AuthenticatorImpl;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.SSOCookieManager;
import ca.nrc.cadc.log.ServletLogInfo;
......@@ -228,9 +229,10 @@ public class LoginServlet extends HttpServlet
final LdapGroupPersistence<HttpPrincipal> gp =
getLdapGroupPersistence();
AuthenticatorImpl ai = new AuthenticatorImpl();
Subject proxySubject = new Subject();
proxySubject.getPrincipals().add(new HttpPrincipal(proxyUser));
ai.augmentSubject(proxySubject);
try
{
Subject.doAs(proxySubject, new PrivilegedExceptionAction<Object>()
......@@ -238,6 +240,7 @@ public class LoginServlet extends HttpServlet
@Override
public Object run() throws Exception
{
if (gp.getGroups(new HttpPrincipal(proxyUser), Role.MEMBER,
proxyGroup).size() == 0)
{
......@@ -253,6 +256,7 @@ public class LoginServlet extends HttpServlet
Subject userSubject = new Subject();
userSubject.getPrincipals().add(new HttpPrincipal(userID));
ai.augmentSubject(userSubject);
Subject.doAs(userSubject, new PrivilegedExceptionAction<Object>()
{
@Override
......
......@@ -124,7 +124,7 @@ public class AuthenticatorImpl implements Authenticator
return subject;
}
protected void augmentSubject(final Subject subject)
public void augmentSubject(final Subject subject)
{
try
......
......@@ -37,7 +37,10 @@ public class UserLoginServletTest
proxyGroups.add(new Group(proxyGroup));
Collection<Group> niGroups = new HashSet<Group>();
niGroups.add(new Group(nonImpersonGroup));
LdapGroupPersistence<HttpPrincipal> mockGp = EasyMock
// mock returns a shell instance
@SuppressWarnings("unchecked")
LdapGroupPersistence<HttpPrincipal> mockGp =
(LdapGroupPersistence<HttpPrincipal>)EasyMock
.createMock(LdapGroupPersistence.class);
mockGp.setDetailSelector(new GroupDetailSelector()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment