请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VsoTokenScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:Microsoft,项目名称:Git-Credential-Manager-for-Mac-and-Linux,代码行数:15,代码来源:VsoAzureAuthority.java


示例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;
    }
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:58,代码来源:VsoAuthInfoProvider.java


示例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;
}
 
开发者ID:Microsoft,项目名称:Git-Credential-Manager-for-Mac-and-Linux,代码行数:50,代码来源:VsoAzureAuthority.java


示例9: generatePersonalAccessToken

import com.microsoft.alm.secret.VsoTokenScope; //导入依赖的package包/类
Token generatePersonalAccessToken(final URI targetUri, final Token accessToken, final VsoTokenScope tokenScope, final boolean requireCompactToken); 
开发者ID:Microsoft,项目名称:Git-Credential-Manager-for-Mac-and-Linux,代码行数:2,代码来源:IVsoAuthority.java



注:本文中的com.microsoft.alm.secret.VsoTokenScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnrecognizableServiceForServiceTicketValidationException类代码示例发布时间:2022-05-16
下一篇:
Java OnRefreshListener类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap