本文整理汇总了Java中org.scribe.extractors.AccessTokenExtractor类的典型用法代码示例。如果您正苦于以下问题:Java AccessTokenExtractor类的具体用法?Java AccessTokenExtractor怎么用?Java AccessTokenExtractor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessTokenExtractor类属于org.scribe.extractors包,在下文中一共展示了AccessTokenExtractor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new AccessTokenExtractor() {
@Override
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
if (matcher.find())
{
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, "", response);
}
else
{
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
};
}
示例2: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new AccessTokenExtractor() {
@Override
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
if (matcher.find())
{
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, "", response);
}
else
{
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
};
}
示例3: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new AccessTokenExtractor() {
@Override
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
// We are not interested in access_token - we and the JWT encrypted token
// Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
Matcher matcher = Pattern.compile("\"id_token\" : \"([^&\"]+)\"").matcher(response);
if (matcher.find()) {
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, "", response);
} else {
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
};
}
示例4: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor()
{
return new AccessTokenExtractor()
{
@Override
public Token extract( String response )
{
Preconditions.checkEmptyString( response, "Response body is incorrect. Can't extract a token from an empty string" );
Matcher matcher = Pattern.compile( "\"access_token\" : \"([^&\"]+)\"" ).matcher( response );
if ( matcher.find() )
{
String token = OAuthEncoder.decode( matcher.group( 1 ) );
return new Token( token, "", response );
}
else
{
throw new OAuthException( "Response body is incorrect. Can't extract a token from this: '" + response + "'", null );
}
}
};
}
示例5: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new AccessTokenExtractor() {
@Override
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
if (matcher.find())
{
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, "", response);
}
else
{
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
};
}
示例6: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
public AccessTokenExtractor getAccessTokenExtractor() {
return new AccessTokenExtractor() {
@Override
public Token extract(String response) {
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
Matcher matcher = Pattern.compile("\"access_token\" : \"([^&\"]+)\"").matcher(response);
if (matcher.find())
{
String token = OAuthEncoder.decode(matcher.group(1));
return new Token(token, "", response);
}
else
{
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
}
}
};
}
示例7: setUp
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Before
public void setUp() {
try {
api = mock(DefaultApi20.class);
config = mock(OAuthConfig.class);
request = mock(ProxyOAuthRequest.class);
response = mock(Response.class);
tokenExtractor = mock(AccessTokenExtractor.class);
verifier = mock(Verifier.class);
when(api.getAccessTokenExtractor()).thenReturn(tokenExtractor);
when(request.send()).thenReturn(response);
when(response.getBody()).thenReturn("body");
when(verifier.getValue()).thenReturn("value");
PowerMockito.whenNew(ProxyOAuthRequest.class).withAnyArguments().thenReturn(request);
} catch (Exception ex) {
Logger.getLogger(ProxyOAuthFIWARETest.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例8: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor()
{
return new JsonTokenExtractor();
}
示例9: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new JsonTokenExtractor();
}
示例10: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new JsonTokenExtractor("\"token\":\\s*\"(\\S*?)\"");
}
示例11: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new JsonTokenExtractor();
}
示例12: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new JsonTokenExtractor();
}
示例13: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new GoogleJsonTokenExtractor();
}
示例14: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new BitbucketTokenExtractor();
}
示例15: getAccessTokenExtractor
import org.scribe.extractors.AccessTokenExtractor; //导入依赖的package包/类
@Override
public AccessTokenExtractor getAccessTokenExtractor() {
return new GitLabJsonTokenExtractor();
}