use of com.alibaba.otter.shared.common.model.user.User in project otter by alibaba.
the class UserServiceImpl method doToModel.
private User doToModel(UserDO userDo) {
User user = new User();
user.setId(userDo.getId());
user.setName(userDo.getName());
user.setDepartment(userDo.getDepartment());
user.setRealName(userDo.getRealName());
user.setAuthorizeType(userDo.getAuthorizeType());
user.setGmtCreate(userDo.getGmtCreate());
user.setGmtModified(userDo.getGmtModified());
return user;
}
use of com.alibaba.otter.shared.common.model.user.User in project otter by alibaba.
the class AuthContextValve method invoke.
public void invoke(PipelineContext pipelineContext) throws Exception {
TurbineRunData rundata = getTurbineRunData(request);
// TODO 走 api 的验证
if (isAPI(rundata)) {
if (apiAuthService.auth(rundata)) {
pipelineContext.invokeNext();
} else {
// TODO 需要转跳到 json 格式的 link
redirect(pipelineContext, rundata, forbiddenLink);
}
return;
}
// 得到请求URL相对路径(不包含域名/端口信息)
String requestUrl = rundata.getRequest().getRequestURI();
List<AuthorizeType> result = urlAnalyze.check(requestUrl);
String action = StringUtil.toCamelCase(trimToNull(rundata.getParameters().getString(actionParam)));
String eventName = getEventName();
// 首先判断是否登录
User user = (User) rundata.getRequest().getSession().getAttribute(WebConstant.USER_SESSION_KEY);
if (StringUtils.isNotEmpty(action)) {
result.addAll(urlAnalyze.check(action, eventName));
}
if (result.isEmpty()) {
// 访问的连接不符合权限匹配规则,跳转到登录页面
redirect(pipelineContext, rundata, forbiddenLink);
} else {
if (null == user) {
// 2.如果集合中只包含匿名权限,则通过。
if (result.contains(AuthorizeType.OPERATOR) || result.contains(AuthorizeType.ADMIN)) {
redirect(pipelineContext, rundata, loginLink);
} else {
pipelineContext.invokeNext();
}
} else {
// 2.如果权限集合有高于用户权限,则跳转到登录页面。
if (compareAuth(user.getAuthorizeType(), result)) {
pipelineContext.invokeNext();
} else {
redirect(pipelineContext, rundata, forbiddenLink);
}
}
}
}
use of com.alibaba.otter.shared.common.model.user.User in project otter by alibaba.
the class UserManager method execute.
public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
@SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
if ("支持ID、用户名、真实姓名、部门搜索".equals(searchKey)) {
searchKey = "";
}
condition.put("searchKey", searchKey);
int count = userService.getCount(condition);
Paginator paginator = new Paginator();
paginator.setItems(count);
paginator.setPage(pageIndex);
condition.put("offset", paginator.getOffset());
condition.put("length", paginator.getLength());
List<User> users = userService.listByCondition(condition);
context.put("users", users);
context.put("paginator", paginator);
context.put("searchKey", searchKey);
}
use of com.alibaba.otter.shared.common.model.user.User in project otter by alibaba.
the class UserAction method doAdd.
public void doAdd(@FormGroup("addUserInfo") Group userInfo, Navigator nav, @FormField(name = "formUserError", group = "addUserInfo") CustomErrors err) {
User user = new User();
userInfo.setProperties(user);
user.setPassword(SecurityUtils.getPassword(user.getPassword()));
try {
userService.createUser(user);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidUser");
return;
}
nav.redirectTo(WebConstant.USER_MANAGER_LINK);
}
use of com.alibaba.otter.shared.common.model.user.User in project otter by alibaba.
the class UserAction method doEdit.
public void doEdit(@FormGroup("editUserInfo") Group userInfo, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Navigator nav, @FormField(name = "formUserError", group = "editUserInfo") CustomErrors err) {
User user = new User();
userInfo.setProperties(user);
if (null != user.getPassword()) {
if (user.getPassword().length() < 6) {
err.setMessage("passwordTooLess");
return;
}
user.setPassword(SecurityUtils.getPassword(user.getPassword()));
}
try {
userService.updataUser(user);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidUser");
return;
}
nav.redirectToLocation("userManager.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
}
Aggregations