From 3029f30d2b243c2ed965c1628e323add9f64bf29 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 7 Aug 2018 13:37:09 +1000 Subject: [PATCH] Issue #321 - DeadCode JaspiAuthenticatorFactory.findServerName Server param not used removed the subject parameter and instead get the subject from findServiceSubject(server) contextPath String was not being used Signed-off-by: Lachlan Roberts --- .../jaspi/JaspiAuthenticatorFactory.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticatorFactory.java b/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticatorFactory.java index e4ac8629aea..bddf40871b5 100644 --- a/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticatorFactory.java +++ b/jetty-jaspi/src/main/java/org/eclipse/jetty/security/jaspi/JaspiAuthenticatorFactory.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; - import javax.security.auth.Subject; import javax.security.auth.message.AuthException; import javax.security.auth.message.config.AuthConfigFactory; @@ -95,20 +94,16 @@ public class JaspiAuthenticatorFactory extends DefaultAuthenticatorFactory try { AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory(); - RegistrationListener listener = new RegistrationListener() - { - @Override - public void notify(String layer, String appContext) - {} - }; + RegistrationListener listener = (layer, appContext) -> {}; Subject serviceSubject=findServiceSubject(server); - String serverName=findServerName(server,serviceSubject); + String serverName=findServerName(server); + String contextPath=context.getContextPath(); if (contextPath==null || contextPath.length()==0) contextPath="/"; - String appContext = serverName + " " + context.getContextPath(); - + String appContext = serverName + " " + contextPath; + AuthConfigProvider authConfigProvider = authConfigFactory.getConfigProvider(MESSAGE_LAYER,appContext,listener); if (authConfigProvider != null) @@ -146,7 +141,7 @@ public class JaspiAuthenticatorFactory extends DefaultAuthenticatorFactory return _serviceSubject; List subjects = (List)server.getBeans(Subject.class); if (subjects.size()>0) - return (Subject)subjects.get(0); + return subjects.get(0); return null; } @@ -155,14 +150,15 @@ public class JaspiAuthenticatorFactory extends DefaultAuthenticatorFactory * If {@link #setServerName(String)} has not been called, then * use the name of the a principal in the service subject. * If not found, return "server". - * @param server not used - * @param subject the subject to use - * @return the server name from the subject (or default value if not found in subject or principals) + * @param server the server to find the name of + * @return the server name from the service Subject (or default value if not found in subject or principals) */ - protected String findServerName(Server server, Subject subject) + protected String findServerName(Server server) { if (_serverName!=null) return _serverName; + + Subject subject = findServiceSubject(server); if (subject!=null) { Set principals = subject.getPrincipals();