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/SubjectAttribute.java $
4
 *              $Id: SubjectAttribute.java 2655 2017-01-26 10:46:08Z filatov $
5
 */
1516 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
public class SubjectAttribute extends Record {
15
 
16
    final byte c_verification_key        = 0x00;
17
    final byte c_encryption_key          = 0x01;
18
    final byte c_assurance_level         = 0x02;
19
    final byte c_reconstruction_value    = 0x03;
1534 garciay 20
    final byte c_its_aid_list            = 0x20;
21
    final byte c_its_aid_ssp_list        = 0x21;
1516 garciay 22
 
23
    public SubjectAttribute(MainCodec mainCodec) {
24
        super(mainCodec);
25
        setLengths();
26
    }
27
 
28
    private void setLengths() {
29
        mainCodec.setHint("SubjectAttributeTypeLen", "8");
30
    }
31
 
32
    @Override
33
    protected void postEncodeField(String fieldName, CodecBuffer buf) {
2655 filatov 34
//        TERFactory.getInstance().logDebug(">>> SubjectAttribute.postEncodeField: " + fieldName);
1516 garciay 35
    }
36
 
37
    @Override
38
    protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 39
//        TERFactory.getInstance().logDebug(">>> SubjectAttribute.preDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
1516 garciay 40
 
41
        if (fieldName.equals("type_")) {
42
            byte type_ = buf.getBytes(0, 1)[0];
43
            switch (type_) {
44
                case (byte)c_verification_key:
1519 garciay 45
                    // No break;
46
                case (byte)c_encryption_key:
1516 garciay 47
                    mainCodec.setHint("SubjectAttributeContainer", "key"); // Set variant 
48
                    break;
1519 garciay 49
                case (byte)c_reconstruction_value:
1516 garciay 50
                    mainCodec.setHint("SubjectAttributeContainer", "rv"); // Set variant 
51
                    break;
52
                case (byte)c_assurance_level:
53
                    mainCodec.setHint("SubjectAttributeContainer", "assurance_level"); // Set variant 
54
                    break;
1519 garciay 55
                case (byte)c_its_aid_list:
1516 garciay 56
                    mainCodec.setHint("SubjectAttributeContainer", "its_aid_list"); // Set variant 
57
                    break;
58
                case (byte)c_its_aid_ssp_list:
59
                    mainCodec.setHint("SubjectAttributeContainer", "its_aid_ssp_list"); // Set variant 
60
                    break;
61
                default:
62
                    mainCodec.setHint("SubjectAttributeContainer", "other_attribute"); // Set variant 
63
                    break;
64
            } // End of 'switch' statement
65
        }
66
    }
67
 
68
    @Override
69
    protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
2655 filatov 70
//        TERFactory.getInstance().logDebug(">>> SubjectAttribute.postDecodeField: " + fieldName + ", " + decodingHypothesis.getName() + ", " + rv.getType().getName());
1516 garciay 71
    }
72
 
73
} // End of class SubjectAttribute