use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class ShowConfiguration method fullReload.
@PUT
@RolesAllowed({ "IbisAdmin", "IbisTester" })
@Path("/configurations")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response fullReload(LinkedHashMap<String, Object> json) throws ApiException {
// PUT defaults to no content
Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equalsIgnoreCase("action")) {
if (value.equals("reload")) {
getIbisManager().handleAction(IbisAction.FULLRELOAD, "", "", "", getUserPrincipalName(), true);
}
response.entity("{\"status\":\"ok\"}");
}
}
return response.build();
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class ShowConfiguration method uploadConfiguration.
@POST
@RolesAllowed({ "IbisTester", "IbisAdmin", "IbisDataAdmin" })
@Path("configurations")
@Produces(MediaType.APPLICATION_JSON)
public Response uploadConfiguration(MultipartBody inputDataMap) throws ApiException {
String fileName = null;
if (inputDataMap == null) {
throw new ApiException("Missing post parameters");
}
String datasource = resolveStringFromMap(inputDataMap, "datasource", JndiDataSourceFactory.GLOBAL_DEFAULT_DATASOURCE_NAME);
boolean multipleConfigs = resolveTypeFromMap(inputDataMap, "multiple_configs", boolean.class, false);
boolean activateConfig = resolveTypeFromMap(inputDataMap, "activate_config", boolean.class, true);
boolean automaticReload = resolveTypeFromMap(inputDataMap, "automatic_reload", boolean.class, false);
InputStream file = resolveTypeFromMap(inputDataMap, "file", InputStream.class, null);
String user = resolveTypeFromMap(inputDataMap, "user", String.class, "");
if (StringUtils.isEmpty(user)) {
user = getUserPrincipalName();
}
fileName = inputDataMap.getAttachment("file").getContentDisposition().getParameter("filename");
Map<String, String> result = new LinkedHashMap<String, String>();
try {
if (multipleConfigs) {
try {
result = ConfigurationUtils.processMultiConfigZipFile(getIbisContext(), datasource, activateConfig, automaticReload, file, user);
} catch (IOException e) {
throw new ApiException(e);
}
} else {
String configName = ConfigurationUtils.addConfigToDatabase(getIbisContext(), datasource, activateConfig, automaticReload, fileName, file, user);
if (configName != null) {
result.put(configName, "loaded");
}
}
return Response.status(Response.Status.CREATED).entity(result).build();
} catch (Exception e) {
throw new ApiException("Failed to upload Configuration", e);
}
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class ShowConfiguration method getConfigurationByName.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/{configuration}")
@Produces(MediaType.APPLICATION_XML)
public Response getConfigurationByName(@PathParam("configuration") String configurationName, @QueryParam("loadedConfiguration") boolean loadedConfiguration) throws ApiException {
String result = "";
Configuration configuration = getIbisManager().getConfiguration(configurationName);
if (configuration == null) {
throw new ApiException("Configuration not found!");
}
if (loadedConfiguration) {
result = configuration.getLoadedConfiguration();
} else {
result = configuration.getOriginalConfiguration();
}
return Response.status(Response.Status.OK).entity(result).build();
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class ShowEnvironmentVariables method environmentVariables.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/environmentvariables")
@Produces(MediaType.APPLICATION_JSON)
public Response environmentVariables() throws ApiException {
List<String> propsToHide = new ArrayList<String>();
String propertiesHideString = AppConstants.getInstance().getString("properties.hide", null);
if (propertiesHideString != null) {
propsToHide.addAll(Arrays.asList(propertiesHideString.split("[,\\s]+")));
}
Map<String, Object> envVars = new HashMap<String, Object>();
Map<String, Object> configVars = new HashMap<String, Object>();
configVars.put("All", convertPropertiesToMap(AppConstants.getInstance(), propsToHide));
for (Configuration config : getIbisManager().getConfigurations()) {
if (config.getClassLoader() != null) {
configVars.put(config.getName(), convertPropertiesToMap(AppConstants.getInstance(config.getClassLoader()), propsToHide));
}
}
envVars.put("Application Constants", configVars);
envVars.put("System Properties", convertPropertiesToMap(System.getProperties(), propsToHide));
try {
envVars.put("Environment Variables", convertPropertiesToMap(Misc.getEnvironmentVariables()));
} catch (Throwable t) {
log.warn("caught Throwable while getting EnvironmentVariables", t);
}
return Response.status(Response.Status.CREATED).entity(envVars).build();
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class ShowLiquibaseScript method getConfigurations.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/jdbc/liquibase")
@Produces(MediaType.APPLICATION_JSON)
public Response getConfigurations() throws ApiException {
List<String> configNames = new ArrayList<String>();
for (Configuration config : getIbisManager().getConfigurations()) {
DatabaseMigratorBase databaseMigrator = config.getBean("jdbcMigrator", DatabaseMigratorBase.class);
if (databaseMigrator.hasMigrationScript()) {
configNames.add(config.getName());
}
}
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("configurationsWithLiquibaseScript", configNames);
return Response.status(Response.Status.OK).entity(resultMap).build();
}
Aggregations