This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new b82c78de66 Clean-up / improve naming. No functional change. b82c78de66 is described below commit b82c78de660d81c4664d62161be1d0b5d72dc95c Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Sep 8 19:38:40 2022 +0100 Clean-up / improve naming. No functional change. --- .../org/apache/tomcat/websocket/Authenticator.java | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/java/org/apache/tomcat/websocket/Authenticator.java b/java/org/apache/tomcat/websocket/Authenticator.java index bc14d5792f..ccfc748de8 100644 --- a/java/org/apache/tomcat/websocket/Authenticator.java +++ b/java/org/apache/tomcat/websocket/Authenticator.java @@ -22,50 +22,53 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * Base class for the authentication methods used by the websocket client. + * Base class for the authentication methods used by the WebSocket client. */ public abstract class Authenticator { - private static final Pattern pattern = Pattern - .compile("(\\w+)\\s*=\\s*(\"([^\"]+)\"|([^,=\"]+))\\s*,?"); + + private static final Pattern pattern = Pattern.compile("(\\w+)\\s*=\\s*(\"([^\"]+)\"|([^,=\"]+))\\s*,?"); /** - * Generate the authentication header that will be sent to the server. - * @param requestUri The request URI - * @param WWWAuthenticate The server auth challenge - * @param UserProperties The user information - * @return The auth header + * Generate the authorization header that will be sent to the server. + * + * @param requestUri The request URI + * @param authenticateHeader The server authentication header received + * @param userProperties The user information + * + * @return The generated authorization header value + * * @throws AuthenticationException When an error occurs */ - public abstract String getAuthorization(String requestUri, String WWWAuthenticate, - Map<String, Object> UserProperties) throws AuthenticationException; + public abstract String getAuthorization(String requestUri, String authenticateHeader, + Map<String, Object> userProperties) throws AuthenticationException; /** * Get the authentication method. - * @return the auth scheme + * @return the authentication scheme */ public abstract String getSchemeName(); /** * Utility method to parse the authentication header. - * @param WWWAuthenticate The server auth challenge - * @return the parsed header + * + * @param authenticateHeader The server authentication header received + * + * @return a map of authentication parameter names and values */ - public Map<String, String> parseWWWAuthenticateHeader(String WWWAuthenticate) { + public Map<String, String> parseWWWAuthenticateHeader(String authenticateHeader) { - Matcher m = pattern.matcher(WWWAuthenticate); - Map<String, String> challenge = new HashMap<>(); + Matcher m = pattern.matcher(authenticateHeader); + Map<String, String> parameterMap = new HashMap<>(); while (m.find()) { String key = m.group(1); String qtedValue = m.group(3); String value = m.group(4); - challenge.put(key, qtedValue != null ? qtedValue : value); + parameterMap.put(key, qtedValue != null ? qtedValue : value); } - return challenge; - + return parameterMap; } - } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org