@Override
    protected void runSecuredCommand(final Bootstrap<Config> bootstrap,
                                     final Namespace namespace,
                                     final Config config,
                                     final Injector injector) {

        injector.injectMembers(this);

        final String userId = namespace.getString(USER_ID_ARG_NAME);
        final String outputPath = namespace.getString(OUTPUT_FILE_PATH_ARG_NAME);

        userService.getUserBySubjectId(userId)
                .map(User::asRef)
                .ifPresentOrElse(
                        userName -> {
                            final CreateHashedApiKeyResponse response = createApiKey(
                                    namespace, userName);
                            if (outputApiKey(response, outputPath)) {
                                final String msg = LogUtil.message("API key successfully created for user '{}'",
                                        userId);
                                LOGGER.info(msg);
                                System.exit(0);
                            } else {
                                final String msg = LogUtil.message("API key for user '{}' could not be output",
                                        userId);
                                logEvent(userId, true, msg);
                                System.exit(1);
                            }
                        },
                        () -> {
                            final String msg = LogUtil.message("Cannot issue API key as Stroom user '{}' " +
                                                               "does not exist", userId);
                            logEvent(userId, false, msg);
                            throw new RuntimeException(msg);
                        });
    }
Creates an API key for a user the internal identity provider
stroom-app/src/main/java/stroom/app/commands/CreateApiKeyCommand.java