Search in sources :

Example 1 with State

use of com.mongodb.crypt.capi.MongoCryptContext.State in project mongo-java-driver by mongodb.

the class Crypt method executeStateMachineWithSink.

private void executeStateMachineWithSink(final MongoCryptContext cryptContext, @Nullable final String databaseName, final MonoSink<RawBsonDocument> sink) {
    State state = cryptContext.getState();
    LOGGER.info("executeStateMachine: " + state);
    switch(state) {
        case NEED_MONGO_COLLINFO:
            collInfo(cryptContext, databaseName, sink);
            break;
        case NEED_MONGO_MARKINGS:
            mark(cryptContext, databaseName, sink);
            break;
        case NEED_MONGO_KEYS:
            fetchKeys(cryptContext, databaseName, sink);
            break;
        case NEED_KMS:
            decryptKeys(cryptContext, databaseName, sink);
            break;
        case READY:
            sink.success(cryptContext.finish());
            break;
        default:
            sink.error(new MongoInternalException("Unsupported encryptor state + " + state));
    }
}
Also used : State(com.mongodb.crypt.capi.MongoCryptContext.State) MongoInternalException(com.mongodb.MongoInternalException)

Aggregations

MongoInternalException (com.mongodb.MongoInternalException)1 State (com.mongodb.crypt.capi.MongoCryptContext.State)1