Table of Contents

Interface IUserService

Namespace
adas_core.Authentication.Interfaces
Assembly
adas-core.Authentication.dll
public interface IUserService
Extension Methods

Fields

TokenTypeRefresh

public static readonly string TokenTypeRefresh

Field Value

string

TokenTypeUser

public static readonly string TokenTypeUser

Field Value

string

Methods

CreateNewAuthority(Authorization)

Asynchronously creates a new authority based on the provided authorization data.

Task<Authorization> CreateNewAuthority(Authorization auth)

Parameters

auth Authorization

The authorization information used to create the new authority.

Returns

Task<Authorization>

A task that represents the asynchronous operation. The task result contains the created Authorization.

CreateNewUserByRequest(User)

Creates a new user based on the provided user data, typically originating from an incoming request. Returns the newly created user, or null if the user could not be created.

Task<User?> CreateNewUserByRequest(User user)

Parameters

user User

The user data to use for creating the new user.

Returns

Task<User>

A task that represents the asynchronous operation. The result is the created User, or null if creation failed.

CreateNewUserWithAuthorities(CreateUserWithAuthDto)

Creates a new user together with the associated authorities based on the supplied data transfer object.

Task<User?> CreateNewUserWithAuthorities(CreateUserWithAuthDto createUserWithAuthDto)

Parameters

createUserWithAuthDto CreateUserWithAuthDto

The data transfer object containing the information required to create the user and its authorities.

Returns

Task<User>

A task that represents the asynchronous operation. The task result contains the created User instance, or null if no user was created.

CreateUser(User)

Creates a user from the provided LDAP user entry.

Task<User?> CreateUser(User userEntryLdap)

Parameters

userEntryLdap User

The LDAP user entry used to create the user.

Returns

Task<User>

A task that represents the asynchronous create operation, containing the created User or null.

DeleteAuthority(string)

Asynchronously deletes an authority identified by the specified identifier.

Task<bool> DeleteAuthority(string id)

Parameters

id string

The unique identifier of the authority to delete.

Returns

Task<bool>

A task that represents the asynchronous delete operation. The task result contains a boolean indicating whether the authority was successfully deleted.

DeleteUser(ObjectId)

Asynchronously deletes a user identified by the specified identifier.

Task<bool> DeleteUser(ObjectId id)

Parameters

id ObjectId

The unique identifier of the user to delete.

Returns

Task<bool>

A task that represents the asynchronous operation, containing a value indicating whether the user was successfully deleted.

GenerateJwt(User)

Asynchronously generates a JSON Web Token (JWT) for the specified user and returns the token result.

Task<TokenResult> GenerateJwt(User user)

Parameters

user User

The user for whom the JWT is being generated.

Returns

Task<TokenResult>

A task that represents the asynchronous operation, containing the TokenResult with the generated token details.

GetAll()

Asynchronously retrieves all users from the data store.

Task<List<User>> GetAll()

Returns

Task<List<User>>

A task that represents the asynchronous operation. The task result contains a list of all User entities.

GetPaginatedUsers(PaginationFilter)

Retrieves a paginated list of users based on the provided pagination filter configuration.

Task<PaginationResponse<User>> GetPaginatedUsers(PaginationFilter config)

Parameters

config PaginationFilter

The pagination filter that defines paging parameters such as page number and page size.

Returns

Task<PaginationResponse<User>>

A task that represents the asynchronous operation, containing the paginated response of User entries.

GetUser(string, string)

Authenticates a user based on the provided username and password and returns the corresponding user.

Task<User> GetUser(string username, string password)

Parameters

username string

The username of the user to authenticate.

password string

The password of the user to authenticate.

Returns

Task<User>

A task that represents the asynchronous operation. The task result contains the authenticated User.

GetUserByCasTicket(string, string)

Asynchronously retrieves a user by validating a CAS (Central Authentication Service) ticket against the specified service.

Task<User?> GetUserByCasTicket(string service, string ticket)

Parameters

service string

The service URL or identifier that the ticket was issued for and must be validated against.

ticket string

The CAS ticket string used to authenticate and identify the user.

Returns

Task<User>

A task that represents the asynchronous operation. The task result contains the associated User if the ticket is valid, or null if the user cannot be found.

GetUserById(ObjectId)

Asynchronously retrieves a user by their unique identifier, returning null when no user matches the provided id.

Task<User?> GetUserById(ObjectId id)

Parameters

id ObjectId

The unique MongoDB.Bson.ObjectId identifier of the user to look up.

Returns

Task<User>

A task that resolves to the matching User, or null if no user is found for the given id.

GetUserByName(string)

Asynchronously retrieves a user matching the specified name, returning null when no matching user is found.

Task<User?> GetUserByName(string name)

Parameters

name string

The name used to look up the user.

Returns

Task<User>

A task that resolves to the matching User, or null if no user with the given name exists.

GetUserByToken(JwtSecurityToken?)

Retrieves the user associated with the provided JWT security token. Returns null if the token is null or if no matching user is found.

Task<User?> GetUserByToken(JwtSecurityToken? jwtToken)

Parameters

jwtToken JwtSecurityToken

The JWT security token used to identify the user. May be null.

Returns

Task<User>

A task that resolves to the User associated with the token, or null if the token is invalid or no user matches.

GetUserByUserName(string)

Asynchronously retrieves a user by their unique username, returning null when no matching user is found.

Task<User?> GetUserByUserName(string name)

Parameters

name string

The username used to look up the user.

Returns

Task<User>

A task that represents the asynchronous operation, containing the matching user if found; otherwise, null.

Login(string, string)

Authenticates a user with the provided credentials and returns a token result upon successful login.

Task<TokenResult> Login(string username, string password)

Parameters

username string

The username of the user attempting to log in.

password string

The password associated with the specified username.

Returns

Task<TokenResult>

A task that represents the asynchronous login operation, containing the TokenResult with the authentication token information.

LoginWithAccessToken(string)

Authenticates a user by exchanging a provided access token for a login result.

Task<TokenResult> LoginWithAccessToken(string token)

Parameters

token string

The access token used to authenticate the user.

Returns

Task<TokenResult>

A task that represents the asynchronous login operation, containing the TokenResult with the outcome of the authentication.

LoginWithGivenAccessToken(string)

Authenticates the user using the provided access token and returns the resulting token information.

Task<TokenResult> LoginWithGivenAccessToken(string token)

Parameters

token string

The access token used to perform the login.

Returns

Task<TokenResult>

A task that represents the asynchronous login operation, containing the token result.

RefreshToken(string)

Refreshes an authentication token using the provided refresh token and returns the resulting token information.

Task<TokenResult> RefreshToken(string refreshToken)

Parameters

refreshToken string

The refresh token used to obtain a new access token.

Returns

Task<TokenResult>

A Task<TResult> that represents the asynchronous operation, containing the TokenResult with the refreshed token details.

UpdateAuthority(Authorization)

Updates the authority information based on the provided authorization data.

Task<bool> UpdateAuthority(Authorization authorization)

Parameters

authorization Authorization

The authorization entity containing the authority details to be updated.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result is true if the update was successful; otherwise, false.

UpdateUserPassword(ObjectId, string, string)

Updates the password for the user identified by the specified identifier, verifying the old password before applying the new one.

Task<bool> UpdateUserPassword(ObjectId id, string oldPassword, string newPassword)

Parameters

id ObjectId

The unique identifier of the user whose password will be updated.

oldPassword string

The user's current password, used to verify the request.

newPassword string

The new password to set for the user.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result is true if the password was updated successfully; otherwise, false.

UpdateUserWithAuthorities(UpdateUserWithAuthDto, bool)

Updates an existing user along with the associated authorities, optionally updating the password.

Task<User?> UpdateUserWithAuthorities(UpdateUserWithAuthDto createUserWithAuthDto, bool updatePass)

Parameters

createUserWithAuthDto UpdateUserWithAuthDto

The data transfer object containing the user information and authorities to update.

updatePass bool

A flag indicating whether the user's password should be updated as part of the operation.

Returns

Task<User>

A task that represents the asynchronous operation, containing the updated User or null if the user was not found.

UpdateUsersByRequest(User, bool)

Updates a user's information based on the provided user data, with an option to include password updates.

Task<User?> UpdateUsersByRequest(User user, bool updatePass)

Parameters

user User

The user entity containing the updated information to be persisted.

updatePass bool

A flag indicating whether the user's password should be updated during this operation.

Returns

Task<User>

A task that returns the updated User, or null if the user could not be found.

ValidateToken(string, string, out SecurityToken)

Validates the specified token according to its type and outputs the corresponding SecurityToken.

void ValidateToken(string token, string tokenType, out SecurityToken securityToken)

Parameters

token string

The token string to be validated.

tokenType string

The type of the token, used to determine the appropriate validation strategy.

securityToken SecurityToken

When the method returns, contains the validated SecurityToken if validation succeeds.