Java Code Examples for cn.hutool.crypto.SecureUtil#sha1()
The following examples show how to use
cn.hutool.crypto.SecureUtil#sha1() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenApiInterceptor.java From Jpom with MIT License | 6 votes |
private boolean checkOpenApi(HttpServletRequest request, HttpServletResponse response) { String header = request.getHeader(ServerOpenApi.HEAD); if (StrUtil.isEmpty(header)) { ServletUtil.write(response, JsonMessage.getString(300, "token empty"), MediaType.APPLICATION_JSON_UTF8_VALUE); return false; } String authorizeToken = ServerExtConfigBean.getInstance().getAuthorizeToken(); if (StrUtil.isEmpty(authorizeToken)) { ServletUtil.write(response, JsonMessage.getString(300, "not config token"), MediaType.APPLICATION_JSON_UTF8_VALUE); return false; } String md5 = SecureUtil.md5(authorizeToken); md5 = SecureUtil.sha1(md5 + ServerOpenApi.HEAD); if (!StrUtil.equals(header, md5)) { ServletUtil.write(response, JsonMessage.getString(300, "not config token"), MediaType.APPLICATION_JSON_UTF8_VALUE); return false; } return true; }
Example 2
Source File: AgentExtConfigBean.java From Jpom with MIT License | 5 votes |
/** * 创建请求对象 * * @param openApi url * @return HttpRequest * @see ServerOpenApi */ public HttpRequest createServerRequest(String openApi) { if (StrUtil.isEmpty(getServerUrl())) { throw new JpomRuntimeException("请先配置server端url"); } if (StrUtil.isEmpty(getServerToken())) { throw new JpomRuntimeException("请先配置server端Token"); } // 加密 String md5 = SecureUtil.md5(getServerToken()); md5 = SecureUtil.sha1(md5 + ServerOpenApi.HEAD); HttpRequest httpRequest = HttpUtil.createPost(String.format("%s%s", serverUrl, openApi)); httpRequest.header(ServerOpenApi.HEAD, md5); return httpRequest; }
Example 3
Source File: AgentAuthorize.java From Jpom with MIT License | 5 votes |
/** * 单例 * * @return this */ public static AgentAuthorize getInstance() { if (agentAuthorize == null) { agentAuthorize = SpringUtil.getBean(AgentAuthorize.class); // 登录名不能为空 if (StrUtil.isEmpty(agentAuthorize.agentName)) { throw new JpomRuntimeException("agent 端登录名不能为空"); } agentAuthorize.checkPwd(); // 生成密码授权字符串 agentAuthorize.authorize = SecureUtil.sha1(agentAuthorize.agentName + "@" + agentAuthorize.agentPwd); } return agentAuthorize; }
Example 4
Source File: NodeModel.java From Jpom with MIT License | 4 votes |
public String getAuthorize(boolean get) { if (authorize == null) { authorize = SecureUtil.sha1(loginName + "@" + loginPwd); } return authorize; }