本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
};
}
示例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;
}
示例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);
}
示例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);
示例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);