// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.openssl;

import org.bouncycastle.util.Arrays;
import java.io.IOException;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.cert.X509CertificateHolder;

public class X509TrustedCertificateBlock
{
    private final X509CertificateHolder certificateHolder;
    private final CertificateTrustBlock trustBlock;
    
    public X509TrustedCertificateBlock(final X509CertificateHolder certificateHolder, final CertificateTrustBlock trustBlock) {
        this.certificateHolder = certificateHolder;
        this.trustBlock = trustBlock;
    }
    
    public X509TrustedCertificateBlock(final byte[] array) throws IOException {
        final ASN1InputStream asn1InputStream = new ASN1InputStream(array);
        this.certificateHolder = new X509CertificateHolder(asn1InputStream.readObject().getEncoded());
        final ASN1Primitive object = asn1InputStream.readObject();
        if (object != null) {
            this.trustBlock = new CertificateTrustBlock(object.getEncoded());
        }
        else {
            this.trustBlock = null;
        }
    }
    
    public byte[] getEncoded() throws IOException {
        return Arrays.concatenate(this.certificateHolder.getEncoded(), this.trustBlock.toASN1Sequence().getEncoded());
    }
    
    public X509CertificateHolder getCertificateHolder() {
        return this.certificateHolder;
    }
    
    public CertificateTrustBlock getTrustBlock() {
        return this.trustBlock;
    }
}
