Debian Codegraph @

ssl-proxies/src/main/java/org/globus/gsi/trustmanager/IdentityChecker.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 org.globus.gsi.util.ProxyCertificateUtil;
19
20 import java.security.cert.CertPathValidatorException;
21 import java.security.cert.X509Certificate;
22
23 import org.globus.gsi.GSIConstants;
24
25 /**
26 * Checks to see if a limited proxy is acceptable (if the chain has a limited proxy).
27 * Also, sets the identity certificate in the certificate path validator.
28 */
29 public class IdentityChecker implements CertificateChecker {
30 private X509ProxyCertPathValidator proxyCertValidator;
31
32 public IdentityChecker(X509ProxyCertPathValidator proxyCertPathValidator) {
33 this.proxyCertValidator = proxyCertPathValidator;
34 }
35
36
37 /**
38 * Method that sets the identity of the certificate path. Also checks if
39 * limited proxy is acceptable.
40 *
41 * @throws CertPathValidatorException If limited proxies are not accepted
42 * and the chain has a limited proxy.
43 */
44
45 public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
46 if (proxyCertValidator.getIdentityCertificate() == null) {
47 // check if limited
48 if (ProxyCertificateUtil.isLimitedProxy(certType)) {
49 proxyCertValidator.setLimited(true);
50
51 if (proxyCertValidator.isRejectLimitedProxy()) {
52 throw new CertPathValidatorException(
53 "Limited proxy not accepted");
54 }
55 }
56
57 // set the identity cert
58 if (!ProxyCertificateUtil.isImpersonationProxy(certType)) {
59 proxyCertValidator.setIdentityCert(cert);
60 }
61 }
62 }
63 }