Klasse DUUIUserController

java.lang.Object
org.texttechnologylab.duui.api.controllers.users.DUUIUserController

public class DUUIUserController extends Object
A Controller for database operations related to the users collection.
Autor:
Cedric Borkowski
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static void
    addToWorkerCount(String id, int count)
    Increment or decrement (negative count) to the worker count.
    static String
    authorizeUser(spark.Request request, spark.Response response)
    Check if the user is authorized.
    static String
    deleteLabel(spark.Request request, spark.Response response)
     
    static String
    deleteOne(spark.Request request, spark.Response response)
    Delete a user from the database.
    static String
    fetchLoginCredentials(spark.Request request, spark.Response response)
    Fetch the login credentials for a user by email.
    static String
    fetchUser(spark.Request request, spark.Response response)
    Retrieve a user from the database given an id.
    static String
    fetchUsers(spark.Request request, spark.Response response)
    Retrieve multiple users from the database.
    static List<String>
     
    static String
    finishDropboxOAuthFromCode(spark.Request request, spark.Response response)
    Finish the Dropbox OAuth 2.0 process given a code returned after accepting the connection with DUUI.
    static String
    finishGoogleOAuthFromCode(spark.Request request, spark.Response response)
    Finish the Google OAuth 2.0 process given a code returned after accepting the connection with DUUI.
    static String
    getDriverLabels(spark.Request request, spark.Response response)
    Get all labels from the database.
    static String
    getDropboxAppSettings(spark.Request request, spark.Response response)
    Get the Dropbox OAuth 2.0 settings.
    static org.bson.Document
    getDropboxCredentials(org.bson.Document user, String providerId)
    Retrieve the stored user credentials for dropbox (access and refresh token).
    static org.bson.Document
    getGoogleCredentials(org.bson.Document user, String providerId)
     
    static String
    getGoogleSettings(spark.Request request, spark.Response response)
    Get the Google OAuth 2.0 settings.
    static String
    getLabels(spark.Request request, spark.Response response)
    Get all labels from the database.
    static org.bson.Document
    getMinioCredentials(org.bson.Document user, String providerId)
    Retrieve the stored user credentials for minio (endpoint access and secret key).
    static org.bson.Document
    getNextCloudCredentials(org.bson.Document user, String providerId)
    Retrieve the stored user credentials for nextcloud (uri, username and password).
    static org.bson.Document
    Get a user by id.
    static org.bson.Document
    getUserById(String id, List<String> includeFields)
    Get a user by id.
    static org.bson.Document
    getUserById(org.bson.types.ObjectId id)
    Get a user by id.
    static org.bson.Document
    getUserById(org.bson.types.ObjectId id, List<String> includeFields)
    Get a user by id.
    static org.bson.Document
    Check if a user with the given password reset toekn exists.
    static String
    insertLabel(spark.Request request, spark.Response response)
    Create and insert a user into the database.
    static String
    insertNewConnection(spark.Request request, spark.Response response)
    Verify and insert new connection details.
    static String
    insertOne(spark.Request request, spark.Response response)
    Create and insert a user into the database.
    static org.bson.Document
    matchApiKey(String authorization)
    Check if a user with the given API key exists.
    static org.bson.Document
    Check if a user with the given session id exists.
    static String
    recoverPassword(spark.Request request, spark.Response response)
    Check if an email to reset the user password can be sent.
    static String
    refreshAccessToken(String refreshToken, String clientId, String clientSecret)
    Refresh the access token for a user given a refresh token.
    static String
    resetPassword(spark.Request request, spark.Response response)
    Reset the password of the user and store the new one.
    static String
    resetPasswordNoToken(spark.Request request, spark.Response response)
    Reset the password of the user and store the new one without.
    static String
    updateLabel(spark.Request request, spark.Response response)
     
    static String
    updateOne(spark.Request request, spark.Response response)
    Update a user given an id and a JSON object with updates.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • DUUIUserController

      public DUUIUserController()
  • Methodendetails

    • getDropboxCredentials

      public static org.bson.Document getDropboxCredentials(org.bson.Document user, String providerId)
      Retrieve the stored user credentials for dropbox (access and refresh token).
      Parameter:
      user - The user to retrieve the credentials for.
      Gibt zurück:
      a Document containing the credentials.
    • getMinioCredentials

      public static org.bson.Document getMinioCredentials(org.bson.Document user, String providerId)
      Retrieve the stored user credentials for minio (endpoint access and secret key).
      Parameter:
      user - The user to retrieve the credentials for.
      Gibt zurück:
      a Document containing the credentials.
    • getNextCloudCredentials

      public static org.bson.Document getNextCloudCredentials(org.bson.Document user, String providerId)
      Retrieve the stored user credentials for nextcloud (uri, username and password).
      Parameter:
      user - The user to retrieve the credentials for.
      Gibt zurück:
      a Document containing the credentials.
    • getGoogleCredentials

      public static org.bson.Document getGoogleCredentials(org.bson.Document user, String providerId)
    • getUserById

      public static org.bson.Document getUserById(org.bson.types.ObjectId id)
      Get a user by id.
      Parameter:
      id - the user id (as an ObjectId).
      Gibt zurück:
      a Document containing the user information.
    • getUserById

      public static org.bson.Document getUserById(org.bson.types.ObjectId id, List<String> includeFields)
      Get a user by id. Fields to be included can be specified.
      Parameter:
      id - the user id (as an ObjectId).
      includeFields - the database fields to include.
      Gibt zurück:
      a Document containing the user information.
    • getUserById

      public static org.bson.Document getUserById(String id)
      Get a user by id.
      Parameter:
      id - the user id.
      Gibt zurück:
      a Document containing the user information.
    • getUserById

      public static org.bson.Document getUserById(String id, List<String> includeFields)
      Get a user by id. Fields to be included can be specified.
      Parameter:
      id - the user id.
      includeFields - the database fields to include.
      Gibt zurück:
      a Document containing the user information.
    • matchApiKey

      public static org.bson.Document matchApiKey(String authorization)
      Check if a user with the given API key exists.
      Parameter:
      authorization - the API key.
      Gibt zurück:
      the user if it exists.
    • matchSession

      public static org.bson.Document matchSession(String session)
      Check if a user with the given session id exists.
      Parameter:
      session - the session id from the web interface.
      Gibt zurück:
      the user if it exists.
    • getUserByResetToken

      public static org.bson.Document getUserByResetToken(String token)
      Check if a user with the given password reset toekn exists.
      Parameter:
      token - the password reset token set from resetting the password in the web interface.
      Gibt zurück:
      the user if it exists.
    • insertOne

      public static String insertOne(spark.Request request, spark.Response response)
      Create and insert a user into the database. TODO: Move request part to DUUIUsersRequestHandler.
      Gibt zurück:
      the created user.
    • insertLabel

      public static String insertLabel(spark.Request request, spark.Response response)
      Create and insert a user into the database.
    • updateLabel

      public static String updateLabel(spark.Request request, spark.Response response)
    • deleteLabel

      public static String deleteLabel(spark.Request request, spark.Response response)
    • getLabels

      public static String getLabels(spark.Request request, spark.Response response)
      Get all labels from the database.
      Gibt zurück:
      a list of labels.
    • getDriverLabels

      public static String getDriverLabels(spark.Request request, spark.Response response)
      Get all labels from the database.
      Gibt zurück:
      a list of labels.
    • filterLabelsByDriver

      public static List<String> filterLabelsByDriver(String driver)
    • deleteOne

      public static String deleteOne(spark.Request request, spark.Response response)
      Delete a user from the database. TODO: Move request part to DUUIUsersRequestHandler.
      Gibt zurück:
      a confirmation message.
    • recoverPassword

      public static String recoverPassword(spark.Request request, spark.Response response)
      Check if an email to reset the user password can be sent.
      Gibt zurück:
      a confirmation message.
    • resetPassword

      public static String resetPassword(spark.Request request, spark.Response response)
      Reset the password of the user and store the new one.
      Gibt zurück:
      a confirmation message and the user email.
    • resetPasswordNoToken

      public static String resetPasswordNoToken(spark.Request request, spark.Response response)
      Reset the password of the user and store the new one without.
      Gibt zurück:
      a confirmation message and the user email.
    • fetchLoginCredentials

      public static String fetchLoginCredentials(spark.Request request, spark.Response response)
      Fetch the login credentials for a user by email.
      Gibt zurück:
      the email and password of the user for logging into the web interface.
    • updateOne

      public static String updateOne(spark.Request request, spark.Response response)
      Update a user given an id and a JSON object with updates.
      Gibt zurück:
      the updated user only including the updated and defaults fields.
    • insertNewConnection

      public static String insertNewConnection(spark.Request request, spark.Response response)
      Verify and insert new connection details.
      Gibt zurück:
      the updated user only including the updated and defaults fields.
    • authorizeUser

      public static String authorizeUser(spark.Request request, spark.Response response)
      Check if the user is authorized.
      Gibt zurück:
      the authorized user.
    • fetchUser

      public static String fetchUser(spark.Request request, spark.Response response)
      Retrieve a user from the database given an id.
      Gibt zurück:
      a user from the database.
    • fetchUsers

      public static String fetchUsers(spark.Request request, spark.Response response)
      Retrieve multiple users from the database. This is only possible for admins and is used to manage roles in the web interface.
      Gibt zurück:
      a list of users.
    • addToWorkerCount

      public static void addToWorkerCount(String id, int count)
      Increment or decrement (negative count) to the worker count. Acts as a rate limit for threads.
      Parameter:
      id - the user id.
      count - the amount of workers to add or subtract.
    • finishDropboxOAuthFromCode

      public static String finishDropboxOAuthFromCode(spark.Request request, spark.Response response)
      Finish the Dropbox OAuth 2.0 process given a code returned after accepting the connection with DUUI.
      Gibt zurück:
      the user with updated dropbox credentials. See getDropboxCredentials(Document, String).
    • finishGoogleOAuthFromCode

      public static String finishGoogleOAuthFromCode(spark.Request request, spark.Response response)
      Finish the Google OAuth 2.0 process given a code returned after accepting the connection with DUUI.
      Parameter:
      request - the request object.
      response - the response object.
      Gibt zurück:
      the user with updated google credentials. See getGoogleCredentials(Document, String).
    • refreshAccessToken

      public static String refreshAccessToken(String refreshToken, String clientId, String clientSecret) throws IOException
      Refresh the access token for a user given a refresh token.
      Parameter:
      refreshToken - the refresh token.
      clientId - the client id.
      clientSecret - the client secret.
      Gibt zurück:
      the new access token.
      Löst aus:
      IOException
    • getGoogleSettings

      public static String getGoogleSettings(spark.Request request, spark.Response response)
      Get the Google OAuth 2.0 settings.
      Gibt zurück:
      the client id, client secret and redirect uri.
    • getDropboxAppSettings

      public static String getDropboxAppSettings(spark.Request request, spark.Response response)
      Get the Dropbox OAuth 2.0 settings.
      Gibt zurück:
      the client id, client secret and redirect uri.