Skip to content

Commit 65bc61a

Browse files
committedApr 20, 2020
Log a warning if adding CredentialHandler to CombinedRealm
1 parent 6a313e9 commit 65bc61a

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 

‎java/org/apache/catalina/realm/CombinedRealm.java

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import javax.management.ObjectName;
2727

2828
import org.apache.catalina.Container;
29+
import org.apache.catalina.CredentialHandler;
2930
import org.apache.catalina.Lifecycle;
3031
import org.apache.catalina.LifecycleException;
3132
import org.apache.catalina.Realm;
@@ -461,4 +462,12 @@ public boolean isAvailable() {
461462
return true;
462463
}
463464

465+
466+
@Override
467+
public void setCredentialHandler(CredentialHandler credentialHandler) {
468+
// This is unusual for a CombinedRealm as it does not use
469+
// CredentialHandlers. It might be a mis-configuration so warn the user.
470+
log.warn(sm.getString("combinedRealm.setCredentialHandler"));
471+
super.setCredentialHandler(credentialHandler);
472+
}
464473
}

‎java/org/apache/catalina/realm/LocalStrings.properties

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ combinedRealm.authSuccess=Authenticated user [{0}] with realm [{1}]
2020
combinedRealm.getPassword=The getPassword() method should never be called
2121
combinedRealm.getPrincipal=The getPrincipal() method should never be called
2222
combinedRealm.realmStartFail=Failed to start [{0}] realm
23+
combinedRealm.setCredentialHandler=A CredentialHandler was set on an instance of the CombinedRealm (or a sub-class of CombinedRealm). CombinedRealm doesn't use a configured CredentialHandler. Is this a configuration error?
2324
combinedRealm.unexpectedMethod=An unexpected call was made to a method on the combined realm
2425

2526
credentialHandler.invalidStoredCredential=The invalid stored credential string [{0}] was provided by the Realm to match with the user provided credentials

‎webapps/docs/changelog.xml

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@
7575
Remove redundant sole path/URI from error page message on SC_NOT_FOUND.
7676
(michaelo)
7777
</update>
78+
<add>
79+
Log a warning if a <code>CredentialHandler</code> instance is added to
80+
an instance of the <code>CombinedRealm</code> (or a sub-class) as the
81+
<code>CombinedRealm</code> doesn't use a configued
82+
<code>CredentialHandler</code> and it is likely that a configuration
83+
error has occurred. (markt)
84+
</add>
7885
</changelog>
7986
</subsection>
8087
<subsection name="Coyote">

0 commit comments

Comments
 (0)
Please sign in to comment.