• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientCredential类代码示例

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

本文整理汇总了Java中com.microsoft.aad.adal4j.ClientCredential的典型用法代码示例。如果您正苦于以下问题:Java ClientCredential类的具体用法?Java ClientCredential怎么用?Java ClientCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClientCredential类属于com.microsoft.aad.adal4j包,在下文中一共展示了ClientCredential类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAccessToken

import com.microsoft.aad.adal4j.ClientCredential; //导入依赖的package包/类
private AuthenticationResult getAccessToken(VertxContext<Server> vertxContext, String clientId, String clientKey, String authorization, String resource) throws Exception {
    AuthenticationContext context = new AuthenticationContext(authorization, false, executorService);
    ClientCredential credentials = new ClientCredential(clientId, clientKey);
    AuthenticationResult result = context.acquireToken(resource, credentials, null).get();
    checkNotNull(result, "AuthenticationResult was null");
    return result;
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:8,代码来源:AzureKms.java


示例2: acquireTokenForGraphApi

import com.microsoft.aad.adal4j.ClientCredential; //导入依赖的package包/类
private AuthenticationResult acquireTokenForGraphApi(
        String idToken,
        String tenantId) throws Throwable {
    final ClientCredential credential = new ClientCredential(
            aadAuthFilterProp.getClientId(), aadAuthFilterProp.getClientSecret());
    final UserAssertion assertion = new UserAssertion(idToken);

    AuthenticationResult result = null;
    ExecutorService service = null;
    try {
        service = Executors.newFixedThreadPool(1);
        final AuthenticationContext context = new AuthenticationContext(
                aadAuthFilterProp.getAadSignInUri() + tenantId + "/",
                true,
                service);
        final Future<AuthenticationResult> future = context
                .acquireToken(aadAuthFilterProp.getAadGraphAPIUri(), assertion, credential, null);
        result = future.get();
    } catch (ExecutionException e) {
        throw e.getCause();
    } finally {
        if (service != null) {
            service.shutdown();
        }
    }

    if (result == null) {
        throw new ServiceUnavailableException(
                "unable to acquire on-behalf-of token for client " + aadAuthFilterProp.getClientId());
    }
    return result;
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:33,代码来源:AADAuthenticationFilter.java


示例3: authenticate

import com.microsoft.aad.adal4j.ClientCredential; //导入依赖的package包/类
/**
 * Authenticates with the partner service.
 * 
 * @param requestContext An optional request context.
 * @return A task that is complete when the authentication is complete.
 */
@Override
public void authenticate( IRequestContext requestContext )
{
    // get the application AAD token
    AuthenticationResult authResult = null;
    ExecutorService service = null;
    try
    {
        URI activeDirectoryEndpoint = new URI( this.getActiveDirectoryAuthority() + this.aadApplicationDomain );
        service = Executors.newFixedThreadPool( 1 );
        AuthenticationContext authenticationContext =
            new AuthenticationContext( activeDirectoryEndpoint.toString(), false, service );
        if ( null != requestContext )
        {
            authenticationContext.setCorrelationId( requestContext.getCorrelationId().toString() );
        }

        ClientCredential clientCred = new ClientCredential( this.getClientId(), this.applicationSecret );
        Future<AuthenticationResult> future =
            authenticationContext.acquireToken( this.getGraphApiEndpoint(), clientCred, null );
        authResult = future.get();
    }
    catch ( Exception e )
    {
        throw new PartnerException( "Failed to do the application AAD login", e );
    }
    finally
    {
        service.shutdown();
    }
    this.setAADToken( new AuthenticationToken( authResult.getAccessToken(),
                                               new DateTime( authResult.getExpiresOnDate() ) ) );
}
 
开发者ID:PartnerCenterSamples,项目名称:Partner-Center-Java-SDK,代码行数:40,代码来源:ApplicationPartnerCredentials.java


示例4: acquireAccessToken

import com.microsoft.aad.adal4j.ClientCredential; //导入依赖的package包/类
private AuthenticationResult acquireAccessToken(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 {
        if (clientSecret != null) {
            return context.acquireToken(
                    resource,
                    new ClientCredential(this.clientId(), clientSecret),
                    null).get();
        } else if (clientCertificate != null && clientCertificatePassword != null) {
            return context.acquireToken(
                    resource,
                    AsymmetricKeyCredential.create(clientId, new ByteArrayInputStream(clientCertificate), clientCertificatePassword),
                    null).get();
        } else if (clientCertificate != null) {
            return context.acquireToken(
                    resource,
                    AsymmetricKeyCredential.create(clientId(), privateKeyFromPem(new String(clientCertificate)), publicKeyFromPem(new String(clientCertificate))),
                    null).get();
        }
        throw new AuthenticationException("Please provide either a non-null secret or a non-null certificate.");
    } catch (Exception e) {
        throw new IOException(e.getMessage(), e);
    } finally {
        executor.shutdown();
    }
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:32,代码来源:ApplicationTokenCredentials.java


示例5: acquireNewAccessToken

import com.microsoft.aad.adal4j.ClientCredential; //导入依赖的package包/类
AuthenticationResult acquireNewAccessToken(String resource) throws IOException {
    if (authorizationCode == null) {
        throw new IllegalArgumentException("You must acquire an authorization code by redirecting to the authentication URL");
    }
    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 {
        if (applicationCredentials.clientSecret() != null) {
            return context.acquireTokenByAuthorizationCode(
                    authorizationCode,
                    new URI(redirectUrl),
                    new ClientCredential(applicationCredentials.clientId(), applicationCredentials.clientSecret()),
                    resource, null).get();
        } else if (applicationCredentials.clientCertificate() != null && applicationCredentials.clientCertificatePassword() != null) {
            return context.acquireTokenByAuthorizationCode(
                    authorizationCode,
                    new URI(redirectUrl),
                    AsymmetricKeyCredential.create(
                            applicationCredentials.clientId(),
                            new ByteArrayInputStream(applicationCredentials.clientCertificate()),
                            applicationCredentials.clientCertificatePassword()),
                    resource,
                    null).get();
        } else if (applicationCredentials.clientCertificate() != null) {
            return context.acquireTokenByAuthorizationCode(
                    authorizationCode,
                    new URI(redirectUrl),
                    AsymmetricKeyCredential.create(
                            clientId(),
                            ApplicationTokenCredentials.privateKeyFromPem(new String(applicationCredentials.clientCertificate())),
                            ApplicationTokenCredentials.publicKeyFromPem(new String(applicationCredentials.clientCertificate()))),
                    resource,
                    null).get();
        }
        throw new AuthenticationException("Please provide either a non-null secret or a non-null certificate.");
    } catch (Exception e) {
        throw new IOException(e.getMessage(), e);
    } finally {
        executor.shutdown();
    }
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:46,代码来源:DelegatedTokenCredentials.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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