@@ -45,17 +45,17 @@ public void offer(CharSequence recipient, CharSequence format, CharSequence chan
4545 @ Override
4646 public void interest (CharSequence sender , CharSequence recipient , CharSequence format ,
4747 CharSequence channel , OutputStream os , boolean signed ,
48- boolean encryted , boolean mustBeEncrypted ) throws IOException , ASAPException {
48+ boolean encryted ) throws IOException , ASAPException {
4949
5050 this .interest (sender , recipient , format , channel , ERA_NOT_DEFINED , ERA_NOT_DEFINED , os ,
51- signed , encryted , mustBeEncrypted );
51+ signed , encryted );
5252 }
5353
5454 @ Override
5555 public void interest (CharSequence sender , CharSequence recipient , CharSequence format ,
5656 CharSequence channel , OutputStream os ) throws IOException , ASAPException {
5757
58- this .interest (sender , recipient , format , channel , os , false , false , false );
58+ this .interest (sender , recipient , format , channel , os , false , false );
5959 }
6060
6161 @ Override
@@ -64,17 +64,26 @@ public void interest(CharSequence sender, CharSequence recipient, CharSequence f
6464 throws IOException , ASAPException {
6565
6666 this .interest (sender , recipient , format , channel , eraFrom , eraTo , os ,
67- signed , false , false );
67+ signed , false );
6868 }
6969
7070 @ Override
7171 public void interest (CharSequence sender , CharSequence recipient , CharSequence format ,
7272 CharSequence channel , int eraFrom , int eraTo , OutputStream os , boolean signed ,
73- boolean encryted , boolean mustBeEncrypted )
73+ boolean encrypted )
7474 throws IOException , ASAPException , ASAPSecurityException {
7575
76- InterestPDU_Impl .sendPDU (sender , recipient , format , channel , eraFrom , eraTo , os ,
77- signed , encryted , mustBeEncrypted , this .signAndEncryptionKeyStorage );
76+ // prepare encryption and signing if required
77+ CryptoSession cryptoSession = new CryptoSession (ASAP_1_0 .INTEREST_CMD ,
78+ os , signed , encrypted , recipient , this .signAndEncryptionKeyStorage );
79+
80+ cryptoSession .sendHeader ();
81+
82+ InterestPDU_Impl .sendPDUWithoutCmd (sender , recipient , format , channel , eraFrom , eraTo ,
83+ cryptoSession .getOutputStream ());
84+
85+ // finish crypto session - if any
86+ cryptoSession .finish ();
7887 }
7988
8089 @ Override
@@ -103,17 +112,17 @@ public ASAP_PDU_1_0 readPDU(InputStream is) throws IOException, ASAPException {
103112
104113 // encrypted?
105114 boolean encrypted = (cmd & ENCRYPTED_MASK ) != 0 ;
106- // remove encrypted flag anyway
115+ // remove encrypted flag
107116 cmd = (byte )(cmd & CMD_MASK );
108117
109118 int flagsInt = PDU_Impl .readByte (is );
110119
111120 ASAP_PDU_1_0 pdu = null ;
112121
113122 switch (cmd ) {
114- case ASAP_1_0 .OFFER_CMD : pdu = new OfferPDU_Impl (flagsInt , is ); break ;
115- case ASAP_1_0 .INTEREST_CMD : pdu = new InterestPDU_Impl (flagsInt , is ); break ;
116- case ASAP_1_0 .ASSIMILATE_CMD : pdu = new AssimilationPDU_Impl (flagsInt , is ); break ;
123+ case ASAP_1_0 .OFFER_CMD : pdu = new OfferPDU_Impl (flagsInt , encrypted , is ); break ;
124+ case ASAP_1_0 .INTEREST_CMD : pdu = new InterestPDU_Impl (flagsInt , encrypted , is ); break ;
125+ case ASAP_1_0 .ASSIMILATE_CMD : pdu = new AssimilationPDU_Impl (flagsInt , encrypted , is ); break ;
117126 default : throw new ASAPException ("unknown command: " + cmd );
118127 }
119128
0 commit comments