Skip to content
Snippets Groups Projects
Commit b339cfe3 authored by Larbi Gharib's avatar Larbi Gharib
Browse files

Configuration turn dht proxy

Change-Id: I31afa4a3fa5d7b68a40178fbd247055bb31fb09d
parent 5f9789e9
No related branches found
No related tags found
No related merge requests found
......@@ -19,104 +19,114 @@
*/
import {
uri,
current_uri,
backend_address,
url_path,
url_port,
api_path_post_install_admin,
api_path_post_auth_login,
api_path_post_install_ca,
api_path_post_install_auth,
api_path_post_install_server,
api_path_get_install_lastKnownStep,
api_path_get_auth_user_search,
api_path_get_auth_devices,
api_path_get_admin_devices,
api_path_delete_admin_user_revoke,
api_path_delete_auth_user_revoke,
api_path_delete_auth_device_revoke,
api_path_rename_device,
api_path_get_server_status,
api_path_get_post_configuration_auth_service,
api_path_get_post_configuration_global_settings,
api_path_post_configuration_change_password,
api_path_post_configuration_register_license,
api_path_get_subscription_status,
api_path_get_directories,
api_path_get_needs_update,
api_path_get_start_update,
api_path_post_create_user,
api_path_get_auth_user,
api_path_post_update_user,
api_path_get_exists_user,
api_path_get_user_directory_search,
api_path_post_create_user_profile,
api_path_put_update_user_profile,
api_path_get_user_search,
} from "globalUrls"
uri,
current_uri,
backend_address,
url_path,
url_port,
api_path_post_install_admin,
api_path_post_auth_login,
api_path_post_install_ca,
api_path_post_install_auth,
api_path_post_install_server,
api_path_get_install_lastKnownStep,
api_path_get_auth_user_search,
api_path_get_auth_devices,
api_path_get_admin_devices,
api_path_delete_admin_user_revoke,
api_path_delete_auth_user_revoke,
api_path_delete_auth_device_revoke,
api_path_rename_device,
api_path_get_server_status,
api_path_get_post_configuration_auth_service,
api_path_get_post_configuration_global_settings,
api_path_post_configuration_change_password,
api_path_post_configuration_register_license,
api_path_get_subscription_status,
api_path_get_directories,
api_path_get_needs_update,
api_path_get_start_update,
api_path_post_create_user,
api_path_get_auth_user,
api_path_post_update_user,
api_path_get_exists_user,
api_path_get_user_directory_search,
api_path_post_create_user_profile,
api_path_put_update_user_profile,
api_path_get_user_search,
api_path_blueprints,
} from "globalUrls";
let isSearch = false;
export default function configApiCall(api_path, request_type, data, credentials) {
// build config call
const config = {
url: url_path + ":" + url_port + api_path,
method: request_type,
crossDomain: true,
dataType: "json",
};
// pass credentials in the header
if (credentials) {
config['headers'] = {
"Authorization": "Basic " + btoa(credentials["username"] + ':' + credentials["password"]),
}
}
if (window.localStorage.getItem('access_token')) {
export default function configApiCall(
api_path,
request_type,
data,
credentials
) {
// build config call
const config = {
url: url_path + ":" + url_port + api_path,
method: request_type,
crossDomain: true,
dataType: "json",
};
const jwt = localStorage.getItem('access_token');
config['headers'] = {
"Authorization": "Bearer " + jwt,
}
}
// pass data in the header
if (data) {
if (api_path == api_path_get_user_directory_search || api_path == api_path_get_auth_user_search ||
(api_path == api_path_post_create_user && request_type == 'POST') || api_path == api_path_post_update_user
|| api_path == api_path_get_auth_devices || api_path == api_path_get_admin_devices || api_path == api_path_post_configuration_change_password)
isSearch = true;
// pass credentials in the header
if (credentials) {
config["headers"] = {
Authorization:
"Basic " +
btoa(credentials["username"] + ":" + credentials["password"]),
};
}
// search dataType
if (isSearch) {
if(request_type == 'GET' || request_type == 'DELETE'){
config['params'] = data
}
else {
config['data'] = data;
}
if (window.localStorage.getItem("access_token")) {
const jwt = localStorage.getItem("access_token");
config["headers"] = {
Authorization: "Bearer " + jwt,
};
}
}
else {
// pass data in the header
if (data) {
if (
api_path == api_path_get_user_directory_search ||
api_path == api_path_get_auth_user_search ||
(api_path == api_path_post_create_user && request_type == "POST") ||
(api_path.includes(api_path_blueprints) && request_type == "POST") ||
api_path == api_path_post_update_user ||
api_path == api_path_get_auth_devices ||
api_path == api_path_get_admin_devices ||
api_path == api_path_post_configuration_change_password
)
isSearch = true;
if (window.localStorage.getItem('access_token')) {
const jwt = localStorage.getItem('access_token');
// search dataType
if (isSearch) {
if (request_type == "GET" || request_type == "DELETE") {
config["params"] = data;
} else {
config["data"] = data;
}
} else {
if (window.localStorage.getItem("access_token")) {
const jwt = localStorage.getItem("access_token");
config['headers'] = {
"Authorization": "Bearer " + jwt,
}
} else {
config['headers'] = {
"Content-type": "application/json"
}
}
config["headers"] = {
Authorization: "Bearer " + jwt,
};
} else {
config["headers"] = {
"Content-type": "application/json",
};
}
config['data'] = JSON.stringify(data);
}
config["data"] = JSON.stringify(data);
}
}
isSearch = false;
return config;
isSearch = false;
return config;
}
This diff is collapsed.
......@@ -72,9 +72,16 @@ public class PolicyServlet extends HttpServlet {
@ScopedServletMethod(securityGroups = {AccessLevel.ADMIN})
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String name = req.getParameter("name");
Scanner s = new Scanner(req.getInputStream()).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
final JSONObject obj = new JSONObject(result);
final String jsonString = obj.toString();
Policy policy = new Policy();
policy.setName(name);
policy.setPolicyData(req.getParameter("policyData"));
policy.setPolicyData(jsonString);
if (dataStore.getPolicyDao().storeObject(policy)) resp.setStatus(200);
else resp.sendError(500, "Could not create a group successfully!");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment