|
35 | 35 | import java.lang.reflect.Method; |
36 | 36 | import java.math.BigInteger; |
37 | 37 | import java.text.ParseException; |
38 | | -import java.util.Collections; |
39 | 38 | import java.util.Date; |
40 | 39 | import java.util.Enumeration; |
41 | 40 | import java.util.HashMap; |
42 | | -import java.util.List; |
43 | 41 | import java.util.Map; |
44 | 42 | import java.util.WeakHashMap; |
45 | 43 |
|
@@ -1154,26 +1152,21 @@ private BytesInputStream(final ByteList bytes) { |
1154 | 1152 |
|
1155 | 1153 | } |
1156 | 1154 |
|
1157 | | - private static IRubyObject decodeImpl(final ThreadContext context, |
1158 | | - final RubyModule ASN1, final BytesInputStream in) throws IOException, IllegalArgumentException { |
| 1155 | + private static IRubyObject decodeImpl(final ThreadContext context, final RubyModule ASN1, final BytesInputStream in) |
| 1156 | + throws IOException, IllegalArgumentException { |
1159 | 1157 | // NOTE: need to handle OpenSSL::ASN1::Constructive wrapping by hand : |
1160 | 1158 | final Integer tag = getConstructiveTag(in.bytes(), in.offset()); |
1161 | 1159 | IRubyObject decoded = decodeObject(context, ASN1, readObject( in )); |
1162 | 1160 | if ( tag != null ) { // OpenSSL::ASN1::Constructive.new( arg ) : |
1163 | | - final String type; List<IRubyObject> value = null; |
1164 | 1161 | if ( tag.intValue() == SEQUENCE ) { |
1165 | 1162 | //type = "Sequence"; // got a OpenSSL::ASN1::Sequence already : |
1166 | 1163 | return Constructive.setInfiniteLength(context, decoded); |
1167 | 1164 | } |
1168 | | - else if ( tag.intValue() == SET ) { |
| 1165 | + if ( tag.intValue() == SET ) { |
1169 | 1166 | //type = "Set"; // got a OpenSSL::ASN1::Set already : |
1170 | 1167 | return Constructive.setInfiniteLength(context, decoded); |
1171 | 1168 | } |
1172 | | - else { |
1173 | | - type = "Constructive"; |
1174 | | - } |
1175 | | - if ( value == null ) value = Collections.singletonList(decoded); |
1176 | | - return Constructive.newInfiniteConstructive(context, type, value, tag); |
| 1169 | + return Constructive.newInfiniteConstructive(context, "Constructive", context.runtime.newArray(decoded), tag); |
1177 | 1170 | } |
1178 | 1171 | return decoded; |
1179 | 1172 | } |
@@ -1744,18 +1737,14 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a |
1744 | 1737 | } |
1745 | 1738 |
|
1746 | 1739 | static Constructive newInfiniteConstructive(final ThreadContext context, |
1747 | | - final String type, final List<IRubyObject> value, final int defaultTag) { |
| 1740 | + final String type, final IRubyObject value, final int defaultTag) { |
1748 | 1741 | final Ruby runtime = context.runtime; |
1749 | 1742 |
|
1750 | 1743 | final RubyClass klass = _ASN1(context.runtime).getClass(type); |
1751 | 1744 | final Constructive self = new Constructive(runtime, klass); |
1752 | 1745 |
|
1753 | | - final RubyArray values = runtime.newArray(value.size()); |
1754 | | - for ( final IRubyObject val : value ) values.append(val); |
1755 | | - // values.append( EndOfContent.newInstance(context) ); |
1756 | | - |
1757 | 1746 | self.setInstanceVariable("@tag", runtime.newFixnum(defaultTag)); |
1758 | | - self.setInstanceVariable("@value", values); |
| 1747 | + self.setInstanceVariable("@value", value); |
1759 | 1748 | self.setInstanceVariable("@tag_class", runtime.newSymbol("UNIVERSAL")); |
1760 | 1749 | self.setInstanceVariable("@tagging", context.nil); |
1761 | 1750 |
|
|
0 commit comments