Search in sources :

Example 1 with WriteOperation

use of org.springframework.boot.actuate.endpoint.annotation.WriteOperation in project spring-boot by spring-projects.

the class LoggersEndpoint method configureLogLevel.

@WriteOperation
public void configureLogLevel(@Selector String name, @Nullable LogLevel configuredLevel) {
    Assert.notNull(name, "Name must not be empty");
    LoggerGroup group = this.loggerGroups.get(name);
    if (group != null && group.hasMembers()) {
        group.configureLogLevel(configuredLevel, this.loggingSystem::setLogLevel);
        return;
    }
    this.loggingSystem.setLogLevel(name, configuredLevel);
}
Also used : LoggerGroup(org.springframework.boot.logging.LoggerGroup) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation)

Example 2 with WriteOperation

use of org.springframework.boot.actuate.endpoint.annotation.WriteOperation in project cas by apereo.

the class LoggingConfigurationEndpoint method updateLoggerLevel.

/**
 * Looks up the logger in the logger factory,
 * and attempts to find the real logger instance
 * based on the underlying logging framework
 * and retrieve the logger object. Then, updates the level.
 * This functionality at this point is heavily dependant
 * on the log4j API.
 *
 * @param loggerName  the logger name
 * @param loggerLevel the logger level
 * @param additive    the additive nature of the logger
 */
@WriteOperation
@Operation(summary = "Update logger level for a logger name", parameters = { @Parameter(name = "loggerName", required = true), @Parameter(name = "loggerLevel", required = true), @Parameter(name = "additive") })
public void updateLoggerLevel(@Selector final String loggerName, final String loggerLevel, final boolean additive) {
    val loggerConfigs = getLoggerConfigurations();
    loggerConfigs.stream().filter(cfg -> cfg.getName().equals(loggerName)).forEachOrdered(cfg -> {
        cfg.setLevel(Level.getLevel(loggerLevel));
        cfg.setAdditive(additive);
    });
    this.loggerContext.updateLoggers();
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) Getter(lombok.Getter) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) SneakyThrows(lombok.SneakyThrows) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerFactory(org.slf4j.LoggerFactory) ToStringStyle(org.apache.commons.lang3.builder.ToStringStyle) Level(org.apache.logging.log4j.Level) HashMap(java.util.HashMap) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) StringUtils(org.apache.commons.lang3.StringUtils) InitializingBean(org.springframework.beans.factory.InitializingBean) HashSet(java.util.HashSet) Operation(io.swagger.v3.oas.annotations.Operation) Pair(org.apache.commons.lang3.tuple.Pair) Configurator(org.apache.logging.log4j.core.config.Configurator) Map(java.util.Map) Log4jLoggerFactory(org.apache.logging.slf4j.Log4jLoggerFactory) Resource(org.springframework.core.io.Resource) ResourceUtils(org.apereo.cas.util.ResourceUtils) Logger(org.slf4j.Logger) ResourceLoader(org.springframework.core.io.ResourceLoader) Endpoint(org.springframework.boot.actuate.endpoint.annotation.Endpoint) lombok.val(lombok.val) Set(java.util.Set) BaseCasActuatorEndpoint(org.apereo.cas.web.BaseCasActuatorEndpoint) Parameter(io.swagger.v3.oas.annotations.Parameter) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) Slf4j(lombok.extern.slf4j.Slf4j) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) Environment(org.springframework.core.env.Environment) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Optional(java.util.Optional) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) ILoggerFactory(org.slf4j.ILoggerFactory) Selector(org.springframework.boot.actuate.endpoint.annotation.Selector) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Example 3 with WriteOperation

use of org.springframework.boot.actuate.endpoint.annotation.WriteOperation in project cas by apereo.

the class CasReleaseAttributesReportEndpoint method releaseAttributes.

/**
 * Method that accepts a JSON body through a POST method to receive user credentials and only returns a
 * map of attributes released for the authenticated user.
 *
 * @param username - the username
 * @param password - the password
 * @param service  - the service id
 * @return - the map
 */
@WriteOperation
@Operation(summary = "Get collection of released attributes for the user and application", parameters = { @Parameter(name = "username", required = true), @Parameter(name = "password", required = true), @Parameter(name = "service", required = true) })
public Map<String, Object> releaseAttributes(final String username, final String password, final String service) {
    val map = releasePrincipalAttributes(username, password, service);
    val assertion = (ImmutableAssertion) map.get("assertion");
    return Map.of("uid", username, "attributes", assertion.getPrimaryAuthentication().getPrincipal().getAttributes());
}
Also used : lombok.val(lombok.val) ImmutableAssertion(org.apereo.cas.validation.ImmutableAssertion) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

WriteOperation (org.springframework.boot.actuate.endpoint.annotation.WriteOperation)3 Operation (io.swagger.v3.oas.annotations.Operation)2 lombok.val (lombok.val)2 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)2 Parameter (io.swagger.v3.oas.annotations.Parameter)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Getter (lombok.Getter)1 SneakyThrows (lombok.SneakyThrows)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)1 ToStringStyle (org.apache.commons.lang3.builder.ToStringStyle)1 Pair (org.apache.commons.lang3.tuple.Pair)1 Level (org.apache.logging.log4j.Level)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1 FileAppender (org.apache.logging.log4j.core.appender.FileAppender)1