Skip to content

Commit 44be899

Browse files
committed
minor refactoring - changed method to setRegInfo, relates to github bcgit#1310.
1 parent 96c6d53 commit 44be899

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

CONTRIBUTORS.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@
595595
<li>Francesco Gini &lt;https://github.com/francesco-gini-privitar&gt; - RadixConverter speed up for SP 800-38G FPE.</li>
596596
<li>Alexander Falb &lt;https://github.com/elexx&gt; - additional JavaDoc in X509Extensions class.</li>
597597
<li>Brady Siegel &lt;https://github.com/bmsiegel&gt; - PKCS10CertificationRequest OID comparison fix.</li>
598+
<li>Andreas Kuehne &lt;https://github.com/kuehne-trustable-de&gt; - addition of regInfo to CRMF request message builder.</li>
598599
</ul>
599600
</body>
600601
</html>

pkix/src/main/java/org/bouncycastle/cert/crmf/CertificateRequestMessageBuilder.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class CertificateRequestMessageBuilder
5050
private POPOPrivKey popoPrivKey;
5151
private ASN1Null popRaVerified;
5252
private PKMACValue agreeMAC;
53-
private AttributeTypeAndValue[] attributeTypeAndValues;
53+
private AttributeTypeAndValue[] regInfo;
5454

5555
public CertificateRequestMessageBuilder(BigInteger certReqId)
5656
{
@@ -59,13 +59,13 @@ public CertificateRequestMessageBuilder(BigInteger certReqId)
5959
this.extGenerator = new ExtensionsGenerator();
6060
this.templateBuilder = new CertTemplateBuilder();
6161
this.controls = new ArrayList();
62-
this.attributeTypeAndValues = new AttributeTypeAndValue[0];
62+
this.regInfo = null;
6363
}
6464

65-
public CertificateRequestMessageBuilder setAttributeTypeAndValues(AttributeTypeAndValue[] attributeTypeAndValues) {
66-
if( attributeTypeAndValues != null) {
67-
this.attributeTypeAndValues = attributeTypeAndValues;
68-
}
65+
public CertificateRequestMessageBuilder setRegInfo(AttributeTypeAndValue[] regInfo)
66+
{
67+
this.regInfo = regInfo;
68+
6969
return this;
7070
}
7171

@@ -113,8 +113,7 @@ public CertificateRequestMessageBuilder setSerialNumber(BigInteger serialNumber)
113113
* Request a validity period for the certificate. Either, but not both, of the date parameters may be null.
114114
*
115115
* @param notBeforeDate not before date for certificate requested.
116-
* @param notAfterDate not after date for the certificate requested.
117-
*
116+
* @param notAfterDate not after date for the certificate requested.
118117
* @return the current builder.
119118
*/
120119
public CertificateRequestMessageBuilder setValidity(Date notBeforeDate, Date notAfterDate)
@@ -136,8 +135,8 @@ private Time createTime(Date date)
136135

137136
public CertificateRequestMessageBuilder addExtension(
138137
ASN1ObjectIdentifier oid,
139-
boolean critical,
140-
ASN1Encodable value)
138+
boolean critical,
139+
ASN1Encodable value)
141140
throws CertIOException
142141
{
143142
CRMFUtil.addExtension(extGenerator, oid, critical, value);
@@ -147,8 +146,8 @@ public CertificateRequestMessageBuilder addExtension(
147146

148147
public CertificateRequestMessageBuilder addExtension(
149148
ASN1ObjectIdentifier oid,
150-
boolean critical,
151-
byte[] value)
149+
boolean critical,
150+
byte[] value)
152151
{
153152
extGenerator.addExtension(oid, critical, value);
154153

@@ -313,15 +312,15 @@ else if (popoPrivKey != null)
313312
else if (agreeMAC != null)
314313
{
315314
proofOfPossession = new ProofOfPossession(ProofOfPossession.TYPE_KEY_AGREEMENT,
316-
POPOPrivKey.getInstance(new DERTaggedObject(false, POPOPrivKey.agreeMAC, agreeMAC)));
315+
POPOPrivKey.getInstance(new DERTaggedObject(false, POPOPrivKey.agreeMAC, agreeMAC)));
317316

318317
}
319318
else if (popRaVerified != null)
320319
{
321320
proofOfPossession = new ProofOfPossession();
322321
}
323322

324-
CertReqMsg certReqMsg = new CertReqMsg(request, proofOfPossession, attributeTypeAndValues);
323+
CertReqMsg certReqMsg = new CertReqMsg(request, proofOfPossession, regInfo);
325324

326325
return new CertificateRequestMessage(certReqMsg);
327326
}

pkix/src/test/java/org/bouncycastle/cert/crmf/test/AllTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void testBasicMessage()
153153
TestCase.assertEquals(kp.getPublic(), certReqMsg.getPublicKey());
154154
}
155155

156-
public void testBasicMessageWithAttributeTypeAndValue()
156+
public void testBasicMessageWithRegInfo()
157157
throws Exception
158158
{
159159
KeyPairGenerator kGen = KeyPairGenerator.getInstance("RSA", BC);
@@ -172,7 +172,7 @@ public void testBasicMessageWithAttributeTypeAndValue()
172172

173173
certReqBuild.setSubject(new X500Principal("CN=Test"))
174174
.setPublicKey(kp.getPublic())
175-
.setAttributeTypeAndValues(atavArr)
175+
.setRegInfo(atavArr)
176176
.setProofOfPossessionSigningKeySigner(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(kp.getPrivate()));
177177

178178
JcaCertificateRequestMessage certReqMsg = new JcaCertificateRequestMessage(certReqBuild.build()).setProvider(BC);

0 commit comments

Comments
 (0)