本文整理汇总了Java中org.springframework.security.oauth2.common.exceptions.OAuth2Exception.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2Exception.valueOf方法的具体用法?Java OAuth2Exception.valueOf怎么用?Java OAuth2Exception.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.oauth2.common.exceptions.OAuth2Exception
的用法示例。
在下文中一共展示了OAuth2Exception.valueOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: obtainNewAccessTokenInternal
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
protected OAuth2AccessToken obtainNewAccessTokenInternal(OAuth2ProtectedResourceDetails details,
AccessTokenRequest request) throws UserRedirectRequiredException, AccessDeniedException {
if (request.isError()) {
// there was an oauth error...
throw OAuth2Exception.valueOf(request.toSingleValueMap());
}
for (AccessTokenProvider tokenProvider : chain) {
if (tokenProvider.supportsResource(details)) {
return tokenProvider.obtainAccessToken(details, request);
}
}
throw new OAuth2AccessDeniedException("Unable to obtain a new access token for resource '" + details.getId()
+ "'. The provider manager is not configured to support it.", details);
}
示例2: maybeThrowExceptionFromHeader
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
private void maybeThrowExceptionFromHeader(String authenticateHeader, String headerType) {
headerType = headerType.toLowerCase();
if (authenticateHeader.toLowerCase().startsWith(headerType)) {
Map<String, String> headerEntries = StringSplitUtils.splitEachArrayElementAndCreateMap(
StringSplitUtils.splitIgnoringQuotes(authenticateHeader.substring(headerType.length()), ','), "=",
"\"");
OAuth2Exception ex = OAuth2Exception.valueOf(headerEntries);
if (ex instanceof InvalidTokenException) {
// Special case: an invalid token can be renewed so tell the caller what to do
throw new AccessTokenRequiredException(resource);
}
throw ex;
}
}
示例3: testExceptionDeserialization
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
@Test
public void testExceptionDeserialization() throws Exception {
Map<String, String> exception = MapBuilder.create("error", "invalid_client").add("error_description", "FOO")
.build();
OAuth2Exception result = OAuth2Exception.valueOf(exception);
// System.err.println(result);
assertEquals("FOO", result.getMessage());
assertEquals("invalid_client", result.getOAuth2ErrorCode());
assertTrue(result instanceof InvalidClientException);
}
示例4: read
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
public OAuth2Exception read(Class<? extends OAuth2Exception> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
MultiValueMap<String, String> data = delegateMessageConverter.read(null, inputMessage);
Map<String,String> flattenedData = data.toSingleValueMap();
return OAuth2Exception.valueOf(flattenedData);
}