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

公開メンバ関数

String getAllWhitelistedSites (ModelMap m)
 
String addNewWhitelistedSite (@RequestBody String jsonString, ModelMap m, Principal p)
 
String updateWhitelistedSite (@PathVariable("id") Long id, @RequestBody String jsonString, ModelMap m, Principal p)
 
String deleteWhitelistedSite (@PathVariable("id") Long id, ModelMap m)
 
String getWhitelistedSite (@PathVariable("id") Long id, ModelMap m)
 

静的公開変数類

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

非公開変数類

WhitelistedSiteService whitelistService
 
Gson gson = new Gson()
 
JsonParser parser = new JsonParser()
 

静的非公開変数類

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

詳解

著者
jricher

関数詳解

◆ addNewWhitelistedSite()

String org.mitre.openid.connect.web.WhitelistAPI.addNewWhitelistedSite ( @RequestBody String  jsonString,
ModelMap  m,
Principal  p 
)
inline

Create a new whitelisted site

引数
jsonString
m
p
戻り値
95  {
96 
97  JsonObject json;
98 
99  WhitelistedSite whitelist = null;
100  try {
101  json = parser.parse(jsonString).getAsJsonObject();
102  whitelist = gson.fromJson(json, WhitelistedSite.class);
103 
104  } catch (JsonParseException e) {
105  logger.error("addNewWhitelistedSite failed due to JsonParseException", e);
106  m.addAttribute(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
107  m.addAttribute(JsonErrorView.ERROR_MESSAGE, "Could not save new whitelisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
108  return JsonErrorView.VIEWNAME;
109  } catch (IllegalStateException e) {
110  logger.error("addNewWhitelistedSite failed due to IllegalStateException", e);
111  m.addAttribute(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
112  m.addAttribute(JsonErrorView.ERROR_MESSAGE, "Could not save new whitelisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
113  return JsonErrorView.VIEWNAME;
114  }
115 
116  // save the id of the person who created this
117  whitelist.setCreatorUserId(p.getName());
118 
119  WhitelistedSite newWhitelist = whitelistService.saveNew(whitelist);
120 
121  m.put(JsonEntityView.ENTITY, newWhitelist);
122 
123  return JsonEntityView.VIEWNAME;
124 
125  }
WhitelistedSite saveNew(WhitelistedSite whitelistedSite)
static final Logger logger
Definition: WhitelistAPI.java:66
JsonParser parser
Definition: WhitelistAPI.java:69
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61
Gson gson
Definition: WhitelistAPI.java:68

◆ deleteWhitelistedSite()

String org.mitre.openid.connect.web.WhitelistAPI.deleteWhitelistedSite ( @PathVariable("id") Long  id,
ModelMap  m 
)
inline

Delete a whitelisted site

176  {
177  WhitelistedSite whitelist = whitelistService.getById(id);
178 
179  if (whitelist == null) {
180  logger.error("deleteWhitelistedSite failed; whitelist with id " + id + " could not be found.");
181  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
182  m.put(JsonErrorView.ERROR_MESSAGE, "Could not delete whitelisted site. The requested whitelisted site with id " + id + "could not be found.");
183  return JsonErrorView.VIEWNAME;
184  } else {
185  m.put(HttpCodeView.CODE, HttpStatus.OK);
186  whitelistService.remove(whitelist);
187  }
188 
189  return HttpCodeView.VIEWNAME;
190  }
void remove(WhitelistedSite whitelistedSite)
static final Logger logger
Definition: WhitelistAPI.java:66
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61

◆ getAllWhitelistedSites()

String org.mitre.openid.connect.web.WhitelistAPI.getAllWhitelistedSites ( ModelMap  m)
inline

Get a list of all whitelisted sites

引数
m
戻り値
77  {
78 
79  Collection<WhitelistedSite> all = whitelistService.getAll();
80 
81  m.put(JsonEntityView.ENTITY, all);
82 
83  return JsonEntityView.VIEWNAME;
84  }
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61

◆ getWhitelistedSite()

String org.mitre.openid.connect.web.WhitelistAPI.getWhitelistedSite ( @PathVariable("id") Long  id,
ModelMap  m 
)
inline

Get a single whitelisted site

196  {
197  WhitelistedSite whitelist = whitelistService.getById(id);
198  if (whitelist == null) {
199  logger.error("getWhitelistedSite failed; whitelist with id " + id + " could not be found.");
200  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
201  m.put(JsonErrorView.ERROR_MESSAGE, "The requested whitelisted site with id " + id + "could not be found.");
202  return JsonErrorView.VIEWNAME;
203  } else {
204 
205  m.put(JsonEntityView.ENTITY, whitelist);
206 
207  return JsonEntityView.VIEWNAME;
208  }
209 
210  }
static final Logger logger
Definition: WhitelistAPI.java:66
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61

◆ updateWhitelistedSite()

String org.mitre.openid.connect.web.WhitelistAPI.updateWhitelistedSite ( @PathVariable("id") Long  id,
@RequestBody String  jsonString,
ModelMap  m,
Principal  p 
)
inline

Update an existing whitelisted site

132  {
133 
134  JsonObject json;
135 
136  WhitelistedSite whitelist = null;
137  try {
138  json = parser.parse(jsonString).getAsJsonObject();
139  whitelist = gson.fromJson(json, WhitelistedSite.class);
140 
141  } catch (JsonParseException e) {
142  logger.error("updateWhitelistedSite failed due to JsonParseException", e);
143  m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
144  m.put(JsonErrorView.ERROR_MESSAGE, "Could not update whitelisted site. The server encountered a JSON syntax exception. Contact a system administrator for assistance.");
145  return JsonErrorView.VIEWNAME;
146  } catch (IllegalStateException e) {
147  logger.error("updateWhitelistedSite failed due to IllegalStateException", e);
148  m.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
149  m.put(JsonErrorView.ERROR_MESSAGE, "Could not update whitelisted site. The server encountered an IllegalStateException. Refresh and try again - if the problem persists, contact a system administrator for assistance.");
150  return JsonErrorView.VIEWNAME;
151  }
152 
153  WhitelistedSite oldWhitelist = whitelistService.getById(id);
154 
155  if (oldWhitelist == null) {
156  logger.error("updateWhitelistedSite failed; whitelist with id " + id + " could not be found.");
157  m.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
158  m.put(JsonErrorView.ERROR_MESSAGE, "Could not update whitelisted site. The requested whitelisted site with id " + id + "could not be found.");
159  return JsonErrorView.VIEWNAME;
160  } else {
161 
162  WhitelistedSite newWhitelist = whitelistService.update(oldWhitelist, whitelist);
163 
164  m.put(JsonEntityView.ENTITY, newWhitelist);
165 
166  return JsonEntityView.VIEWNAME;
167  }
168  }
static final Logger logger
Definition: WhitelistAPI.java:66
JsonParser parser
Definition: WhitelistAPI.java:69
WhitelistedSiteService whitelistService
Definition: WhitelistAPI.java:61
WhitelistedSite update(WhitelistedSite oldWhitelistedSite, WhitelistedSite whitelistedSite)
Gson gson
Definition: WhitelistAPI.java:68

メンバ詳解

◆ gson

Gson org.mitre.openid.connect.web.WhitelistAPI.gson = new Gson()
private

◆ logger

final Logger org.mitre.openid.connect.web.WhitelistAPI.logger = LoggerFactory.getLogger(WhitelistAPI.class)
staticprivate

Logger for this class

◆ parser

JsonParser org.mitre.openid.connect.web.WhitelistAPI.parser = new JsonParser()
private

◆ URL

final String org.mitre.openid.connect.web.WhitelistAPI.URL = RootController.API_URL + "/whitelist"
static

◆ whitelistService

WhitelistedSiteService org.mitre.openid.connect.web.WhitelistAPI.whitelistService
private

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