Skip to content

Commit d78fb68

Browse files
committed
prepare to unify (internal) X509Object descendants
1 parent 6a5b3c3 commit d78fb68

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

Diff for: src/main/java/org/jruby/ext/openssl/x509store/CRL.java

+19-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
*/
3737
public class CRL extends X509Object {
3838

39-
public java.security.cert.CRL crl;
39+
public /* final */ java.security.cert.CRL crl;
40+
41+
@Deprecated // not-used
42+
public CRL() { /* */ }
43+
44+
public CRL(X509CRL crl) {
45+
this.crl = crl;
46+
}
4047

4148
@Override
4249
public int type() {
@@ -45,22 +52,24 @@ public int type() {
4552

4653
@Override
4754
public boolean isName(final Name name) {
48-
return name.equalTo( ((X509CRL) this.crl).getIssuerX500Principal() );
55+
return name.equalTo( ((X509CRL) crl).getIssuerX500Principal() );
4956
}
5057

5158
@Override
5259
public boolean matches(final X509Object other) {
53-
return other instanceof CRL &&
54-
((X509CRL) crl).getIssuerX500Principal().equals( ((X509CRL)((CRL) other).crl).getIssuerX500Principal() );
60+
if (other instanceof CRL) {
61+
final X509CRL thisCRL = (X509CRL) crl;
62+
final X509CRL thatCRL = (X509CRL)((CRL) other).crl;
63+
return thisCRL.getIssuerX500Principal().equals( thatCRL.getIssuerX500Principal() );
64+
}
65+
return false;
5566
}
5667

5768
@Override
58-
public int compareTo(X509Object oth) {
59-
int ret = super.compareTo(oth);
60-
if (ret == 0) {
61-
ret = crl.equals( ((CRL) oth).crl ) ? 0 : -1;
62-
}
63-
return ret;
69+
public int compareTo(final X509Object other) {
70+
int cmp = super.compareTo(other);
71+
if (cmp != 0) return cmp;
72+
return crl.equals( ((CRL) other).crl ) ? 0 : -1;
6473
}
6574

6675
}// X509_OBJECT_CRL

Diff for: src/main/java/org/jruby/ext/openssl/x509store/Certificate.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@ public boolean isName(final Name name) {
5252

5353
@Override
5454
public boolean matches(final X509Object other) {
55-
return other instanceof Certificate &&
56-
x509.getSubjectX500Principal().equals( ((Certificate) other).x509.getSubjectX500Principal() );
55+
if (other instanceof Certificate) {
56+
final Certificate that = (Certificate) other;
57+
return this.x509.getSubjectX500Principal().equals( that.x509.getSubjectX500Principal() );
58+
}
59+
return false;
5760
}
5861

5962
@Override
6063
public int compareTo(final X509Object other) {
61-
int ret = super.compareTo(other);
62-
if (ret == 0) {
63-
ret = x509.equals( ( (Certificate) other ).x509 ) ? 0 : -1;
64-
}
65-
return ret;
64+
int cmp = super.compareTo(other);
65+
if (cmp != 0) return cmp;
66+
return x509.equals( ( (Certificate) other ).x509 ) ? 0 : -1;
6667
}
6768

6869
}// X509_OBJECT_CERT

Diff for: src/main/java/org/jruby/ext/openssl/x509store/PKey.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* rights and limitations under the License.
1313
*
1414
* Copyright (C) 2006 Ola Bini <ola@ologix.com>
15-
*
15+
*
1616
* Alternatively, the contents of this file may be used under the terms of
1717
* either of the GNU General Public License Version 2 or later (the "GPL"),
1818
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -27,13 +27,23 @@
2727
***** END LICENSE BLOCK *****/
2828
package org.jruby.ext.openssl.x509store;
2929

30+
import java.security.PrivateKey;
31+
3032
/**
3133
* c: X509_OBJECT
3234
*
3335
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
3436
*/
3537
public class PKey extends X509Object {
36-
public java.security.PrivateKey pkey;
38+
39+
public /* final */ java.security.PrivateKey pkey;
40+
41+
@Deprecated // not-used
42+
public PKey() { /* no-op */ }
43+
44+
public PKey(PrivateKey pkey) {
45+
this.pkey = pkey;
46+
}
3747

3848
public int type() {
3949
return X509Utils.X509_LU_PKEY;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy