本文整理汇总了Java中com.alibaba.cobar.manager.util.EncryptUtil类的典型用法代码示例。如果您正苦于以下问题:Java EncryptUtil类的具体用法?Java EncryptUtil怎么用?Java EncryptUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EncryptUtil类属于com.alibaba.cobar.manager.util包,在下文中一共展示了EncryptUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequestInternal
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
long userId = 0;
try {
userId = Long.parseLong(request.getParameter("userId").trim());
} catch (Exception e) {
throw new IllegalArgumentException("parameter 'userId' is invalid:" + request.getParameter("cobarId"));
}
UserDO editUser = xmlAccesser.getUserDAO().getUserById(userId);
UserDO u = new UserDO();
u.setId(editUser.getId());
u.setPassword(EncryptUtil.decrypt(editUser.getPassword()));
u.setRealname(editUser.getRealname());
u.setStatus(editUser.getStatus());
u.setUser_role(editUser.getUser_role());
u.setUsername(editUser.getUsername());
return new ModelAndView("m_editUser", new FluenceHashMap<String, Object>().putKeyValue("editUser", u));
}
示例2: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
BindException errors) throws Exception {
PasswordForm form = (PasswordForm) command;
UserDO user = (UserDO) request.getSession().getAttribute("user");
user.setPassword(EncryptUtil.encrypt(form.getNewPassword()));
boolean flag = xmlAccesser.getUserDAO().modifyUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "密码修改成功");
} else {
return new ModelAndView("failure", "reason", "写文件失败,请联系管理员");
}
}
示例3: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
BindException errors) throws Exception {
UserForm form = (UserForm) command;
UserDO user = new UserDO();
user.setId(form.getUserId());
user.setPassword(EncryptUtil.encrypt(form.getPassword().trim()));
user.setRealname(form.getRealname().trim());
user.setUser_role(form.getUser_role().trim());
user.setUsername(form.getUsername().trim());
user.setStatus(form.getStatus().trim());
boolean flag = xmlAccesser.getUserDAO().modifyUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "用户信息修改成功");
} else {
String reason = form.getUsername() + "已经存在";
return new ModelAndView("failure", "reason", reason);
}
}
示例4: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
BindException errors) throws Exception {
UserForm form = (UserForm) command;
UserDO user = new UserDO();
user.setPassword(EncryptUtil.encrypt(form.getPassword().trim()));
user.setUser_role(form.getUser_role().trim());
user.setRealname(form.getRealname().trim());
user.setStatus(form.getStatus().trim());
user.setUsername(form.getUsername().trim());
boolean flag = xmlAccesser.getUserDAO().addUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "用户信息添加成功");
} else {
String reason = form.getUsername() + "已经存在";
return new ModelAndView("failure", "reason", reason);
}
}
示例5: validateUser
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public UserDO validateUser(String username, String password) {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Long, UserDO> entry = (Entry<Long, UserDO>) it.next();
UserDO user = entry.getValue();
if (username.equals(user.getUsername()) && EncryptUtil.encrypt(password).equals(user.getPassword())) {
// encrypt check success
return user;
} else if (username.equals(user.getUsername()) && password.equals(user.getPassword())) {
// no encrypt check success,then change pwd to encrypted
user.setPassword(EncryptUtil.encrypt(password));
modifyUser(user);
return user;
}
}
return null;
}
示例6: write
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
private boolean write(CobarDO cobar) {
try {
writePrefix(false);
xsl.startTag(null, "cobar");
xsl.text("\n");
writeProperty("id", String.valueOf(cobar.getId()));
writeProperty("clusterId", String.valueOf(cobar.getClusterId()));
writeProperty("name", cobar.getName());
writeProperty("status", cobar.getStatus());
writeProperty("host", cobar.getHost());
writeProperty("serverPort", String.valueOf(cobar.getServerPort()));
writeProperty("port", String.valueOf(cobar.getPort()));
writeProperty("user", cobar.getUser());
String password = EncryptUtil.encrypt(cobar.getPassword());
writeProperty("password", password);
writeProperty("time_diff", cobar.getTime_diff());
writePrefix(true);
xsl.endTag(null, "cobar");
xsl.text("\n");
return true;
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return false;
}
示例7: handleRequestInternal
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
throws Exception {
long userId = 0;
try {
userId = Long.parseLong(request.getParameter("userId").trim());
} catch (Exception e) {
throw new IllegalArgumentException("parameter 'userId' is invalid:" + request.getParameter("cobarId"));
}
UserDO editUser = xmlAccesser.getUserDAO().getUserById(userId);
UserDO u = new UserDO();
u.setId(editUser.getId());
u.setPassword(EncryptUtil.decrypt(editUser.getPassword()));
u.setRealname(editUser.getRealname());
u.setStatus(editUser.getStatus());
u.setUser_role(editUser.getUser_role());
u.setUsername(editUser.getUsername());
return new ModelAndView("m_editUser", new FluenceHashMap<String, Object>().putKeyValue("editUser", u));
}
示例8: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors) throws Exception {
PasswordForm form = (PasswordForm) command;
UserDO user = (UserDO) request.getSession().getAttribute("user");
user.setPassword(EncryptUtil.encrypt(form.getNewPassword()));
boolean flag = xmlAccesser.getUserDAO().modifyUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "success");
} else {
return new ModelAndView("failure", "reason", "fail");
}
}
示例9: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors) throws Exception {
UserForm form = (UserForm) command;
UserDO user = new UserDO();
user.setId(form.getUserId());
user.setPassword(EncryptUtil.encrypt(form.getPassword().trim()));
user.setRealname(form.getRealname().trim());
user.setUser_role(form.getUser_role().trim());
user.setUsername(form.getUsername().trim());
user.setStatus(form.getStatus().trim());
boolean flag = xmlAccesser.getUserDAO().modifyUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "success");
} else {
String reason = form.getUsername() + " exist";
return new ModelAndView("failure", "reason", reason);
}
}
示例10: onSubmit
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors) throws Exception {
UserForm form = (UserForm) command;
UserDO user = new UserDO();
user.setPassword(EncryptUtil.encrypt(form.getPassword().trim()));
user.setUser_role(form.getUser_role().trim());
user.setRealname(form.getRealname().trim());
user.setStatus(form.getStatus().trim());
user.setUsername(form.getUsername().trim());
boolean flag = xmlAccesser.getUserDAO().addUser(user);
if (flag) {
return new ModelAndView("m_success", "info", "add success");
} else {
String reason = form.getUsername() + " exist";
return new ModelAndView("failure", "reason", reason);
}
}
示例11: validateUser
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public UserDO validateUser(String username, String password) {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Long, UserDO> entry = (Entry<Long, UserDO>) it.next();
UserDO user = entry.getValue();
if (username.equals(user.getUsername()) && EncryptUtil.encrypt(password).equals(user.getPassword())) {
//encrypt check success
return user;
} else if (username.equals(user.getUsername()) && password.equals(user.getPassword())) {
//no encrypt check success,then change pwd to encrypted
user.setPassword(EncryptUtil.encrypt(password));
modifyUser(user);
return user;
}
}
return null;
}
示例12: testEncrypt
import com.alibaba.cobar.manager.util.EncryptUtil; //导入依赖的package包/类
@Test
public void testEncrypt() {
String src = "test";
String encrySrc = EncryptUtil.encrypt(src);
Assert.assertEquals(encrySrc, EncryptUtil.encrypt(src));
Assert.assertEquals(src, EncryptUtil.decrypt(encrySrc));
}