当前位置: 首页>>代码示例>>Java>>正文


Java OAuthCredentials类代码示例

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


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

示例1: setUp

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Before
public void setUp() {
    this.fbClient = new MockFacebookClient();
    final Clients clients = new Clients(CALLBACK_URL, fbClient);
    this.handler = new ClientAuthenticationHandler();
    this.handler.setClients(clients);
    final Credentials credentials = new OAuthCredentials(null, MockFacebookClient.CLIENT_NAME);
    this.clientCredential = new ClientCredential(credentials);
    ExternalContextHolder.setExternalContext(mock(ServletExternalContext.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:ClientAuthenticationHandlerTests.java

示例2: getOAuthCredentials

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuthCredentials getOAuthCredentials(final WebContext context) throws HttpAction {
    final String tokenParameter = context.getRequestParameter(OAUTH_TOKEN);
    final String verifierParameter = context.getRequestParameter(OAUTH_VERIFIER);
    if (tokenParameter != null && verifierParameter != null) {
        // get request token from session
        final OAuth1RequestToken tokenSession = (OAuth1RequestToken) context.getSessionAttribute(getRequestTokenSessionAttributeName());
        logger.debug("tokenRequest: {}", tokenSession);
        final String token = OAuthEncoder.decode(tokenParameter);
        final String verifier = OAuthEncoder.decode(verifierParameter);
        logger.debug("token: {} / verifier: {}", token, verifier);
        return new OAuth10Credentials(tokenSession, token, verifier, getName());
    } else {
        final String message = "No credential found";
        throw new OAuthCredentialsException(message);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:BaseOAuth10Client.java

示例3: setUp

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Before
public void setUp() {
    this.fbClient = new MockFacebookClient();
    final Clients clients = new Clients(CALLBACK_URL, fbClient);
    this.handler = new ClientAuthenticationHandler(clients);
    final Credentials credentials = new OAuthCredentials(null, MockFacebookClient.CLIENT_NAME);
    this.clientCredential = new ClientCredential(credentials);
    ExternalContextHolder.setExternalContext(mock(ServletExternalContext.class));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:ClientAuthenticationHandlerTests.java

示例4: retrieveAccessToken

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected CompletableFuture<Void> retrieveAccessToken(OAuthCredentials credentials) {
    final OAuth20Credentials oAuth20Credentials = (OAuth20Credentials) credentials;
    // no request token saved in context and no token (OAuth v2.0)
    final String code = oAuth20Credentials.getCode();
    logger.debug("code: {}", code);
    final CompletableFuture<OAuth2AccessToken> accessTokenFuture = new CompletableFuture<>();

    this.configuration.getService().getAccessTokenAsync(code, ScribeCallbackAdapter.toScribeOAuthRequestCallback(accessTokenFuture));

    return accessTokenFuture.thenAccept(accessToken -> {
        logger.debug("accessToken: {}", accessToken);
        oAuth20Credentials.setAccessToken(accessToken);
    });
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:16,代码来源:AsyncOAuth20Authenticator.java

示例5: getOAuthCredentials

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuthCredentials getOAuthCredentials(final WebContext context) throws HttpAction {
    final String codeParameter = context.getRequestParameter(OAUTH_CODE);
    if (codeParameter != null) {
        final String code = OAuthEncoder.decode(codeParameter);
        logger.debug("code: {}", code);
        return new OAuth20Credentials(code, getName());
    } else {
        final String message = "No credential found";
        throw new OAuthCredentialsException(message);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:BaseOAuth20Client.java

示例6: getAccessToken

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuth2AccessToken getAccessToken(final OAuthCredentials credentials) throws HttpAction {
    OAuth20Credentials oAuth20Credentials = (OAuth20Credentials) credentials;
    // no request token saved in context and no token (OAuth v2.0)
    final String code = oAuth20Credentials.getCode();
    logger.debug("code: {}", code);
    final OAuth2AccessToken accessToken = this.service.getAccessToken(code);
    logger.debug("accessToken: {}", accessToken);
    return accessToken;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:BaseOAuth20Client.java

示例7: retrieveCredentials

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuthCredentials retrieveCredentials(final WebContext context) throws HttpAction {
    // check if the authentication has been cancelled
    if (hasBeenCancelled(context)) {
        logger.debug("authentication has been cancelled by user");
        return null;
    }
    // check errors
    try {
        boolean errorFound = false;
        final OAuthCredentialsException oauthCredentialsException = new OAuthCredentialsException("Failed to retrieve OAuth credentials, error parameters found");
        for (final String key : OAuthCredentialsException.ERROR_NAMES) {
            final String value = context.getRequestParameter(key);
            if (value != null) {
                errorFound = true;
                oauthCredentialsException.setErrorMessage(key, value);
            }
        }
        if (errorFound) {
            throw oauthCredentialsException;
        } else {
            return getOAuthCredentials(context);
        }
    } catch (final OAuthException e) {
        throw new TechnicalException(e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:28,代码来源:BaseOAuthClient.java

示例8: retrieveUserProfile

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected U retrieveUserProfile(final OAuthCredentials credentials, final WebContext context) throws HttpAction {
    try {
        final T token = getAccessToken(credentials);
        return retrieveUserProfileFromToken(token);
    } catch (final OAuthException e) {
        throw new TechnicalException(e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:BaseOAuthClient.java

示例9: testGetCredentialOK

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Test
public void testGetCredentialOK() throws HttpAction {
    final BaseOAuthClient client = new GitHubClient();
    client.setKey(KEY);
    client.setSecret(SECRET);
    client.setCallbackUrl(CALLBACK_URL);
    assertTrue(client.getCredentials(MockWebContext.create().addRequestParameter(BaseOAuth20Client.OAUTH_CODE,
                                                                                 FAKE_VALUE)) instanceof OAuthCredentials);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:BaseOAuthClientTests.java

示例10: retrieveCredentials

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuthCredentials retrieveCredentials(final WebContext context) {
    return new OAuthCredentials("fakeVerifier", getName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:MockFacebookClient.java

示例11: retrieveUserProfile

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected FacebookProfile retrieveUserProfile(final OAuthCredentials credentials, final WebContext context) {
    return facebookProfile;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:MockFacebookClient.java

示例12: newClient

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected BaseClient<OAuthCredentials, TencentProfile> newClient() {
    final TencentClient tencentClient = new TencentClient();
    tencentClient.setScope(this.getScope());
    return tencentClient;
}
 
开发者ID:btpka3,项目名称:pac4j-oauth-tencent,代码行数:7,代码来源:TencentClient.java

示例13: retrieveAccessToken

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
/**
 * Retrieve the access token from OAuth credentials.
 *
 * @param credentials credentials
 * Return a CompletableFuture<Void> which will complete successfully on successful validation
 * or exceptionally with a HttpAction if an additional HTTP action is required
 * or exceptionally with an OAuthCredentialsException if the credentials are invalid
 */
protected abstract CompletableFuture<Void> retrieveAccessToken(OAuthCredentials credentials);
 
开发者ID:millross,项目名称:pac4j-async,代码行数:10,代码来源:AsyncOAuthAuthenticator.java

示例14: getOAuthCredentials

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
/**
 * Get the OAuth credentials from the web context.
 *
 * @param context the web context
 * @return the OAuth credentials
 * @throws HttpAction whether an additional HTTP action is required
 */
protected abstract OAuthCredentials getOAuthCredentials(final WebContext context) throws HttpAction;
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:BaseOAuthClient.java

示例15: getAccessToken

import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
/**
 * Get the access token from OAuth credentials.
 *
 * @param credentials credentials
 * @return the access token
 * @throws HttpAction whether an additional HTTP action is required
 */
protected abstract T getAccessToken(OAuthCredentials credentials) throws HttpAction;
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:BaseOAuthClient.java


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