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  package org.apache.directory.ldap.client.template.exception;
21  
22  
23  import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum;
24  import org.apache.directory.api.ldap.model.exception.LdapException;
25  import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
26  import org.apache.directory.ldap.client.template.LdapConnectionTemplate;
27  
28  
29  /**
30   * Thrown when an attempt to bind or modify a userPassword fails when using
31   * {@link LdapConnectionTemplate}.
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public class PasswordException extends Exception
36  {
37      private static final long serialVersionUID = -1185823188085178776L;
38  
39      private LdapException ldapException;
40      private ResultCodeEnum resultCode;
41      private PasswordPolicyErrorEnum passwordPolicyError;
42  
43  
44      public PasswordException()
45      {
46          super();
47      }
48  
49  
50      /**
51       * If an LdapException was thrown causing this exception, that 
52       * LdapException is returned.  Otherwise null is returned.
53       *
54       * @return The LdapException that was thrown, or null.
55       */
56      public LdapException getLdapException()
57      {
58          return ldapException;
59      }
60  
61  
62      /**
63       * Returns the result code from the attempt to bind or modify the 
64       * userPassword.
65       *
66       * @return The result code.
67       */
68      public ResultCodeEnum getResultCode()
69      {
70          return resultCode;
71      }
72  
73  
74      /**
75       * Returns the password policy error code if present, otherwise null.
76       *
77       * @return The password policy error code or null.
78       */
79      public PasswordPolicyErrorEnum getPasswordPolicyError()
80      {
81          return passwordPolicyError;
82      }
83  
84  
85      public PasswordException setLdapException( LdapException ldapException )
86      {
87          this.ldapException = ldapException;
88          return this;
89      }
90  
91  
92      public PasswordException setPasswordPolicyError( PasswordPolicyErrorEnum passwordPolicyError )
93      {
94          this.passwordPolicyError = passwordPolicyError;
95          return this;
96      }
97  
98  
99      public PasswordException setResultCode( ResultCodeEnum resultCode )
100     {
101         this.resultCode = resultCode;
102         return this;
103     }
104 }