本文整理汇总了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);
}
}
示例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);
});
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例10: retrieveCredentials
import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected OAuthCredentials retrieveCredentials(final WebContext context) {
return new OAuthCredentials("fakeVerifier", getName());
}
示例11: retrieveUserProfile
import org.pac4j.oauth.credentials.OAuthCredentials; //导入依赖的package包/类
@Override
protected FacebookProfile retrieveUserProfile(final OAuthCredentials credentials, final WebContext context) {
return facebookProfile;
}
示例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;
}
示例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);
示例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;
示例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;