Rev

Rev 2230 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | Bug Tracker

Rev 2230 Rev 2655
Line 2... Line 2...
2
 * @author      ETSI / STF481 / Yann Garcia
2
 * @author      ETSI / STF481 / Yann Garcia
3
 * @version     $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/codec/org/etsi/ttcn/codec/its/security/SecPayload.java $
3
 * @version     $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/codec/org/etsi/ttcn/codec/its/security/SecPayload.java $
4
 *              $Id: SecPayload.java 2230 2015-06-03 09:11:02Z mullers $
4
 *              $Id: SecPayload.java 2655 2017-01-26 10:46:08Z filatov $
5
 */
5
 */
6
package org.etsi.ttcn.codec.its.security;
6
package org.etsi.ttcn.codec.its.security;
7
7
8
import org.etsi.ttcn.codec.CodecBuffer;
8
import org.etsi.ttcn.codec.CodecBuffer;
9
import org.etsi.ttcn.codec.MainCodec;
9
import org.etsi.ttcn.codec.MainCodec;
Line 24... Line 24...
24
        mainCodec.setHint("SecPayloadTypeLen", "8");
24
        mainCodec.setHint("SecPayloadTypeLen", "8");
25
    }
25
    }
26
   
26
   
27
    @Override
27
    @Override
28
    protected void postEncodeField(String fieldName, CodecBuffer buf) {
28
    protected void postEncodeField(String fieldName, CodecBuffer buf) {
29
//        System.out.println(">>> SecPayload.postEncodeField: " + fieldName);
29
//        TERFactory.getInstance().logDebug(">>> SecPayload.postEncodeField: " + fieldName);
30
       
30
       
31
        if (fieldName.equals("data")) {
31
        if (fieldName.equals("data")) {
32
            // Store first the octetstring length as specified in Draft ETSI TS 103 097 V1.1.14 Clause 4.2
32
            // Store first the octetstring length as specified in Draft ETSI TS 103 097 V1.1.14 Clause 4.2
33
            CodecBuffer bufLen = new CodecBuffer(new byte[] { (byte)buf.getNbBytes() } );
33
            CodecBuffer bufLen = new CodecBuffer(new byte[] { (byte)buf.getNbBytes() } );
34
            bufLen.append(buf);
34
            bufLen.append(buf);
35
            buf.overwriteWith(bufLen);
35
            buf.overwriteWith(bufLen);
36
        }
36
        }
37
    }
37
    }
38
   
38
   
39
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
39
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
40
//        System.out.println(">>> SecPayload.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
40
//        TERFactory.getInstance().logDebug(">>> SecPayload.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
41
       
41
       
42
        if (fieldName.equals("type_")) {
42
        if (fieldName.equals("type_")) {
43
            mainCodec.setPresenceHint("data", buf.getBytes(0, 1)[0] != c_signed_external);
43
            mainCodec.setPresenceHint("data", buf.getBytes(0, 1)[0] != c_signed_external);
44
        } else if (fieldName.equals("data") && (mainCodec.getPresenceHint("data") == true)) {
44
        } else if (fieldName.equals("data") && (mainCodec.getPresenceHint("data") == true)) {
45
            int len = (int) TlsHelper.getInstance().tls2size(buf);
45
            int len = (int) TlsHelper.getInstance().tls2size(buf);
46
//            System.out.println("SecPayload.preDecodeField: len = " + len);
46
//            TERFactory.getInstance().logDebug("SecPayload.preDecodeField: len = " + len);
47
            mainCodec.setHint("octetstringLen", Integer.toString(len));
47
            mainCodec.setHint("octetstringLen", Integer.toString(len));
48
        }
48
        }
49
    }
49
    }
50
   
50
   
51
    @Override
51
    @Override
52
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
52
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
53
//        System.out.println(">>> SecPayload.postDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
53
//        TERFactory.getInstance().logDebug(">>> SecPayload.postDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
54
    }
54
    }
55
   
55
   
56
} // End of class SecPayload
56
} // End of class SecPayload