1 | /* |
---|
2 | * Copyright (C) 2013 DASISH |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU General Public License |
---|
6 | * as published by the Free Software Foundation; either version 2 |
---|
7 | * of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this program; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
17 | */ |
---|
18 | package eu.dasish.annotation.backend.rest; |
---|
19 | |
---|
20 | import java.util.HashMap; |
---|
21 | import java.util.Map; |
---|
22 | import org.junit.Test; |
---|
23 | import org.junit.runner.RunWith; |
---|
24 | import org.springframework.test.context.ContextConfiguration; |
---|
25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
---|
26 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
---|
27 | /** |
---|
28 | * |
---|
29 | * @author olhsha |
---|
30 | */ |
---|
31 | @RunWith(value = SpringJUnit4ClassRunner.class) |
---|
32 | @ContextConfiguration({"/spring-test-config/dataSource.xml"}) |
---|
33 | public class BCryptTestUserPasswordEncoder { |
---|
34 | |
---|
35 | final Map<String, String> userPassword= new HashMap<String, String>(); |
---|
36 | private Map<String, String> passwordHash= new HashMap<String, String>(); |
---|
37 | private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
---|
38 | |
---|
39 | |
---|
40 | public BCryptTestUserPasswordEncoder(){ |
---|
41 | userPassword.put("olha", "olha"+"password"); |
---|
42 | userPassword.put("stephanie", "stephanie"+"password"); |
---|
43 | userPassword.put("olof", "olof"+"password"); |
---|
44 | userPassword.put("twan", "twan"+"password"); |
---|
45 | userPassword.put("peter", "peter"+"password"); |
---|
46 | userPassword.put("przemek", "przemek"+"password"); |
---|
47 | userPassword.put("daan", "daan"+"password"); |
---|
48 | userPassword.put("menzo", "menzo"+"password"); |
---|
49 | userPassword.put("eric", "eric"+"password"); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | @Test |
---|
54 | public void generateHashes(){ |
---|
55 | System.out.println("Passwords -- hashes:"); |
---|
56 | for (String user:userPassword.keySet()){ |
---|
57 | String hash = passwordEncoder.encode(userPassword.get(user)); |
---|
58 | System.out.println(userPassword.get(user)+" -- "+hash); |
---|
59 | passwordHash.put(userPassword.get(user), hash); |
---|
60 | } |
---|
61 | } |
---|
62 | } |
---|