use of com.ctrip.xpipe.api.sso.UserInfo in project x-pipe by ctripcorp.
the class CtripUserInfoHolder method getUser.
@Override
public UserInfo getUser() {
try {
Assertion assertion = AssertionHolder.getAssertion();
if (assertion != null) {
AttributePrincipal principal = assertion.getPrincipal();
String userId = principal.getName();
UserInfo userInfo = new CtripUserInfo();
userInfo.setUserId(userId);
return userInfo;
}
} catch (Exception e) {
throw new RuntimeException("get user info from assertion holder error", e);
}
return CtripUserInfo.noBody();
}
use of com.ctrip.xpipe.api.sso.UserInfo in project x-pipe by ctripcorp.
the class ConfigController method changeConfig.
private RetMessage changeConfig(final String key, final String val, final String uri) {
UserInfo user = UserInfoHolder.DEFAULT.getUser();
String userId = user.getUserId();
ConfigModel configModel = new ConfigModel();
configModel.setUpdateUser(userId);
configModel.setUpdateIP(uri);
logger.info("[changeConfig] Config changed by user: {} and ip: {}", userId, uri);
try {
boolean target = Boolean.parseBoolean(val);
if (DefaultConsoleDbConfig.KEY_ALERT_SYSTEM_ON.equalsIgnoreCase(key)) {
if (target) {
configService.startAlertSystem(configModel);
} else {
configService.stopAlertSystem(configModel, consoleConfig.getConfigDefaultRestoreHours());
}
} else if (DefaultConsoleDbConfig.KEY_SENTINEL_AUTO_PROCESS.equalsIgnoreCase(key)) {
if (target) {
configService.startSentinelAutoProcess(configModel);
} else {
configService.stopSentinelAutoProcess(configModel, consoleConfig.getConfigDefaultRestoreHours());
}
} else {
return RetMessage.createFailMessage("Unknown config key: " + key);
}
return RetMessage.createSuccessMessage();
} catch (Exception e) {
logger.error("[getExecuteFunction] Exception: {}", e);
return RetMessage.createFailMessage(e.getMessage());
}
}
Aggregations