本文整理汇总了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();
}
示例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);
}
示例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();
}