| 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; |
| 16 |
|
| 17 |
/** |
| 18 |
* Defines common constants used by GSI. |
| 19 |
*/ |
| 20 |
// COMMENT: 2 ways to defined a certificate type: integer and enum. |
| 21 |
public interface GSIConstants { |
| 22 |
|
| 23 |
/** The character sent on the wire to request delegation */ |
| 24 |
public static final char DELEGATION_CHAR = 'D'; |
| 25 |
|
| 26 |
/** Null ciphersuite supported in older Globus servers */ |
| 27 |
public static final String[] GLOBUS_CIPHER = {"SSL_RSA_WITH_NULL_MD5"}; |
| 28 |
|
| 29 |
/** Indicates no delegation |
| 30 |
* @deprecated Use DelegationType.NONE instead |
| 31 |
*/ |
| 32 |
public static final int DELEGATION_NONE = 1; |
| 33 |
|
| 34 |
/** Indicates limited delegation. |
| 35 |
* Depending on the settings it might mean GSI-2 limited delegation |
| 36 |
* or GSI-3 limited delegation. |
| 37 |
* @deprecated Use DelegationType.LIMITED instead |
| 38 |
*/ |
| 39 |
public static final int DELEGATION_LIMITED = 2; |
| 40 |
|
| 41 |
/** Indicates full delegation. |
| 42 |
* Depending on the settings it might mean GSI-2 full delegation |
| 43 |
* or GSI-3 impersonation delegation. |
| 44 |
* @deprecated Use DelegationType.FULL instead |
| 45 |
*/ |
| 46 |
public static final int DELEGATION_FULL = 3; |
| 47 |
|
| 48 |
/** Indicates GSI mode (allows for delegation during authentication). |
| 49 |
*/ |
| 50 |
public static final Integer MODE_GSI = new Integer(1); |
| 51 |
|
| 52 |
/** Indicates SSL compatibility mode (does not allow for delegation |
| 53 |
* during authentication). */ |
| 54 |
public static final Integer MODE_SSL = new Integer(2); |
| 55 |
|
| 56 |
/** Indicates full delegation. */ |
| 57 |
public static final Integer DELEGATION_TYPE_FULL |
| 58 |
= new Integer(GSIConstants.DELEGATION_FULL); |
| 59 |
|
| 60 |
/** Indicates limited delegation. */ |
| 61 |
public static final Integer DELEGATION_TYPE_LIMITED |
| 62 |
= new Integer(GSIConstants.DELEGATION_LIMITED); |
| 63 |
|
| 64 |
/** Indicates End-Entity Certificate, e.g. user certificate |
| 65 |
* @deprecated Use CertificateType.EEC instead |
| 66 |
*/ |
| 67 |
public static final int EEC = 3; |
| 68 |
|
| 69 |
/** Indicates Certificate Authority certificate |
| 70 |
* @deprecated Use CertificateType.CA instead |
| 71 |
*/ |
| 72 |
public static final int CA = 4; |
| 73 |
|
| 74 |
/** Indicates legacy full Globus proxy |
| 75 |
* @deprecated Use CertificateType.GSI_2_PROXY instead |
| 76 |
*/ |
| 77 |
public static final int GSI_2_PROXY = 10; |
| 78 |
|
| 79 |
/** Indicates legacy limited Globus proxy |
| 80 |
* @deprecated Use CertificateType.GSI_2_LIMITED_PROXY instead |
| 81 |
*/ |
| 82 |
public static final int GSI_2_LIMITED_PROXY = 11; |
| 83 |
|
| 84 |
/** Indicates proxy draft compliant restricted proxy. |
| 85 |
* A proxy with embedded policy. |
| 86 |
* @deprecated Use CertificateType.GSI_3_RESTRICTED_PROXY instead |
| 87 |
*/ |
| 88 |
public static final int GSI_3_RESTRICTED_PROXY = 12; |
| 89 |
|
| 90 |
/** Indicates proxy draft compliant independent proxy. |
| 91 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#INDEPENDENT |
| 92 |
* ProxyPolicy.INDEPENDENT} policy language OID. |
| 93 |
* @deprecated Use CertificateType.GSI_3_INDEPENDENT_PROXY instead |
| 94 |
*/ |
| 95 |
public static final int GSI_3_INDEPENDENT_PROXY = 13; |
| 96 |
|
| 97 |
/** Indicates proxy draft compliant impersonation proxy. |
| 98 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#IMPERSONATION |
| 99 |
* ProxyPolicy.IMPERSONATION} policy language OID. |
| 100 |
* @deprecated Use CertificateType.GSI_3_IMPERSONATION_PROXY instead |
| 101 |
*/ |
| 102 |
public static final int GSI_3_IMPERSONATION_PROXY = 14; |
| 103 |
|
| 104 |
/** Indicates proxy draft compliant limited impersonation proxy. |
| 105 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#LIMITED |
| 106 |
* ProxyPolicy.LIMITED} policy language OID. |
| 107 |
* @deprecated Use CertificateType.GSI_3_RESTRICTED_PROXY instead |
| 108 |
*/ |
| 109 |
public static final int GSI_3_LIMITED_PROXY = 15; |
| 110 |
|
| 111 |
/** Indicates RFC 3820 compliant restricted proxy. |
| 112 |
* A proxy with embedded policy. |
| 113 |
* @deprecated Use CertificateType.GSI_4_RESTRICTED_PROXY instead |
| 114 |
*/ |
| 115 |
public static final int GSI_4_RESTRICTED_PROXY = 16; |
| 116 |
|
| 117 |
/** Indicates RFC 3820 compliant independent proxy. |
| 118 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#INDEPENDENT |
| 119 |
* ProxyPolicy.INDEPENDENT} policy language OID. |
| 120 |
* @deprecated Use CertificateType.GSI_4_INDEPENDENT_PROXY instead |
| 121 |
*/ |
| 122 |
public static final int GSI_4_INDEPENDENT_PROXY = 17; |
| 123 |
|
| 124 |
/** Indicates RFC 3820 compliant impersonation proxy. |
| 125 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#IMPERSONATION |
| 126 |
* ProxyPolicy.IMPERSONATION} policy language OID. |
| 127 |
* @deprecated Use CertificateType.GSI_4_IMPERSONATION_PROXY instead |
| 128 |
*/ |
| 129 |
public static final int GSI_4_IMPERSONATION_PROXY = 18; |
| 130 |
|
| 131 |
/** Indicates RFC 3820 compliant limited impersonation proxy. |
| 132 |
* A proxy with {@link org.globus.gsi.proxy.ext.ProxyPolicy#LIMITED |
| 133 |
* ProxyPolicy.LIMITED} policy language OID. |
| 134 |
* @deprecated Use CertificateType.GSI_4_LIMITED_PROXY instead |
| 135 |
*/ |
| 136 |
public static final int GSI_4_LIMITED_PROXY = 19; |
| 137 |
|
| 138 |
/** GSI Transport protection method type |
| 139 |
* that will be used or was used to protect the request. |
| 140 |
* Can be set to: |
| 141 |
* {@link GSIConstants#SIGNATURE SIGNATURE} or |
| 142 |
* {@link GSIConstants#ENCRYPTION ENCRYPTION} or |
| 143 |
* {@link GSIConstants#NONE NONE}. |
| 144 |
*/ |
| 145 |
public static final String GSI_TRANSPORT = |
| 146 |
"org.globus.security.transport.type"; |
| 147 |
|
| 148 |
/** integrity message protection method. */ |
| 149 |
public static final Integer SIGNATURE |
| 150 |
= new Integer(1); |
| 151 |
|
| 152 |
/** privacy message protection method. */ |
| 153 |
public static final Integer ENCRYPTION |
| 154 |
= new Integer(2); |
| 155 |
|
| 156 |
/** none message protection method. */ |
| 157 |
public static final Integer NONE = |
| 158 |
new Integer(Integer.MAX_VALUE); |
| 159 |
|
| 160 |
/** |
| 161 |
* It is used to set a list of trusted certificates |
| 162 |
* to use during authentication (by default, the trusted certificates |
| 163 |
* are loaded from a standard location) The value is an instance of |
| 164 |
* {@link org.globus.gsi.TrustedCertificates TrustedCertificates} |
| 165 |
*/ |
| 166 |
public static final String TRUSTED_CERTIFICATES = |
| 167 |
"org.globus.security.trustedCertifictes"; |
| 168 |
|
| 169 |
/** |
| 170 |
* It is set to a Boolean value and if false, |
| 171 |
* client authorization requirement with delegation is disabled. By |
| 172 |
* default, client side authorization (to authorize the server) is |
| 173 |
* required for delegation of credentials. |
| 174 |
*/ |
| 175 |
public static final String AUTHZ_REQUIRED_WITH_DELEGATION = |
| 176 |
"org.globus.security.authz.required.delegation"; |
| 177 |
|
| 178 |
/** |
| 179 |
* Enumeration of Certificate types used by the Globus security provider. |
| 180 |
*/ |
| 181 |
// COMMENT: TODO: replace the the cert type constants with this enum |
| 182 |
public enum CertificateType { |
| 183 |
EEC(3), CA(4), GSI_2_PROXY(10), GSI_2_LIMITED_PROXY(11), GSI_3_RESTRICTED_PROXY(12), |
| 184 |
GSI_3_INDEPENDENT_PROXY(13), GSI_3_IMPERSONATION_PROXY(14), GSI_3_LIMITED_PROXY(15), |
| 185 |
GSI_4_RESTRICTED_PROXY(16), GSI_4_INDEPENDENT_PROXY(17), GSI_4_IMPERSONATION_PROXY(18), |
| 186 |
GSI_4_LIMITED_PROXY(19), UNDEFINED(-1); |
| 187 |
|
| 188 |
private int code; |
| 189 |
|
| 190 |
private CertificateType(int c) { |
| 191 |
code = c; |
| 192 |
} |
| 193 |
|
| 194 |
public int getCode() { |
| 195 |
return code; |
| 196 |
} |
| 197 |
|
| 198 |
public static CertificateType get(int code) { |
| 199 |
for (CertificateType tmp : CertificateType.values()) { |
| 200 |
if (tmp.getCode() == code) { |
| 201 |
return tmp; |
| 202 |
} |
| 203 |
} |
| 204 |
throw new IllegalArgumentException("invalid certificate type code"); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
/** |
| 209 |
* Enumeration of Certificate types used by the Globus security provider. |
| 210 |
*/ |
| 211 |
// COMMENT: TODO: replace the the delegation type constants with this enum |
| 212 |
public enum DelegationType { |
| 213 |
NONE(1), LIMITED(2), FULL(3); |
| 214 |
|
| 215 |
private int code; |
| 216 |
|
| 217 |
private DelegationType(int c) { |
| 218 |
code = c; |
| 219 |
} |
| 220 |
|
| 221 |
public int getCode() { |
| 222 |
return code; |
| 223 |
} |
| 224 |
|
| 225 |
public static DelegationType get(int code) { |
| 226 |
for (DelegationType tmp : DelegationType.values()) { |
| 227 |
if (tmp.getCode() == code) { |
| 228 |
return tmp; |
| 229 |
} |
| 230 |
} |
| 231 |
throw new IllegalArgumentException("invalid delegation type code"); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
} |