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   *    https://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.api.ldap.model.exception;
21  
22  
23  import java.security.cert.CertPathValidatorException.BasicReason;
24  import java.security.cert.CertPathValidatorException.Reason;
25  
26  
27  public class LdapTlsHandshakeFailCause
28  {
29      private Throwable cause;
30      private Throwable rootCause;
31      private Reason reason;
32      private String reasonPhrase;
33  
34  
35      public LdapTlsHandshakeFailCause()
36      {
37      }
38  
39  
40      public LdapTlsHandshakeFailCause( Throwable cause, Throwable rootCause, Reason reason, String reasonPhrase )
41      {
42          this.cause = cause;
43          this.rootCause = rootCause;
44          this.reason = reason;
45          this.reasonPhrase = reasonPhrase;
46      }
47  
48  
49      public Throwable getCause()
50      {
51          return cause;
52      }
53  
54  
55      public void setCause( Throwable cause )
56      {
57          this.cause = cause;
58      }
59  
60  
61      public Throwable getRootCause()
62      {
63          return rootCause;
64      }
65  
66  
67      public void setRootCause( Throwable rootCause )
68      {
69          this.rootCause = rootCause;
70      }
71  
72  
73      public Reason getReason()
74      {
75          return reason;
76      }
77  
78  
79      public void setReason( Reason reason )
80      {
81          this.reason = reason;
82      }
83  
84  
85      public String getReasonPhrase()
86      {
87          return reasonPhrase;
88      }
89  
90  
91      public void setReasonPhrase( String reasonPhrase )
92      {
93          this.reasonPhrase = reasonPhrase;
94      }
95  
96      /**
97       * Additional reasons.
98       * 
99       * @see BasicReason
100      *
101      */
102     public enum LdapApiReason implements Reason
103     {
104         NO_VALID_CERTIFICATION_PATH,
105         SELF_SIGNED,
106         HOST_NAME_VERIFICATION_FAILED,
107     }
108 
109 
110     public String getMessage()
111     {
112         String message = reasonPhrase;
113         if ( rootCause != null && rootCause != cause )
114         {
115             message += ": " + rootCause.getMessage();
116         }
117         return message;
118     }
119 
120 }