use of com.alibaba.dubbo.registry.common.domain.User in project incubator-dubbo-ops by apache.
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 incubator-dubbo-ops by apache.
the class Infos method update.
public boolean update(Map<String, Object> context) {
User user = new User();
user.setId(currentUser.getId());
user.setUsername(currentUser.getUsername());
user.setOperatorAddress(operatorAddress);
user.setName((String) context.get("name"));
user.setDepartment((String) context.get("department"));
user.setEmail((String) context.get("email"));
user.setPhone((String) context.get("phone"));
user.setAlitalk((String) context.get("alitalk"));
user.setLocale((String) context.get("locale"));
userDAO.modifyUser(user);
context.put("redirect", "../" + getClass().getSimpleName().toLowerCase());
return true;
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class Menu method execute.
public void execute(HttpSession session, Context context, CookieParser parser) {
User user = (User) session.getAttribute(WebConstants.CURRENT_USER_KEY);
if (user != null)
context.put("operator", user.getUsername());
RootContextPath rootContextPath = new RootContextPath(request.getContextPath());
context.put("rootContextPath", rootContextPath);
if (!context.containsKey("bucLogoutAddress")) {
context.put("bucLogoutAddress", rootContextPath.getURI("logout"));
}
if (!context.containsKey("helpUrl")) {
context.put("helpUrl", "http://code.alibabatech.com/wiki/display/dubbo");
}
context.put(WebConstants.CURRENT_USER_KEY, user);
context.put("language", parser.getString("locale"));
context.put("registryServerSync", registryServerSync);
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class AuthorizationValve method loginByDigest.
private User loginByDigest(String value) throws IOException {
Map<String, String> params = parseParameters(value);
String username = params.get("username");
if (username != null && username.length() > 0) {
String passwordDigest = params.get("response");
if (passwordDigest != null && passwordDigest.length() > 0) {
User user = getUser(username);
if (user != null) {
String pwd = user.getPassword();
// 本地User,密码本地
if (pwd != null && pwd.length() > 0) {
String uri = params.get("uri");
String nonce = params.get("nonce");
String nc = params.get("nc");
String cnonce = params.get("cnonce");
String qop = params.get("qop");
String method = request.getMethod();
String a1 = pwd;
String a2 = "auth-int".equals(qop) ? Coder.encodeMd5(method + ":" + uri + ":" + Coder.encodeMd5(readToBytes(request.getInputStream()))) : Coder.encodeMd5(method + ":" + uri);
String digest = "auth".equals(qop) || "auth-int".equals(qop) ? Coder.encodeMd5(a1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + a2) : Coder.encodeMd5(a1 + ":" + nonce + ":" + a2);
if (digest.equals(passwordDigest)) {
return user;
}
}
}
}
}
return null;
}
use of com.alibaba.dubbo.registry.common.domain.User in project dubbo by alibaba.
the class AuthorizationValve method invoke.
public void invoke(PipelineContext pipelineContext) throws Exception {
if (logger.isInfoEnabled()) {
logger.info("AuthorizationValve of uri: " + request.getRequestURI());
}
String uri = request.getRequestURI();
String contextPath = request.getContextPath();
if (contextPath != null && contextPath.length() > 0 && !"/".equals(contextPath)) {
uri = uri.substring(contextPath.length());
}
if (uri.equals(logout)) {
if (!isLogout()) {
setLogout(true);
showLoginForm();
} else {
setLogout(false);
response.sendRedirect(contextPath == null || contextPath.length() == 0 ? "/" : contextPath);
}
return;
}
//FIXME
if (!uri.startsWith("/status/")) {
User user = null;
String authType = null;
String authorization = request.getHeader("Authorization");
if (authorization != null && authorization.length() > 0) {
int i = authorization.indexOf(' ');
if (i >= 0) {
authType = authorization.substring(0, i);
String authPrincipal = authorization.substring(i + 1);
if (BASIC_CHALLENGE.equalsIgnoreCase(authType)) {
user = loginByBase(authPrincipal);
} else if (DIGEST_CHALLENGE.equalsIgnoreCase(authType)) {
user = loginByDigest(authPrincipal);
}
}
}
if (user == null || user.getUsername() == null || user.getUsername().length() == 0) {
showLoginForm();
pipelineContext.breakPipeline(1);
}
if (user != null && StringUtils.isNotEmpty(user.getUsername())) {
request.getSession().setAttribute(WebConstants.CURRENT_USER_KEY, user);
pipelineContext.invokeNext();
}
} else {
pipelineContext.invokeNext();
}
}
Aggregations