Skip to content

Commit

Permalink
Apply violetagg's performance improvement.
Browse files Browse the repository at this point in the history
This closes #43

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1782779 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Feb 13, 2017
1 parent 5845934 commit f14440d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 14 additions & 13 deletions java/org/apache/catalina/authenticator/AuthenticatorBase.java
Expand Up @@ -23,6 +23,7 @@
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.Set; import java.util.Set;


import javax.security.auth.Subject; import javax.security.auth.Subject;
Expand Down Expand Up @@ -219,7 +220,7 @@ public AuthenticatorBase() {
protected SingleSignOn sso = null; protected SingleSignOn sso = null;


private volatile String jaspicAppContextID = null; private volatile String jaspicAppContextID = null;
private volatile AuthConfigProvider jaspicProvider = null; private volatile Optional<AuthConfigProvider> jaspicProvider = null;




// ------------------------------------------------------------- Properties // ------------------------------------------------------------- Properties
Expand Down Expand Up @@ -1186,29 +1187,29 @@ protected synchronized void stopInternal() throws LifecycleException {




private AuthConfigProvider getJaspicProvider() { private AuthConfigProvider getJaspicProvider() {
AuthConfigProvider provider = jaspicProvider; Optional<AuthConfigProvider> provider = jaspicProvider;
if (provider == null) { if (provider == null) {
AuthConfigFactory factory = AuthConfigFactory.getFactory(); provider = findJaspicProvider();
provider = factory.getConfigProvider("HttpServlet", jaspicAppContextID, this);
if (provider != null) {
jaspicProvider = provider;
}
} }
return provider; return provider.orElse(null);
} }


private Optional<AuthConfigProvider> findJaspicProvider() {
AuthConfigFactory factory = AuthConfigFactory.getFactory();
Optional<AuthConfigProvider> provider =
Optional.ofNullable(factory.getConfigProvider("HttpServlet", jaspicAppContextID, this));
jaspicProvider = provider;
return provider;
}


@Override @Override
public void notify(String layer, String appContext) { public void notify(String layer, String appContext) {
AuthConfigFactory factory = AuthConfigFactory.getFactory(); findJaspicProvider();
AuthConfigProvider provider = factory.getConfigProvider("HttpServlet", jaspicAppContextID,
this);
jaspicProvider = provider;
} }




private static class JaspicState { private static class JaspicState {
public MessageInfo messageInfo = null; public MessageInfo messageInfo = null;
public ServerAuthContext serverAuthContext = null; public ServerAuthContext serverAuthContext = null;
} }
} }
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -80,6 +80,10 @@
registered <code>RegistrationListener</code>s when a new registered <code>RegistrationListener</code>s when a new
<code>AuthConfigProvider</code> is registered. (markt) <code>AuthConfigProvider</code> is registered. (markt)
</fix> </fix>
<scode>
Improve the performance of <code>AuthenticatorBase</code> when there is
no JASPIC configuration available. (violetagg)
</scode>
</changelog> </changelog>
</subsection> </subsection>
<subsection name="Coyote"> <subsection name="Coyote">
Expand Down

0 comments on commit f14440d

Please sign in to comment.