blob: 9a68b7d3bdeab4c8698142d414cf74ee8e0db684 (
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
67
68
69
70
71
72
73
74
75
76
|
package org.spongycastle.dvcs;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.spongycastle.asn1.dvcs.CertEtcToken;
import org.spongycastle.asn1.dvcs.DVCSRequestInformationBuilder;
import org.spongycastle.asn1.dvcs.DVCSTime;
import org.spongycastle.asn1.dvcs.Data;
import org.spongycastle.asn1.dvcs.ServiceType;
import org.spongycastle.asn1.dvcs.TargetEtcChain;
import org.spongycastle.asn1.x509.Extension;
import org.spongycastle.cert.X509CertificateHolder;
/**
* Builder of DVC requests to VPKC service (Verify Public Key Certificates).
*/
public class VPKCRequestBuilder
extends DVCSRequestBuilder
{
private List chains = new ArrayList();
public VPKCRequestBuilder()
{
super(new DVCSRequestInformationBuilder(ServiceType.VPKC));
}
/**
* Adds a TargetChain representing a X.509 certificate to the request.
*
* @param cert the certificate to be added
*/
public void addTargetChain(X509CertificateHolder cert)
{
chains.add(new TargetEtcChain(new CertEtcToken(CertEtcToken.TAG_CERTIFICATE, cert.toASN1Structure())));
}
/**
* Adds a TargetChain representing a single X.509 Extension to the request
*
* @param extension the extension to be added.
*/
public void addTargetChain(Extension extension)
{
chains.add(new TargetEtcChain(new CertEtcToken(extension)));
}
/**
* Adds a X.509 certificate to the request.
*
* @param targetChain the CertChain object to be added.
*/
public void addTargetChain(TargetChain targetChain)
{
chains.add(targetChain.toASN1Structure());
}
public void setRequestTime(Date requestTime)
{
requestInformationBuilder.setRequestTime(new DVCSTime(requestTime));
}
/**
* Build DVCS request to VPKC service.
*
* @throws DVCSException
*/
public DVCSRequest build()
throws DVCSException
{
Data data = new Data((TargetEtcChain[])chains.toArray(new TargetEtcChain[chains.size()]));
return createDVCRequest(data);
}
}
|