com.unbound.provider.kmip.response.ResponseMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unbound-java-provider Show documentation
Show all versions of unbound-java-provider Show documentation
This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi
package com.unbound.provider.kmip.response;
import com.unbound.common.Log;
import com.unbound.provider.kmip.KMIP;
import com.unbound.provider.kmip.KMIPConvertException;
import com.unbound.provider.kmip.KMIPConverter;
import java.util.ArrayList;
/**
* Created by valery.osheter on 19-Nov-15.
*/
public class ResponseMessage
{
public ResponseHeader header = new ResponseHeader();
public ArrayList batch = new ArrayList<>();
public ResponseMessage()
{
header.version.major = 1;
header.version.minor = 0;
}
public void convert(KMIPConverter converter) throws KMIPConvertException
{
int begin = converter.convertBegin(KMIP.Tag.ResponseMessage);
header.convert(converter);
// int count = converter.isWrite() ? batch.size() : header.batch_count;
if (converter.isWrite())
{
for (ResponseItem item : batch) ResponseItem.convert(converter, item);
}
else
{
for (int i = 0; i < header.batchCount; i++)
{
ResponseItem item = ResponseItem.convert(converter, null);
batch.add(item);
}
}
converter.convertEnd(begin);
}
public void add(ResponseItem responseItem, byte[] uid)
{
if (responseItem.operation == KMIP.Operation.Poll)
{
if (((PollResponse) responseItem).responseItem != null)
{
add(((PollResponse) responseItem).responseItem);
return;
}
}
responseItem.responseUID = uid;
batch.add(responseItem);
header.batchCount++;
}
public void add(ResponseItem responseItem)
{
add(responseItem, null);
}
public void clear()
{
batch.clear();
header.batchCount = 0;
}
public void log()
{
Log log = Log.func("ResponseMessage").end();
for (ResponseItem item : batch)
{
if (item.resultStatus ==0) item.log();
else item.logStatus();
}
log.leave();
}
}