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


Java OAuth2Exception.valueOf方法代码示例

本文整理汇总了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);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:18,代码来源:AccessTokenProviderChain.java

示例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;
	}
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:15,代码来源:OAuth2ErrorHandler.java

示例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);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:11,代码来源:DefaultOAuth2SerializationServiceTests.java

示例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);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:7,代码来源:FormOAuth2ExceptionHttpMessageConverter.java


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