|
|
|
@ -31,33 +31,29 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.validation.BeanPropertyBindingResult;
|
|
|
|
|
import org.springframework.web.servlet.view.AbstractView;
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
|
import com.google.gson.ExclusionStrategy;
|
|
|
|
|
import com.google.gson.FieldAttributes;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
import com.google.gson.JsonParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component("userInfoView")
|
|
|
|
|
public class UserInfoView extends AbstractView {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static JsonParser jsonParser = new JsonParser();
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(UserInfoView.class);
|
|
|
|
|
|
|
|
|
|
private Gson gson = new GsonBuilder()
|
|
|
|
|
.setExclusionStrategies(new ExclusionStrategy() {
|
|
|
|
|
|
|
|
|
|
//@Override
|
|
|
|
|
private Gson gson = new GsonBuilder().setExclusionStrategies(new ExclusionStrategy() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldSkipField(FieldAttributes f) {
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@Override
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldSkipClass(Class<?> clazz) {
|
|
|
|
|
// skip the JPA binding wrapper
|
|
|
|
|
if (clazz.equals(BeanPropertyBindingResult.class)) {
|
|
|
|
@ -68,8 +64,13 @@ public class UserInfoView extends AbstractView {
|
|
|
|
|
|
|
|
|
|
}).create();
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
|
* @see org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
|
|
|
|
/*
|
|
|
|
|
* (non-Javadoc)
|
|
|
|
|
*
|
|
|
|
|
* @see
|
|
|
|
|
* org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel
|
|
|
|
|
* (java.util.Map, javax.servlet.http.HttpServletRequest,
|
|
|
|
|
* javax.servlet.http.HttpServletResponse)
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
@ -77,21 +78,7 @@ public class UserInfoView extends AbstractView {
|
|
|
|
|
UserInfo userInfo = (UserInfo) model.get("userInfo");
|
|
|
|
|
|
|
|
|
|
Set<String> scope = (Set<String>) model.get("scope");
|
|
|
|
|
|
|
|
|
|
String claimsRequestJsonString = (String) model.get("claimsRequest");
|
|
|
|
|
|
|
|
|
|
// getting the 'claims request parameter' from the model
|
|
|
|
|
JsonObject claimsRequest = null;
|
|
|
|
|
if (!Strings.isNullOrEmpty(claimsRequestJsonString)) {
|
|
|
|
|
JsonElement parsed = jsonParser.parse(claimsRequestJsonString);
|
|
|
|
|
if (parsed.isJsonObject()) {
|
|
|
|
|
claimsRequest = parsed.getAsJsonObject();
|
|
|
|
|
} else {
|
|
|
|
|
// claimsRequest stays null
|
|
|
|
|
logger.warn("Claims parameter not a valid JSON object: " + claimsRequestJsonString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setContentType("application/json");
|
|
|
|
|
|
|
|
|
|
Writer out;
|
|
|
|
|