mitreid-connect
公開メンバ関数 | 静的公開変数類 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.oauth2.web.ScopeAPI クラス
org.mitre.oauth2.web.ScopeAPI 連携図
Collaboration graph

公開メンバ関数

String getAll (ModelMap m)
 
String getScope (@PathVariable("id") Long id, ModelMap m)
 
String updateScope (@PathVariable("id") Long id, @RequestBody String json, ModelMap m)
 
String createScope (@RequestBody String json, ModelMap m)
 
String deleteScope (@PathVariable("id") Long id, ModelMap m)
 

静的公開変数類

static final String URL = RootController.API_URL + "/scopes"
 

非公開変数類

SystemScopeService scopeService
 
Gson gson = new Gson()
 

静的非公開変数類

static final Logger logger = LoggerFactory.getLogger(ScopeAPI.class)
 

詳解

著者
jricher

関数詳解

◆ createScope()

String org.mitre.oauth2.web.ScopeAPI.createScope ( @RequestBody String  json,
ModelMap  m 
)
inline
137  {
138  SystemScope scope = gson.fromJson(json, SystemScope.class);
139 
140  SystemScope alreadyExists = scopeService.getByValue(scope.getValue());
141  if (alreadyExists != null) {
142  //Error, cannot save a scope with the same value as an existing one
143  logger.error("Error: attempting to save a scope with a value that already exists: " + scope.getValue());
144  m.put(HttpCodeView.CODE, HttpStatus.CONFLICT);
145  m.put(JsonErrorView.ERROR_MESSAGE, "A scope with value " + scope.getValue() + " already exists, please choose a different value.");
146  return JsonErrorView.VIEWNAME;
147  }
148 
149  scope = scopeService.save(scope);
150 
151  if (scope != null && scope.getId() != null) {
152 
153  m.put(JsonEntityView.ENTITY, scope);
154 
155  return JsonEntityView.VIEWNAME;
156  } else {
157 
158  logger.error("createScope failed; JSON was invalid: " + json);
159  m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
160  m.put(JsonErrorView.ERROR_MESSAGE, "Could not save new scope " + scope + ". The scope service failed to return a saved entity.");
161  return JsonErrorView.VIEWNAME;
162 
163  }
164  }
SystemScope save(SystemScope scope)
static final Logger logger
Definition: ScopeAPI.java:63
SystemScope getByValue(String value)
Gson gson
Definition: ScopeAPI.java:65
SystemScopeService scopeService
Definition: ScopeAPI.java:58

◆ deleteScope()

String org.mitre.oauth2.web.ScopeAPI.deleteScope ( @PathVariable("id") Long  id,
ModelMap  m 
)
inline
168  {
169  SystemScope existing = scopeService.getById(id);
170 
171  if (existing != null) {
172 
173  scopeService.remove(existing);
174 
175  return HttpCodeView.VIEWNAME;
176  } else {
177 
178  logger.error("deleteScope failed; scope with id " + id + " not found.");
179  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
180  m.put(JsonErrorView.ERROR_MESSAGE, "Could not delete scope. The requested scope with id " + id + " could not be found.");
181  return JsonErrorView.VIEWNAME;
182  }
183  }
static final Logger logger
Definition: ScopeAPI.java:63
SystemScopeService scopeService
Definition: ScopeAPI.java:58

◆ getAll()

String org.mitre.oauth2.web.ScopeAPI.getAll ( ModelMap  m)
inline
68  {
69 
70  Set<SystemScope> allScopes = scopeService.getAll();
71 
72  m.put(JsonEntityView.ENTITY, allScopes);
73 
74  return JsonEntityView.VIEWNAME;
75  }
SystemScopeService scopeService
Definition: ScopeAPI.java:58

◆ getScope()

String org.mitre.oauth2.web.ScopeAPI.getScope ( @PathVariable("id") Long  id,
ModelMap  m 
)
inline
78  {
79 
80  SystemScope scope = scopeService.getById(id);
81 
82  if (scope != null) {
83 
84  m.put(JsonEntityView.ENTITY, scope);
85 
86  return JsonEntityView.VIEWNAME;
87  } else {
88 
89  logger.error("getScope failed; scope not found: " + id);
90 
91  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
92  m.put(JsonErrorView.ERROR_MESSAGE, "The requested scope with id " + id + " could not be found.");
93  return JsonErrorView.VIEWNAME;
94  }
95  }
static final Logger logger
Definition: ScopeAPI.java:63
SystemScopeService scopeService
Definition: ScopeAPI.java:58

◆ updateScope()

String org.mitre.oauth2.web.ScopeAPI.updateScope ( @PathVariable("id") Long  id,
@RequestBody String  json,
ModelMap  m 
)
inline
99  {
100 
101  SystemScope existing = scopeService.getById(id);
102 
103  SystemScope scope = gson.fromJson(json, SystemScope.class);
104 
105  if (existing != null && scope != null) {
106 
107  if (existing.getId().equals(scope.getId())) {
108  // sanity check
109 
110  scope = scopeService.save(scope);
111 
112  m.put(JsonEntityView.ENTITY, scope);
113 
114  return JsonEntityView.VIEWNAME;
115  } else {
116 
117  logger.error("updateScope failed; scope ids to not match: got "
118  + existing.getId() + " and " + scope.getId());
119 
120  m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
121  m.put(JsonErrorView.ERROR_MESSAGE, "Could not update scope. Scope ids to not match: got "
122  + existing.getId() + " and " + scope.getId());
123  return JsonErrorView.VIEWNAME;
124  }
125 
126  } else {
127 
128  logger.error("updateScope failed; scope with id " + id + " not found.");
129  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
130  m.put(JsonErrorView.ERROR_MESSAGE, "Could not update scope. The scope with id " + id + " could not be found.");
131  return JsonErrorView.VIEWNAME;
132  }
133  }
SystemScope save(SystemScope scope)
static final Logger logger
Definition: ScopeAPI.java:63
Gson gson
Definition: ScopeAPI.java:65
SystemScopeService scopeService
Definition: ScopeAPI.java:58

メンバ詳解

◆ gson

Gson org.mitre.oauth2.web.ScopeAPI.gson = new Gson()
private

◆ logger

final Logger org.mitre.oauth2.web.ScopeAPI.logger = LoggerFactory.getLogger(ScopeAPI.class)
staticprivate

Logger for this class

◆ scopeService

SystemScopeService org.mitre.oauth2.web.ScopeAPI.scopeService
private

◆ URL

final String org.mitre.oauth2.web.ScopeAPI.URL = RootController.API_URL + "/scopes"
static

このクラス詳解は次のファイルから抽出されました: