use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AttributesResource method getAttributeByInum.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.ATTRIBUTES_READ_ACCESS })
@Path(ApiConstants.INUM_PATH)
public Response getAttributeByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
GluuAttribute attribute = attributeService.getAttributeByInum(inum);
checkResourceNotNull(attribute, GLUU_ATTRIBUTE);
return Response.ok(attribute).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AttributesResource method updateAttribute.
@PUT
@ProtectedApi(scopes = { ApiAccessConstants.ATTRIBUTES_WRITE_ACCESS })
public Response updateAttribute(@Valid GluuAttribute attribute) {
log.debug(" GluuAttribute details to update - attribute = " + attribute);
String inum = attribute.getInum();
checkResourceNotNull(inum, GLUU_ATTRIBUTE);
checkNotNull(attribute.getName(), AttributeNames.NAME);
checkNotNull(attribute.getDisplayName(), AttributeNames.DISPLAY_NAME);
checkResourceNotNull(attribute.getDataType(), AttributeNames.DATA_TYPE);
GluuAttribute existingAttribute = attributeService.getAttributeByInum(inum);
checkResourceNotNull(existingAttribute, GLUU_ATTRIBUTE);
attribute.setInum(existingAttribute.getInum());
attribute.setBaseDn(attributeService.getDnForAttribute(inum));
attributeService.updateAttribute(attribute);
GluuAttribute result = attributeService.getAttributeByInum(inum);
return Response.ok(result).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class AttributesResource method createAttribute.
@POST
@ProtectedApi(scopes = { ApiAccessConstants.ATTRIBUTES_WRITE_ACCESS })
public Response createAttribute(@Valid GluuAttribute attribute) {
log.debug(" GluuAttribute details to add - attribute = " + attribute);
checkNotNull(attribute.getName(), AttributeNames.NAME);
checkNotNull(attribute.getDisplayName(), AttributeNames.DISPLAY_NAME);
checkResourceNotNull(attribute.getDataType(), AttributeNames.DATA_TYPE);
String inum = attributeService.generateInumForNewAttribute();
attribute.setInum(inum);
attribute.setDn(attributeService.getDnForAttribute(inum));
attributeService.addAttribute(attribute);
GluuAttribute result = attributeService.getAttributeByInum(inum);
return Response.status(Response.Status.CREATED).entity(result).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ConfigResource method getPersistenceDetails.
@GET
@ProtectedApi(scopes = { ApiAccessConstants.JANS_AUTH_CONFIG_READ_ACCESS })
@Path(ApiConstants.PERSISTENCE)
public Response getPersistenceDetails() {
String persistenceType = configurationService.getPersistenceType();
log.debug("ConfigResource::getPersistenceDetails() - persistenceType - " + persistenceType);
JSONObject jsonObject = new JSONObject();
jsonObject.put("persistenceType", persistenceType);
log.debug("\n\n\n ConfigResource::getPersistenceDetails() - jsonObject = " + jsonObject + "\n\n");
return Response.ok(jsonObject.toString()).build();
}
use of io.jans.configapi.core.rest.ProtectedApi in project jans by JanssenProject.
the class ConfigResource method patchAppConfigurationProperty.
@PATCH
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
@ProtectedApi(scopes = { ApiAccessConstants.JANS_AUTH_CONFIG_WRITE_ACCESS })
public Response patchAppConfigurationProperty(@NotNull String requestString) throws Exception {
log.debug("AUTH CONF details to patch - requestString = " + requestString);
Conf conf = configurationService.findConf();
AppConfiguration appConfiguration = configurationService.find();
log.debug("AUTH CONF details BEFORE patch - appConfiguration = " + appConfiguration);
appConfiguration = Jackson.applyPatch(requestString, conf.getDynamic());
log.debug("AUTH CONF details BEFORE patch merge - appConfiguration = " + appConfiguration);
conf.setDynamic(appConfiguration);
configurationService.merge(conf);
appConfiguration = configurationService.find();
log.debug("AUTH CONF details AFTER patch merge - appConfiguration = " + appConfiguration);
return Response.ok(appConfiguration).build();
}
Aggregations