/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Lachlan Dowding
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package permafrost.tundra.security;

/**
 * List of supported message digest algorithms.
 */
public enum MessageDigestAlgorithm {
    MD2("MD2"), MD5("MD5"), SHA_1("SHA-1"), SHA_256("SHA-256"), SHA_384("SHA-384"), SHA_512("SHA-512");

    private String name;
    private static java.util.Map<String, MessageDigestAlgorithm> map = new java.util.HashMap<String, MessageDigestAlgorithm>();

    static {
        for (MessageDigestAlgorithm algorithm : MessageDigestAlgorithm.values()) {
            map.put(algorithm.name, algorithm);
        }
    }

    MessageDigestAlgorithm(String input) {
        name = input;
    }

    /**
     * Returns the MessageDigestAlgorithm for the given algorithm name.
     * @param name The name of the algorithm to return.
     * @return     The MessageDigestAlgorithm for the given algorithm name.
     */
    public static MessageDigestAlgorithm normalize(String name) {
        MessageDigestAlgorithm algorithm = null;
        if (name != null) {
            algorithm = map.get(name);
        }
        return normalize(algorithm);
    }

    /**
     * Returns a normalized MessageDigestAlgorithm.
     * @param algorithm The algorithm to normalize.
     * @return          If the given algorithm is null then SHA_256 is returned,
     *                  otherwise the given algorithm is returned.
     */
    public static MessageDigestAlgorithm normalize(MessageDigestAlgorithm algorithm) {
        return algorithm == null ? SHA_256 : algorithm;
    }

    /**
     * Returns the MessageDigestAlgorithm's algorithm name.
     * @return The MessageDigestAlgorithm's algorithm name.
     */
    @Override
    public String toString() {
        return name;
    }
}

@@ -1661,16 +1661,30 @@
 thm.name
+.toLowerCase()
 , algori
@@ -1685,24 +1685,24 @@
 algorithm);%0A
-
         %7D%0A  
@@ -2177,16 +2177,30 @@
 get(name
+.toLowerCase()
 );%0A     
@@ -2638,23 +2638,28 @@
  null ? 
-SHA_256
+getDefault()
  : algor
@@ -2848,24 +2848,24 @@
 oString() %7B%0A
-
         retu
@@ -2878,11 +2878,216 @@
 e;%0A    %7D
+%0A%0A    /**%0A     * Returns the default MessageDigestAlgorithm.%0A     * @return The default MessageDigestAlgorithm.%0A     */%0A    public static MessageDigestAlgorithm getDefault() %7B%0A        return SHA_256;%0A    %7D
 %0A%7D%0A

Change MessageDigestAlgorithm.normalize(String) to be case insensitive