Merge branch 'master' of github.com:jricher/OpenID-Connect-Java-Spring-Server
commit
7c73b8f34d
|
@ -1,4 +1,4 @@
|
|||
package org.mitre.openid.connect.model.serializer;
|
||||
package org.mitre.openid.connect.view;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
|
@ -1,4 +1,4 @@
|
|||
package org.mitre.openid.connect.model.serializer;
|
||||
package org.mitre.openid.connect.view;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.mitre.openid.connect.view;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
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.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public class JwkKeyListView extends AbstractView {
|
||||
|
||||
@Override
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
Gson gson = new GsonBuilder()
|
||||
.setExclusionStrategies(new ExclusionStrategy() {
|
||||
|
||||
public boolean shouldSkipField(FieldAttributes f) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldSkipClass(Class<?> clazz) {
|
||||
// skip the JPA binding wrapper
|
||||
if (clazz.equals(BeanPropertyBindingResult.class)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
})
|
||||
.registerTypeAdapter(RSAPublicKey.class, new JsonSerializer<RSAPublicKey>() {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(RSAPublicKey src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
|
||||
|
||||
|
||||
JsonObject o = new JsonObject();
|
||||
o.addProperty("mod", src.getModulus().toString());
|
||||
|
||||
return o;
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
.create();
|
||||
|
||||
|
||||
response.setContentType("application/json");
|
||||
|
||||
Writer out = response.getWriter();
|
||||
|
||||
Object obj = model.get("entity");
|
||||
if (obj == null) {
|
||||
obj = model;
|
||||
}
|
||||
|
||||
gson.toJson(obj, out);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package org.mitre.openid.connect.web;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.List;
|
||||
|
||||
import org.mitre.jwt.service.JwtSigningAndValidationService;
|
||||
|
@ -22,7 +24,7 @@ public class JsonWebKeyEndpoint {
|
|||
|
||||
// TODO: check if keys are empty, return a 404 here?
|
||||
|
||||
return new ModelAndView("jwkView", "keys", keys); // TODO: make a view
|
||||
return new ModelAndView("jwkKeyList", "keys", keys); // TODO: make a view
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
<!-- JSON views for each type of model object -->
|
||||
<beans:bean id="jsonOpenIdConfigurationView" class="org.mitre.swd.view.JsonOpenIdConfigurationView" />
|
||||
<beans:bean id="jsonSwdResponseView" class="org.mitre.swd.view.SwdResponse" />
|
||||
<!-- <beans:bean id="jsonUserInfoView" class="org.mitre.openid.connect.model.serializer.JSONUserInfoView"/> -->
|
||||
<!-- <beans:bean id="jsonIdTokenView" class="org.mitre.openid.connect.model.serializer.JSONIdTokenView"/> -->
|
||||
<!-- <beans:bean id="jsonUserInfoView" class="org.mitre.openid.connect.view.JSONUserInfoView"/> -->
|
||||
<!-- <beans:bean id="jsonIdTokenView" class="org.mitre.openid.connect.view.JSONIdTokenView"/> -->
|
||||
|
||||
<beans:import resource="controllers.xml" />
|
||||
|
||||
|
|
Loading…
Reference in New Issue