Client updates.

pull/105/merge
Michael Jett 2012-05-15 17:03:17 -04:00
parent 0f9b828066
commit 0c7ea88323
6 changed files with 49 additions and 29 deletions

View File

@ -55,21 +55,21 @@ 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;
private Set<String> authorizedGrantTypes;
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 String clientName= "";
private String clientDescription = "";
private boolean allowRefresh = false; // do we allow refresh tokens for this client?
private Integer accessTokenTimeout; // in seconds
private Integer refreshTokenTimeout; // in seconds
private String owner; // userid of who registered it
private Set<String> registeredRedirectUri;
private Set<String> resourceIds;
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
//http://openid.net/specs/openid-connect-registration-1_0.html

View File

@ -28,7 +28,9 @@ public interface ClientDetailsEntityService extends ClientDetailsService {
public ClientDetailsEntity loadClientByClientId(String clientId) throws OAuth2Exception;
public ClientDetailsEntity createClient(String clientId, String clientSecret, Set<String> scope, Set<String> grantTypes, String redirectUri, Set<GrantedAuthority> authorities, Set<String> resourceIds, String name, String description, boolean allowRefresh, Integer accessTokenTimeout, Integer refreshTokenTimeout, String owner);
public ClientDetailsEntity createClient(ClientDetailsEntity client);
public void deleteClient(ClientDetailsEntity client);
public ClientDetailsEntity updateClient(ClientDetailsEntity oldClient, ClientDetailsEntity newClient);

View File

@ -108,6 +108,15 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt
return client;
}
@Override
public ClientDetailsEntity createClient(ClientDetailsEntity client) {
clientRepository.saveClient(client);
return client;
}
/**
* Delete a client and all its associated tokens

View File

@ -15,6 +15,7 @@
******************************************************************************/
package org.mitre.openid.connect.web;
import com.google.gson.Gson;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.service.ClientDetailsEntityService;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,6 +23,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@ -56,13 +58,19 @@ public class ClientAPI {
return modelAndView;
}
@RequestMapping(method = RequestMethod.POST, headers="Accept=application/json")
@ResponseBody
public ClientDetailsEntity apiAddClient(@RequestBody ClientDetailsEntity c) {
@RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
public String apiAddClient(@RequestBody String json, Model m) {
return null;
ClientDetailsEntity client = new Gson().fromJson(json, ClientDetailsEntity.class);
m.addAttribute("entity", client);
clientService.createClient(client);
return "jsonClientView";
}
@RequestMapping(value="/{id}", method=RequestMethod.GET, headers="Accept=application/json")
@ResponseBody
public Object apiShowClient(@PathVariable("id") Long id, ModelAndView modelAndView) {

View File

@ -4,13 +4,14 @@
// We can pass it default values.
defaults:{
name:null,
redirectURL:"http://myURL.domain",
grantType:["my grant type 1", "my grant type 2"],
clientName:"my name",
//registeredRedirectUri:["http://myURL.domain"],
/*grantType:["my grant type 1", "my grant type 2"],
scope:["scope 1", "scope 2"],
authority:"my authority",
description:"my description",
refreshTokens:false
authority:"my authority",*/
clientDescription:"my description",
clientId:"123"
//refreshTokens:false
},
urlRoot:"/api/clients"
@ -108,9 +109,9 @@
saveClient:function () {
this.model.set({
name:$('#name').val(),
redirectURL:$('#redirectURL').val(),
description:$('#description').val()
clientName:$('#clientName').val(),
//registeredRedirectUri:[$('#registeredRedirectUri').val()],
clientDescription:$('#clientDescription').val()
});
if (this.model.isNew()) {
var self = this;

View File

@ -87,14 +87,14 @@
<div class="row-fluid">
<div class="span6">
<label>Client name</label>
<input id="name" type="text" class="" placeholder="Type something"> <span class="help-inline">Associated help text!</span>
<input id="clientName" type="text" class="" placeholder="Type something"> <span class="help-inline">Associated help text!</span>
<label>Redirect URL</label>
<input id="redirectURL" type="text" class="" placeholder="http://"><span class="help-inline">Associated help text!</span>
<input id="registeredRedirectUri" type="text" class="" placeholder="http://"><span class="help-inline">Associated help text!</span>
</div>
<div class="span6">
<label>Description</label>
<textarea id="description" class="input-xlarge" placeholder="Type a description"
<textarea id="clientDescription" class="input-xlarge" placeholder="Type a description"
rows="3"></textarea> <span class="help-inline">Associated help text!</span>
</div>
</div>