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


Java OAuth2Exception.getAdditionalInformation方法代码示例

本文整理汇总了Java中org.springframework.security.oauth2.common.exceptions.OAuth2Exception.getAdditionalInformation方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2Exception.getAdditionalInformation方法的具体用法?Java OAuth2Exception.getAdditionalInformation怎么用?Java OAuth2Exception.getAdditionalInformation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.oauth2.common.exceptions.OAuth2Exception的用法示例。


在下文中一共展示了OAuth2Exception.getAdditionalInformation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serialize

import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
@Override
public void serialize(OAuth2Exception value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
		JsonProcessingException {
       jgen.writeStartObject();
	jgen.writeStringField("code", value.getOAuth2ErrorCode());
	jgen.writeStringField("message", value.getMessage());
	jgen.writeBooleanField("success", false);
	jgen.writeBooleanField("error", true);
	if (value.getAdditionalInformation()!=null) {
		for (Entry<String, String> entry : value.getAdditionalInformation().entrySet()) {
			String key = entry.getKey();
			String add = entry.getValue();
			jgen.writeStringField(key, add);				
		}
	}
       jgen.writeEndObject();
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:18,代码来源:OAuth2ExceptionDataResultJsonSerializer.java

示例2: write

import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
public void write(OAuth2Exception t, MediaType contentType, HttpOutputMessage outputMessage) throws IOException,
		HttpMessageNotWritableException {
	MultiValueMap<String, String> data = new LinkedMultiValueMap<String, String>();
	data.add(OAuth2Exception.ERROR, t.getOAuth2ErrorCode());
	data.add(OAuth2Exception.DESCRIPTION, t.getMessage());
	Map<String, String> additionalInformation = t.getAdditionalInformation();
	if(additionalInformation != null) {
		for(Map.Entry<String,String> entry : additionalInformation.entrySet()) {
			data.add(entry.getKey(), entry.getValue());
		}
	}
	delegateMessageConverter.write(data, contentType, outputMessage);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:14,代码来源:FormOAuth2ExceptionHttpMessageConverter.java

示例3: getUnsuccessfulRedirect

import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; //导入方法依赖的package包/类
private String getUnsuccessfulRedirect(AuthorizationRequest authorizationRequest, OAuth2Exception failure,
		boolean fragment) {

	if (authorizationRequest == null || authorizationRequest.getRedirectUri() == null) {
		// we have no redirect for the user. very sad.
		throw new UnapprovedClientAuthenticationException("Authorization failure, and no redirect URI.", failure);
	}

	String redirectUri = authorizationRequest.getRedirectUri();

	// extract existing fragments if any
	String[] fragments = redirectUri.split("#");

	StringBuilder url = new StringBuilder(fragment ? redirectUri : fragments[0]);

	char separator = fragment ? '#' : '?';
	if (redirectUri.indexOf(separator) < 0) {
		url.append(separator);
	}
	else {
		url.append('&');
	}
	url.append("error=").append(failure.getOAuth2ErrorCode());
	try {

		url.append("&error_description=").append(URLEncoder.encode(failure.getMessage(), "UTF-8"));

		if (authorizationRequest.getState() != null) {
			url.append('&').append("state=").append(authorizationRequest.getState());
		}

		if (failure.getAdditionalInformation() != null) {
			for (Map.Entry<String, String> additionalInfo : failure.getAdditionalInformation().entrySet()) {
				url.append('&').append(additionalInfo.getKey()).append('=')
						.append(URLEncoder.encode(additionalInfo.getValue(), "UTF-8"));
			}
		}

	}
	catch (UnsupportedEncodingException e) {
		throw new IllegalStateException(e);
	}

	if (!fragment && fragments.length > 1) {
		url.append("#" + fragments[1]);
	}

	return url.toString();

}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:51,代码来源:AuthorizationEndpoint.java


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