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 */
020
021package org.apache.directory.api.ldap.model.password;
022
023
024import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
025
026
027/**
028 * A class to store all informations about an password.
029 *
030 * This includes:
031 * - the used algorithm
032 * - the salt if any
033 * - the password itself.
034 *
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public class PasswordDetails
038{
039    private final LdapSecurityConstants algorithm;
040    private final byte[] salt;
041    private final byte[] password;
042
043
044    /**
045     * Creates a new PasswordDetails instance
046     * 
047     * @param algorithm The algorithm to use
048     * @param salt The Salt to use
049     * @param password The password
050     */
051    public PasswordDetails( LdapSecurityConstants algorithm, byte[] salt, byte[] password )
052    {
053        this.algorithm = algorithm;
054        this.salt = salt;
055        this.password = password;
056    }
057
058
059    /**
060     * The hash algorithm used to hash the password, null for plain text passwords.
061     * 
062     * @return the hash algorithm used to hash the password, null for plain text passwords
063     */
064    public LdapSecurityConstants getAlgorithm()
065    {
066        return algorithm;
067    }
068
069
070    /**
071     * The salt used to hash the password, null if no salt was used.
072     * 
073     * @return the salt used to hash the password, null if no salt was used
074     */
075    public byte[] getSalt()
076    {
077        return salt;
078    }
079
080
081    /**
082     * The hashed or plain text password.
083     * 
084     * @return the hashed or plain text password
085     */
086    public byte[] getPassword()
087    {
088        return password;
089    }
090
091}