You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/09/25 21:33:02 UTC
svn commit: r1627606 - in /tomcat/trunk/java/org/apache/catalina/realm:
CredentialHandlerBase.java MessageDigestCredentialHandler.java
PBECredentialHandler.java
Author: markt
Date: Thu Sep 25 19:33:02 2014
New Revision: 1627606
URL: http://svn.apache.org/r1627606
Log:
More docs.
Code updates after review while writing docs
Modified:
tomcat/trunk/java/org/apache/catalina/realm/CredentialHandlerBase.java
tomcat/trunk/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
tomcat/trunk/java/org/apache/catalina/realm/PBECredentialHandler.java
Modified: tomcat/trunk/java/org/apache/catalina/realm/CredentialHandlerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/CredentialHandlerBase.java?rev=1627606&r1=1627605&r2=1627606&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/CredentialHandlerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/CredentialHandlerBase.java Thu Sep 25 19:33:02 2014
@@ -24,6 +24,9 @@ import org.apache.catalina.CredentialHan
import org.apache.tomcat.util.buf.HexUtils;
import org.apache.tomcat.util.res.StringManager;
+/**
+ * Base implementation for the Tomcat provided {@link CredentialHandler}s.
+ */
public abstract class CredentialHandlerBase implements CredentialHandler {
protected static final StringManager sm = StringManager.getManager(Constants.Package);
@@ -32,16 +35,33 @@ public abstract class CredentialHandlerB
private Random random = null;
+ /**
+ * Return the number of iterations of the associated algorithm that will be
+ * used to convert the plain text credential into the stored credential.
+ */
public int getIterations() {
return iterations;
}
+ /**
+ * Set the number of iterations of the associated algorithm that will be
+ * used to convert the plain text credential into the stored credential.
+ */
public void setIterations(int iterations) {
this.iterations = iterations;
}
+ /**
+ * Generate a stored credential from the given plain text credential.
+ *
+ * @param saltLength Length of random salt to be generated and used
+ * as part of the transformation
+ * @param userCredential The plain text credential
+ *
+ * @return The credential to be stored
+ */
public String generate(int saltLength, String userCredential) {
byte[] salt = null;
int iterations = getIterations();
@@ -61,7 +81,17 @@ public abstract class CredentialHandlerB
}
- protected boolean matchesSaltIterationsEncoded(String inputCredentials, String storedCredentials) {
+ /**
+ * Checks whether the provided credential matches the stored credential when
+ * the stored credential is in the form salt$iteration-count$credential
+ *
+ * @param inputCredentials The input credential
+ * @param storedCredentials The stored credential
+ *
+ * @return <code>true</code> if they match, otherwise <code>false</code>
+ */
+ protected boolean matchesSaltIterationsEncoded(String inputCredentials,
+ String storedCredentials) {
int sep1 = storedCredentials.indexOf('$');
int sep2 = storedCredentials.indexOf('$', sep1 + 1);
@@ -79,7 +109,23 @@ public abstract class CredentialHandlerB
}
- protected abstract void setAlgorithm(String algorithm) throws NoSuchAlgorithmException;
-
+ /**
+ * Set the algorithm used to convert input credentials to stored
+ * credentials.
+ */
+ public abstract void setAlgorithm(String algorithm) throws NoSuchAlgorithmException;
+
+
+ /**
+ * Get the algorithm used to convert input credentials to stored
+ * credentials.
+ */
+ public abstract String getAlgorithm();
+
+
+ /**
+ * Get the default number of iterations used by the
+ * {@link CredentialHandler}.
+ */
protected abstract int getDefaultIterations();
}
Modified: tomcat/trunk/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java?rev=1627606&r1=1627605&r2=1627606&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/MessageDigestCredentialHandler.java Thu Sep 25 19:33:02 2014
@@ -81,6 +81,7 @@ public class MessageDigestCredentialHand
}
+ @Override
public String getAlgorithm() {
return algorithm;
}
Modified: tomcat/trunk/java/org/apache/catalina/realm/PBECredentialHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/PBECredentialHandler.java?rev=1627606&r1=1627605&r2=1627606&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/PBECredentialHandler.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/PBECredentialHandler.java Thu Sep 25 19:33:02 2014
@@ -44,6 +44,7 @@ public class PBECredentialHandler extend
}
+ @Override
public String getAlgorithm() {
return secretKeyFactory.getAlgorithm();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org