Debian Codegraph @

ssl-proxies/src/main/java/org/globus/gsi/proxy/ProxyPathValidatorException.java

raw
1 /*
2 * Copyright 1999-2010 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 * express or implied.
12 *
13 * See the License for the specific language governing permissions and limitations under the License.
14 */
15 package org.globus.gsi.proxy;
16
17 import java.util.Date;
18 import java.text.DateFormat;
19 import java.util.TimeZone;
20 import java.text.SimpleDateFormat;
21
22 import java.security.GeneralSecurityException;
23 import java.security.cert.X509Certificate;
24
25 /**
26 * @deprecated
27 */
28 public class ProxyPathValidatorException
29 extends GeneralSecurityException {
30
31 public static final int FAILURE = -1;
32
33 // proxy constraints violation
34 public static final int PROXY_VIOLATION = 1;
35
36 // unsupported critical extensions
37 public static final int UNSUPPORTED_EXTENSION = 2;
38
39 // proxy or CA path length exceeded
40 public static final int PATH_LENGTH_EXCEEDED = 3;
41
42 // unknown CA
43 public static final int UNKNOWN_CA = 4;
44
45 // unknown proxy policy
46 public static final int UNKNOWN_POLICY = 5;
47
48 // cert revoked
49 public static final int REVOKED = 6;
50
51 // limited proxy not accepted
52 public static final int LIMITED_PROXY_ERROR = 7;
53
54 // CRL expired
55 public static final int EXPIRED_CRL = 8;
56
57 // signing policy not found
58 public static final int NO_SIGNING_POLICY_FILE = 9;
59
60 // no relevant signing policy in the file
61 public static final int NO_SIGNING_POLICY = 10;
62
63 // DN violates signing policy
64 public static final int SIGNING_POLICY_VIOLATION = 11;
65
66 private X509Certificate cert;
67
68 private int errorCode = FAILURE;
69
70 public ProxyPathValidatorException(int errorCode) {
71 this(errorCode, null);
72 }
73
74 public ProxyPathValidatorException(int errorCode,
75 Throwable root) {
76 this(errorCode, "", root);
77 }
78
79 public ProxyPathValidatorException(int errorCode,
80 String msg,
81 Throwable root) {
82 super(msg, root);
83 this.errorCode = errorCode;
84 }
85
86 public ProxyPathValidatorException(int errorCode,
87 X509Certificate cert,
88 String msg) {
89 super(msg, null);
90 this.errorCode = errorCode;
91 this.cert = cert;
92 }
93
94 public int getErrorCode() {
95 return this.errorCode;
96 }
97
98
99 /**
100 * Returns the certificate that was being validated when
101 * the exception was thrown.
102 *
103 * @return the <code>Certificate</code> that was being validated when
104 * the exception was thrown (or <code>null</code> if not specified)
105 */
106 public X509Certificate getCertificate() {
107 return this.cert;
108 }
109
110 public static String getDateAsString(Date date) {
111 TimeZone tz = TimeZone.getTimeZone("GMT");
112 DateFormat df = new SimpleDateFormat("MMM dd HH:mm:ss yyyy z");
113 df.setTimeZone(tz);
114 return df.format(date);
115 }
116 }