@NotNull public static AuthenticationResult getToken(@NotNull final AuthorizationTokenInputs inputs) throws Exception { final ExecutorService service = Executors.newSingleThreadExecutor(); final AuthenticationContext context = new AuthenticationContext(inputs.getAuthority(), false, service); context.setProxy(getProxy(inputs.getProxyHost(), inputs.getProxyPort(), inputs.getProxyUsername(), inputs.getProxyPassword())); final Future<AuthenticationResult> future = context.acquireToken(inputs.getResource(), inputs.getClientId(), inputs.getUsername(), inputs.getPassword(), null); service.shutdown(); return future.get(); } }
AuthenticationResult acquireNewAccessToken(String resource) throws IOException { String authorityUrl = this.environment().activeDirectoryEndpoint() + this.domain(); ExecutorService executor = Executors.newSingleThreadExecutor(); AuthenticationContext context = new AuthenticationContext(authorityUrl, false, executor); if (proxy() != null) { context.setProxy(proxy()); } try { return context.acquireToken( resource, this.clientId(), this.username(), this.password, null).get(); } catch (Exception e) { throw new IOException(e.getMessage(), e); } finally { executor.shutdown(); } }
@NotNull public static AuthenticationResult getToken(@NotNull final AuthorizationTokenInputs inputs) throws Exception { final ExecutorService service = Executors.newSingleThreadExecutor(); final AuthenticationContext context = new AuthenticationContext(inputs.getAuthority(), false, service); context.setProxy(getProxy(inputs.getProxyHost(), inputs.getProxyPort(), inputs.getProxyUsername(), inputs.getProxyPassword())); //Verifying if loginType is API to instantiate ClientCredential object if (inputs.getLoginType().equalsIgnoreCase(API)) { final ClientCredential credential = new ClientCredential(inputs.getClientId(), inputs.getClientSecret()); return acquireToken(context, inputs, credential, service); } //Otherwise, the loginType is Native since the verification was already made in the @Action return acquireToken(context, inputs, service); }
AuthenticationContext context = new AuthenticationContext(authorityUrl, false, executor); if (proxy() != null) { context.setProxy(proxy());
AuthenticationContext context = new AuthenticationContext(authorityUrl, false, executor); if (proxy() != null) { context.setProxy(proxy());