JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Source: bop/js/api/operation/BOPAuthenticators.js

define([
    'bop/js/DefaultBOPAuthenticator',
    'extensions/js/api/CustomParameters'
], function (
        DefaultBOPAuthenticator,
        CustomParameters) {

    'use strict';

    /**
     * Provide a reference to the default implementation of The {@link bop/js/spi/operation/BOPAuthenticator BOPAuthenticator}
     * object
     *
     * @version 17.1.1
     * @AbcsExtension stable
     * @exports bop/js/api/operation/BOPAuthenticators
     *
     * @constructor
     * @private
     */
    var BOPAuthenticators = function () {
        AbcsLib.checkThis(this);
        AbcsLib.checkSingleton(BOPAuthenticators);
    };

    /**
     * Returns the default authenticator, for internal use only
     *
     * @return {bop/js/spi/operation/BOPAuthenticator} the default authenticator
     */
    BOPAuthenticators.prototype.getInternal = function (authentication) {
        return new DefaultBOPAuthenticator(authentication, undefined);
    };

    /**
     * Returns an instance of the default authenticator for invoking rest
     * services that defines a whitelist of resources in order to make use of
     * the built in authentication mechanism.
     *
     * @AbcsExtension stable
     * @version 17.1.1
     *
     * @param {Object} dependencies A representation of the dependencies used to instantiate a {@link bop/js/spi/BOP BOP}.
     * @param {bop/js/spi/resource/ResourceProvider} resourceProvider The instance of {@link bop/js/spi/resource/ResourceProvider ResourceProvider}
     *   that defines the whitelist of resources that this authenticator can access.
     * @return {bop/js/spi/operation/BOPAuthenticator} the default authenticator
     */
    BOPAuthenticators.prototype.getDefault = function (dependencies, resourceProvider) {

        var parameters = CustomParameters.getParameters(dependencies);

        return new DefaultBOPAuthenticator(
                parameters.serviceAuth, resourceProvider);
    };

    return AbcsLib.initSingleton(BOPAuthenticators);
});