Java 类org.bouncycastle.asn1.tsp.TSTInfo 实例源码

项目:ipack    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;

    try
    {
        this.genTime = tstInfo.getGenTime().getDate();
    }
    catch (ParseException e)
    {
        throw new TSPException("unable to parse genTime field");
    }
}
项目:Aki-SSL    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;

    try
    {
        this.genTime = tstInfo.getGenTime().getDate();
    }
    catch (ParseException e)
    {
        throw new TSPException("unable to parse genTime field");
    }
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;

    try
    {
        this.genTime = tstInfo.getGenTime().getDate();
    }
    catch (ParseException e)
    {
        throw new TSPException("unable to parse genTime field");
    }
}
项目:irma_future_id    文件:TimeStampTokenInfoUnitTest.java   
private TimeStampTokenInfo getTimeStampTokenInfo(
    byte[] tstInfo) 
    throws IOException, TSPException
{
    ASN1InputStream    aIn = new ASN1InputStream(tstInfo);
    TSTInfo            info = TSTInfo.getInstance(aIn.readObject());

    return new TimeStampTokenInfo(info);
}
项目:bc-java    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;

    try
    {
        this.genTime = tstInfo.getGenTime().getDate();
    }
    catch (ParseException e)
    {
        throw new TSPException("unable to parse genTime field");
    }
}
项目:bc-java    文件:TimeStampTokenInfoUnitTest.java   
private TimeStampTokenInfo getTimeStampTokenInfo(
    byte[] tstInfo) 
    throws IOException, TSPException
{
    ASN1InputStream    aIn = new ASN1InputStream(tstInfo);
    TSTInfo            info = TSTInfo.getInstance(aIn.readObject());

    return new TimeStampTokenInfo(info);
}
项目:jpdfsigner    文件:TimeStampToken.java   
TimeStampTokenInfo(TSTInfo tstInfo) throws TSPException,
        IOException {
    this.tstInfo = tstInfo;

    try {
        this.genTime = tstInfo.getGenTime().getDate();
    } catch (ParseException e) {
        throw new TSPException("unable to parse genTime field");
    }
}
项目:ipack    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:ipack    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:ipack    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:gwt-crypto    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;
    this.genTime = tstInfo.getGenTime().getDate();
}
项目:gwt-crypto    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:gwt-crypto    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:gwt-crypto    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:Aki-SSL    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:Aki-SSL    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:Aki-SSL    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;
    this.genTime = tstInfo.getGenTime().getDate();
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:irma_future_id    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:irma_future_id    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:irma_future_id    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:irma_future_id    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:irma_future_id    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:bc-java    文件:TimeStampTokenInfo.java   
TimeStampTokenInfo(TSTInfo tstInfo)
    throws TSPException, IOException
{
    this.tstInfo = tstInfo;
    this.genTime = tstInfo.getGenTime().getDate();
}
项目:bc-java    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:bc-java    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:bc-java    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:bc-java    文件:TimeStampTokenInfo.java   
/**
 * @deprecated use toASN1Structure
 * @return
 */
public TSTInfo toTSTInfo()
{
    return tstInfo;
}
项目:bc-java    文件:TimeStampTokenInfo.java   
public TSTInfo toASN1Structure()
{
    return tstInfo;
}
项目:bc-java    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:bc-java    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:bc-java    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
    throws TSPException, IOException
{
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(PKCSObjectIdentifiers.id_ct_TSTInfo.getId()))
    {
        throw new TSPValidationException("ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1)
    {
        throw new IllegalArgumentException("Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation)signers.iterator().next();

    try
    {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute   attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr != null)
        {
            SigningCertificate    signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertID.getInstance(signCert.getCerts()[0]));
        }
        else
        {
            attr = tsaSignerInfo.getSignedAttributes().get(PKCSObjectIdentifiers.id_aa_signingCertificateV2);

            if (attr == null)
            {
                throw new TSPValidationException("no signing certificate attribute found, time stamp invalid.");
            }

            SigningCertificateV2 signCertV2 = SigningCertificateV2.getInstance(attr.getAttrValues().getObjectAt(0));

            this.certID = new CertID(ESSCertIDv2.getInstance(signCertV2.getCerts()[0]));
        }
    }
    catch (CMSException e)
    {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}
项目:jpdfsigner    文件:TimeStampToken.java   
public TimeStampToken(CMSSignedData signedData)
        throws TSPException, IOException {
    this.tsToken = signedData;

    if (!this.tsToken.getSignedContentTypeOID().equals(
            PKCSObjectIdentifiers.id_ct_TSTInfo.getId())) {
        throw new TSPValidationException(
                "ContentInfo object not for a time stamp.");
    }

    Collection signers = tsToken.getSignerInfos().getSigners();

    if (signers.size() != 1) {
        throw new IllegalArgumentException(
                "Time-stamp token signed by "
                + signers.size()
                + " signers, but it must contain just the TSA signature.");
    }

    tsaSignerInfo = (SignerInformation) signers.iterator().next();

    try {
        CMSProcessable content = tsToken.getSignedContent();
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        content.write(bOut);

        ASN1InputStream aIn = new ASN1InputStream(
                new ByteArrayInputStream(bOut.toByteArray()));

        this.tstInfo = new TimeStampTokenInfo(TSTInfo.getInstance(aIn.readObject()));

        Attribute attr = tsaSignerInfo.getSignedAttributes().get(
                PKCSObjectIdentifiers.id_aa_signingCertificate);

        if (attr == null) {
            throw new TSPValidationException(
                    "no signing certificate attribute found, time stamp invalid.");
        }

        SigningCertificate signCert = SigningCertificate.getInstance(attr.getAttrValues().getObjectAt(0));

        this.certID = ESSCertID.getInstance(signCert.getCerts()[0]);
    } catch (CMSException e) {
        throw new TSPException(e.getMessage(), e.getUnderlyingException());
    }
}