Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.eac;
  
  
an Iso7816CertificateBody structure.
  CertificateBody ::= SEQUENCE {
      // version of the certificate format. Must be 0 (version 1)
      CertificateProfileIdentifer         DERApplicationSpecific,
      //uniquely identifies the issuinng CA's signature key pair
      // contains the iso3166-1 alpha2 encoded country code, the
      // name of issuer and the sequence number of the key pair.
      CertificationAuthorityReference        DERApplicationSpecific,
      // stores the encoded public key
      PublicKey                            Iso7816PublicKey,
      //associates the public key contained in the certificate with a unique name
      // contains the iso3166-1 alpha2 encoded country code, the
      // name of the holder and the sequence number of the key pair.
      certificateHolderReference            DERApplicationSpecific,
      // Encodes the role of the holder (i.e. CVCA, DV, IS) and assigns read/write
      // access rights to data groups storing sensitive data
      certificateHolderAuthorization        Iso7816CertificateHolderAuthorization,
      // the date of the certificate generation
      CertificateEffectiveDate            DERApplicationSpecific,
      // the date after wich the certificate expires
      certificateExpirationDate            DERApplicationSpecific
  }
 
 
 public class CertificateBody
     extends ASN1Object
 {
     private DERApplicationSpecific certificateProfileIdentifier;// version of the certificate format. Must be 0 (version 1)
     private DERApplicationSpecific certificationAuthorityReference;//uniquely identifies the issuinng CA's signature key pair
     private PublicKeyDataObject publicKey;// stores the encoded public key
     private DERApplicationSpecific certificateHolderReference;//associates the public key contained in the certificate with a unique name
     private CertificateHolderAuthorization certificateHolderAuthorization;// Encodes the role of the holder (i.e. CVCA, DV, IS) and assigns read/write access rights to data groups storing sensitive data
     private DERApplicationSpecific certificateEffectiveDate;// the date of the certificate generation
     private DERApplicationSpecific certificateExpirationDate;// the date after wich the certificate expires
     private int certificateType = 0;// bit field of initialized data. This will tell us if the data are valid.
     private static final int CPI = 0x01;//certificate Profile Identifier
     private static final int CAR = 0x02;//certification Authority Reference
     private static final int PK = 0x04;//public Key
     private static final int CHR = 0x08;//certificate Holder Reference
     private static final int CHA = 0x10;//certificate Holder Authorization
     private static final int CEfD = 0x20;//certificate Effective Date
     private static final int CExD = 0x40;//certificate Expiration Date
 
     public static final int profileType = 0x7f;//Profile type Certificate
     public static final int requestType = 0x0D;// Request type Certificate
 
     private void setIso7816CertificateBody(DERApplicationSpecific appSpe)
         throws IOException
     {
         byte[] content;
         if (appSpe.getApplicationTag() == .)
         {
             content = appSpe.getContents();
         }
         else
         {
             throw new IOException("Bad tag : not an iso7816 CERTIFICATE_CONTENT_TEMPLATE");
         }
         ASN1InputStream aIS = new ASN1InputStream(content);
         ASN1Primitive obj;
         while ((obj = aIS.readObject()) != null)
         {
             DERApplicationSpecific aSpe;
 
             if (obj instanceof DERApplicationSpecific)
             {
                 aSpe = (DERApplicationSpecific)obj;
             }
             else
             {
                 throw new IOException("Not a valid iso7816 content : not a DERApplicationSpecific Object :" + EACTags.encodeTag(appSpe) + obj.getClass());
             }
             switch (aSpe.getApplicationTag())
             {
             case .:
                 setCertificateProfileIdentifier(aSpe);
                 break;
             case .:
                 setCertificationAuthorityReference(aSpe);
                 break;
             case .:
                 setPublicKey(PublicKeyDataObject.getInstance(aSpe.getObject(.)));
                 break;
            case .:
                setCertificateHolderReference(aSpe);
                break;
                setCertificateHolderAuthorization(new CertificateHolderAuthorization(aSpe));
                break;
            case .:
                setCertificateEffectiveDate(aSpe);
                break;
            case .:
                setCertificateExpirationDate(aSpe);
                break;
            default:
                 = 0;
                throw new IOException("Not a valid iso7816 DERApplicationSpecific tag " + aSpe.getApplicationTag());
            }
        }
    }

    
builds an Iso7816CertificateBody by settings each parameters.

Parameters:
certificateProfileIdentifier
certificationAuthorityReference
publicKey
certificateHolderReference
certificateHolderAuthorization
certificateEffectiveDate
certificateExpirationDate
    public CertificateBody(
        DERApplicationSpecific certificateProfileIdentifier,
        CertificationAuthorityReference certificationAuthorityReference,
        PublicKeyDataObject publicKey,
        CertificateHolderReference certificateHolderReference,
        CertificateHolderAuthorization certificateHolderAuthorization,
        PackedDate certificateEffectiveDate,
        PackedDate certificateExpirationDate
    )
    {
        setCertificateProfileIdentifier(certificateProfileIdentifier);
            .certificationAuthorityReference.getEncoded()));
        setPublicKey(publicKey);
            .certificateHolderReference.getEncoded()));
        setCertificateHolderAuthorization(certificateHolderAuthorization);
        try
        {
                false.new DEROctetString(certificateEffectiveDate.getEncoding())));
                false.new DEROctetString(certificateExpirationDate.getEncoding())));
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("unable to encode dates: " + e.getMessage());
        }
    }

    
builds an Iso7816CertificateBody with an ASN1InputStream.

Parameters:
obj DERApplicationSpecific containing the whole body.
Throws:
java.io.IOException if the body is not valid.
        throws IOException
    {
        setIso7816CertificateBody(obj);
    }

    
create a profile type Iso7816CertificateBody.

Returns:
return the "profile" type certificate body.
Throws:
java.io.IOException if the DERApplicationSpecific cannot be created.
        throws IOException
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        v.add();
        v.add();
    }
    private void setCertificateProfileIdentifier(DERApplicationSpecific certificateProfileIdentifier)
        throws IllegalArgumentException
    {
        if (certificateProfileIdentifier.getApplicationTag() == .)
        {
            this. = certificateProfileIdentifier;
             |= ;
        }
        else
        {
            throw new IllegalArgumentException("Not an Iso7816Tags.INTERCHANGE_PROFILE tag :" + EACTags.encodeTag(certificateProfileIdentifier));
        }
    }
    private void setCertificateHolderReference(DERApplicationSpecific certificateHolderReference)
        throws IllegalArgumentException
    {
        if (certificateHolderReference.getApplicationTag() == .)
        {
            this. = certificateHolderReference;
             |= ;
        }
        else
        {
            throw new IllegalArgumentException("Not an Iso7816Tags.CARDHOLDER_NAME tag");
        }
    }

    
set the CertificationAuthorityReference.

Parameters:
certificationAuthorityReference the DERApplicationSpecific containing the CertificationAuthorityReference.
Throws:
java.lang.IllegalArgumentException if the DERApplicationSpecific is not valid.
        DERApplicationSpecific certificationAuthorityReference)
        throws IllegalArgumentException
    {
        if (certificationAuthorityReference.getApplicationTag() == .)
        {
            this. = certificationAuthorityReference;
             |= ;
        }
        else
        {
            throw new IllegalArgumentException("Not an Iso7816Tags.ISSUER_IDENTIFICATION_NUMBER tag");
        }
    }

    
set the public Key

Parameters:
publicKey : the DERApplicationSpecific containing the public key
Throws:
java.io.IOException
    private void setPublicKey(PublicKeyDataObject publicKey)
    {
        this. = PublicKeyDataObject.getInstance(publicKey);
        this. |= ;
    }

    
create a request type Iso7816CertificateBody.

Returns:
return the "request" type certificate body.
Throws:
java.io.IOException if the DERApplicationSpecific cannot be created.
        throws IOException
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
    }

    
create a "request" or "profile" type Iso7816CertificateBody according to the variables sets.

Returns:
return the ASN1Primitive representing the "request" or "profile" type certificate body.
    {
        try
        {
            if ( == )
            {
                return profileToASN1Object();
            }
            if ( == )
            {
                return requestToASN1Object();
            }
        }
        catch (IOException e)
        {
            return null;
        }
        return null;
    }

    
gives the type of the certificate (value should be profileType or requestType if all data are set).

Returns:
the int representing the data already set.
    public int getCertificateType()
    {
        return ;
    }

    
Gives an instance of Iso7816CertificateBody taken from Object obj

Parameters:
obj is the Object to extract the certificate body from.
Returns:
the Iso7816CertificateBody taken from Object obj.
Throws:
java.io.IOException if object is not valid.
    public static CertificateBody getInstance(Object obj)
        throws IOException
    {
        if (obj instanceof CertificateBody)
        {
            return (CertificateBody)obj;
        }
        else if (obj != null)
        {
            return new CertificateBody(DERApplicationSpecific.getInstance(obj));
        }
        return null;
    }

    

Returns:
the date of the certificate generation
    {
        if ((this. & .) ==
            .)
        {
            return new PackedDate(.getContents());
        }
        return null;
    }

    
set the date of the certificate generation

Parameters:
ced DERApplicationSpecific containing the date of the certificate generation
Throws:
java.lang.IllegalArgumentException if the tag is not Iso7816Tags.APPLICATION_EFFECTIVE_DATE
        throws IllegalArgumentException
    {
        {
            this. = ced;
             |= ;
        }
        else
        {
            throw new IllegalArgumentException("Not an Iso7816Tags.APPLICATION_EFFECTIVE_DATE tag :" + EACTags.encodeTag(ced));
        }
    }

    

Returns:
the date after wich the certificate expires
        throws IOException
    {
        if ((this. & .) ==
            .)
        {
            return new PackedDate(.getContents());
        }
        throw new IOException("certificate Expiration Date not set");
    }

    
set the date after wich the certificate expires

Parameters:
ced DERApplicationSpecific containing the date after wich the certificate expires
Throws:
java.lang.IllegalArgumentException if the tag is not Iso7816Tags.APPLICATION_EXPIRATION_DATE
        throws IllegalArgumentException
    {
        {
            this. = ced;
             |= ;
        }
        else
        {
            throw new IllegalArgumentException("Not an Iso7816Tags.APPLICATION_EXPIRATION_DATE tag");
        }
    }

    
the Iso7816CertificateHolderAuthorization encodes the role of the holder (i.e. CVCA, DV, IS) and assigns read/write access rights to data groups storing sensitive data. This functions returns the Certificate Holder Authorization

Returns:
the Iso7816CertificateHolderAuthorization
        throws IOException
    {
        if ((this. & .) ==
            .)
        {
            return ;
        }
        throw new IOException("Certificate Holder Authorisation not set");
    }

    
set the CertificateHolderAuthorization

Parameters:
cha the Certificate Holder Authorization
    private void setCertificateHolderAuthorization(
        CertificateHolderAuthorization cha)
    {
        this. = cha;
         |= ;
    }

    
certificateHolderReference : associates the public key contained in the certificate with a unique name

Returns:
the certificateHolderReference.
    {
    }

    
CertificateProfileIdentifier : version of the certificate format. Must be 0 (version 1)

Returns:
the CertificateProfileIdentifier
    {
        return ;
    }

    
get the certificationAuthorityReference certificationAuthorityReference : uniquely identifies the issuinng CA's signature key pair

Returns:
the certificationAuthorityReference
        throws IOException
    {
        if ((this. & .) ==
            .)
        {
        }
        throw new IOException("Certification authority reference not set");
    }

    

Returns:
the PublicKey
    {
        return ;
    }
New to GrepCode? Check out our FAQ X