Search in sources :

Example 1 with GetRevisionsResponse

use of com.google.nigori.common.NigoriMessages.GetRevisionsResponse in project nigori by ucam-cl-dtg.

the class CryptoNigoriDatastore method getRevisions.

@Override
public List<Revision> getRevisions(Index index) throws NigoriCryptographyException, UnsupportedEncodingException, IOException, UnauthorisedException {
    byte[] encIndex = keyManager.encryptDeterministically(index.getBytes());
    try {
        GetRevisionsResponse getResponse = protocol.getRevisions(MessageLibrary.getRevisionsRequestAsProtobuf(keyManager.getServerName(), keyManager.signer(), encIndex));
        if (getResponse == null) {
            return null;
        }
        List<ByteString> revisions = getResponse.getRevisionsList();
        List<Revision> answer = new ArrayList<Revision>(revisions.size());
        for (ByteString revision : revisions) {
            answer.add(new Revision(keyManager.decrypt(revision.toByteArray())));
        }
        return answer;
    } catch (NotFoundException e) {
        return null;
    }
}
Also used : Revision(com.google.nigori.common.Revision) GetRevisionsResponse(com.google.nigori.common.NigoriMessages.GetRevisionsResponse) ByteString(com.google.protobuf.ByteString) ArrayList(java.util.ArrayList) NotFoundException(com.google.nigori.common.NotFoundException)

Aggregations

GetRevisionsResponse (com.google.nigori.common.NigoriMessages.GetRevisionsResponse)1 NotFoundException (com.google.nigori.common.NotFoundException)1 Revision (com.google.nigori.common.Revision)1 ByteString (com.google.protobuf.ByteString)1 ArrayList (java.util.ArrayList)1