ClientAPI now fully supports RESTful DELETE

pull/105/merge
Michael Jett 2012-05-16 14:32:40 -04:00
parent 7f5b9e2c82
commit 3402a3e463
3 changed files with 36 additions and 30 deletions

View File

@ -19,18 +19,10 @@
package org.mitre.oauth2.model;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CollectionTable;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails;
@ -56,22 +48,22 @@ public class ClientDetailsEntity implements ClientDetails {
public enum AuthType {
client_secret_post, client_secret_basic, client_secret_jwt, private_key_jwt
}
private String clientId = "";
private String clientSecret = "";
private Set<String> scope= Collections.emptySet();
private Set<String> authorizedGrantTypes= Collections.emptySet();
private Set<GrantedAuthority> authorities = Collections.emptySet();
private String clientName= "";
private String clientDescription = "";
private boolean allowRefresh = false; // do we allow refresh tokens for this client?
private Integer accessTokenTimeout = 0; // in seconds
private Integer refreshTokenTimeout = 0; // in seconds
private String owner = ""; // userid of who registered it
private Set<String> registeredRedirectUri = Collections.emptySet();
private Set<String> resourceIds = Collections.emptySet();
//Additional properties added by OpenID Connect Dynamic Client Registration spec
private String clientId = "";
private String clientSecret = "";
private Set<String> scope = new HashSet<String>();
private Set<String> authorizedGrantTypes = new HashSet<String>();
private Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
private String clientName = "";
private String clientDescription = "";
private boolean allowRefresh = false; // do we allow refresh tokens for this client?
private Integer accessTokenTimeout = 0; // in seconds
private Integer refreshTokenTimeout = 0; // in seconds
private String owner = ""; // userid of who registered it
private Set<String> registeredRedirectUri = new HashSet<String>();
private Set<String> resourceIds = new HashSet<String>();
//Additional properties added by OpenID Connect Dynamic Client Registration spec
//http://openid.net/specs/openid-connect-registration-1_0.html
/**
@ -122,7 +114,7 @@ public class ClientDetailsEntity implements ClientDetails {
/**
* @return the clientId
*/
@Id
@Id @GeneratedValue
public String getClientId() {
return clientId;
}

View File

@ -69,10 +69,10 @@ public class ClientAPI {
return "jsonClientView";
}
@RequestMapping(method = RequestMethod.DELETE, headers = "Accept=application/json")
public String apiDeleteClient(@RequestBody String json, Model m) {
@RequestMapping(value="/{id}", method=RequestMethod.DELETE, headers="Accept=application/json")
public String apiDeleteClient(@PathVariable("id") String id, ModelAndView modelAndView) {
ClientDetailsEntity client = new Gson().fromJson(json, ClientDetailsEntity.class);
ClientDetailsEntity client = clientService.loadClientByClientId(id);
clientService.deleteClient(client);
return "jsonClientView";

View File

@ -2,6 +2,8 @@
var ClientModel = Backbone.Model.extend({
idAttribute: "clientId",
// We can pass it default values.
defaults:{
clientName:"",
@ -53,7 +55,19 @@
},
deleteClient:function () {
alert('delete');
var self = this;
this.model.destroy({
success:function () {
self.$el.fadeTo("slow", 0.00, function(){ //fade
$(this).slideUp("slow", function() { //slide up
$(this).remove(); //then remove from the DOM
});
});
}
});
return false;
},
close:function () {