@@ -71,11 +71,10 @@ public void interest(CharSequence sender, CharSequence recipient, CharSequence f
7171 @ Override
7272 public void interest (CharSequence sender , CharSequence recipient , CharSequence format ,
7373 CharSequence channel , int eraFrom , int eraTo , OutputStream os , boolean signed ,
74- boolean encrypted )
75- throws IOException , ASAPException , ASAPSecurityException {
74+ boolean encrypted ) throws IOException , ASAPException {
7675
7776 // prepare encryption and signing if required
78- CryptoMessage cryptoMessage = new CryptoMessage (ASAP_1_0 .INTEREST_CMD ,
77+ ASAPCryptoMessage cryptoMessage = new ASAPCryptoMessage (ASAP_1_0 .INTEREST_CMD ,
7978 os , signed , encrypted , recipient ,
8079 this .signAndEncryptionKeyStorage );
8180
@@ -84,7 +83,7 @@ public void interest(CharSequence sender, CharSequence recipient, CharSequence f
8483 InterestPDU_Impl .sendPDUWithoutCmd (sender , recipient , format , channel , eraFrom , eraTo ,
8584 cryptoMessage .getOutputStream (), signed );
8685
87- // finish crypto session - if any
86+ // finish crypto session - maybe nothing has to be done
8887 cryptoMessage .finish ();
8988 }
9089
@@ -93,19 +92,46 @@ public void assimilate(CharSequence sender, CharSequence recipient, CharSequence
9392 CharSequence channel , int era , long length , List <Long > offsets , InputStream dataIS ,
9493 OutputStream os , boolean signed ) throws IOException , ASAPException {
9594
96- AssimilationPDU_Impl .sendPDU (sender , recipient , format , channel , era , length , offsets , dataIS , os , signed );
95+ this .assimilate (sender , recipient , format , channel , era , length , offsets , dataIS , os , signed , false );
96+ }
97+
98+ @ Override
99+ public void assimilate (CharSequence sender , CharSequence recipient , CharSequence format ,
100+ CharSequence channel , int era , long length , List <Long > offsets , InputStream dataIS ,
101+ OutputStream os , boolean signed , boolean encrypted ) throws IOException , ASAPException {
102+
103+ // prepare encryption and signing if required
104+ ASAPCryptoMessage cryptoMessage = new ASAPCryptoMessage (ASAP_1_0 .ASSIMILATE_CMD ,
105+ os , signed , encrypted , recipient ,
106+ this .signAndEncryptionKeyStorage );
107+
108+ cryptoMessage .sendCmd ();
109+
110+ AssimilationPDU_Impl .sendPDUWithoutCmd (sender , recipient , format , channel , era ,
111+ length , offsets , dataIS , cryptoMessage .getOutputStream (), signed );
112+
113+ // finish crypto session - maybe nothing has to be done
114+ cryptoMessage .finish ();
97115 }
98116
99117 @ Override
100118 public void assimilate (CharSequence sender , CharSequence recipient , CharSequence format ,
101119 CharSequence channel , int era , List <Long > offsets , byte [] data ,
102120 OutputStream os , boolean signed ) throws IOException , ASAPException {
103121
122+ this .assimilate (sender , recipient , format , channel , era , offsets , data , os , signed , false );
123+ }
124+
125+ @ Override
126+ public void assimilate (CharSequence sender , CharSequence recipient , CharSequence format ,
127+ CharSequence channel , int era , List <Long > offsets , byte [] data ,
128+ OutputStream os , boolean signed , boolean encrypted ) throws IOException , ASAPException {
129+
104130 if (data == null || data .length == 0 ) throw new ASAPException ("data must not be null" );
105131 if (era < 0 ) throw new ASAPException ("era must be a non-negative value: " + era );
106132
107133 this .assimilate (sender , recipient , format , channel , era , data .length , offsets ,
108- new ByteArrayInputStream (data ), os , signed );
134+ new ByteArrayInputStream (data ), os , signed , encrypted );
109135 }
110136
111137 @ Override
@@ -116,7 +142,7 @@ public ASAP_PDU_1_0 readPDU(InputStream is) throws IOException, ASAPException {
116142 boolean encrypted = (cmd & ENCRYPTED_MASK ) != 0 ;
117143
118144 if (encrypted ) {
119- CryptoMessage cryptoMessage = new CryptoMessage (this .signAndEncryptionKeyStorage );
145+ ASAPCryptoMessage cryptoMessage = new ASAPCryptoMessage (this .signAndEncryptionKeyStorage );
120146 boolean ownerIsRecipient = cryptoMessage .initDecryption (cmd , is );
121147 if (ownerIsRecipient ) {
122148 // peer is recipient - decrypt and go ahead
@@ -133,10 +159,10 @@ public ASAP_PDU_1_0 readPDU(InputStream is) throws IOException, ASAPException {
133159 int flagsInt = PDU_Impl .readByte (is );
134160
135161 InputStream realIS = is ;
136- CryptoMessage verifyCryptoMessage = null ;
162+ ASAPCryptoMessage verifyCryptoMessage = null ;
137163 if (PDU_Impl .flagSet (PDU_Impl .SIGNED_TO_BIT_POSITION , flagsInt )) {
138- verifyCryptoMessage = new CryptoMessage (this .signAndEncryptionKeyStorage );
139- is = verifyCryptoMessage .setupInputStreamCopier (flagsInt , is );
164+ verifyCryptoMessage = new ASAPCryptoMessage (this .signAndEncryptionKeyStorage );
165+ is = verifyCryptoMessage .initVerifiction (flagsInt , is );
140166 }
141167
142168 PDU_Impl pdu = null ;
0 commit comments