本文整理匯總了Java中com.microsoft.alm.secret.VsoTokenScope類的典型用法代碼示例。如果您正苦於以下問題:Java VsoTokenScope類的具體用法?Java VsoTokenScope怎麽用?Java VsoTokenScope使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VsoTokenScope類屬於com.microsoft.alm.secret包,在下文中一共展示了VsoTokenScope類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: VsoAadAuthentication
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
/**
* @param tenantId <p>The unique identifier for the responsible Azure tenant.</p>
* <p>Use {@link BaseVsoAuthentication}
* to detect the tenant identity and create the authentication object.</p>
* @param tokenScope The scope of all access tokens acquired by the authority.
* @param personalAccessTokenStore The secure secret store for storing any personal
* access tokens acquired.
* @param adaRefreshTokenStore The secure secret store for storing any Azure tokens
* acquired
*/
public VsoAadAuthentication(
final UUID tenantId,
final VsoTokenScope tokenScope,
final ICredentialStore personalAccessTokenStore,
final ITokenStore adaRefreshTokenStore)
{
super(tokenScope,
personalAccessTokenStore,
adaRefreshTokenStore);
if (tenantId == null || tenantId.equals(Guid.Empty))
{
this.VsoAuthority = new VsoAzureAuthority(DefaultAuthorityHost);
}
else
{
// create an authority host url in the format of https://login.microsoft.com/12345678-9ABC-DEF0-1234-56789ABCDEF0
String authorityHost = AzureAuthority.getAuthorityUrl(tenantId);
this.VsoAuthority = new VsoAzureAuthority(authorityHost);
}
}
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:31,代碼來源:VsoAadAuthentication.java
示例2: VsoMsaAuthentication
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
public VsoMsaAuthentication(
VsoTokenScope tokenScope,
ICredentialStore personalAccessTokenStore,
ITokenStore adaRefreshTokenStore)
{
super(tokenScope,
personalAccessTokenStore,
adaRefreshTokenStore);
this.VsoAuthority = new VsoAzureAuthority(DefaultAuthorityHost);
}
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:11,代碼來源:VsoMsaAuthentication.java
示例3: BaseVsoAuthentication
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
private BaseVsoAuthentication(final VsoTokenScope tokenScope, final ICredentialStore personalAccessTokenStore, final ITokenStore vsoIdeTokenCache, final ITokenStore adaRefreshTokenStore, final IVsoAuthority vsoAuthority)
{
if (tokenScope == null)
throw new IllegalArgumentException("The `tokenScope` parameter is null.");
if (personalAccessTokenStore == null)
throw new IllegalArgumentException("The `personalAccessTokenStore` parameter is null.");
this.ClientId = DefaultClientId;
this.Resource = DefaultResource;
this.TokenScope = tokenScope;
this.VsoIdeTokenCache = vsoIdeTokenCache;
this.PersonalAccessTokenStore = personalAccessTokenStore;
this.AdaRefreshTokenStore = adaRefreshTokenStore != null ? adaRefreshTokenStore : new SecretCache(AdalRefreshPrefix);
this.VsoAuthority = vsoAuthority;
}
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:16,代碼來源:BaseVsoAuthentication.java
示例4: getAuthentication
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
/**
* Creates a new authentication broker based for the specified resource.
*
* @param targetUri The resource for which authentication is being requested.
* @param scope The scope of the access being requested.
* @param personalAccessTokenStore Storage container for personal access token secrets.
* @param adaRefreshTokenStore Storage container for Azure access token secrets.
* @param authentication An implementation of {@link BaseAuthentication} if one was detected;
* null otherwise.
* @return True if an authority could be determined; false otherwise.
*/
public static boolean getAuthentication(
final URI targetUri,
final VsoTokenScope scope,
final ICredentialStore personalAccessTokenStore,
final ITokenStore adaRefreshTokenStore,
final AtomicReference<IAuthentication> authentication)
{
Trace.writeLine("BaseVsoAuthentication::getAuthentication");
final AtomicReference<UUID> tenantId = new AtomicReference<UUID>();
if (detectAuthority(targetUri, tenantId))
{
// empty Guid is MSA, anything else is AAD
if (Guid.Empty.equals(tenantId.get()))
{
Trace.writeLine(" MSA authority detected");
authentication.set(new VsoMsaAuthentication(scope, personalAccessTokenStore, adaRefreshTokenStore));
}
else
{
Trace.writeLine(" AAD authority for tenant '" + tenantId + "' detected");
authentication.set(new VsoAadAuthentication(tenantId.get(), scope, personalAccessTokenStore, adaRefreshTokenStore));
((BaseVsoAuthentication)authentication.get()).TenantId = tenantId.get();
}
}
else
{
authentication.set(null);
}
return authentication.get() != null;
}
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:44,代碼來源:BaseVsoAuthentication.java
示例5: getAccessTokenRequestBody
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
private StringContent getAccessTokenRequestBody(final URI targetUri, final Token accessToken, final VsoTokenScope tokenScope)
{
final String ContentJsonFormat = "{ \"scope\" : \"%1$s\", \"targetAccounts\" : [\"%2$s\"], \"displayName\" : \"Git: %3$s on %4$s\" }";
Debug.Assert(accessToken != null && (accessToken.Type == TokenType.Access || accessToken.Type == TokenType.Federated), "The accessToken parameter is null or invalid");
Debug.Assert(tokenScope != null, "The tokenScope parameter is null");
final String targetIdentity = accessToken.getTargetIdentity().toString();
Trace.writeLine(" creating access token scoped to '" + tokenScope + "' for '" + targetIdentity + "'");
final String jsonContent = String.format(ContentJsonFormat, tokenScope, targetIdentity, targetUri, Environment.getMachineName());
final StringContent content = StringContent.createJson(jsonContent);
return content;
}
示例6: ctor_DefaultAuthorityHost
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
@Test public void ctor_DefaultAuthorityHost() throws URISyntaxException
{
final SecretCache secretCache = new SecretCache("test");
final VsoAadAuthentication vaa = new VsoAadAuthentication(Guid.Empty, VsoTokenScope.CodeWrite, secretCache, secretCache);
final AzureAuthority azureAuthority = (AzureAuthority) vaa.VsoAuthority;
final URI uri = new URI(azureAuthority.authorityHostUrl);
Assert.assertEquals(true, uri.isAbsolute());
}
開發者ID:Microsoft,項目名稱:Git-Credential-Manager-for-Mac-and-Linux,代碼行數:11,代碼來源:VsoAadAuthenticationTest.java
示例7: getAuthenticationInfo
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
public AuthenticationInfo getAuthenticationInfo(final URI serverUri, final TokenPair tokenPair) {
if (tokenPair != null) {
final Client client = RestClientHelper.getClient(serverUri.toString(), tokenPair.AccessToken.Value);
if (client != null) {
//Or we could reconsider the name of the token. Now we call Profile endpoint just to get the email address
//which is used in token description, but do we need it? User can only view PATs after they login, and
//at that time user knows which account/email they are logged in under already. So the email provides
//no additional value.
final AccountHttpClient accountHttpClient
= new MyHttpClient(client, OAuth2Authenticator.APP_VSSPS_VISUALSTUDIO);
final Profile me = accountHttpClient.getMyProfile();
final String emailAddress = me.getCoreAttributes().getEmailAddress().getValue();
final String tokenDescription = AuthHelper.getTokenDescription(emailAddress);
if (serverUri.equals(OAuth2Authenticator.APP_VSSPS_VISUALSTUDIO)) {
logger.debug("Creating authenticationInfo backed by AccessToken for: {}", serverUri);
return new AuthenticationInfo(
me.getId().toString(),
tokenPair.AccessToken.Value,
serverUri.toString(),
emailAddress,
CredsType.AccessToken,
tokenPair.RefreshToken.Value);
} else {
logger.debug("Getting a PersonalAccessToken for: {}", serverUri);
final Token token = vstsPatAuthenticator.getPersonalAccessToken(
serverUri,
VsoTokenScope.AllScopes,
tokenDescription,
PromptBehavior.AUTO,
tokenPair);
if (token != null) {
logger.debug("Creating authenticationInfo backed by PersonalAccessToken for: {}", serverUri);
return new AuthenticationInfo(
me.getId().toString(),
token.Value,
serverUri.toString(),
emailAddress,
CredsType.PersonalAccessToken,
null);
} else {
logger.warn("Failed to get a Personal Access Token");
}
}
} else {
logger.warn("Failed to get authenticated jaxrs client.");
}
} else {
logger.warn("Failed to get AuthenticationInfo because AccessToken is null.");
}
return null;
}
示例8: generatePersonalAccessToken
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
/**
* Generates a personal access token for use with Visual Studio Online.
*
* @param targetUri The uniform resource indicator of the resource access tokens are being requested for.
* @param accessToken
* @param tokenScope
* @param requireCompactToken
* @return
*/
@Override public Token generatePersonalAccessToken(final URI targetUri, final Token accessToken, final VsoTokenScope tokenScope, final boolean requireCompactToken)
{
Debug.Assert(targetUri != null, "The targetUri parameter is null");
Debug.Assert(accessToken != null && !StringHelper.isNullOrWhiteSpace(accessToken.Value) && (accessToken.Type == TokenType.Access || accessToken.Type == TokenType.Federated), "The accessToken parameter is null or invalid");
Debug.Assert(tokenScope != null, "The tokenScope parameter is invalid");
Trace.writeLine("VsoAzureAuthority::generatePersonalAccessToken");
try
{
// TODO: 449524: create a `HttpClient` with a minimum number of redirects, default creds, and a reasonable timeout (access token generation seems to hang occasionally)
final HttpClient client = new HttpClient(Global.getUserAgent());
Trace.writeLine(" using token to acquire personal access token");
accessToken.contributeHeader(client.Headers);
if (populateTokenTargetId(targetUri, accessToken))
{
final URI requestUrl = createPersonalAccessTokenRequestUri(client, targetUri, requireCompactToken);
final StringContent content = getAccessTokenRequestBody(targetUri, accessToken, tokenScope);
final HttpURLConnection response = client.post(requestUrl, content);
if (response.getResponseCode() == HttpURLConnection.HTTP_OK)
{
final String responseText = HttpClient.readToString(response);
final Token token = parsePersonalAccessTokenFromJson(responseText);
if (token != null)
{
Trace.writeLine(" personal access token acquisition succeeded.");
}
return token;
}
}
}
catch (final IOException e)
{
throw new Error(e);
}
return null;
}
示例9: generatePersonalAccessToken
import com.microsoft.alm.secret.VsoTokenScope; //導入依賴的package包/類
Token generatePersonalAccessToken(final URI targetUri, final Token accessToken, final VsoTokenScope tokenScope, final boolean requireCompactToken);