All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.eac.CertificateHolderReference Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.

There is a newer version: 2.0.3
Show newest version
/***************************************************************/
/******    DO NOT EDIT THIS CLASS bc-java SOURCE FILE     ******/
/***************************************************************/
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());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy