use of com.google.nigori.common.NotFoundException in project nigori by ucam-cl-dtg.
the class DatabaseNigoriProtocol method get.
@Override
public GetResponse get(GetRequest request) throws IOException, NotFoundException, UnauthorisedException {
byte[] index = request.getKey().toByteArray();
AuthenticateRequest auth = request.getAuth();
User user;
byte[] revision = null;
if (request.hasRevision()) {
revision = request.getRevision().toByteArray();
user = authenticateUser(auth, MessageLibrary.REQUEST_GET, index, revision);
} else {
user = authenticateUser(auth, MessageLibrary.REQUEST_GET, index);
}
Collection<RevValue> value;
if (request.hasRevision()) {
value = new ArrayList<RevValue>(1);
RevValue revVal = database.getRevision(user, index, revision);
if (revVal == null) {
throw new NotFoundException("Cannot find requested index with revision");
}
value.add(revVal);
} else {
value = database.getRecord(user, index);
}
if (value == null) {
throw new NotFoundException("No value for that index");
}
return MessageLibrary.getResponseAsProtobuf(value);
}
use of com.google.nigori.common.NotFoundException in project nigori by ucam-cl-dtg.
the class CryptoNigoriDatastore method getIndices.
@Override
public List<Index> getIndices() throws NigoriCryptographyException, IOException, UnauthorisedException {
try {
GetIndicesResponse getResponse = protocol.getIndices(MessageLibrary.getIndicesRequestAsProtobuf(keyManager.getServerName(), keyManager.signer()));
if (getResponse == null) {
return null;
}
List<ByteString> indices = getResponse.getIndicesList();
List<Index> answer = new ArrayList<Index>(indices.size());
for (ByteString index : indices) {
answer.add(new Index(keyManager.decrypt(index.toByteArray())));
}
return answer;
} catch (NotFoundException e) {
return null;
}
}
Aggregations