001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019 package org.apache.shiro.crypto.hash;
020
021 import org.apache.shiro.codec.Base64;
022 import org.apache.shiro.codec.Hex;
023
024
025 /**
026 * Generates an SHA-384 Hash from a given input <tt>source</tt> with an optional <tt>salt</tt> and hash iterations.
027 *
028 * <p>See the {@link AbstractHash AbstractHash} parent class JavaDoc for a detailed explanation of Hashing
029 * techniques and how the overloaded constructors function.
030 *
031 * <p><b>JDK Version Note</b> - Attempting to instantiate this class on JREs prior to version 1.4.0 will throw
032 * an {@link IllegalStateException IllegalStateException}
033 *
034 * @author Les Hazlewood
035 * @since 0.9
036 */
037 public class Sha384Hash extends AbstractHash {
038
039 //TODO - complete JavaDoc
040
041 public static final String ALGORITHM_NAME = "SHA-384";
042
043 public Sha384Hash() {
044 }
045
046 public Sha384Hash(Object source) {
047 super(source);
048 }
049
050 public Sha384Hash(Object source, Object salt) {
051 super(source, salt);
052 }
053
054 public Sha384Hash(Object source, Object salt, int hashIterations) {
055 super(source, salt, hashIterations);
056 }
057
058 protected String getAlgorithmName() {
059 return ALGORITHM_NAME;
060 }
061
062 public static Sha384Hash fromHexString(String hex) {
063 Sha384Hash hash = new Sha384Hash();
064 hash.setBytes(Hex.decode(hex));
065 return hash;
066 }
067
068 public static Sha384Hash fromBase64String(String base64) {
069 Sha384Hash hash = new Sha384Hash();
070 hash.setBytes(Base64.decode(base64));
071 return hash;
072 }
073
074
075 }