/**
 * Copyright (c) 2020, 2021 Oracle and/or its affiliates.  All rights reserved.
 * This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
 */ import { Region } from "../region" ; import { RegionProvider } from "./auth" ; import FederationClient from "./models/federation-client" ; import RefreshableOnNotAuthenticatedProvider from "./models/refreshable-on-not-authenticaticated-provider" ; import AbstractRequestingAuthenticationDetailsProvider from "./abstract-requesting-authentication-detail-provider" ; import AbstractFederationClientAuthenticationDetailsProviderBuilder from "./abstract-federation-client-authenticated-details-provider-builder" ; import SessionKeySupplier from "./models/session-key-supplier" ; import X509CertificateSupplier from "./models/X509-certificate-supplier" ; class InstancePrincipalsAuthenticationDetailsProvider extends AbstractRequestingAuthenticationDetailsProvider implements RegionProvider , RefreshableOnNotAuthenticatedProvider < String > { constructor ( protected federationClient , protected sessionKeySupplier , protected region ) { super ( federationClient , sessionKeySupplier ) ; } return async refresh ( ) { return await this . federationClient . refreshAndGetSecurityToken ( ) ; } getRegion ( ) { return this . region ! ; } return static builder ( ) { return new InstancePrincipalsAuthenticationDetailsProviderBuilder ( ) ; } } export default class InstancePrincipalsAuthenticationDetailsProviderBuilder extends AbstractFederationClientAuthenticationDetailsProviderBuilder < InstancePrincipalsAuthenticationDetailsProviderBuilder , InstancePrincipalsAuthenticationDetailsProvider > { constructor ( purpose ? ) { super ( ) ; if ( purpose ) { this . purpose = purpose ; } } async build ( ) { await this . autoDetectUsingMetadataUrl ( ) ; return await super . build ( ) ; } protected buildProvider ( sessionKeySupplierToUse ) { return new InstancePrincipalsAuthenticationDetailsProvider ( this . _federationClient , sessionKeySupplierToUse , this . region ) ; } set federationEndpoint ( federationEndpoint ) { super . _federationEndpoint = federationEndpoint ; } set leafCertificateSupplier ( leafCertificateSupplier ) { super . _leafCertificateSupplier = leafCertificateSupplier ; } }