use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class LoggingConfigurationEndpoint method configuration.
/**
* Configuration map.
*
* @return the map
*/
@ReadOperation
@Operation(summary = "Get logging configuration report")
public Map<String, Object> configuration() {
val configuredLoggers = new HashSet<>();
getLoggerConfigurations().forEach(config -> {
val loggerMap = new HashMap<String, Object>();
loggerMap.put("name", StringUtils.defaultIfBlank(config.getName(), LOGGER_NAME_ROOT));
loggerMap.put("state", config.getState());
if (config.getPropertyList() != null) {
loggerMap.put("properties", config.getPropertyList());
}
loggerMap.put("additive", config.isAdditive());
loggerMap.put("level", config.getLevel().name());
val appenders = new HashSet<>();
config.getAppenders().keySet().stream().map(key -> config.getAppenders().get(key)).forEach(appender -> {
val builder = new ToStringBuilder(this, ToStringStyle.JSON_STYLE);
builder.append("name", appender.getName());
builder.append("state", appender.getState());
builder.append("layoutFormat", appender.getLayout().getContentFormat());
builder.append("layoutContentType", appender.getLayout().getContentType());
if (appender instanceof FileAppender) {
builder.append(FILE_PARAM, ((FileAppender) appender).getFileName());
builder.append(FILE_PATTERN_PARAM, "(none)");
}
if (appender instanceof RandomAccessFileAppender) {
builder.append(FILE_PARAM, ((RandomAccessFileAppender) appender).getFileName());
builder.append(FILE_PATTERN_PARAM, "(none)");
}
if (appender instanceof RollingFileAppender) {
builder.append(FILE_PARAM, ((RollingFileAppender) appender).getFileName());
builder.append(FILE_PATTERN_PARAM, ((RollingFileAppender) appender).getFilePattern());
}
if (appender instanceof MemoryMappedFileAppender) {
builder.append(FILE_PARAM, ((MemoryMappedFileAppender) appender).getFileName());
builder.append(FILE_PATTERN_PARAM, "(none)");
}
if (appender instanceof RollingRandomAccessFileAppender) {
builder.append(FILE_PARAM, ((RollingRandomAccessFileAppender) appender).getFileName());
builder.append(FILE_PATTERN_PARAM, ((RollingRandomAccessFileAppender) appender).getFilePattern());
}
appenders.add(builder.build());
});
loggerMap.put("appenders", appenders);
configuredLoggers.add(loggerMap);
});
val responseMap = new HashMap<String, Object>();
responseMap.put("loggers", configuredLoggers);
val loggers = getActiveLoggersInFactory();
responseMap.put("activeLoggers", loggers.values());
return responseMap;
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class AttributeConsentReportEndpoint method importAccount.
/**
* Import account.
*
* @param request the request
* @return the http status
* @throws Exception the exception
*/
@PostMapping(path = "/import", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Import a consent decision as a JSON document")
public HttpStatus importAccount(final HttpServletRequest request) throws Exception {
val requestBody = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
LOGGER.trace("Submitted account: [{}]", requestBody);
val decision = MAPPER.readValue(requestBody, new TypeReference<ConsentDecision>() {
});
LOGGER.trace("Storing account: [{}]", decision);
consentRepository.getObject().storeConsentDecision(decision);
return HttpStatus.CREATED;
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class AttributeConsentReportEndpoint method export.
/**
* Export.
*
* @return the response entity
*/
@GetMapping(path = "/export", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
@Operation(summary = "Export consent decisions as a zip file")
public ResponseEntity<Resource> export() {
val accounts = consentRepository.getObject().findConsentDecisions();
val resource = CompressionUtils.toZipFile(accounts.stream(), Unchecked.function(entry -> {
val acct = (ConsentDecision) entry;
val fileName = String.format("%s-%s", acct.getPrincipal(), acct.getId());
val sourceFile = File.createTempFile(fileName, ".json");
MAPPER.writeValue(sourceFile, acct);
return sourceFile;
}), "attrconsent");
val headers = new HttpHeaders();
headers.setContentDisposition(ContentDisposition.attachment().filename(Objects.requireNonNull(resource.getFilename())).build());
return new ResponseEntity<>(resource, headers, HttpStatus.OK);
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class AttributeConsentReportEndpoint method consentDecisions.
/**
* Consent decisions collection.
*
* @param principal the principal
* @return the collection
*/
@GetMapping(path = "{principal}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get consent decisions for principal", parameters = { @Parameter(name = "principal", required = true) })
public Collection<Map<String, Object>> consentDecisions(@PathVariable final String principal) {
val result = new HashSet<Map<String, Object>>();
LOGGER.debug("Fetching consent decisions for principal [{}]", principal);
val consentDecisions = this.consentRepository.getObject().findConsentDecisions(principal);
LOGGER.debug("Resolved consent decisions for principal [{}]: [{}]", principal, consentDecisions);
consentDecisions.forEach(d -> {
val map = new HashMap<String, Object>();
map.put("decision", d);
map.put("attributes", this.consentEngine.getObject().resolveConsentableAttributesFrom(d));
result.add(map);
});
return result;
}
use of io.swagger.v3.oas.models.Operation in project cas by apereo.
the class SingleSignOnSessionsEndpoint method destroySsoSession.
/**
* Endpoint for destroying a single SSO Session.
*
* @param ticketGrantingTicket the ticket granting ticket
* @param request the request
* @param response the response
* @return result map
*/
@DeleteMapping(path = "/{ticketGrantingTicket}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Remove single sign-on session for ticket id")
public Map<String, Object> destroySsoSession(@PathVariable final String ticketGrantingTicket, final HttpServletRequest request, final HttpServletResponse response) {
val sessionsMap = new HashMap<String, Object>(1);
try {
val sloRequests = singleLogoutRequestExecutor.getObject().execute(ticketGrantingTicket, request, response);
sessionsMap.put(STATUS, HttpServletResponse.SC_OK);
sessionsMap.put(TICKET_GRANTING_TICKET, ticketGrantingTicket);
sessionsMap.put("singleLogoutRequests", sloRequests);
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
sessionsMap.put(STATUS, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
sessionsMap.put(TICKET_GRANTING_TICKET, ticketGrantingTicket);
sessionsMap.put("message", e.getMessage());
}
return sessionsMap;
}
Aggregations