Permalink
Browse files

Client updates.

  • Loading branch information...
1 parent 27b8ffb commit 65f374635fcdf398442e78267ed377d96c5fa699 Michael Jett committed May 15, 2012
@@ -55,21 +55,21 @@ public ClientDetailsEntity() {
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
@@ -28,7 +28,9 @@
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);
@@ -108,6 +108,15 @@ public ClientDetailsEntity createClient(String clientId, String clientSecret,
return client;
}
+
+ @Override
+ public ClientDetailsEntity createClient(ClientDetailsEntity client) {
+
+ clientRepository.saveClient(client);
+
+ return client;
+
+ }
/**
* Delete a client and all its associated tokens
@@ -15,13 +15,15 @@
******************************************************************************/
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;
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 ModelAndView apiGetAllClients(ModelAndView modelAndView) {
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) {
+
+ ClientDetailsEntity client = new Gson().fromJson(json, ClientDetailsEntity.class);
+
+ m.addAttribute("entity", client);
- return null;
+ 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) {
@@ -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;
@@ -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>

0 comments on commit 65f3746

Please sign in to comment.