}
// After this continue on with the SCPE requests
// Generate the SCEP GetCert request
final ScepRequestGenerator gen = new ScepRequestGenerator();
gen.setKeys(StressTest.this.keyPair);
gen.setDigestOid(CMSSignedGenerator.DIGEST_SHA1);
final int keyUsagelength = 9;
final boolean keyUsage[] = new boolean[keyUsagelength];
{
final byte[] msgBytes;
{
int bcKeyUsage = 0;
for ( int i=0; i<keyUsagelength; i++ ) {
keyUsage[i] = StressTest.this.random.nextBoolean();
if ( keyUsage[i] ) {
bcKeyUsage += i<8 ? 1<<(7-i) : 1<<(15+8-i);
}
}
msgBytes = gen.generateCertReq(userDN, "foo123", transactionId, this.sessionData.certchain[0], generateExtensions(bcKeyUsage));
}
// Get some valuable things to verify later on
final String senderNonce = gen.getSenderNonce();
// Send message with HTTP GET
final byte[] retMsg = sendScep(false, msgBytes);
if ( retMsg == null ) {
StressTest.this.performanceTest.getLog().error("Error sending SCEP message.");
return false;
}
if (!isScepResponseMessageOfType(retMsg, ResponseStatus.PENDING)) {
final boolean okSuccess = checkScepResponse(retMsg, senderNonce, transactionId, false, CMSSignedGenerator.DIGEST_SHA1, true, ResponseStatus.SUCCESS, userDN, keyUsage);
if ( !okSuccess ) {
StressTest.this.performanceTest.getLog().error("Error receiving success response.");
return false;
}
return true;
}
final boolean okCertReq = checkScepResponse(retMsg, senderNonce, transactionId, false, CMSSignedGenerator.DIGEST_SHA1, false, ResponseStatus.PENDING, userDN, keyUsage);
if ( !okCertReq ) {
StressTest.this.performanceTest.getLog().error("Error receiving response to CertReq request.");
return false;
}
}
// Send GetCertInitial and wait for a certificate response, you will probably get PENDING reply several times
for ( int keeprunning = 0; keeprunning<5; keeprunning++) {
//System.out.println("Waiting 5 secs...");
Thread.sleep(5000); // wait 5 seconds between polls
// Generate a SCEP GerCertInitial message
gen.setKeys(StressTest.this.keyPair);
gen.setDigestOid(CMSSignedGenerator.DIGEST_SHA1);
final byte[] msgBytes = gen.generateGetCertInitial(userDN, transactionId, this.sessionData.certchain[0]);
// Get some valuable things to verify later on
final String senderNonce = gen.getSenderNonce();
// Send message with GET
final byte retMsg[] = sendScep(false, msgBytes);
if ( retMsg == null ) {
StressTest.this.performanceTest.getLog().error("Error sending SCEP message.");