Commit 0245eee6 authored by Jeff Burke's avatar Jeff Burke
Browse files

s1728: WhoAmIServlet fixes.

parent 773fa9a3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -259,7 +259,6 @@ public class UserServlet extends HttpServlet
    {
        ServletPrincipalExtractor extractor = new ServletPrincipalExtractor(request);
        Set<Principal> principals = extractor.getPrincipals();
        log.debug("Principals: " + principals);

        for (Principal principal : principals)
        {
@@ -267,12 +266,12 @@ public class UserServlet extends HttpServlet
            {
                if (principal.getName().equalsIgnoreCase(notAugmentedX500User))
                {
                    log.debug("found notAugmentedX500User " + notAugmentedX500User);
                    return true;
                }
            }
        }

        return false;

    }
}
+5 −3
Original line number Diff line number Diff line
@@ -162,11 +162,13 @@ public class WhoAmIServlet extends HttpServlet
        final RegistryClient registryClient = getRegistryClient();
        final URL redirectURL =
                registryClient.getServiceURL(
                        URI.create(AC.GMS_SERVICE_URI), "http", USER_GET_PATH);
                        URI.create(AC.GMS_SERVICE_URI), "https", USER_GET_PATH);

        // Take the first one.
        response.sendRedirect(String.format(redirectURL.toExternalForm(),
            webPrincipal.getName()));
        final String redirectUrl =
            String.format(redirectURL.toString(), webPrincipal.getName());
        log.debug("redirecting to " + redirectUrl);
        response.sendRedirect(redirectUrl);
    }

    /**
+5 −3
Original line number Diff line number Diff line
@@ -102,9 +102,13 @@ public class AuthenticatorImpl implements Authenticator
     */
    public Subject getSubject(Subject subject)
    {
        log.debug("ac augment subject: " + subject);
        AuthMethod am = AuthenticationUtil.getAuthMethod(subject);
        if (am == null || AuthMethod.ANON.equals(am))
        {
            log.debug("returning anon subject");
            return subject;
        }

        if (subject != null && subject.getPrincipals().size() > 0)
        {
@@ -126,14 +130,13 @@ public class AuthenticatorImpl implements Authenticator

    protected void augmentSubject(final Subject subject)
    {

        try
        {
            LdapUserPersistence<Principal> dao = new LdapUserPersistence<Principal>();
            User<Principal> user = dao.getAugmentedUser(subject.getPrincipals().iterator().next());
            if (user.getIdentities() != null)
            {
                log.debug("Found " + user.getIdentities().size() + " principals after agument");
                log.debug("Found " + user.getIdentities().size() + " principals after argument");
            }
            else
            {
@@ -150,7 +153,6 @@ public class AuthenticatorImpl implements Authenticator
        {
            throw new IllegalStateException("Internal error", e);
        }

    }

}