Debian Codegraph @

ssl-proxies/src/main/java/org/globus/gsi/bc/BouncyCastleX509Extension.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.bc;
16
17 import java.io.IOException;
18
19 import org.bouncycastle.asn1.ASN1Encodable;
20
21 import org.globus.gsi.X509Extension;
22
23 import org.globus.util.I18n;
24
25 /**
26 * A convenience class for creating X.509 extensions from
27 * <code>DEREncodable</code> objects.
28 */
29 public class BouncyCastleX509Extension extends X509Extension {
30
31 private static I18n i18n =
32 I18n.getI18n("org.globus.gsi.errors",
33 BouncyCastleX509Extension.class.getClassLoader());
34
35 public BouncyCastleX509Extension(String oid) {
36 this(oid, false, null);
37 }
38
39 public BouncyCastleX509Extension(String oid, ASN1Encodable value) {
40 this(oid, false, value);
41 }
42
43 public BouncyCastleX509Extension(String oid, boolean critical,
44 ASN1Encodable value) {
45 super(oid, critical, null);
46 setValue(value);
47 }
48
49 protected void setValue(ASN1Encodable value) {
50 if (value == null) {
51 return;
52 }
53 try {
54 setValue(BouncyCastleUtil.toByteArray(value.toASN1Primitive()));
55 } catch (IOException e) {
56 throw new RuntimeException(i18n.getMessage("byteArrayErr") +
57 e.getMessage());
58 }
59 }
60 }