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

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

Introduction

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

Prototype

String ALGORITHM_NAME

To view the source code for org.apache.shiro.crypto.hash Md5Hash ALGORITHM_NAME.

Click Source Link

Usage

From source file:com.cuisongliu.springboot.shiro.autoconfig.ShiroAutoConfig.java

License:Open Source License

@Bean
CredentialsMatcher credentialsMatcher() {
    HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher();
    md5CredentialsMatcher.setHashAlgorithmName(Md5Hash.ALGORITHM_NAME);
    md5CredentialsMatcher.setHashIterations(springShiroProperties.getMd5Iterations());
    return md5CredentialsMatcher;
}

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

License:Open Source License

/**
 * shiro?/*from   w  ww  . j a v a2  s  . 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.metropolitan.methotels727.services.UserRealm.java

public UserRealm(Session session) {
    super(new MemoryConstrainedCacheManager());
    setName("localaccounts");
    this.session = session;
    setAuthenticationTokenClass(UsernamePasswordToken.class);
    setCredentialsMatcher(new HashedCredentialsMatcher(Md5Hash.ALGORITHM_NAME));
}

From source file:com.milospaunovic.sedam.services.UserRealm.java

public UserRealm(Session session) {
    super(new MemoryConstrainedCacheManager());
    this.session = session;
    setName("localaccounts");
    // setName("localaccounts");
    this.session = session;
    setAuthenticationTokenClass(UsernamePasswordToken.class);
    setCredentialsMatcher(new HashedCredentialsMatcher(Md5Hash.ALGORITHM_NAME));
}

From source file:oculus.aperture.test.SimpleShiroAuthModule.java

License:MIT License

@SuppressWarnings("unchecked")
@Override//from  w  w w  . j av  a2s. com
protected void configureShiroWeb() {
    // Use IniRealm - a simple Realm implementation that allows us to define
    // users, passwords, and roles in an INI file
    // Must bind an Ini.class implementation
    try {
        bindRealm().toConstructor(IniRealm.class.getConstructor(Ini.class));
    } catch (NoSuchMethodException e) {
        throw new RuntimeException("Missing IniRealm class implementation", e);
    }

    // Use the following three lines to instruct Shiro to expect passwords stored
    // in the INI file to be encrypted using MD5
    // Comment out to use plaintext passwords in the INI file
    bind(CredentialsMatcher.class).to(HashedCredentialsMatcher.class);
    bind(HashedCredentialsMatcher.class);
    bindConstant().annotatedWith(Names.named(HASH_ALGORITHM_NAME))
            .to(config.getString(HASH_ALGORITHM_NAME, Md5Hash.ALGORITHM_NAME));

    // Configure filters in the order they should be applied
    // Make the /** filter last so that it doesn't catch everything and never to get /logout

    // Configure auto logout when accessing /logout
    // Logout when the user hits this url
    addFilterChain("/logout", LOGOUT);
    // Logout Filter: redirect to login.jsp after logout
    bindConstant().annotatedWith(Names.named("shiro.redirectUrl"))
            .to(config.getString(REDIRECT_URL, "/login.jsp"));

    // Configure all URLs to be protected by AuthC filter
    // You may replace filter chain definition with more complex authentication
    // filters and roles

    // All URLs are protected: require Form-based login
    addFilterChain("/**", AUTHC);
    // Login at login.jsp
    bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to(config.getString(LOGIN_URL, "/login.jsp"));
    // If not logging in via redirect, go to /example.html after successful login
    bindConstant().annotatedWith(Names.named("shiro.successUrl"))
            .to(config.getString(SUCCESS_URL, "/example.html"));

}

From source file:org.qi4j.library.shiro.crypto.HashFactory.java

License:Open Source License

public static Hash create(String algorithmName, Object source, Object salt, int hashIterations) {
    if (algorithmName == null || algorithmName.length() <= 0) {
        throw new IllegalArgumentException("Algorithm name was null or empty");
    }/* w  w  w .ja v a  2 s  .c o m*/
    if (!Arrays.asList(VALID_ALGORITHM_NAMES).contains(algorithmName)) {
        throw new IllegalArgumentException(algorithmName + " is not a valid algorithm. Valid ones are : "
                + Arrays.toString(VALID_ALGORITHM_NAMES));
    }
    if (Md2Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Md2Hash(source, salt, hashIterations);
    }
    if (Md5Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Md5Hash(source, salt, hashIterations);
    }
    if (Sha1Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Sha1Hash(source, salt, hashIterations);
    }
    if (Sha256Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Sha256Hash(source, salt, hashIterations);
    }
    if (Sha384Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Sha384Hash(source, salt, hashIterations);
    }
    if (Sha512Hash.ALGORITHM_NAME.equals(algorithmName)) {
        return new Sha512Hash(source, salt, hashIterations);
    }
    throw new InternalError("You shall not pass!");
}