private AuthenticationResult acquireAccessTokenFromRefreshToken(String resource, String refreshToken, boolean isMultipleResourceRefreshToken) throws IOException { ExecutorService executor = Executors.newSingleThreadExecutor(); try { return refreshTokenClient.refreshToken(domain(), clientId(), resource, refreshToken, isMultipleResourceRefreshToken); } catch (Exception e) { return null; } finally { executor.shutdown(); } }
/** * Initializes a new instance of the UserTokenCredentials. * * @param clientId the active directory application client id. * @param domain the domain or tenant id containing this application. * @param username the user name for the Organization Id account. * @param password the password for the Organization Id account. * @param environment the Azure environment to authenticate with. * If null is provided, AzureEnvironment.AZURE will be used. */ public UserTokenCredentials(String clientId, String domain, String username, String password, AzureEnvironment environment) { super(environment, domain); // defer token acquisition this.clientId = clientId; this.username = username; this.password = password; this.tokens = new ConcurrentHashMap<>(); this.refreshTokenClient = new RefreshTokenClient(environment.activeDirectoryEndpoint(), proxy()); }
/** * Initializes a new instance of the DelegatedTokenCredentials. * * @param applicationCredentials the credentials representing a service principal * @param redirectUrl the URL to redirect to after authentication in Active Directory */ public DelegatedTokenCredentials(ApplicationTokenCredentials applicationCredentials, String redirectUrl) { super(applicationCredentials.environment(), applicationCredentials.domain()); // defer token acquisition this.applicationCredentials = applicationCredentials; this.tokens = new ConcurrentHashMap<>(); this.redirectUrl = redirectUrl; this.refreshTokenClient = new RefreshTokenClient(applicationCredentials.environment().activeDirectoryEndpoint(), proxy()); }
AuthenticationResult acquireAccessTokenFromRefreshToken(String resource, String refreshToken, boolean isMultipleResourceRefreshToken) throws IOException { ExecutorService executor = Executors.newSingleThreadExecutor(); try { return refreshTokenClient.refreshToken(domain(), clientId(), resource, refreshToken, isMultipleResourceRefreshToken); } catch (Exception e) { return null; } finally { executor.shutdown(); } } }