fixed split client views, fixed typos in various places

pull/306/merge
Justin Richer 2013-03-05 17:26:25 -05:00
parent f07c31bbe2
commit 70b2342864
9 changed files with 140 additions and 146 deletions

View File

@ -97,7 +97,7 @@ public class ClientDetailsEntity implements ClientDetails {
private JWSAlgorithmEmbed idTokenSignedResponseAlg; // id_token_signed_response_alg
private JWEAlgorithmEmbed idTokenEncryptedResponseAlg; // id_token_encrypted_response_alg
private JWEEncryptionMethodEmbed idTokenEncryptedReponseEnc; // id_token_encrypted_response_enc
private JWEEncryptionMethodEmbed idTokenEncryptedResponseEnc; // id_token_encrypted_response_enc
private Integer defaultMaxAge; // default_max_age
private Boolean requireAuthTime; // require_auth_time
@ -734,12 +734,12 @@ public class ClientDetailsEntity implements ClientDetails {
@AttributeOverrides({
@AttributeOverride(name = "algorithmName", column=@Column(name="id_token_encrypted_response_enc"))
})
public JWEEncryptionMethodEmbed getIdTokenEncryptedReponseEnc() {
return idTokenEncryptedReponseEnc;
public JWEEncryptionMethodEmbed getIdTokenEncryptedResponseEnc() {
return idTokenEncryptedResponseEnc;
}
public void setIdTokenEncryptedReponseEnc(JWEEncryptionMethodEmbed idTokenEncryptedReponseEnc) {
this.idTokenEncryptedReponseEnc = idTokenEncryptedReponseEnc;
public void setIdTokenEncryptedResponseEnc(JWEEncryptionMethodEmbed idTokenEncryptedResponseEnc) {
this.idTokenEncryptedResponseEnc = idTokenEncryptedResponseEnc;
}
@Basic

View File

@ -0,0 +1,107 @@
/**
*
*/
package org.mitre.openid.connect.view;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Type;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mitre.jose.JWEAlgorithmEmbed;
import org.mitre.jose.JWEEncryptionMethodEmbed;
import org.mitre.jose.JWSAlgorithmEmbed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
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.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
/**
* @author jricher
*
*/
public abstract class AbstractClientEntityView extends AbstractView {
private static Logger logger = LoggerFactory.getLogger(ClientEntityViewForAdmins.class);
private Gson gson = new GsonBuilder()
.setExclusionStrategies(getExclusionStrategy())
.registerTypeAdapter(JWSAlgorithmEmbed.class, new JsonSerializer<JWSAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWSAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEAlgorithmEmbed.class, new JsonSerializer<JWEAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWEAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEEncryptionMethodEmbed.class, new JsonSerializer<JWEEncryptionMethodEmbed>() {
@Override
public JsonElement serialize(JWEEncryptionMethodEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.serializeNulls()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
.create();
/**
* @return
*/
protected abstract ExclusionStrategy getExclusionStrategy();
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/json");
HttpStatus code = (HttpStatus) model.get("code");
if (code == null) {
code = HttpStatus.OK; // default to 200
}
response.setStatus(code.value());
try {
Writer out = response.getWriter();
Object obj = model.get("entity");
gson.toJson(obj, out);
} catch (IOException e) {
logger.error("IOException in JsonEntityView.java: ", e);
}
}
}

View File

@ -36,13 +36,14 @@ import com.google.gson.JsonSerializer;
* @author jricher
*
*/
@Component("clientEntityViewAdmin")
public class ClientEntityViewForAdmins extends AbstractView {
@Component("clientEntityViewAdmins")
public class ClientEntityViewForAdmins extends AbstractClientEntityView {
private static Logger logger = LoggerFactory.getLogger(ClientEntityViewForAdmins.class);
private Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
/**
* @return
*/
protected ExclusionStrategy getExclusionStrategy() {
return new ExclusionStrategy() {
public boolean shouldSkipField(FieldAttributes f) {
if (f.getName().equals("additionalProperties")) {
@ -60,65 +61,6 @@ public class ClientEntityViewForAdmins extends AbstractView {
return false;
}
})
.registerTypeAdapter(JWSAlgorithmEmbed.class, new JsonSerializer<JWSAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWSAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEAlgorithmEmbed.class, new JsonSerializer<JWEAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWEAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEEncryptionMethodEmbed.class, new JsonSerializer<JWEEncryptionMethodEmbed>() {
@Override
public JsonElement serialize(JWEEncryptionMethodEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.serializeNulls()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
.create();
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/json");
HttpStatus code = (HttpStatus) model.get("code");
if (code == null) {
code = HttpStatus.OK; // default to 200
}
response.setStatus(code.value());
try {
Writer out = response.getWriter();
Object obj = model.get("entity");
gson.toJson(obj, out);
} catch (IOException e) {
logger.error("IOException in JsonEntityView.java: ", e);
}
};
}
}

View File

@ -36,14 +36,16 @@ import com.google.gson.JsonSerializer;
* @author jricher
*
*/
@Component("clientEntityViewUser")
public class ClientEntityViewForUsers extends AbstractView {
@Component("clientEntityViewUsers")
public class ClientEntityViewForUsers extends AbstractClientEntityView {
private static Logger logger = LoggerFactory.getLogger(ClientEntityViewForUsers.class);
private Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
/* (non-Javadoc)
* @see org.mitre.openid.connect.view.AbstractClientEntityView#getExclusionStrategy()
*/
@Override
protected ExclusionStrategy getExclusionStrategy() {
return new ExclusionStrategy() {
public boolean shouldSkipField(FieldAttributes f) {
// whitelist the handful of fields that are good
if (f.getName().equals("clientName") ||
@ -66,65 +68,7 @@ public class ClientEntityViewForUsers extends AbstractView {
return false;
}
})
.registerTypeAdapter(JWSAlgorithmEmbed.class, new JsonSerializer<JWSAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWSAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEAlgorithmEmbed.class, new JsonSerializer<JWEAlgorithmEmbed>() {
@Override
public JsonElement serialize(JWEAlgorithmEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.registerTypeAdapter(JWEEncryptionMethodEmbed.class, new JsonSerializer<JWEEncryptionMethodEmbed>() {
@Override
public JsonElement serialize(JWEEncryptionMethodEmbed src, Type typeOfSrc, JsonSerializationContext context) {
if (src != null) {
return new JsonPrimitive(src.getAlgorithmName());
} else {
return null;
}
}
})
.serializeNulls()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
.create();
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/json");
HttpStatus code = (HttpStatus) model.get("code");
if (code == null) {
code = HttpStatus.OK; // default to 200
}
response.setStatus(code.value());
try {
Writer out = response.getWriter();
Object obj = model.get("entity");
gson.toJson(obj, out);
} catch (IOException e) {
logger.error("IOException in JsonEntityView.java: ", e);
}
};
}
}

View File

@ -97,7 +97,7 @@ public class ClientInformationResponseView extends AbstractView {
o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getAlgorithmName() : null);
o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getAlgorithmName() : null);
o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getAlgorithmName() : null);
o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedReponseEnc() != null ? c.getIdTokenEncryptedReponseEnc().getAlgorithmName() : null);
o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getAlgorithmName() : null);
o.addProperty("default_max_age", c.getDefaultMaxAge());
o.addProperty("require_auth_time", c.getRequireAuthTime());
o.add("default_acr_values", getAsArray(c.getDefaultACRvalues()));

View File

@ -106,7 +106,7 @@ public class ClientAPI {
Collection<ClientDetailsEntity> clients = clientService.getAllClients();
modelAndView.addObject("entity", clients);
modelAndView.setViewName("clientEntityView");
modelAndView.setViewName("clientEntityViewAdmins");
return modelAndView;
}
@ -143,7 +143,7 @@ public class ClientAPI {
ClientDetailsEntity newClient = clientService.saveNewClient(client);
m.addAttribute("entity", newClient);
return "clientEntityView";
return "clientEntityViewAdmins";
}
/**
@ -185,7 +185,7 @@ public class ClientAPI {
ClientDetailsEntity newClient = clientService.updateClient(oldClient, client);
m.addAttribute("entity", newClient);
return "clientEntityView";
return "clientEntityViewAdmins";
}
/**
@ -224,7 +224,7 @@ public class ClientAPI {
}
modelAndView.addObject("entity", client);
modelAndView.setViewName("clientEntityView");
modelAndView.setViewName("clientEntityViewAdmins");
return modelAndView;
}

View File

@ -205,7 +205,7 @@ public class ClientDynamicRegistrationEndpoint {
c.setIdTokenSignedResponseAlg(getAsJwsAlgorithm(o, "id_token_signed_response_alg"));
c.setIdTokenEncryptedResponseAlg(getAsJweAlgorithm(o, "id_token_encrypted_response_alg"));
c.setIdTokenEncryptedReponseEnc(getAsJweEncryptionMethod(o, "id_token_encrypted_response_enc"));
c.setIdTokenEncryptedResponseEnc(getAsJweEncryptionMethod(o, "id_token_encrypted_response_enc"));
if (o.has("default_max_age")) {
if (o.get("default_max_age").isJsonPrimitive()) {

View File

@ -495,7 +495,7 @@ var ClientFormView = Backbone.View.extend({
$('#requestUris .controls', this.el).html(new ListWidgetView({
type: 'uri',
placeholder: 'http://',
collection: this.requestUrisCollection}).render.el());
collection: this.requestUrisCollection}).render().el);
// build and bind default ACR values
_.each(this.model.get('defaultAcrValues'), function (defaultAcrValue) {
@ -505,7 +505,7 @@ var ClientFormView = Backbone.View.extend({
$('#defaultAcrValues .controls', this.el).html(new ListWidgetView({
placeholder: 'new ACR value',
// TODO: autocomplete from spec
collection: this.defaultAcrValuesCollection}).render.el());
collection: this.defaultAcrValuesCollection}).render().el);
// build and bind

View File

@ -482,6 +482,7 @@
<option value="ES256" <%=userInfoSignedResponseAlg == "ES256" ? 'selected' : ''%>>ECDSA using P-256 curve and SHA-256 hash algorithm</option>
<option value="ES384" <%=userInfoSignedResponseAlg == "ES384" ? 'selected' : ''%>>ECDSA using P-384 curve and SHA-384 hash algorithm</option>
<option value="ES512" <%=userInfoSignedResponseAlg == "ES512" ? 'selected' : ''%>>ECDSA using P-512 curve and SHA-512 hash algorithm</option>
</select>
</div>
</div>