當前位置: 首頁>>代碼示例>>Java>>正文


Java Action類代碼示例

本文整理匯總了Java中com.microsoft.alm.helpers.Action的典型用法代碼示例。如果您正苦於以下問題:Java Action類的具體用法?Java Action怎麽用?Java Action使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Action類屬於com.microsoft.alm.helpers包,在下文中一共展示了Action類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deviceLogon

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
public boolean deviceLogon(final URI targetUri, final boolean requestCompactToken, final Action<DeviceFlowResponse> callback)
{
    BaseSecureStore.validateTargetUri(targetUri);

    Trace.writeLine("VsoMsaAuthentication::deviceLogon");

    TokenPair tokens;
    if ((tokens = this.VsoAuthority.acquireToken(targetUri, this.ClientId, this.Resource, RedirectUri, callback)) != null)
    {
        Trace.writeLine("   token successfully acquired.");

        this.storeRefreshToken(targetUri, tokens.RefreshToken);

        return this.generatePersonalAccessToken(targetUri, tokens.AccessToken, requestCompactToken);
    }

    Trace.writeLine("   failed to acquire token.");
    return false;
}
 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:20,代碼來源:VsoMsaAuthentication.java

示例2: createConnectionDataRequest

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
private HttpURLConnection createConnectionDataRequest(final URI targetUri, final Credential credentials) throws IOException
{
    Debug.Assert(targetUri != null && targetUri.isAbsolute(), "The targetUri parameter is null or invalid");
    Debug.Assert(credentials != null, "The credentials parameter is null or invalid");

    final HttpClient client = new HttpClient(Global.getUserAgent());

    // create an request to the VSO deployment data end-point
    final URI requestUri = createConnectionDataUri(targetUri);

    credentials.contributeHeader(client.Headers);

    final HttpURLConnection result = client.get(requestUri, new Action<HttpURLConnection>()
    {
        @Override public void call(final HttpURLConnection conn)
        {
            conn.setConnectTimeout(RequestTimeout);
        }
    });
    return result;
}
 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:22,代碼來源:VsoAzureAuthority.java

示例3: deviceLogon

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
public boolean deviceLogon(final URI targetUri, final boolean requestCompactToken, final Action<DeviceFlowResponse> callback)
{
    BaseSecureStore.validateTargetUri(targetUri);

    Trace.writeLine("VsoAadAuthentication::deviceLogon");

    TokenPair tokens;
    if ((tokens = this.VsoAuthority.acquireToken(targetUri, this.ClientId, this.Resource, RedirectUri, callback)) != null)
    {
        Trace.writeLine("   token successfully acquired.");

        this.storeRefreshToken(targetUri, tokens.RefreshToken);

        return this.generatePersonalAccessToken(targetUri, tokens.AccessToken, requestCompactToken);
    }

    Trace.writeLine("   failed to acquire token.");
    return false;
}
 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:20,代碼來源:VsoAadAuthentication.java

示例4: onPageFinished

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
@Override
protected boolean onPageFinished() {
    if (serverTypeSelectControl.isVstsSelected()) {

        final Action<DeviceFlowResponse> deviceFlowCallback = getDeviceFlowCallback();
        final AtomicReference<JwtCredentials> vstsCredentials = new AtomicReference<JwtCredentials>();

        final List<Account> accounts = getUserAccounts(vstsCredentials, deviceFlowCallback);

        final List<TFSConnection> configurationServers =
            getConfigurationServers(accounts, vstsCredentials, deviceFlowCallback);
        setPageData(configurationServers);

        return configurationServers.size() > 0;
    } else {
        final URI serverURI = serverTypeSelectControl.getServer();

        if (serverURI == null) {
            return false;
        }

        final TFSConnection connection = openAccount(serverURI, null);
        setPageData(connection);

        return connection != null;
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:28,代碼來源:WizardServerSelectionPage.java

示例5: getConfigurationServers

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
private List<TFSConnection> getConfigurationServers(
    final List<Account> accounts,
    final AtomicReference<JwtCredentials> vstsCredentialsHolder,
    final Action<DeviceFlowResponse> deviceFlowCallback) {
    final List<TFSConnection> configurationServers = new ArrayList<TFSConnection>(100);

    final JwtCredentials vstsCredentials = vstsCredentialsHolder.get();
    for (final Account account : accounts) {
        log.debug("Account name = " + account.getAccountName()); //$NON-NLS-1$
        log.debug("Account URI  = " + account.getAccountUri()); //$NON-NLS-1$

        final String accountURI = "https://" + account.getAccountName() + ".visualstudio.com"; //$NON-NLS-1$ //$NON-NLS-2$

        try {
            final URI uri = URIUtils.newURI(accountURI);
            final TFSConnection configurationServer =
                openAccount(uri, CredentialsHelper.getOAuthCredentials(uri, vstsCredentials, deviceFlowCallback));
            if (configurationServer != null) {
                configurationServers.add(configurationServer);
            }
        } catch (final Exception e) {
            log.error(e.getMessage(), e);
        }
    }

    return configurationServers;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:28,代碼來源:WizardServerSelectionPage.java

示例6: getAzureAccessToken

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
private JwtCredentials getAzureAccessToken(
    final boolean tryCurrentCredentials,
    final Action<DeviceFlowResponse> deviceFlowCallback) {
    final Credentials azureAccessToken;

    // If ServerURI is null, we will get an Azure Access Token that is
    // global to all VSTS accounts
    azureAccessToken = CredentialsHelper.getOAuthCredentials(null, null, deviceFlowCallback);

    if (azureAccessToken != null && (azureAccessToken instanceof JwtCredentials)) {
        return (JwtCredentials) azureAccessToken;
    }

    return null;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:16,代碼來源:WizardServerSelectionPage.java

示例7: getDeviceFlowCallback

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
private Action<DeviceFlowResponse> getDeviceFlowCallback() {
    final Action<DeviceFlowResponse> deviceFlowCallback = new Action<DeviceFlowResponse>() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void call(final DeviceFlowResponse response) {
            final OAuth2DeviceFlowCallbackDialog callbackDialog =
                new OAuth2DeviceFlowCallbackDialog(getShell(), response);
            callbackDialog.open();
        }
    };

    return deviceFlowCallback;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:16,代碼來源:WizardServerSelectionPage.java

示例8: getDeviceFlowCallback

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
private Action<DeviceFlowResponse> getDeviceFlowCallback(final Shell parentShell) {

            final Action<DeviceFlowResponse> deviceFlowCallback = new Action<DeviceFlowResponse>() {
                @Override
                public void call(final DeviceFlowResponse response) {
                    final OAuth2DeviceFlowCallbackDialog callbackDialog =
                        new OAuth2DeviceFlowCallbackDialog(parentShell, response);
                    callbackDialog.open();

                }

            };

            return deviceFlowCallback;
        }
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:16,代碼來源:UITransportOAuthRunnable.java

示例9: getCallback

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Action<DeviceFlowResponse> getCallback(final Action<String> cancellationCallback) {

    return new Action<DeviceFlowResponse>() {
        @Override
        public void call(final DeviceFlowResponse deviceFlowResponse) {
            IdeaHelper.runOnUIThread(new Runnable() {

                @Override
                public void run() {
                    final DeviceFlowResponsePromptDialog promptDialog = new DeviceFlowResponsePromptDialog();;

                    promptDialog.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            if (BaseDialog.CMD_CANCEL.equals(e.getActionCommand())) {
                                deviceFlowResponse.requestCancel();
                                cancellationCallback.call("User cancelled the device flow dialog.");
                            } else if (BaseDialog.CMD_OK.equals(e.getActionCommand())) {
                                /*
                                 *  If users clicked on OK, it means they should have completed auth flow on the
                                 *  browser.  Shorten the timeout to 5 seconds as this should be enough time to
                                 *  make one server call to get the token.  If left unchanged and user clicked on OK
                                 *  without completing the oauth flow in browser, we will hang their session for a
                                 *  long time.
                                 */
                                deviceFlowResponse.getExpiresAt().setTime(new Date());
                                deviceFlowResponse.getExpiresAt().add(Calendar.SECOND, 5);
                            }
                        }
                    });

                    promptDialog.setResponse(deviceFlowResponse);
                    promptDialog.show();
                }
            }, true);
        }
    };
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:43,代碼來源:DeviceFlowResponsePromptImpl.java

示例10: acquireToken

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
public TokenPair acquireToken(final URI targetUri, final String clientId, final String resource, final URI redirectUri, final Action<DeviceFlowResponse> callback)
{
    Debug.Assert(targetUri != null && targetUri.isAbsolute(), "The targetUri parameter is null or invalid");
    Debug.Assert(!StringHelper.isNullOrWhiteSpace(clientId), "The clientId parameter is null or empty");
    Debug.Assert(!StringHelper.isNullOrWhiteSpace(resource), "The resource parameter is null or empty");
    Debug.Assert(callback != null, "The callback parameter is null");

    Trace.writeLine("AzureAuthority::acquireToken");

    _azureDeviceFlow.setResource(resource);
    _azureDeviceFlow.setRedirectUri(redirectUri);
    final StringBuilder sb = new StringBuilder(authorityHostUrl);
    sb.append("/oauth2/devicecode");
    final URI deviceEndpoint = URI.create(sb.toString());
    final DeviceFlowResponse response = _azureDeviceFlow.requestAuthorization(deviceEndpoint, clientId, null);

    callback.call(response);

    TokenPair tokens = null;
    final URI tokenEndpoint = createTokenEndpointUri(authorityHostUrl);
    try
    {
        tokens = _azureDeviceFlow.requestToken(tokenEndpoint, clientId, response);

        Trace.writeLine("   token acquisition succeeded.");
    }
    catch (final AuthorizationException e)
    {
        Trace.writeLine("   token acquisition failed: ", e);
    }
    return tokens;
}
 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:33,代碼來源:AzureAuthority.java

示例11: getAuthenticationInfoAsync

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
@Override
public void getAuthenticationInfoAsync(String serverUri, final AuthenticationInfoCallback callback) {
    final SettableFuture<AuthenticationInfo> authenticationInfoFuture = SettableFuture.<AuthenticationInfo>create();

    // Callback for the Device Flow dialog to cancel the current authenticating process.
    // Normally this is hooked up to the cancel button so if user cancels, we do not wait forever in
    // a polling loop.
    final Action<String> cancellationCallback = new Action<String>() {
        @Override
        public void call(final String reasonForCancel) {
            authenticationInfoFuture.setException(new AuthorizationException(reasonForCancel));
        }
    };

    // Must share the same accessTokenStore with the member variable vstsPatAuthenticator to avoid prompt the user
    // when we generate PersonalAccessToken
    final OAuth2Authenticator.OAuth2AuthenticatorBuilder oAuth2AuthenticatorBuilder = new OAuth2Authenticator.OAuth2AuthenticatorBuilder()
            .withClientId(CLIENT_ID)
            .redirectTo(REDIRECT_URL)
            .backedBy(accessTokenStore)
            .manage(OAuth2Authenticator.MANAGEMENT_CORE_RESOURCE)
            .withDeviceFlowCallback(deviceFlowResponsePrompt.getCallback(cancellationCallback));
    final OAuth2Authenticator oAuth2Authenticator = oAuth2AuthenticatorBuilder.build();

    final URI encodedServerUri = UrlHelper.createUri(serverUri);
    final TokenPair tokenPair = oAuth2Authenticator.getOAuth2TokenPair(encodedServerUri, PromptBehavior.AUTO);

    try {
        final AuthenticationInfo authenticationInfo = getAuthenticationInfo(encodedServerUri, tokenPair);

        if (authenticationInfo != null) {
            authenticationInfoFuture.set(authenticationInfo);
        } else {
            authenticationInfoFuture.setException(new TeamServicesException(TeamServicesException.KEY_VSO_AUTH_FAILED));
        }

    } catch (Throwable t) {
        authenticationInfoFuture.setException(t);
    }

    Futures.addCallback(authenticationInfoFuture, callback);
}
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:43,代碼來源:VsoAuthInfoProvider.java

示例12: detectAuthority

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
/**
 * Detects the backing authority of the end-point.
 *
 * @param targetUri The resource which the authority protects.
 * @param tenantId  The identity of the authority tenant; null otherwise.
 * @return True if the authority is Visual Studio Online; false otherwise.
 */
public static boolean detectAuthority(final URI targetUri, final AtomicReference<UUID> tenantId)
{
    final String VsoBaseUrlHost = "visualstudio.com";
    final String VsoResourceTenantHeader = "X-VSS-ResourceTenant";

    Trace.writeLine("BaseVsoAuthentication::detectAuthority");

    tenantId.set(Guid.Empty);

    if (StringHelper.endsWithIgnoreCase(targetUri.getHost(), VsoBaseUrlHost))
    {
        Trace.writeLine("   detected visualstudio.com, checking AAD vs MSA");

        String tenant = null;

        HttpURLConnection connection = null;
        final HttpClient client = new HttpClient(Global.getUserAgent());
        try
        {
            connection = client.head(targetUri, new Action<HttpURLConnection>()
            {
                @Override public void call(final HttpURLConnection conn)
                {
                    conn.setInstanceFollowRedirects(false);
                }
            });

            tenant = connection.getHeaderField(VsoResourceTenantHeader);
            Trace.writeLine("   server has responded");

            return !StringHelper.isNullOrWhiteSpace(tenant)
                    && Guid.tryParse(tenant, tenantId);
        }
        catch (final IOException e)
        {
            throw new Error(e);
        }
    }

    Trace.writeLine("   failed detection");

    // if all else fails, fallback to basic authentication
    return false;
}
 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:52,代碼來源:BaseVsoAuthentication.java

示例13: getCallback

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
/**
 * Get a callback for the device flow to display the relevant information to end users
 *
 * @param cancellationCallback
 *      This is the action listener on the cancel button -- if user cancels the dialog,
 *      we should give control back to user
 *
 * @return a device flow response callback action
 */
Action<DeviceFlowResponse> getCallback(final Action<String> cancellationCallback);
 
開發者ID:Microsoft,項目名稱:vso-intellij,代碼行數:11,代碼來源:DeviceFlowResponsePrompt.java

示例14: deviceLogon

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
boolean deviceLogon(final URI targetUri, final boolean requestCompactToken, final Action<DeviceFlowResponse> callback); 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:2,代碼來源:IVsoAadAuthentication.java

示例15: acquireToken

import com.microsoft.alm.helpers.Action; //導入依賴的package包/類
TokenPair acquireToken(final URI targetUri, final String clientId, final String resource, final URI redirectUri, final Action<DeviceFlowResponse> callback); 
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:2,代碼來源:IAzureAuthority.java


注:本文中的com.microsoft.alm.helpers.Action類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。