Source code

    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.codec.digest;
    019
    020/**
    021 * Standard {@link HmacUtils} algorithm names from the <cite>Java Cryptography Architecture Standard Algorithm Name
    022 * Documentation</cite>.
    023 *
    024 * <p>
    025 * <strong>Note: Not all JCE implementations supports all algorithms in this enum.</strong>
    026 * </p>
    027 *
    028 * @see <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html">Java Cryptography
    029 *      Architecture Standard Algorithm Name Documentation</a>
    030 * @since 1.10
    031 * @version $Id: HmacAlgorithms.java 1634405 2014-10-26 23:07:26Z ggregory $
    032 */
    033public enum HmacAlgorithms {
    034
    035    /**
    036     * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321.
    037     * <p>
    038     * Every implementation of the Java platform is required to support this standard Mac algorithm.
    039     * </p>
    040     */
    041    HMAC_MD5("HmacMD5"),
    042
    043    /**
    044     * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    045     * <p>
    046     * Every implementation of the Java platform is required to support this standard Mac algorithm.
    047     * </p>
    048     */
    049    HMAC_SHA_1("HmacSHA1"),
    050
    051    /**
    052     * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    053     * <p>
    054     * Every implementation of the Java platform is required to support this standard Mac algorithm.
    055     * </p>
    056     */
    057    HMAC_SHA_256("HmacSHA256"),
    058
    059    /**
    060     * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    061     * <p>
    062     * Every implementation of the Java platform is <em>not</em> required to support this Mac algorithm.
    063     * </p>
    064     */
    065    HMAC_SHA_384("HmacSHA384"),
    066
    067    /**
    068     * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    069     * <p>
    070     * Every implementation of the Java platform is <em>not</em> required to support this Mac algorithm.
    071     * </p>
    072     */
    073    HMAC_SHA_512("HmacSHA512");
    074
    075    private final String algorithm;
    076
    077    private HmacAlgorithms(final String algorithm) {
    078        this.algorithm = algorithm;
    079    }
    080
    081    /**
    082     * The algorithm name
    083     *
    084     * @see <a
    085     *      href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider">Java
    086     *      Cryptography Architecture Sun Providers Documentation</a>
    087     * @return The algorithm name ("HmacSHA512" for example)
    088     */
    089    @Override
    090    public String toString() {
    091        return algorithm;
    092    }
    093
    094}