本文整理汇总了Java中org.scribe.utils.OAuthEncoder.decode方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthEncoder.decode方法的具体用法?Java OAuthEncoder.decode怎么用?Java OAuthEncoder.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.scribe.utils.OAuthEncoder
的用法示例。
在下文中一共展示了OAuthEncoder.decode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessTokenExtractor
import org.scribe.utils.OAuthEncoder; //导入方法依赖的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.utils.OAuthEncoder; //导入方法依赖的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.utils.OAuthEncoder; //导入方法依赖的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.utils.OAuthEncoder; //导入方法依赖的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.utils.OAuthEncoder; //导入方法依赖的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.utils.OAuthEncoder; //导入方法依赖的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: extractToken
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
private static String extractToken(String name, String responseBody) {
try {
Preconditions.checkEmptyString(name, "name String is incorrect!");
Preconditions.checkEmptyString(responseBody, "Response body is incorrect. Can't extract a token from an empty string");
} catch (IllegalArgumentException e) {
throw new OAuthException(e.getMessage());
}
//{"access_token" : ""}
String REGEX = "\"%s\"\\s*:\\s*\"([^\"]+)\"";
REGEX = String.format(REGEX, name);
Matcher matcher = Pattern.compile(REGEX).matcher(responseBody);
if (matcher.find()) {
return OAuthEncoder.decode(matcher.group(1));
} else {
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + responseBody + "'", null);
}
}
示例8: extract
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
private static String extract(String response, Pattern p) {
Matcher matcher = p.matcher(response);
if (matcher.find() && matcher.groupCount() >= 1) {
return OAuthEncoder.decode(matcher.group(1));
} else {
throw new OAuthException("Response body is incorrect. Can't extract token and secret from this: " + response);
}
}
示例9: extract
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
private String extract(String response, Pattern p) {
Matcher matcher = p.matcher(response);
if (matcher.find() && matcher.groupCount() >= 1) {
return OAuthEncoder.decode(matcher.group(1));
} else {
throw new OAuthException("Response body is incorrect. " +
"Can't extract token and secret from this: '" + response + "'", null);
}
}
示例10: checkError
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
private static void checkError(CharSequence response) {
Matcher matcher = ERROR_MESSAGE_REGEX.matcher(response);
if (matcher.find() && matcher.groupCount() >= 1)
{
throw new OAuthException(OAuthEncoder.decode(matcher.group(1)));
}
}
示例11: addQuerystring
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
public void addQuerystring(String queryString)
{
if (queryString != null && queryString.length() > 0)
{
for (String param : queryString.split(PARAM_SEPARATOR))
{
String pair[] = param.split(PAIR_SEPARATOR);
String key = OAuthEncoder.decode(pair[0]);
String value = pair.length > 1 ? OAuthEncoder.decode(pair[1]) : EMPTY_STRING;
params.add(new Parameter(key, value));
}
}
}
示例12: extract
import org.scribe.utils.OAuthEncoder; //导入方法依赖的package包/类
private String extract(String response, Pattern p) {
Matcher matcher = p.matcher(response);
if (matcher.find() && matcher.groupCount() >= 1) {
return OAuthEncoder.decode(matcher.group(1));
} else {
throw new OAuthException(
"Response body is incorrect. Can't extract token and secret from this: '"
+ response + "'", null);
}
}