/*
 * Copyright 2017-2025 VMware, Inc. All rights reserved. VMware Confidential
 */
import { AuthTokenData } from "../models/auth";

/**
 * Base service for storing authorization token information.
 */
export abstract class AuthTokenHolderService {
    /**
     * Obsolete. @see VCLOUD_AUTHORIZATION_HEADER
     */
    abstract get token(): string;

    /**
     * Obsolete.@see VCLOUD_AUTHORIZATION_HEADER
     * @param token
     */
    abstract set token(token: string);

    /**
     * @returns the currently used JWT token, if any.
     */
    abstract get jwt(): string;

    /**
     * Sets the value of the currently used JWT token.
     * @param token
     */
    abstract set jwt(token: string);

    /**
     * Value used for API 'Authorization' header - i.e. 'Bearer <jwt token>'
     */
    abstract get authorizationHeader(): string;

    /**
     * @returns the current authorization context, if any.
     * For example, 'System' for the provider portal.
     */
    abstract get authContext(): string;

    /**
     * Sets the current authorization context.
     * @param authContext - For example, 'System' for the provider portal.
     */
    abstract set authContext(authContext: string);

    /**
     * @returns the user name of the currently logged in user.
     */
    abstract get username(): string;

    /**
     * Updates the current authorization information.
     * @param token - obsolete @see VCLOUD_AUTHORIZATION_HEADER
     * @param username - the current user name
     * @param authContext the authorization context
     * @param jwt - the jwt token
     */
    abstract update(token: string, username: string, authContext: string, jwt: string): void;

    /**
     * Deletes the currently used token information.
     */
    abstract deleteToken(): void;

    /**
     * @returns the information related to the currently used auth token and context, if available.
     */
    abstract get authTokenData(): AuthTokenData;
}
