ClientAPI now fully supports RESTful DELETE
parent
7f5b9e2c82
commit
3402a3e463
|
@ -19,18 +19,10 @@
|
||||||
package org.mitre.oauth2.model;
|
package org.mitre.oauth2.model;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.*;
|
||||||
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 org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||||
|
@ -59,17 +51,17 @@ public class ClientDetailsEntity implements ClientDetails {
|
||||||
|
|
||||||
private String clientId = "";
|
private String clientId = "";
|
||||||
private String clientSecret = "";
|
private String clientSecret = "";
|
||||||
private Set<String> scope= Collections.emptySet();
|
private Set<String> scope = new HashSet<String>();
|
||||||
private Set<String> authorizedGrantTypes= Collections.emptySet();
|
private Set<String> authorizedGrantTypes = new HashSet<String>();
|
||||||
private Set<GrantedAuthority> authorities = Collections.emptySet();
|
private Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
|
||||||
private String clientName = "";
|
private String clientName = "";
|
||||||
private String clientDescription = "";
|
private String clientDescription = "";
|
||||||
private boolean allowRefresh = false; // do we allow refresh tokens for this client?
|
private boolean allowRefresh = false; // do we allow refresh tokens for this client?
|
||||||
private Integer accessTokenTimeout = 0; // in seconds
|
private Integer accessTokenTimeout = 0; // in seconds
|
||||||
private Integer refreshTokenTimeout = 0; // in seconds
|
private Integer refreshTokenTimeout = 0; // in seconds
|
||||||
private String owner = ""; // userid of who registered it
|
private String owner = ""; // userid of who registered it
|
||||||
private Set<String> registeredRedirectUri = Collections.emptySet();
|
private Set<String> registeredRedirectUri = new HashSet<String>();
|
||||||
private Set<String> resourceIds = Collections.emptySet();
|
private Set<String> resourceIds = new HashSet<String>();
|
||||||
|
|
||||||
//Additional properties added by OpenID Connect Dynamic Client Registration spec
|
//Additional properties added by OpenID Connect Dynamic Client Registration spec
|
||||||
//http://openid.net/specs/openid-connect-registration-1_0.html
|
//http://openid.net/specs/openid-connect-registration-1_0.html
|
||||||
|
@ -122,7 +114,7 @@ public class ClientDetailsEntity implements ClientDetails {
|
||||||
/**
|
/**
|
||||||
* @return the clientId
|
* @return the clientId
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id @GeneratedValue
|
||||||
public String getClientId() {
|
public String getClientId() {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,10 @@ public class ClientAPI {
|
||||||
return "jsonClientView";
|
return "jsonClientView";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, headers = "Accept=application/json")
|
@RequestMapping(value="/{id}", method=RequestMethod.DELETE, headers="Accept=application/json")
|
||||||
public String apiDeleteClient(@RequestBody String json, Model m) {
|
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);
|
clientService.deleteClient(client);
|
||||||
|
|
||||||
return "jsonClientView";
|
return "jsonClientView";
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
var ClientModel = Backbone.Model.extend({
|
var ClientModel = Backbone.Model.extend({
|
||||||
|
|
||||||
|
idAttribute: "clientId",
|
||||||
|
|
||||||
// We can pass it default values.
|
// We can pass it default values.
|
||||||
defaults:{
|
defaults:{
|
||||||
clientName:"",
|
clientName:"",
|
||||||
|
@ -53,7 +55,19 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteClient:function () {
|
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 () {
|
close:function () {
|
||||||
|
|
Loading…
Reference in New Issue