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