Rev

Rev 1822 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
1665 garciay 1
/**
2
 * @author      ETSI / STF481 / Yann Garcia
3
 * @version     $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/codec/org/etsi/ttcn/codec/its/security/HeaderField.java $
4
 *              $Id: HeaderField.java 2655 2017-01-26 10:46:08Z filatov $
5
 */
1494 garciay 6
package org.etsi.ttcn.codec.its.security;
7
 
8
import org.etsi.ttcn.codec.CodecBuffer;
9
import org.etsi.ttcn.codec.MainCodec;
10
import org.etsi.ttcn.codec.generic.Record;
11
import org.etsi.ttcn.tci.RecordValue;
12
import org.etsi.ttcn.tci.Type;
13
 
14
/**
15
 * @desc Information of interest to the security layer
1789 garciay 16
 * @see Draft ETSI TS 103 097 V1.1.14 Clause 5.4    HeaderField
1494 garciay 17
 */
18
public class HeaderField extends Record {
19
 
1504 garciay 20
    final byte c_generation_time                        = 0x00;                /** A timestamp of type Time64 */
21
    final byte c_generation_time_with_standard_deviation= 0x01;                /** A timestamp of type Time64WithStandardDeviation */
22
    final byte c_expiration                             = 0x02;                /** The point in time the validity of this message expires */
23
    final byte c_generation_location                    = 0x03;                /** The location where this message was created  */
24
    final byte c_request_unrecognized_certificate       = 0x04;                /** A request for certificates */
1741 garciay 25
    final byte c_its_aid                                = 0x05;                /** Its AID valued used to identify CAM/DENM secured messages */
1731 garciay 26
    final byte c_signer_info                            = (byte)0x80;          /** Information about the message's signer */
27
    final byte c_encryption_parameters                  = (byte)0x81;          /** Information specific for certain recipients */
28
    final byte c_recipient_info                         = (byte)0x82;          /** Additional parameters necessary for encryption purposes  */
1494 garciay 29
 
30
    /**
31
     * Constructor
32
     * @param mainCodec MainCodec reference
33
     */
34
    public HeaderField(MainCodec mainCodec) {
35
        super(mainCodec);
36
        setLengths();
37
    }
38
 
39
    /**
40
     * @desc Predefined field lengths
41
     */
42
    private void setLengths() {
43
        mainCodec.setHint("HeaderFieldTypeLen", "8");
1516 garciay 44
        mainCodec.setHint("Oct2Len", "2");
1494 garciay 45
    }
46
 
47
    /**
48
     * @desc Set the variant according to the HeaderField type
1789 garciay 49
     * @see See Draft ETSI TS 103 097 V1.1.14 Clause 5.5    HeaderFieldType
1494 garciay 50
     */
51
    @Override
52
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 53
//        TERFactory.getInstance().logDebug(">>> HeaderField.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
54
 
1494 garciay 55
        if (fieldName.equals("type_")) {
56
            byte type_ = buf.getBytes(0, 1)[0];
57
            switch (type_) {
58
                case (byte)c_generation_time:
1504 garciay 59
                    mainCodec.setHint("HeaderFieldContainer", "generation_time"); // Set variant 
1494 garciay 60
                    break;
1504 garciay 61
                case (byte)c_generation_time_with_standard_deviation:
62
                    mainCodec.setHint("HeaderFieldContainer", "generation_time_with_standard_deviation"); // Set variant 
1494 garciay 63
                    break;
64
                case (byte)c_expiration:
1504 garciay 65
                    mainCodec.setHint("HeaderFieldContainer", "expiry_time"); // Set variant 
1494 garciay 66
                    break;
67
                case (byte)c_generation_location:
1504 garciay 68
                    mainCodec.setHint("HeaderFieldContainer", "generation_location"); // Set variant 
1494 garciay 69
                    break;
70
                case (byte)c_request_unrecognized_certificate:
1504 garciay 71
                    mainCodec.setHint("HeaderFieldContainer", "digests"); // Set variant 
1510 garciay 72
                    mainCodec.setHint("HashedId3Len", "3"); // FIXME TCT3 returns 12/length(3)/HashedId3 instead of 12/LibItsSecurity/HashedId3
73
                    break;
1731 garciay 74
                case (byte)c_its_aid:
75
                    mainCodec.setHint("HeaderFieldContainer", "its_aid"); // Set variant 
76
                    break;
1494 garciay 77
                case (byte)c_signer_info:
1504 garciay 78
                    mainCodec.setHint("HeaderFieldContainer", "signer"); // Set variant 
1494 garciay 79
                    break;
1731 garciay 80
                case (byte)c_encryption_parameters:
81
                    mainCodec.setHint("HeaderFieldContainer", "enc_params"); // Set variant 
82
                    break;
1494 garciay 83
                case (byte)c_recipient_info:
1510 garciay 84
                    mainCodec.setHint("HeaderFieldContainer", "recipients"); // Set variant 
1494 garciay 85
                    break;
86
                default:
1504 garciay 87
                    mainCodec.setHint("HeaderFieldContainer", "other_header"); // Set variant 
1494 garciay 88
                    break;
89
            } // End of 'switch' statement
90
        }
91
    }
92
 
93
} // End of class HeaderField