use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class AuthorizationValve method loginByBase.
private User loginByBase(String authorization) {
authorization = Coder.decodeBase64(authorization);
int i = authorization.indexOf(':');
String username = authorization.substring(0, i);
if (username != null && username.length() > 0) {
String password = authorization.substring(i + 1);
if (password != null && password.length() > 0) {
String passwordDigest = Coder.encodeMd5(username + ":" + REALM + ":" + password);
User user = getUser(username);
if (user != null) {
String pwd = user.getPassword();
if (pwd != null && pwd.length() > 0) {
if (passwordDigest.equals(pwd)) {
return user;
}
}
}
}
}
return null;
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class ServicePrivilegeCheckValve method invoke.
public void invoke(PipelineContext pipelineContext) throws Exception {
User user = (User) request.getSession().getAttribute(WebConstants.CURRENT_USER_KEY);
invokeCheckServicePrivilege(user);
pipelineContext.invokeNext();
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class UserServiceImpl method findUser.
public User findUser(String username) {
if ("guest".equals(username)) {
User user = new User();
user.setUsername(username);
user.setPassword(Coder.encodeMd5(username + ":" + User.REALM + ":" + guestPassword));
user.setName(username);
user.setRole(User.GUEST);
user.setEnabled(true);
user.setLocale("zh");
user.setServicePrivilege("");
return user;
} else if ("root".equals(username)) {
User user = new User();
user.setUsername(username);
user.setPassword(Coder.encodeMd5(username + ":" + User.REALM + ":" + rootPassword));
user.setName(username);
user.setRole(User.ROOT);
user.setEnabled(true);
user.setLocale("zh");
user.setServicePrivilege("*");
return user;
}
return null;
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class Shell method execute.
public void execute(Map<String, Object> context) throws Exception {
if (context.get(WebConstants.CURRENT_USER_KEY) != null) {
User user = (User) context.get(WebConstants.CURRENT_USER_KEY);
currentUser = user;
operator = user.getUsername();
role = user.getRole();
context.put(WebConstants.CURRENT_USER_KEY, user);
}
operatorAddress = (String) context.get("request.remoteHost");
context.put("operator", operator);
context.put("operatorAddress", operatorAddress);
try {
String message = doExecute(context);
context.put("message", "OK: " + filterERROR(message));
} catch (Throwable t) {
context.put("message", "ERROR: " + filterOK(t.getMessage()));
}
PrintWriter writer = response.getWriter();
writer.print(context.get("message"));
writer.flush();
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class Infos method index.
public void index(Map<String, Object> context) {
User user = userDAO.findById(currentUser.getId());
context.put("user", user);
}
Aggregations