Example usage for org.apache.shiro.crypto.hash Md5Hash Md5Hash

List of usage examples for org.apache.shiro.crypto.hash Md5Hash Md5Hash

Introduction

In this page you can find the example usage for org.apache.shiro.crypto.hash Md5Hash Md5Hash.

Prototype

public Md5Hash(Object source) 

Source Link

Usage

From source file:ApacheShiro.ShiroMVC.java

    a(String password) {
    String encodedPassword = new Md5Hash(password).toBase64();
    return encodedPassword;
}

From source file:cn.com.xl.core.shiro.DefaultShiroFactory.java

License:Apache License

public SimpleAuthenticationInfo info(ShiroUser shiroUser, User user, String realmName) {
    String credentials = user.getPassword();
    // ??/*  ww  w .  j  a  v  a  2  s  . co  m*/
    String source = user.getSalt();
    ByteSource credentialsSalt = new Md5Hash(source);
    return new SimpleAuthenticationInfo(shiroUser, credentials, credentialsSalt, realmName);
}

From source file:cn.com.xl.core.shiro.ShiroKit.java

License:Apache License

/**
 * shiro?/*from w  ww .  ja  va 2 s .co  m*/
 * 
 * @param ?
 * @param ??
 * @return
 */
public static String md5(String credentials, String saltSource) {
    ByteSource salt = new Md5Hash(saltSource);
    return new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations).toString();
}

From source file:cn.itganhuo.app.common.utils.StringUtil.java

License:Apache License

/**
 * MD5//from  w  ww.ja  v a 2  s .co  m
 * <ol>
 * <li>shiro??</li>
 * </ol>
 * 
 * @version 0.0.1-SNAPSHOT
 * @author -?
 * @param str
 * @return
 */
public static final String getMD5Shiro(String str) {
    if (!StringUtil.hasText(str))
        return "";
    return new Md5Hash(str).toHex();
}

From source file:com.baguaz.module.user.BgzSessionIDGenerator.java

License:Apache License

@Override
public Serializable generateId(Session session) {
    return new Md5Hash(UUID.randomUUID().toString()).toString();
}

From source file:com.biu.core.shiro.DefaultShiroFactory.java

License:Apache License

public SimpleAuthenticationInfo info(ShiroUser shiroUser, User user, String realmName) {
    String credentials = user.getPassword();
    // ???//from  ww  w. jav  a2 s. c  om
    String source = user.getSalt();
    ByteSource credentialsSalt = new Md5Hash(source);
    return new SimpleAuthenticationInfo(shiroUser, credentials, credentialsSalt, realmName);
}

From source file:com.cuisongliu.springboot.shiro.support.password.PasswordHelper.java

License:Open Source License

/**
 * shiro?// ww w .  j  ava  2s .c o m
 *
 * @param credentials ?
 * @param saltSource ??
 * @return
 */
public String md5(String credentials, String saltSource) {
    ByteSource salt = new Md5Hash(saltSource);
    return new SimpleHash(Md5Hash.ALGORITHM_NAME, credentials, salt, springShiroProperties.getMd5Iterations())
            .toString();
}

From source file:com.cuisongliu.springboot.shiro.support.password.PasswordHelper.java

License:Open Source License

/**
 * shiro ?/*  www .  j  a va 2 s  .  c  om*/
 * @param userInfo shiro
 * @param realm  realm
 * @return
 */
public SimpleAuthenticationInfo authInfo(UserInfo userInfo, ShiroAbstractRealm realm) {
    ByteSource credentialsSalt = new Md5Hash(userInfo.getUsername() + userInfo.getSalt());
    //AuthenticatingRealmCredentialsMatcher????
    SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(userInfo.getUsername(), //??
            userInfo.getPassword(), //?
            credentialsSalt, //salt=username+salt
            realm.getName() //realm name
    );
    return authenticationInfo;
}

From source file:com.github.dactiv.fear.service.service.account.AccountService.java

License:Apache License

/**
 * /*from  w w w.j  a v  a 2 s  .c o m*/
 *
 * @param entity    Map
 * @param groupIds ? ID ?
 */
private void insertUser(Map<String, Object> entity, List<Integer> groupIds) {

    if (!isUsernameUnique(entity.get("username").toString())) {
        throw new ServiceException("[" + entity.get("username") + "]");
    }

    Md5Hash md5Hash = new Md5Hash(entity.get("password"));
    entity.put("password", md5Hash.toHex());

    userDao.insert(entity);

    if (CollectionUtils.isNotEmpty(groupIds)) {
        Integer id = Casts.cast(entity.get("id"), Integer.class);
        userDao.insertGroupAssociation(id, groupIds);
    }
}

From source file:com.github.dactiv.fear.service.service.account.AccountService.java

License:Apache License

/**
 * ?//from ww w . j  av a 2 s  . com
 *
 * @param entity       Map
 * @param oldPassword ??
 * @param newPassword ?
 */
public void updateUserPassword(Map<String, Object> entity, String oldPassword, String newPassword) {

    Md5Hash md5Hash = new Md5Hash(oldPassword);

    if (!md5Hash.toHex().equals(entity.get("password"))) {
        throw new ServiceException("???");
    }

    if (StringUtils.isEmpty(newPassword)) {
        throw new ServiceException("??");
    }

    Integer id = Casts.cast(entity.get("id"), Integer.class);
    updateUserPassword(id, newPassword);
}