use of com.runwaysdk.mvc.CookieResponse in project geoprism-registry by terraframe.
the class RegistrySessionController method login.
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF login(ServletRequestIF req, @RequestParamter(name = "username", required = true) String username, @RequestParamter(name = "password", required = true) String password) throws JSONException {
if (username != null) {
username = username.trim();
}
Locale[] locales = this.getLocales(req);
// Locale sessionLocale = req.getLocale();
//
// JSONArray installedLocalesArr = new JSONArray();
// Collection<Locale> installedLocales = LocalizationFacade.getInstalledLocales();
// for (Locale loc : installedLocales)
// {
// JSONObject locObj = new JSONObject();
// locObj.put("language", loc.getDisplayLanguage(sessionLocale));
// locObj.put("country", loc.getDisplayCountry(sessionLocale));
// locObj.put("name", loc.getDisplayName(sessionLocale));
// locObj.put("variant", loc.getDisplayVariant(sessionLocale));
//
// installedLocalesArr.put(locObj);
// }
ClientRequestIF clientRequest = loginWithLocales(req, username, password, locales);
JSONArray jaLocales = new JSONArray(ServiceFactory.getRegistryService().getLocales(clientRequest.getSessionId()).toString());
JsonArray roles = JsonParser.parseString(RoleViewDTO.getCurrentRoles(clientRequest)).getAsJsonArray();
JsonArray roleDisplayLabels = JsonParser.parseString(RoleViewDTO.getCurrentRoleDisplayLabels(clientRequest)).getAsJsonArray();
JsonObject cookieValue = new JsonObject();
cookieValue.addProperty("loggedIn", clientRequest.isLoggedIn());
cookieValue.add("roles", roles);
cookieValue.add("roleDisplayLabels", roleDisplayLabels);
cookieValue.addProperty("userName", username);
cookieValue.addProperty("version", ClientConfigurationService.getServerVersion());
CookieResponse response = new CookieResponse("user", -1, cookieValue.toString());
response.set("installedLocales", jaLocales);
return response;
}
Aggregations