Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CertificateHolderReference.java « eac « asn1 « bouncycastle « org « java « main « src « core - gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec8dec08d0bce9b64cde453d3e50e6bad7d5f3da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.bouncycastle.asn1.eac;

import java.io.UnsupportedEncodingException;

public class CertificateHolderReference
{
    private static final String ReferenceEncoding = "ISO-8859-1";

    private String countryCode;
    private String holderMnemonic;
    private String sequenceNumber;

    public CertificateHolderReference(String countryCode, String holderMnemonic, String sequenceNumber)
    {
        this.countryCode = countryCode;
        this.holderMnemonic = holderMnemonic;
        this.sequenceNumber = sequenceNumber;
    }

    CertificateHolderReference(byte[] contents)
    {
        try
        {
            String concat = new String(contents, ReferenceEncoding);

            this.countryCode = concat.substring(0, 2);
            this.holderMnemonic = concat.substring(2, concat.length() - 5);

            this.sequenceNumber = concat.substring(concat.length() - 5);
        }
        catch (UnsupportedEncodingException e)
        {
            throw new IllegalStateException(e.toString());
        }
    }

    public String getCountryCode()
    {
        return countryCode;
    }

    public String getHolderMnemonic()
    {
        return holderMnemonic;
    }

    public String getSequenceNumber()
    {
        return sequenceNumber;
    }


    public byte[] getEncoded()
    {
        String ref = countryCode + holderMnemonic + sequenceNumber;

        try
        {
            return ref.getBytes(ReferenceEncoding);
        }
        catch (UnsupportedEncodingException e)
        {
            throw new IllegalStateException(e.toString());
        }
    }
}