当前位置: 首页>>代码示例>>Java>>正文


Java Coder.encodeMd5方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.registry.common.util.Coder.encodeMd5方法的典型用法代码示例。如果您正苦于以下问题:Java Coder.encodeMd5方法的具体用法?Java Coder.encodeMd5怎么用?Java Coder.encodeMd5使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.registry.common.util.Coder的用法示例。


在下文中一共展示了Coder.encodeMd5方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loginByBase

import com.alibaba.dubbo.registry.common.util.Coder; //导入方法依赖的package包/类
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;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:AuthorizationValve.java

示例2: loginByDigest

import com.alibaba.dubbo.registry.common.util.Coder; //导入方法依赖的package包/类
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;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:35,代码来源:AuthorizationValve.java

示例3: loginByDigest

import com.alibaba.dubbo.registry.common.util.Coder; //导入方法依赖的package包/类
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;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:35,代码来源:AuthorizationValve.java


注:本文中的com.alibaba.dubbo.registry.common.util.Coder.encodeMd5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。