Package com.cloud.server.auth

Examples of com.cloud.server.auth.SHA256SaltedUserAuthenticator


  public void setUp() throws Exception {
  }

  @Test
  public void testEncode() throws UnsupportedEncodingException, NoSuchAlgorithmException {
    SHA256SaltedUserAuthenticator authenticator =
        new SHA256SaltedUserAuthenticator();

    try {
      authenticator.configure("SHA256", Collections.<String,Object>emptyMap());
    } catch (ConfigurationException e) {
      fail(e.toString());
    }
   
    String encodedPassword = authenticator.encode("password");
       
    String storedPassword[] = encodedPassword.split(":");
        assertEquals ("hash must consist of two components", storedPassword.length, 2);

        byte salt[] = Base64.decode(storedPassword[0]);
        String hashedPassword = authenticator.encode("password", salt);
       
        assertEquals("compare hashes", storedPassword[1], hashedPassword);

  }
View Full Code Here

TOP

Related Classes of com.cloud.server.auth.SHA256SaltedUserAuthenticator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.