Github user mike-jumper commented on a diff in the pull request:

    https://github.com/apache/guacamole-client/pull/181#discussion_r189082729
  
    --- Diff: 
extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
 ---
    @@ -184,6 +184,43 @@ public static GuacamoleConfiguration 
getConfiguration(String uri)
             return parameters;
         }
     
    +    /**
    +     * Parse the given string for username and password values,
    +     * and return a map containing the username, password
    +     * or both.
    +     *
    +     * @param userInfo
    +     *     The string to parse for username/password values.
    +     * 
    +     * @return
    +     *     A map with the username, password, or both.
    +     *
    +     * @throws UnsupportedEncodingException
    +     *     If Java lacks UTF-8 support.
    +     */
    +    public static Map<String, String> parseUserInfo(String userInfo)
    +            throws UnsupportedEncodingException {
    +
    +        Map<String, String> userInfoMap = new HashMap<String, String>();
    +        Matcher userinfoMatcher = userinfoPattern.matcher(userInfo);
    +
    +        if (userinfoMatcher.matches()) {
    +            String username = URLDecoder.decode(
    +                    userinfoMatcher.group(USERNAME_GROUP), "UTF-8");
    +            String password = URLDecoder.decode(
    +                    userinfoMatcher.group(PASSWORD_GROUP), "UTF-8");
    +
    +            if (username != null && !username.isEmpty())
    +                userInfoMap.put("username", username);
    +
    +            if (password != null && !password.isEmpty())
    +                userInfoMap.put("password", password);
    --- End diff --
    
    We shouldn't be using a `Map` as a sort of poor man's object. If we need to 
return a username/password pair, then we should either have an object which 
represents a username/password pair, or this function should just set the 
username/password on the `GuacamoleConfiguration` directly (might be easier).


---

Reply via email to