equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Sun designates this |
7 * published by the Free Software Foundation. Sun designates this |
68 private boolean ca = false; |
68 private boolean ca = false; |
69 private int pathLen = -1; |
69 private int pathLen = -1; |
70 |
70 |
71 // Encode this extension value |
71 // Encode this extension value |
72 private void encodeThis() throws IOException { |
72 private void encodeThis() throws IOException { |
73 if (ca == false && pathLen < 0) { |
|
74 this.extensionValue = null; |
|
75 return; |
|
76 } |
|
77 DerOutputStream out = new DerOutputStream(); |
73 DerOutputStream out = new DerOutputStream(); |
78 DerOutputStream tmp = new DerOutputStream(); |
74 DerOutputStream tmp = new DerOutputStream(); |
79 |
75 |
80 if (ca) { |
76 if (ca) { |
81 tmp.putBoolean(ca); |
77 tmp.putBoolean(ca); |
82 } |
78 // Only encode pathLen when ca == true |
83 if (pathLen >= 0) { |
79 if (pathLen >= 0) { |
84 tmp.putInteger(pathLen); |
80 tmp.putInteger(pathLen); |
|
81 } |
85 } |
82 } |
86 out.write(DerValue.tag_Sequence, tmp); |
83 out.write(DerValue.tag_Sequence, tmp); |
87 this.extensionValue = out.toByteArray(); |
84 this.extensionValue = out.toByteArray(); |
88 } |
85 } |
89 |
86 |
132 DerValue val = new DerValue(this.extensionValue); |
129 DerValue val = new DerValue(this.extensionValue); |
133 if (val.tag != DerValue.tag_Sequence) { |
130 if (val.tag != DerValue.tag_Sequence) { |
134 throw new IOException("Invalid encoding of BasicConstraints"); |
131 throw new IOException("Invalid encoding of BasicConstraints"); |
135 } |
132 } |
136 |
133 |
137 if (val.data == null) { |
134 if (val.data == null || val.data.available() == 0) { |
138 // non-CA cert ("cA" field is FALSE by default), return -1 |
135 // non-CA cert ("cA" field is FALSE by default), return -1 |
139 return; |
136 return; |
140 } |
137 } |
141 DerValue opt = val.data.getDerValue(); |
138 DerValue opt = val.data.getDerValue(); |
142 if (opt.tag != DerValue.tag_Boolean) { |
139 if (opt.tag != DerValue.tag_Boolean) { |