File tree Expand file tree Collapse file tree 5 files changed +19
-14
lines changed
pg/src/main/java/org/bouncycastle Expand file tree Collapse file tree 5 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,22 @@ public BCPGInputStream(
2626 this .in = in ;
2727 }
2828
29+ /**
30+ * If the argument is a {@link BCPGInputStream}, return it.
31+ * Otherwise wrap it in a {@link BCPGInputStream} and then return the result.
32+ *
33+ * @param in input stream
34+ * @return BCPGInputStream
35+ */
36+ public static BCPGInputStream wrap (InputStream in )
37+ {
38+ if (in instanceof BCPGInputStream )
39+ {
40+ return (BCPGInputStream )in ;
41+ }
42+ return new BCPGInputStream (in );
43+ }
44+
2945 public int available ()
3046 throws IOException
3147 {
Original file line number Diff line number Diff line change 11package org .bouncycastle .openpgp ;
22
33import java .io .IOException ;
4- import java .io .InputStream ;
54import java .io .OutputStream ;
65import java .util .ArrayList ;
76import java .util .Iterator ;
@@ -30,16 +29,6 @@ public abstract class PGPKeyRing
3029 {
3130 }
3231
33- static BCPGInputStream wrap (InputStream in )
34- {
35- if (in instanceof BCPGInputStream )
36- {
37- return (BCPGInputStream )in ;
38- }
39-
40- return new BCPGInputStream (in );
41- }
42-
4332 static TrustPacket readOptionalTrustPacket (
4433 BCPGInputStream pIn )
4534 throws IOException
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public PGPObjectFactory(
5454 InputStream in ,
5555 KeyFingerPrintCalculator fingerPrintCalculator )
5656 {
57- this .in = new BCPGInputStream (in );
57+ this .in = BCPGInputStream . wrap (in );
5858 this .fingerPrintCalculator = fingerPrintCalculator ;
5959 }
6060
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public PGPPublicKeyRing(
9494 {
9595 this .keys = new ArrayList <PGPPublicKey >();
9696
97- BCPGInputStream pIn = wrap (in );
97+ BCPGInputStream pIn = BCPGInputStream . wrap (in );
9898
9999 int initialTag = pIn .skipMarkerPackets ();
100100 if (initialTag != PacketTags .PUBLIC_KEY && initialTag != PacketTags .PUBLIC_SUBKEY )
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public PGPSecretKeyRing(
101101 this .keys = new ArrayList <PGPSecretKey >();
102102 this .extraPubKeys = new ArrayList <PGPPublicKey >();
103103
104- BCPGInputStream pIn = wrap (in );
104+ BCPGInputStream pIn = BCPGInputStream . wrap (in );
105105
106106 int initialTag = pIn .skipMarkerPackets ();
107107 if (initialTag != PacketTags .SECRET_KEY && initialTag != PacketTags .SECRET_SUBKEY )
You can’t perform that action at this time.
0 commit comments