Search in sources :

Example 11 with User

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;
}
Also used : User(com.alibaba.dubbo.registry.common.domain.User)

Example 12 with User

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();
}
Also used : User(com.alibaba.dubbo.registry.common.domain.User)

Example 13 with User

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;
}
Also used : User(com.alibaba.dubbo.registry.common.domain.User)

Example 14 with User

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();
}
Also used : User(com.alibaba.dubbo.registry.common.domain.User) PrintWriter(java.io.PrintWriter)

Example 15 with User

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);
}
Also used : User(com.alibaba.dubbo.registry.common.domain.User)

Aggregations

User (com.alibaba.dubbo.registry.common.domain.User)24 RootContextPath (com.alibaba.dubbo.governance.web.common.pulltool.RootContextPath)4 PrintWriter (java.io.PrintWriter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Map (java.util.Map)2 ServletOutputStream (javax.servlet.ServletOutputStream)2