Skip to content

Commit 5b5e0e5

Browse files
committed
support dup for X.509 Attribute/Extension
1 parent f69a6e7 commit 5b5e0e5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/main/java/org/jruby/ext/openssl/X509Attribute.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
127127
return this;
128128
}
129129

130+
@Override
131+
public IRubyObject initialize_copy(final IRubyObject original) {
132+
if (this == original) return this;
133+
checkFrozen();
134+
135+
final X509Attribute that = (X509Attribute) original;
136+
this.value = that.value == null ? null : that.value.dup();
137+
this.oid = that.oid;
138+
this.objectId = that.objectId;
139+
return this;
140+
}
141+
130142
@JRubyMethod
131143
public IRubyObject to_der(final ThreadContext context) {
132144
final byte[] bytes;

src/main/java/org/jruby/ext/openssl/X509Extension.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ else if ( args.length > 1 ) {
280280
return this;
281281
}
282282

283+
@Override
284+
public IRubyObject initialize_copy(final IRubyObject original) {
285+
if (this == original) return this;
286+
checkFrozen();
287+
288+
final X509Extension that = (X509Extension) original;
289+
this.value = that.value;
290+
this.objectID = that.objectID;
291+
this.critical = that.critical;
292+
return this;
293+
}
294+
283295
@JRubyMethod
284296
public IRubyObject oid(final ThreadContext context) {
285297
return context.runtime.newString( oidSym(context.runtime) );

0 commit comments

Comments
 (0)