View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  
21  package org.apache.directory.api.ldap.model.password;
22  
23  
24  import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
25  
26  
27  /**
28   * A class to store all informations about an password.
29   *
30   * This includes:
31   * <ul>
32   * <li> the used algorithm</li>
33   * <li> the salt if any</li>
34   * <li> the password itself</li>
35   * </ul>
36   *
37   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
38   */
39  public class PasswordDetails
40  {
41      private final LdapSecurityConstants algorithm;
42      private final byte[] salt;
43      private final byte[] password;
44  
45  
46      /**
47       * Creates a new PasswordDetails instance
48       * 
49       * @param algorithm The algorithm to use
50       * @param salt The Salt to use
51       * @param password The password
52       */
53      public PasswordDetails( LdapSecurityConstants algorithm, byte[] salt, byte[] password )
54      {
55          this.algorithm = algorithm;
56          this.salt = salt;
57          this.password = password;
58      }
59  
60  
61      /**
62       * The hash algorithm used to hash the password, null for plain text passwords.
63       * 
64       * @return the hash algorithm used to hash the password, null for plain text passwords
65       */
66      public LdapSecurityConstants getAlgorithm()
67      {
68          return algorithm;
69      }
70  
71  
72      /**
73       * The salt used to hash the password, null if no salt was used.
74       * 
75       * @return the salt used to hash the password, null if no salt was used
76       */
77      public byte[] getSalt()
78      {
79          return salt;
80      }
81  
82  
83      /**
84       * The hashed or plain text password.
85       * 
86       * @return the hashed or plain text password
87       */
88      public byte[] getPassword()
89      {
90          return password;
91      }
92  
93  }