Package com.loja.security

Examples of com.loja.security.Authenticator


  public void setSenha(String senha) {
    this.senha = senha;
  }
 
  public void senhaToMd5() {
    setSenha(new Authenticator().toHash(this.senha));
  }
View Full Code Here


    grupoUsuario.setAtivo(true);
    grupoUsuario.setNome("Administrativo");
    grupoUsuario.setRole("ADMINISTRATIVO");
    em.persist(grupoUsuario);
   
    Authenticator authenticator = new Authenticator();
    Usuario usuario = new Usuario();
    usuario.setEmail("r.oliveira@gmail.com");
    usuario.setHierarquia_id(1);
    usuario.setGruposUsuarios(grupoUsuario);
    usuario.setNome("Teste");
    usuario.setSenha(authenticator.toHash("123456"));
    em.persist(usuario);
    Assert.assertNotNull(usuario.getId());
  }
View Full Code Here

    Assert.assertNotNull(usuario.getId());
  }
 
  @Test
  public void userAuthenticate() {
    Authenticator authenticator = new Authenticator();
    credentials.setUsername("r.oliveira@gmail.com");
    credentials.setPassword("123456");
    authenticator.setEntityManager(em);
    authenticator.setCredentials(credentials);
    authenticator.setIdentity(identity);
    boolean retorno = false;
    try {
      retorno = authenticator.authenticate();
    } catch (Exception e) {
      System.out.println("pau");
    }
    Assert.assertTrue(retorno);
  }
View Full Code Here

    Assert.assertTrue(retorno);
  }
 
  @Test
  public void authenticateError() {
    Authenticator authenticator = new Authenticator();
    credentials.setUsername("rodrigo.dealer@gmail.com");
    credentials.setPassword("123457");
    authenticator.setEntityManager(em);
    authenticator.setCredentials(credentials);
    authenticator.setIdentity(identity);
    try {
      authenticator.authenticate();
    } catch (Exception e) {
      Assert.assertEquals(e.getMessage(), "Usuario ou senha invalidos");
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void hashTest() {
    Authenticator authenticator = new Authenticator();
    Assert.assertEquals(authenticator.toHash("123"), "202cb962ac59075b964b07152d234b70");
  }
View Full Code Here

TOP

Related Classes of com.loja.security.Authenticator

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.