Debian Codegraph @

ssl-proxies/src/main/java/org/globus/gsi/trustmanager/DateValidityChecker.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
16 package org.globus.gsi.trustmanager;
17
18 import java.security.cert.CertPathValidatorException;
19 import java.security.cert.CertificateExpiredException;
20 import java.security.cert.CertificateNotYetValidException;
21 import java.security.cert.X509Certificate;
22
23 import org.globus.gsi.GSIConstants;
24
25 /**
26 * Checks if the certificate has expried or is not yet valid.
27 *
28 * @version ${version}
29 * @since 1.0
30 */
31 public class DateValidityChecker implements CertificateChecker {
32
33 /**
34 * Method that checks the time validity. Uses the standard Certificate.checkValidity method.
35 *
36 * @throws CertPathValidatorException If certificate has expired or is not yet valid.
37 */
38
39 public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
40 try {
41 cert.checkValidity();
42 } catch (CertificateExpiredException e) {
43 throw new CertPathValidatorException(
44 "Certificate " + cert.getSubjectDN() + " expired", e);
45 } catch (CertificateNotYetValidException e) {
46 throw new CertPathValidatorException(
47 "Certificate " + cert.getSubjectDN() + " not yet valid.", e);
48 }
49 }
50 }