├── .gitignore ├── JavaSwingPasswordManager ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── lib │ └── sqlite-jdbc-3.23.1.jar ├── resources │ └── pwd_manager.db ├── screenshots │ ├── Page Admin - pass manager.png │ ├── Page connexion - pass manager.png │ └── Page d'inscription - pass manager.png └── src │ ├── Main.java │ ├── TestAccount.java │ ├── TestUser.java │ ├── bean │ ├── AccountBean.java │ ├── AccountItemView.java │ ├── ReturnCallDbFunctionBean.java │ └── UserBean.java │ ├── dao │ ├── AccountDaoImpl.java │ └── UserDaoImpl.java │ ├── database │ └── DbConnexion.java │ ├── service │ ├── AESEncryption.java │ └── PasswordHash.java │ ├── ui │ ├── AdminUI.java │ ├── AdminUI_OLD.java │ ├── AuthenticationUI.java │ ├── InscriptionUI.java │ ├── images │ │ ├── cancel.png │ │ ├── dashboard.png │ │ ├── delete_icon.png │ │ ├── edit_icon.png │ │ ├── editing.png │ │ ├── eye.png │ │ ├── eye_invisible.png │ │ ├── eye_invisible_white.png │ │ ├── eye_white.png │ │ ├── facebook.png │ │ ├── github_logo.png │ │ ├── lock_pass.png │ │ ├── logout.png │ │ ├── passgenerator.png │ │ ├── pm_logo.png │ │ ├── pm_logo64.png │ │ ├── twitter.png │ │ ├── user.png │ │ └── warning.png │ └── test │ │ ├── UIEnd.java │ │ ├── UITest2.java │ │ └── UiTestScroll.java │ └── utils │ ├── Constants.java │ ├── Guide des tailles des composants Item │ └── Utils.java └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaSwingPasswordManager 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/lib/sqlite-jdbc-3.23.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/lib/sqlite-jdbc-3.23.1.jar -------------------------------------------------------------------------------- /JavaSwingPasswordManager/resources/pwd_manager.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/resources/pwd_manager.db -------------------------------------------------------------------------------- /JavaSwingPasswordManager/screenshots/Page Admin - pass manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/screenshots/Page Admin - pass manager.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/screenshots/Page connexion - pass manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/screenshots/Page connexion - pass manager.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/screenshots/Page d'inscription - pass manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/screenshots/Page d'inscription - pass manager.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.sql.SQLException; 2 | import java.sql.Statement; 3 | import java.util.logging.Level; 4 | 5 | import bean.ReturnCallDbFunctionBean; 6 | import bean.UserBean; 7 | import dao.UserDaoImpl; 8 | import database.DbConnexion; 9 | import service.AESEncryption; 10 | import service.PasswordHash; 11 | import utils.Constants; 12 | import utils.Utils; 13 | 14 | public class Main { 15 | 16 | public static void main(String[] args) { 17 | 18 | Utils.getLogger(Level.INFO, "Encryption en cours..."); 19 | Statement stmt = null; 20 | 21 | ReturnCallDbFunctionBean callDbFunctionBean = new ReturnCallDbFunctionBean(); 22 | 23 | String originalString = "Bonjour soumaila Abdoulaye DIARRA "; 24 | String encryptedString = AESEncryption.encrypt(originalString) ; 25 | String decryptedString = AESEncryption.decrypt(encryptedString) ; 26 | 27 | Utils.getLogger(Level.INFO, "Fin de l'encryption"); 28 | 29 | UserBean userBean = new UserBean("Djeneba Seck", "djene.seck@gmail.com", "Bonjour01"); 30 | 31 | UserDaoImpl daoImpl = new UserDaoImpl(); 32 | //UserBean userBean = null; 33 | /* 34 | try { 35 | userBean = daoImpl.retrieveUser("enoc.coulibaly@gmail.com"); 36 | } catch (SQLException e) { 37 | // TODO Auto-generated catch block 38 | e.printStackTrace(); 39 | } 40 | */ 41 | 42 | try { 43 | userBean = daoImpl.insertUser(userBean); 44 | //userBean = daoImpl.retrieveUser("enoc.coulibaly@gmail.com"); 45 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 46 | System.out.println(userBean.getCallDbFunctionBean().getMessageRetour()); 47 | }else { 48 | System.out.println(userBean.getCallDbFunctionBean().getMessageRetour()); 49 | } 50 | 51 | } catch (SQLException e) { 52 | // TODO Auto-generated catch block 53 | e.printStackTrace(); 54 | } catch (Exception e) { 55 | // TODO Auto-generated catch block 56 | e.printStackTrace(); 57 | } 58 | 59 | System.out.println("L'utilisateur est " + userBean.toString()); 60 | 61 | /* 62 | * Test PasswordHash 63 | */ 64 | String mdp = "Soumaila"; 65 | try { 66 | String mdpHash = PasswordHash.getSaltedHash(mdp); 67 | System.out.println("Mdp "+ mdp +" hash " + mdpHash); 68 | System.out.println(PasswordHash.checkPassword(mdp, mdpHash)); 69 | } catch (Exception e) { 70 | // TODO Auto-generated catch block 71 | e.printStackTrace(); 72 | } 73 | 74 | 75 | System.out.println(originalString); 76 | System.out.println(encryptedString); 77 | System.out.println(decryptedString); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/TestAccount.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.List; 3 | 4 | import bean.AccountBean; 5 | import bean.UserBean; 6 | import dao.AccountDaoImpl; 7 | import utils.Constants; 8 | 9 | public class TestAccount { 10 | public static void main(String[] args) { 11 | 12 | /* 13 | * Ajout d'un compte lier à un utilisateur 14 | */ 15 | 16 | /* 17 | 18 | UserBean userBean = new UserBean(); 19 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 20 | userBean.setIdentifiantUser("c858cfb2-e53b-43cf-bc81-66cb85b8fdd0"); 21 | AccountBean accountBean = new AccountBean("Oumar Sanogo", "oumar.s@gmail.com", "12345678", "https://www.youtube.com/", userBean); 22 | try { 23 | accountBean = accountDaoImpl.insertAccount(accountBean); 24 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 25 | System.out.println("Username du compte ajouter " + accountBean.getUsernameAccount()); 26 | System.out.println("Identifiant utilisateur " + accountBean.getUserBean().getIdentifiantUser()); 27 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 28 | }else { 29 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 30 | } 31 | 32 | } catch (Exception e) { 33 | // TODO Auto-generated catch block 34 | e.printStackTrace(); 35 | } 36 | 37 | */ 38 | 39 | 40 | /* 41 | * Affichage d'un compte via son id. 42 | */ 43 | 44 | /* 45 | 46 | UserBean userBean = new UserBean(); 47 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 48 | AccountBean accountBean = new AccountBean(); 49 | try { 50 | accountBean = accountDaoImpl.retrieveAccountById("e63d8d83-f57e-4f3b-88bf-d444e9c23c8d"); 51 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 52 | System.out.println(accountBean.toString()); 53 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 54 | }else { 55 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 56 | } 57 | 58 | } catch (Exception e) { 59 | // TODO Auto-generated catch block 60 | e.printStackTrace(); 61 | } 62 | 63 | */ 64 | 65 | 66 | /* 67 | * Affichage de tous les comptes. 68 | */ 69 | 70 | /* 71 | 72 | UserBean userBean = new UserBean(); 73 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 74 | List accounts = new ArrayList(); 75 | try { 76 | accounts = accountDaoImpl.retrieveAllAccounts(); 77 | for (AccountBean accountBean : accounts) { 78 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 79 | System.out.println(accountBean.toString()); 80 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 81 | }else { 82 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 83 | } 84 | } 85 | 86 | } catch (Exception e) { 87 | // TODO Auto-generated catch block 88 | e.printStackTrace(); 89 | } 90 | 91 | */ 92 | 93 | /* 94 | * Affichage de tous les comptes. 95 | */ 96 | 97 | 98 | 99 | UserBean userBean = new UserBean(); 100 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 101 | List accounts = new ArrayList(); 102 | try { 103 | //USER soman 9964a398-cec1-431c-b390-b0a73d488840 104 | accounts = accountDaoImpl.retrieveAllAccountsByUserId("c858cfb2-e53b-43cf-bc81-66cb85b8fdd0"); 105 | for (AccountBean accountBean : accounts) { 106 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 107 | System.out.println(accountBean.toString()); 108 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 109 | }else { 110 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 111 | } 112 | } 113 | 114 | } catch (Exception e) { 115 | // TODO Auto-generated catch block 116 | e.printStackTrace(); 117 | } 118 | 119 | 120 | 121 | 122 | /* 123 | * Suppression d'un compte via son id. 124 | */ 125 | 126 | /* 127 | 128 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 129 | AccountBean accountBean = new AccountBean(); 130 | try { 131 | accountBean = accountDaoImpl.deleteAccountById("74bd8c65-ca07-46c7-9689-727e9402ed95"); 132 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 133 | System.out.println(accountBean.getIdentifiantAccount()); 134 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 135 | }else { 136 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 137 | } 138 | 139 | } catch (Exception e) { 140 | // TODO Auto-generated catch block 141 | e.printStackTrace(); 142 | } 143 | 144 | */ 145 | 146 | 147 | /* 148 | * Mise à jour d'un compte lier à un utilisateur 149 | */ 150 | 151 | /* 152 | 153 | UserBean userBean = new UserBean(); 154 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 155 | userBean.setIdentifiantUser("c858cfb2-e53b-43cf-bc81-66cb85b8fdd0"); 156 | AccountBean accountBean = new AccountBean("895a61c1-0f6c-495e-8bee-2d92cbfee28c","Assetou DIARRA KADI", "setou.s@gmail.com", "12345678", "https://www.youtube.com/", userBean); 157 | try { 158 | accountBean = accountDaoImpl.updateAccount(accountBean); 159 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 160 | System.out.println("Identifiant utilisateur " + accountBean.getUserBean().getIdentifiantUser()); 161 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 162 | }else { 163 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 164 | } 165 | 166 | } catch (Exception e) { 167 | // TODO Auto-generated catch block 168 | e.printStackTrace(); 169 | } 170 | 171 | */ 172 | 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/TestUser.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.Collections; 3 | import java.util.List; 4 | 5 | import bean.UserBean; 6 | import dao.UserDaoImpl; 7 | import utils.Constants; 8 | import utils.Utils; 9 | 10 | public class TestUser { 11 | 12 | public static void main(String[] args) { 13 | 14 | 15 | System.out.println(Utils.generatePassword()); 16 | System.out.println(Utils.generatePassword()); 17 | System.out.println(Utils.generatePassword()); 18 | 19 | /* 20 | * Insertion d'un user 21 | */ 22 | 23 | 24 | /* 25 | try { 26 | 27 | UserDaoImpl daoImpl = new UserDaoImpl(); 28 | UserBean userBean = new UserBean("Saran soman", "saran.d@gmail.com", "12345678"); 29 | userBean = daoImpl.insertUser(userBean); 30 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 31 | System.out.println("Email du user ajouté " + userBean.getEmailUser()); 32 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 33 | System.out.println(userBean.toString()); 34 | } else { 35 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 36 | } 37 | 38 | } catch (Exception e) { 39 | // TODO Auto-generated catch block 40 | e.printStackTrace(); 41 | } 42 | 43 | */ 44 | 45 | 46 | /* 47 | * Affichage d'un user via son Id ou son email 48 | */ 49 | 50 | /* 51 | 52 | try { 53 | 54 | UserDaoImpl daoImpl = new UserDaoImpl(); 55 | UserBean userBean = new UserBean(); 56 | //userBean = daoImpl.retrieveUserByEmail("alioune.d@gmail.com"); 57 | userBean = daoImpl.retrieveUserById("c858cfb2-e53b-43cf-bc81-66cb85b8fdd0"); 58 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 59 | System.out.println(userBean.toString()); 60 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 61 | }else { 62 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 63 | } 64 | 65 | } catch (Exception e) { 66 | // TODO Auto-generated catch block 67 | e.printStackTrace(); 68 | } 69 | 70 | */ 71 | 72 | 73 | /* 74 | * Authentification d'un user via son email et son mot de passe 75 | */ 76 | 77 | /* 78 | 79 | try { 80 | 81 | UserDaoImpl daoImpl = new UserDaoImpl(); 82 | UserBean userBean = new UserBean(); 83 | userBean = daoImpl.authenticationUser("dadju@gmail.com", "Bonjour01"); 84 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 85 | System.out.println(userBean.toString()); 86 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 87 | }else { 88 | System.out.println("Message de retour " + userBean.getCallDbFunctionBean().getMessageRetour()); 89 | } 90 | 91 | } catch (Exception e) { 92 | // TODO Auto-generated catch block 93 | e.printStackTrace(); 94 | } 95 | 96 | */ 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/bean/AccountBean.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import java.sql.Date; 4 | 5 | public class AccountBean { 6 | String identifiantAccount; 7 | String nameAccount; 8 | String usernameAccount; 9 | String passwordAccount; 10 | String urlAccount; 11 | String createDateAccount; 12 | String lastUpdateDateAccount; 13 | UserBean userBean; 14 | ReturnCallDbFunctionBean callDbFunctionBean; 15 | 16 | public AccountBean(String identifiantAccount, String nameAccount, String usernameAccount, String passwordAccount, 17 | String urlAccount, String createDateAccount, String lastUpdateDateAccount, UserBean userBean, 18 | ReturnCallDbFunctionBean callDbFunctionBean) { 19 | super(); 20 | this.identifiantAccount = identifiantAccount; 21 | this.nameAccount = nameAccount; 22 | this.usernameAccount = usernameAccount; 23 | this.passwordAccount = passwordAccount; 24 | this.urlAccount = urlAccount; 25 | this.createDateAccount = createDateAccount; 26 | this.lastUpdateDateAccount = lastUpdateDateAccount; 27 | this.userBean = userBean; 28 | this.callDbFunctionBean = callDbFunctionBean; 29 | } 30 | 31 | public AccountBean(String nameAccount, String usernameAccount, String passwordAccount, 32 | String urlAccount, UserBean userBean) { 33 | super(); 34 | this.nameAccount = nameAccount; 35 | this.usernameAccount = usernameAccount; 36 | this.passwordAccount = passwordAccount; 37 | this.urlAccount = urlAccount; 38 | this.userBean = userBean; 39 | } 40 | 41 | public AccountBean(String identifiantAccount, String nameAccount, String usernameAccount, String passwordAccount, 42 | String urlAccount, UserBean userBean) { 43 | super(); 44 | this.identifiantAccount = identifiantAccount; 45 | this.nameAccount = nameAccount; 46 | this.usernameAccount = usernameAccount; 47 | this.passwordAccount = passwordAccount; 48 | this.urlAccount = urlAccount; 49 | this.userBean = userBean; 50 | } 51 | 52 | public AccountBean(UserBean userBean) { 53 | super(); 54 | this.userBean = userBean; 55 | } 56 | 57 | public AccountBean() { 58 | 59 | } 60 | 61 | public String getIdentifiantAccount() { 62 | return identifiantAccount; 63 | } 64 | 65 | public void setIdentifiantAccount(String identifiantAccount) { 66 | this.identifiantAccount = identifiantAccount; 67 | } 68 | 69 | public String getNameAccount() { 70 | return nameAccount; 71 | } 72 | 73 | public void setNameAccount(String nameAccount) { 74 | this.nameAccount = nameAccount; 75 | } 76 | 77 | public String getUsernameAccount() { 78 | return usernameAccount; 79 | } 80 | 81 | public void setUsernameAccount(String usernameAccount) { 82 | this.usernameAccount = usernameAccount; 83 | } 84 | 85 | public String getPasswordAccount() { 86 | return passwordAccount; 87 | } 88 | 89 | public void setPasswordAccount(String passwordAccount) { 90 | this.passwordAccount = passwordAccount; 91 | } 92 | 93 | public String getUrlAccount() { 94 | return urlAccount; 95 | } 96 | 97 | public void setUrlAccount(String urlAccount) { 98 | this.urlAccount = urlAccount; 99 | } 100 | 101 | public String getCreateDateAccount() { 102 | return createDateAccount; 103 | } 104 | 105 | public void setCreateDateAccount(String createDateAccount) { 106 | this.createDateAccount = createDateAccount; 107 | } 108 | 109 | public String getLastUpdateDateAccount() { 110 | return lastUpdateDateAccount; 111 | } 112 | 113 | public void setLastUpdateDateAccount(String lastUpdateDateAccount) { 114 | this.lastUpdateDateAccount = lastUpdateDateAccount; 115 | } 116 | 117 | public UserBean getUserBean() { 118 | return userBean; 119 | } 120 | 121 | public void setUserBean(UserBean userBean) { 122 | this.userBean = userBean; 123 | } 124 | 125 | public ReturnCallDbFunctionBean getCallDbFunctionBean() { 126 | return callDbFunctionBean; 127 | } 128 | 129 | public void setCallDbFunctionBean(ReturnCallDbFunctionBean callDbFunctionBean) { 130 | this.callDbFunctionBean = callDbFunctionBean; 131 | } 132 | 133 | @Override 134 | public String toString() { 135 | return "AccountBean [identifiantAccount=" + identifiantAccount + ", nameAccount=" + nameAccount 136 | + ", usernameAccount=" + usernameAccount + ", passwordAccount=" + passwordAccount + ", urlAccount=" 137 | + urlAccount + ", createDateAccount=" + createDateAccount + ", lastUpdateDateAccount=" 138 | + lastUpdateDateAccount + ", getUserBean()=" + getUserBean().getIdentifiantUser() + ", getCallDbFunctionBean()=" 139 | + getCallDbFunctionBean().toString() + "]"; 140 | } 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | } 152 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/bean/AccountItemView.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class AccountItemView { 4 | 5 | String identifiantAccountItem; 6 | String usernameAccountItem; 7 | String nomCompletAccountItem; 8 | String passwordAccountItem; 9 | String etatPasswordAccountItem; 10 | String urlAccountItem; 11 | String etatUrlAccountItem; 12 | 13 | public AccountItemView(String identifiantAccountItem, String usernameAccountItem, String nomCompletAccountItem, 14 | String passwordAccountItem, String etatPasswordAccountItem, String urlAccountItem, 15 | String etatUrlAccountItem) { 16 | super(); 17 | this.identifiantAccountItem = identifiantAccountItem; 18 | this.usernameAccountItem = usernameAccountItem; 19 | this.nomCompletAccountItem = nomCompletAccountItem; 20 | this.passwordAccountItem = passwordAccountItem; 21 | this.etatPasswordAccountItem = etatPasswordAccountItem; 22 | this.urlAccountItem = urlAccountItem; 23 | this.etatUrlAccountItem = etatUrlAccountItem; 24 | } 25 | 26 | public String getIdentifiantAccountItem() { 27 | return identifiantAccountItem; 28 | } 29 | 30 | public void setIdentifiantAccountItem(String identifiantAccountItem) { 31 | this.identifiantAccountItem = identifiantAccountItem; 32 | } 33 | 34 | public String getUsernameAccountItem() { 35 | return usernameAccountItem; 36 | } 37 | 38 | public void setUsernameAccountItem(String usernameAccountItem) { 39 | this.usernameAccountItem = usernameAccountItem; 40 | } 41 | 42 | public String getNomCompletAccountItem() { 43 | return nomCompletAccountItem; 44 | } 45 | 46 | public void setNomCompletAccountItem(String nomCompletAccountItem) { 47 | this.nomCompletAccountItem = nomCompletAccountItem; 48 | } 49 | 50 | public String getPasswordAccountItem() { 51 | return passwordAccountItem; 52 | } 53 | 54 | public void setPasswordAccountItem(String passwordAccountItem) { 55 | this.passwordAccountItem = passwordAccountItem; 56 | } 57 | 58 | public String getEtatPasswordAccountItem() { 59 | return etatPasswordAccountItem; 60 | } 61 | 62 | public void setEtatPasswordAccountItem(String etatPasswordAccountItem) { 63 | this.etatPasswordAccountItem = etatPasswordAccountItem; 64 | } 65 | 66 | public String getUrlAccountItem() { 67 | return urlAccountItem; 68 | } 69 | 70 | public void setUrlAccountItem(String urlAccountItem) { 71 | this.urlAccountItem = urlAccountItem; 72 | } 73 | 74 | public String getEtatUrlAccountItem() { 75 | return etatUrlAccountItem; 76 | } 77 | 78 | public void setEtatUrlAccountItem(String etatUrlAccountItem) { 79 | this.etatUrlAccountItem = etatUrlAccountItem; 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return "AccountItemView [identifiantAccountItem=" + identifiantAccountItem + ", usernameAccountItem=" 85 | + usernameAccountItem + ", nomCompletAccountItem=" + nomCompletAccountItem + ", passwordAccountItem=" 86 | + passwordAccountItem + ", etatPasswordAccountItem=" + etatPasswordAccountItem + ", urlAccountItem=" 87 | + urlAccountItem + ", etatUrlAccountItem=" + etatUrlAccountItem + "]"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/bean/ReturnCallDbFunctionBean.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | public class ReturnCallDbFunctionBean { 4 | private int codeRetour; 5 | private boolean errorRetour; 6 | private String messageRetour; 7 | 8 | public int getCodeRetour() { 9 | return codeRetour; 10 | } 11 | public void setCodeRetour(int codeRetour) { 12 | this.codeRetour = codeRetour; 13 | } 14 | public boolean isErrorRetour() { 15 | return errorRetour; 16 | } 17 | public void setErrorRetour(boolean errorRetour) { 18 | this.errorRetour = errorRetour; 19 | } 20 | public String getMessageRetour() { 21 | return messageRetour; 22 | } 23 | public void setMessageRetour(String messageRetour) { 24 | this.messageRetour = messageRetour; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "ReturnCallDbFunctionBean [codeRetour=" + codeRetour + ", errorRetour=" + errorRetour 30 | + ", messageRetour=" + messageRetour + "]"; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/bean/UserBean.java: -------------------------------------------------------------------------------- 1 | package bean; 2 | 3 | import java.sql.Date; 4 | 5 | public class UserBean { 6 | 7 | String identifiantUser; 8 | String nameUser; 9 | String emailUser; 10 | String passwordUser; 11 | String createDateUser; 12 | String lastUpdateDateUser; 13 | ReturnCallDbFunctionBean callDbFunctionBean; 14 | 15 | public UserBean(String identifiantUser, String nameUser, String emailUser, String passwordUser, String createDateUser, 16 | String lastUpdateDateUser, ReturnCallDbFunctionBean callDbFunctionBean) { 17 | super(); 18 | this.identifiantUser = identifiantUser; 19 | this.nameUser = nameUser; 20 | this.emailUser = emailUser; 21 | this.passwordUser = passwordUser; 22 | this.createDateUser = createDateUser; 23 | this.lastUpdateDateUser = lastUpdateDateUser; 24 | this.callDbFunctionBean = callDbFunctionBean; 25 | } 26 | 27 | public UserBean(String nameUser, String emailUser, String passwordUser, ReturnCallDbFunctionBean callDbFunctionBean) { 28 | super(); 29 | this.nameUser = nameUser; 30 | this.emailUser = emailUser; 31 | this.passwordUser = passwordUser; 32 | this.callDbFunctionBean = callDbFunctionBean; 33 | } 34 | 35 | public UserBean(String nameUser, String emailUser, String passwordUser) { 36 | super(); 37 | this.nameUser = nameUser; 38 | this.emailUser = emailUser; 39 | this.passwordUser = passwordUser; 40 | } 41 | 42 | public UserBean() { 43 | 44 | } 45 | 46 | public String getIdentifiantUser() { 47 | return identifiantUser; 48 | } 49 | 50 | public void setIdentifiantUser(String identifiantUser) { 51 | this.identifiantUser = identifiantUser; 52 | } 53 | 54 | public String getNameUser() { 55 | return nameUser; 56 | } 57 | 58 | public void setNameUser(String nameUser) { 59 | this.nameUser = nameUser; 60 | } 61 | 62 | public String getEmailUser() { 63 | return emailUser; 64 | } 65 | 66 | public void setEmailUser(String emailUser) { 67 | this.emailUser = emailUser; 68 | } 69 | 70 | public String getPasswordUser() { 71 | return passwordUser; 72 | } 73 | 74 | public void setPasswordUser(String passwordUser) { 75 | this.passwordUser = passwordUser; 76 | } 77 | 78 | public String getCreateDateUser() { 79 | return createDateUser; 80 | } 81 | 82 | public void setCreateDateUser(String createDateUser) { 83 | this.createDateUser = createDateUser; 84 | } 85 | 86 | public String getLastUpdateDateUser() { 87 | return lastUpdateDateUser; 88 | } 89 | 90 | public void setLastUpdateDateUser(String lastUpdateDateUser) { 91 | this.lastUpdateDateUser = lastUpdateDateUser; 92 | } 93 | 94 | public ReturnCallDbFunctionBean getCallDbFunctionBean() { 95 | return callDbFunctionBean; 96 | } 97 | 98 | public void setCallDbFunctionBean(ReturnCallDbFunctionBean callDbFunctionBean) { 99 | this.callDbFunctionBean = callDbFunctionBean; 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return "UserBean [identifiantUser=" + identifiantUser + ", nameUser=" + nameUser + ", emailUser=" + emailUser 105 | + ", createDateUser=" + createDateUser + ", lastUpdateDateUser=" 106 | + lastUpdateDateUser + ", getCallDbFunctionBean()=" + getCallDbFunctionBean().toString() + "]"; 107 | } 108 | 109 | /* 110 | @Override 111 | public String toString() { 112 | return "UserBean [identifiantUser=" + identifiantUser + ", nameUser=" + nameUser + ", emailUser=" + emailUser 113 | + ", passwordUser=" + passwordUser + ", createDateUser=" + createDateUser + ", lastUpdateDateUser=" 114 | + lastUpdateDateUser + ", callDbFunctionBean=" + callDbFunctionBean + 115 | "[" + "callDbFunctionBean.codeRetour" + callDbFunctionBean.getCodeRetour() + 116 | "callDbFunctionBean.errorRetour" + callDbFunctionBean.isErrorRetour() + 117 | "callDbFunctionBean.messageRetour" + callDbFunctionBean.getMessageRetour() + 118 | "]"; 119 | } 120 | */ 121 | 122 | 123 | 124 | 125 | 126 | 127 | } 128 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/dao/AccountDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import bean.AccountBean; 11 | import bean.ReturnCallDbFunctionBean; 12 | import bean.UserBean; 13 | import database.DbConnexion; 14 | import service.AESEncryption; 15 | import service.PasswordHash; 16 | import utils.Constants; 17 | import utils.Utils; 18 | 19 | public class AccountDaoImpl { 20 | public static final String INSERT_ACCOUNT_SQL_QUERY = "INSERT INTO PM_ACCOUNT (A_ID,A_NAME,A_USERNAME,A_PASSWORD,A_URL,PM_USER_U_ID) VALUES(?,?,?,?,?,?)"; 21 | public static final String SELECT_ACCOUNT_SQL_QUERY_ID = "SELECT * FROM PM_ACCOUNT WHERE A_ID=?"; 22 | public static final String SELECT_ACCOUNTS_SQL_QUERY = "SELECT * FROM PM_ACCOUNT"; 23 | public static final String SELECT_ACCOUNTS_SQL_QUERY_BY_USER_ID = "SELECT * FROM PM_ACCOUNT WHERE PM_USER_U_ID = ?"; 24 | public static final String DELETE_ACCOUNT_SQL_QUERY_ID = "DELETE FROM PM_ACCOUNT WHERE A_ID=?"; 25 | public static final String UPDATE_ACCOUNT_SQL_QUERY_ID = "UPDATE PM_ACCOUNT SET A_NAME=?, A_USERNAME=?, A_PASSWORD=?, A_URL=?,A_LAST_UPDATE=CURRENT_TIMESTAMP WHERE A_ID=?"; 26 | 27 | static ReturnCallDbFunctionBean callDbFunctionBean = new ReturnCallDbFunctionBean(); 28 | static UserBean userBean = new UserBean(); 29 | 30 | public static AccountBean insertAccount(AccountBean accountBean) throws Exception { 31 | 32 | Connection con = null; 33 | PreparedStatement ps = null; 34 | AccountBean account = new AccountBean(); 35 | try { 36 | con = DbConnexion.getConnection(); 37 | if (con == null) { 38 | Utils.errorDbConnection(); 39 | return account; 40 | } 41 | 42 | if (UserDaoImpl.testIfUserIdExistInDb(accountBean.getUserBean().getIdentifiantUser()) == true) { 43 | ps = con.prepareStatement(INSERT_ACCOUNT_SQL_QUERY); 44 | ps.setString(1, Utils.generateUUID()); 45 | ps.setString(2, accountBean.getNameAccount()); 46 | ps.setString(3, accountBean.getUsernameAccount()); 47 | ps.setString(4, AESEncryption.encrypt(accountBean.getPasswordAccount())); 48 | ps.setString(5, accountBean.getUrlAccount()); 49 | ps.setString(6, accountBean.getUserBean().getIdentifiantUser()); 50 | 51 | int count = ps.executeUpdate(); 52 | System.out.println("insertUser => " + ps.toString()); 53 | if (count > 0) { 54 | account.setUsernameAccount(accountBean.getUsernameAccount()); 55 | userBean.setIdentifiantUser(accountBean.getUserBean().getIdentifiantUser()); 56 | account.setUserBean(userBean); 57 | callDbFunctionBean.setErrorRetour(false); 58 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 59 | callDbFunctionBean.setMessageRetour("Ajout du compte utilisateur " 60 | + accountBean.getUsernameAccount() + " effectué avec succès !"); 61 | account.setCallDbFunctionBean(callDbFunctionBean); 62 | 63 | } else { 64 | callDbFunctionBean.setErrorRetour(true); 65 | callDbFunctionBean.setCodeRetour(Constants.UNKNOW_ERROR); 66 | callDbFunctionBean 67 | .setMessageRetour("Une erreur est survenue lors de l'ajout du compte utilisateur !"); 68 | account.setCallDbFunctionBean(callDbFunctionBean); 69 | } 70 | } else { 71 | callDbFunctionBean.setErrorRetour(true); 72 | callDbFunctionBean.setCodeRetour(Constants.USER_ID_NOT_EXIST); 73 | callDbFunctionBean.setMessageRetour("L'identifiant utilisateur " 74 | + accountBean.getUserBean().getIdentifiantUser() + " n'existe pas dans la base de donnée !"); 75 | account.setCallDbFunctionBean(callDbFunctionBean); 76 | } 77 | 78 | } catch (SQLException e) { 79 | try { 80 | if (con != null) { 81 | con.rollback(); 82 | } 83 | } catch (SQLException e1) { 84 | throw e1; 85 | } 86 | throw e; 87 | } finally { 88 | try { 89 | DbConnexion.closePrepaerdStatement(ps); 90 | DbConnexion.closeConnection(con); 91 | } catch (SQLException e) { 92 | throw e; 93 | } 94 | } 95 | 96 | return account; 97 | } 98 | 99 | public static AccountBean retrieveAccountById(String idAccount) throws SQLException { 100 | Connection con = null; 101 | PreparedStatement ps = null; 102 | ResultSet rs = null; 103 | AccountBean accountBean = new AccountBean(); 104 | 105 | try { 106 | con = DbConnexion.getConnection(); 107 | if (con == null) { 108 | Utils.errorDbConnection(); 109 | return accountBean; 110 | } 111 | if ((idAccount != null) && (!idAccount.isEmpty())) { 112 | ps = con.prepareStatement(SELECT_ACCOUNT_SQL_QUERY_ID); 113 | ps.setString(1, idAccount); 114 | 115 | rs = ps.executeQuery(); 116 | boolean testRowReturnLigne = rs.next(); 117 | if (testRowReturnLigne == false) { 118 | callDbFunctionBean.setErrorRetour(true); 119 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 120 | callDbFunctionBean 121 | .setMessageRetour("Aucun compte ne correspond à l'identifiant de compte " + idAccount); 122 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 123 | } 124 | 125 | while (testRowReturnLigne) { 126 | accountBean.setIdentifiantAccount(rs.getString(Constants.A_ID)); 127 | accountBean.setNameAccount(rs.getString(Constants.A_NAME)); 128 | accountBean.setUsernameAccount(rs.getString(Constants.A_USERNAME)); 129 | accountBean.setPasswordAccount(AESEncryption.decrypt(rs.getString(Constants.A_PASSWORD))); 130 | accountBean.setUrlAccount(rs.getString(Constants.A_URL)); 131 | accountBean.setCreateDateAccount(rs.getString(Constants.A_CREATE_DATE)); 132 | accountBean.setLastUpdateDateAccount(rs.getString(Constants.A_LAST_UPDATE)); 133 | userBean.setIdentifiantUser(rs.getString(Constants.PM_USER_U_ID)); 134 | accountBean.setUserBean(userBean); 135 | callDbFunctionBean.setErrorRetour(false); 136 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 137 | callDbFunctionBean.setMessageRetour("Le compte a été retrouver avec succès !"); 138 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 139 | 140 | testRowReturnLigne = rs.next(); 141 | } 142 | } 143 | 144 | } catch (SQLException e) { 145 | throw e; 146 | 147 | } 148 | 149 | finally { 150 | try { 151 | DbConnexion.closeResultSet(rs); 152 | DbConnexion.closePrepaerdStatement(ps); 153 | DbConnexion.closeConnection(con); 154 | 155 | } catch (SQLException e) { 156 | throw e; 157 | } 158 | } 159 | return accountBean; 160 | } 161 | 162 | public static List retrieveAllAccounts() throws SQLException { 163 | Connection con = null; 164 | PreparedStatement ps = null; 165 | ResultSet rs = null; 166 | List listAccountsBean = new ArrayList(); 167 | AccountBean accountBean = new AccountBean(); 168 | 169 | try { 170 | con = DbConnexion.getConnection(); 171 | if (con == null) { 172 | Utils.errorDbConnection(); 173 | return listAccountsBean; 174 | } 175 | 176 | ps = con.prepareStatement(SELECT_ACCOUNTS_SQL_QUERY); 177 | 178 | rs = ps.executeQuery(); 179 | boolean testRowReturnLigne = rs.next(); 180 | if (testRowReturnLigne == false) { 181 | callDbFunctionBean.setErrorRetour(true); 182 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 183 | callDbFunctionBean 184 | .setMessageRetour("Aucun compte ne correspond trouvé !"); 185 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 186 | listAccountsBean.add(accountBean); 187 | } 188 | 189 | while (testRowReturnLigne) { 190 | accountBean = new AccountBean(); 191 | 192 | accountBean.setIdentifiantAccount(rs.getString(Constants.A_ID)); 193 | accountBean.setNameAccount(rs.getString(Constants.A_NAME)); 194 | accountBean.setUsernameAccount(rs.getString(Constants.A_USERNAME)); 195 | accountBean.setPasswordAccount(AESEncryption.decrypt(rs.getString(Constants.A_PASSWORD))); 196 | accountBean.setUrlAccount(rs.getString(Constants.A_URL)); 197 | accountBean.setCreateDateAccount(rs.getString(Constants.A_CREATE_DATE)); 198 | accountBean.setLastUpdateDateAccount(rs.getString(Constants.A_LAST_UPDATE)); 199 | 200 | userBean.setIdentifiantUser(rs.getString(Constants.PM_USER_U_ID)); 201 | accountBean.setUserBean(userBean); 202 | 203 | callDbFunctionBean.setErrorRetour(false); 204 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 205 | callDbFunctionBean.setMessageRetour("Le compte a été retrouver avec succès !"); 206 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 207 | listAccountsBean.add(accountBean); 208 | 209 | testRowReturnLigne = rs.next(); 210 | } 211 | 212 | } catch (SQLException e) { 213 | throw e; 214 | 215 | } 216 | 217 | finally { 218 | try { 219 | DbConnexion.closeResultSet(rs); 220 | DbConnexion.closePrepaerdStatement(ps); 221 | DbConnexion.closeConnection(con); 222 | 223 | } catch (SQLException e) { 224 | throw e; 225 | } 226 | } 227 | return listAccountsBean; 228 | } 229 | 230 | public List retrieveAllAccountsByUserId(String userId) throws SQLException { 231 | Connection con = null; 232 | PreparedStatement ps = null; 233 | ResultSet rs = null; 234 | List listAccountsBean = new ArrayList(); 235 | AccountBean accountBean = new AccountBean(); 236 | 237 | try { 238 | con = DbConnexion.getConnection(); 239 | if (con == null) { 240 | Utils.errorDbConnection(); 241 | return listAccountsBean; 242 | } 243 | 244 | if (!Utils.isNullOrEmpty(userId)) { 245 | if (UserDaoImpl.testIfUserIdExistInDb(userId) == true) { 246 | 247 | ps = con.prepareStatement(SELECT_ACCOUNTS_SQL_QUERY_BY_USER_ID); 248 | ps.setString(1, userId); 249 | 250 | rs = ps.executeQuery(); 251 | boolean testRowReturnLigne = rs.next(); 252 | if (testRowReturnLigne == false) { 253 | callDbFunctionBean.setErrorRetour(true); 254 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 255 | callDbFunctionBean 256 | .setMessageRetour("Il n'y a aucun compte correspondant à l'utilisateur " + userId); 257 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 258 | listAccountsBean.add(accountBean); 259 | } 260 | 261 | while (testRowReturnLigne) { 262 | accountBean = new AccountBean(); 263 | 264 | accountBean.setIdentifiantAccount(rs.getString(Constants.A_ID)); 265 | accountBean.setNameAccount(rs.getString(Constants.A_NAME)); 266 | accountBean.setUsernameAccount(rs.getString(Constants.A_USERNAME)); 267 | accountBean.setPasswordAccount(AESEncryption.decrypt(rs.getString(Constants.A_PASSWORD))); 268 | accountBean.setUrlAccount(rs.getString(Constants.A_URL)); 269 | accountBean.setCreateDateAccount(rs.getString(Constants.A_CREATE_DATE)); 270 | accountBean.setLastUpdateDateAccount(rs.getString(Constants.A_LAST_UPDATE)); 271 | 272 | userBean.setIdentifiantUser(rs.getString(Constants.PM_USER_U_ID)); 273 | accountBean.setUserBean(userBean); 274 | 275 | callDbFunctionBean.setErrorRetour(false); 276 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 277 | callDbFunctionBean.setMessageRetour("Le compte a été retrouver avec succès !"); 278 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 279 | listAccountsBean.add(accountBean); 280 | 281 | testRowReturnLigne = rs.next(); 282 | } 283 | 284 | } else { 285 | 286 | callDbFunctionBean.setErrorRetour(true); 287 | callDbFunctionBean.setCodeRetour(Constants.USER_ID_NOT_EXIST); 288 | callDbFunctionBean.setMessageRetour("L'identifiant utilisateur " 289 | + accountBean.getUserBean().getIdentifiantUser() + " n'existe pas dans la base de donnée !"); 290 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 291 | } 292 | } 293 | 294 | } catch (SQLException e) { 295 | throw e; 296 | 297 | } 298 | 299 | finally { 300 | try { 301 | DbConnexion.closeResultSet(rs); 302 | DbConnexion.closePrepaerdStatement(ps); 303 | DbConnexion.closeConnection(con); 304 | 305 | } catch (SQLException e) { 306 | throw e; 307 | } 308 | } 309 | return listAccountsBean; 310 | } 311 | 312 | public static AccountBean deleteAccountById(String idAccount) throws SQLException { 313 | 314 | Connection con = null; 315 | PreparedStatement ps = null; 316 | ResultSet rs = null; 317 | AccountBean accountBean = new AccountBean(); 318 | 319 | try { 320 | con = DbConnexion.getConnection(); 321 | if (con == null) { 322 | Utils.errorDbConnection(); 323 | return accountBean; 324 | } 325 | 326 | if ((idAccount != null) && (!idAccount.isEmpty())) { 327 | 328 | if (testIfAccountIdExistInDb(idAccount) == true) { 329 | 330 | ps = con.prepareStatement(DELETE_ACCOUNT_SQL_QUERY_ID); 331 | ps.setString(1, idAccount); 332 | 333 | int count = ps.executeUpdate(); 334 | System.out.println("insertUser => " + ps.toString()); 335 | if (count > 0) { 336 | accountBean.setIdentifiantAccount(accountBean.getIdentifiantAccount()); 337 | callDbFunctionBean.setErrorRetour(false); 338 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 339 | callDbFunctionBean.setMessageRetour("Suppression du compte " 340 | + idAccount + " effectué avec succès !"); 341 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 342 | 343 | } else { 344 | callDbFunctionBean.setErrorRetour(true); 345 | callDbFunctionBean.setCodeRetour(Constants.UNKNOW_ERROR); 346 | callDbFunctionBean 347 | .setMessageRetour("Une erreur est survenue lors de la suppression du compte utilisateur !"); 348 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 349 | } 350 | 351 | } else { 352 | 353 | callDbFunctionBean.setErrorRetour(true); 354 | callDbFunctionBean.setCodeRetour(Constants.USER_ID_NOT_EXIST); 355 | callDbFunctionBean.setMessageRetour("L'identifiant du compte " 356 | + idAccount + " n'existe pas dans la base de donnée !"); 357 | accountBean.setCallDbFunctionBean(callDbFunctionBean); 358 | } 359 | 360 | } 361 | 362 | } catch (SQLException e) { 363 | throw e; 364 | 365 | } 366 | 367 | finally { 368 | try { 369 | DbConnexion.closeResultSet(rs); 370 | DbConnexion.closePrepaerdStatement(ps); 371 | DbConnexion.closeConnection(con); 372 | 373 | } catch (SQLException e) { 374 | throw e; 375 | } 376 | } 377 | 378 | return accountBean; 379 | } 380 | 381 | 382 | public static AccountBean updateAccount(AccountBean accountBean) throws Exception { 383 | 384 | Connection con = null; 385 | PreparedStatement ps = null; 386 | AccountBean account = new AccountBean(); 387 | try { 388 | con = DbConnexion.getConnection(); 389 | if (con == null) { 390 | Utils.errorDbConnection(); 391 | return account; 392 | } 393 | 394 | if (UserDaoImpl.testIfUserIdExistInDb(accountBean.getUserBean().getIdentifiantUser()) == true) { 395 | 396 | ps = con.prepareStatement(UPDATE_ACCOUNT_SQL_QUERY_ID); 397 | ps.setString(1, accountBean.getNameAccount()); 398 | ps.setString(2, accountBean.getUsernameAccount()); 399 | ps.setString(3, AESEncryption.encrypt(accountBean.getPasswordAccount())); 400 | ps.setString(4, accountBean.getUrlAccount()); 401 | ps.setString(5, accountBean.getIdentifiantAccount()); 402 | 403 | System.out.println(ps.toString()); 404 | 405 | int count = ps.executeUpdate(); 406 | System.out.println("updateAccount => " + ps.toString()); 407 | if (count > 0) { 408 | userBean.setIdentifiantUser(accountBean.getUserBean().getIdentifiantUser()); 409 | account.setUserBean(userBean); 410 | 411 | callDbFunctionBean.setErrorRetour(false); 412 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 413 | callDbFunctionBean.setMessageRetour("Modification du compte utilisateur " 414 | + accountBean.getIdentifiantAccount() + " effectué avec succès !"); 415 | account.setCallDbFunctionBean(callDbFunctionBean); 416 | 417 | } else { 418 | callDbFunctionBean.setErrorRetour(true); 419 | callDbFunctionBean.setCodeRetour(Constants.UNKNOW_ERROR); 420 | callDbFunctionBean 421 | .setMessageRetour("Une erreur est survenue lors de la modification du compte utilisateur !"); 422 | account.setCallDbFunctionBean(callDbFunctionBean); 423 | } 424 | } else { 425 | callDbFunctionBean.setErrorRetour(true); 426 | callDbFunctionBean.setCodeRetour(Constants.USER_ID_NOT_EXIST); 427 | callDbFunctionBean.setMessageRetour("L'identifiant utilisateur " 428 | + accountBean.getUserBean().getIdentifiantUser() + " n'existe pas dans la base de donnée !"); 429 | account.setCallDbFunctionBean(callDbFunctionBean); 430 | } 431 | 432 | } catch (SQLException e) { 433 | try { 434 | if (con != null) { 435 | con.rollback(); 436 | } 437 | } catch (SQLException e1) { 438 | throw e1; 439 | } 440 | throw e; 441 | } finally { 442 | try { 443 | DbConnexion.closePrepaerdStatement(ps); 444 | DbConnexion.closeConnection(con); 445 | } catch (SQLException e) { 446 | throw e; 447 | } 448 | } 449 | 450 | return account; 451 | } 452 | 453 | public static boolean testIfAccountIdExistInDb(String idAccount) { 454 | AccountBean accountBean = new AccountBean(); 455 | boolean testId = false; 456 | try { 457 | if ((idAccount != null && !idAccount.isEmpty())) { 458 | accountBean = retrieveAccountById(idAccount); 459 | if ((accountBean.getCallDbFunctionBean().isErrorRetour() == false) && (accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY)) { 460 | testId = true; 461 | }else { 462 | testId = false; 463 | } 464 | } 465 | 466 | } catch (SQLException e) { 467 | // TODO Auto-generated catch block 468 | e.printStackTrace(); 469 | } 470 | 471 | return testId; 472 | } 473 | 474 | 475 | } 476 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/dao/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.logging.Level; 9 | 10 | import bean.ReturnCallDbFunctionBean; 11 | import bean.UserBean; 12 | import database.DbConnexion; 13 | import service.PasswordHash; 14 | import utils.Constants; 15 | import utils.Utils; 16 | 17 | public class UserDaoImpl { 18 | /* 19 | * INSERT INTO pm_user (u_id, u_name, u_email, u_password) VALUES (1, 'Soumaila 20 | * A DIARRA', 'diarra176@gmail.com', 'soumaila'); 21 | */ 22 | public static final String INSERT_USER_SQL_QUERY = "INSERT INTO PM_USER (U_ID,U_NAME,U_EMAIL,U_PASSWORD) VALUES(?,?,?,?)"; 23 | public static final String SELECT_USER_SQL_QUERY_EMAIL = "SELECT * FROM PM_USER WHERE U_EMAIL=?"; 24 | public static final String SELECT_USER_SQL_QUERY_ID = "SELECT * FROM PM_USER WHERE U_ID=?"; 25 | 26 | static ReturnCallDbFunctionBean callDbFunctionBean = new ReturnCallDbFunctionBean(); 27 | 28 | public static UserBean insertUser(UserBean userBean) throws Exception { 29 | 30 | Connection con = null; 31 | PreparedStatement ps = null; 32 | UserBean user= new UserBean(); 33 | try { 34 | con = DbConnexion.getConnection(); 35 | if (con == null) { 36 | Utils.errorDbConnection(); 37 | return user; 38 | } 39 | 40 | if (testIfUserEmailExistInDb(userBean.getEmailUser()) == false) { 41 | ps = con.prepareStatement(INSERT_USER_SQL_QUERY); 42 | String uuidGenerated = Utils.generateUUID(); 43 | ps.setString(1, uuidGenerated); 44 | ps.setString(2, userBean.getNameUser()); 45 | ps.setString(3, userBean.getEmailUser()); 46 | ps.setString(4, PasswordHash.getSaltedHash(userBean.getPasswordUser())); 47 | 48 | int count = ps.executeUpdate(); 49 | System.out.println("insertUser => " + ps.toString()); 50 | if (count > 0) { 51 | user.setIdentifiantUser(uuidGenerated); 52 | user.setNameUser(userBean.getNameUser()); 53 | user.setEmailUser(userBean.getEmailUser()); 54 | callDbFunctionBean.setErrorRetour(false); 55 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 56 | callDbFunctionBean.setMessageRetour("Insertion de l'utilisateur " + userBean.getEmailUser() + " effectué avec succès !"); 57 | user.setCallDbFunctionBean(callDbFunctionBean); 58 | 59 | }else { 60 | callDbFunctionBean.setErrorRetour(true); 61 | callDbFunctionBean.setCodeRetour(Constants.UNKNOW_ERROR); 62 | callDbFunctionBean.setMessageRetour("Une erreur est survenue lors de la création de votre compte !"); 63 | user.setCallDbFunctionBean(callDbFunctionBean); 64 | } 65 | } else { 66 | callDbFunctionBean.setErrorRetour(true); 67 | callDbFunctionBean.setCodeRetour(Constants.EMAIL_EXIST); 68 | callDbFunctionBean.setMessageRetour("L'email " + userBean.getEmailUser() + " existe déjà !"); 69 | user.setCallDbFunctionBean(callDbFunctionBean); 70 | } 71 | 72 | } catch (SQLException e) { 73 | try { 74 | if (con != null) { 75 | con.rollback(); 76 | } 77 | } catch (SQLException e1) { 78 | throw e1; 79 | } 80 | throw e; 81 | } finally { 82 | try { 83 | DbConnexion.closePrepaerdStatement(ps); 84 | DbConnexion.closeConnection(con); 85 | } catch (SQLException e) { 86 | throw e; 87 | } 88 | } 89 | 90 | return user; 91 | 92 | } 93 | 94 | public static UserBean retrieveUserByEmail(String emailUser) throws SQLException { 95 | Connection con = null; 96 | PreparedStatement ps = null; 97 | ResultSet rs = null; 98 | UserBean userBean = new UserBean(); 99 | try { 100 | con = DbConnexion.getConnection(); 101 | if (con == null) { 102 | Utils.errorDbConnection(); 103 | return userBean; 104 | } 105 | if((emailUser != null)&&(!emailUser.isEmpty())) { 106 | ps = con.prepareStatement(SELECT_USER_SQL_QUERY_EMAIL); 107 | ps.setString(1, emailUser); 108 | 109 | rs = ps.executeQuery(); 110 | boolean testRowReturnLigne = rs.next(); 111 | if (testRowReturnLigne == false) { 112 | callDbFunctionBean.setErrorRetour(true); 113 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 114 | callDbFunctionBean.setMessageRetour("Aucun utilisateur ne correspond à l'utilisateur " + emailUser); 115 | userBean.setCallDbFunctionBean(callDbFunctionBean); 116 | } 117 | 118 | while (testRowReturnLigne) { 119 | userBean.setIdentifiantUser(rs.getString(Constants.U_ID)); 120 | userBean.setNameUser(rs.getString(Constants.U_NAME)); 121 | userBean.setEmailUser(rs.getString(Constants.U_EMAIL)); 122 | userBean.setCreateDateUser(rs.getString(Constants.U_CREATE_DATE)); 123 | userBean.setLastUpdateDateUser(rs.getString(Constants.U_LAST_UPDATE)); 124 | callDbFunctionBean.setErrorRetour(false); 125 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 126 | callDbFunctionBean.setMessageRetour("L'utilisateur a été retrouver avec succès !"); 127 | userBean.setCallDbFunctionBean(callDbFunctionBean); 128 | 129 | testRowReturnLigne = rs.next(); 130 | } 131 | } 132 | 133 | } catch (SQLException e) { 134 | throw e; 135 | 136 | } 137 | 138 | finally { 139 | try { 140 | DbConnexion.closeResultSet(rs); 141 | DbConnexion.closePrepaerdStatement(ps); 142 | DbConnexion.closeConnection(con); 143 | 144 | } catch (SQLException e) { 145 | throw e; 146 | } 147 | } 148 | return userBean; 149 | } 150 | 151 | public static UserBean retrieveUserById(String id) throws SQLException { 152 | Connection con = null; 153 | PreparedStatement ps = null; 154 | ResultSet rs = null; 155 | UserBean userBean = new UserBean(); 156 | try { 157 | con = DbConnexion.getConnection(); 158 | if (con == null) { 159 | Utils.errorDbConnection(); 160 | return userBean; 161 | } 162 | if((id != null)&&(!id.isEmpty())) { 163 | ps = con.prepareStatement(SELECT_USER_SQL_QUERY_ID); 164 | ps.setString(1, id); 165 | 166 | rs = ps.executeQuery(); 167 | boolean testRowReturnLigne = rs.next(); 168 | if (testRowReturnLigne == false) { 169 | callDbFunctionBean.setErrorRetour(true); 170 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 171 | callDbFunctionBean.setMessageRetour("Aucun utilisateur ne correspond à l'utilisateur " + id); 172 | userBean.setCallDbFunctionBean(callDbFunctionBean); 173 | } 174 | 175 | while (testRowReturnLigne) { 176 | userBean.setIdentifiantUser(rs.getString(Constants.U_ID)); 177 | userBean.setNameUser(rs.getString(Constants.U_NAME)); 178 | userBean.setEmailUser(rs.getString(Constants.U_EMAIL)); 179 | userBean.setCreateDateUser(rs.getString(Constants.U_CREATE_DATE)); 180 | userBean.setLastUpdateDateUser(rs.getString(Constants.U_LAST_UPDATE)); 181 | callDbFunctionBean.setErrorRetour(false); 182 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 183 | callDbFunctionBean.setMessageRetour("L'utilisateur a été retrouver avec succès !"); 184 | userBean.setCallDbFunctionBean(callDbFunctionBean); 185 | 186 | testRowReturnLigne = rs.next(); 187 | } 188 | } 189 | 190 | } catch (SQLException e) { 191 | throw e; 192 | 193 | } 194 | 195 | finally { 196 | try { 197 | DbConnexion.closeResultSet(rs); 198 | DbConnexion.closePrepaerdStatement(ps); 199 | DbConnexion.closeConnection(con); 200 | 201 | } catch (SQLException e) { 202 | throw e; 203 | } 204 | } 205 | return userBean; 206 | } 207 | 208 | public static UserBean authenticationUser(String emailUser, String passwordUser) throws Exception { 209 | Connection con = null; 210 | PreparedStatement ps = null; 211 | ResultSet rs = null; 212 | UserBean userBean = new UserBean(); 213 | 214 | try { 215 | 216 | if ((emailUser != null && !emailUser.isEmpty()) || (passwordUser != null && !passwordUser.isEmpty())) { 217 | 218 | con = DbConnexion.getConnection(); 219 | if (con == null) { 220 | Utils.errorDbConnection(); 221 | return userBean; 222 | } 223 | 224 | ps = con.prepareStatement(SELECT_USER_SQL_QUERY_EMAIL); 225 | ps.setString(1, emailUser); 226 | 227 | rs = ps.executeQuery(); 228 | boolean testRowReturnLigne = rs.next(); 229 | if (testRowReturnLigne == false) { 230 | callDbFunctionBean.setErrorRetour(true); 231 | callDbFunctionBean.setCodeRetour(Constants.NOT_FOUND); 232 | callDbFunctionBean.setMessageRetour("Aucun utilisateur ne correspond à l'utilisateur " + emailUser); 233 | userBean.setCallDbFunctionBean(callDbFunctionBean); 234 | } 235 | 236 | while (testRowReturnLigne) { 237 | if (PasswordHash.checkPassword(passwordUser, rs.getString(Constants.U_PASSWORD))) { 238 | userBean.setIdentifiantUser(rs.getString(Constants.U_ID)); 239 | userBean.setNameUser(rs.getString(Constants.U_NAME)); 240 | userBean.setEmailUser(rs.getString(Constants.U_EMAIL)); 241 | userBean.setCreateDateUser(rs.getString(Constants.U_CREATE_DATE)); 242 | userBean.setLastUpdateDateUser(rs.getString(Constants.U_LAST_UPDATE)); 243 | callDbFunctionBean.setErrorRetour(false); 244 | callDbFunctionBean.setCodeRetour(Constants.COMPLETED_SUCCESSFULLY); 245 | callDbFunctionBean.setMessageRetour("L'utilisateur est authentifié avec succès !"); 246 | userBean.setCallDbFunctionBean(callDbFunctionBean); 247 | }else { 248 | callDbFunctionBean.setErrorRetour(true); 249 | callDbFunctionBean.setCodeRetour(Constants.PASSWORD_ERROR); 250 | callDbFunctionBean.setMessageRetour("Mot de passe invalide !"); 251 | userBean.setCallDbFunctionBean(callDbFunctionBean); 252 | } 253 | 254 | testRowReturnLigne = rs.next(); 255 | } 256 | 257 | } 258 | 259 | } catch (SQLException e) { 260 | throw e; 261 | 262 | } 263 | 264 | finally { 265 | try { 266 | DbConnexion.closeResultSet(rs); 267 | DbConnexion.closePrepaerdStatement(ps); 268 | DbConnexion.closeConnection(con); 269 | 270 | } catch (SQLException e) { 271 | throw e; 272 | } 273 | } 274 | return userBean; 275 | } 276 | 277 | public static boolean testIfUserEmailExistInDb(String email) { 278 | UserBean userBean = new UserBean(); 279 | boolean testEmail = false; 280 | try { 281 | if ((email != null && !email.isEmpty())) { 282 | userBean = retrieveUserByEmail(email); 283 | if ((userBean.getCallDbFunctionBean().isErrorRetour() == false) && (userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY)) { 284 | testEmail = true; 285 | }else { 286 | testEmail = false; 287 | } 288 | } 289 | 290 | } catch (SQLException e) { 291 | // TODO Auto-generated catch block 292 | e.printStackTrace(); 293 | } 294 | 295 | return testEmail; 296 | } 297 | 298 | public static boolean testIfUserIdExistInDb(String id) { 299 | UserBean userBean = new UserBean(); 300 | boolean testId = false; 301 | try { 302 | if ((id != null && !id.isEmpty())) { 303 | userBean = retrieveUserById(id); 304 | if ((userBean.getCallDbFunctionBean().isErrorRetour() == false) && (userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY)) { 305 | testId = true; 306 | }else { 307 | testId = false; 308 | } 309 | } 310 | 311 | } catch (SQLException e) { 312 | // TODO Auto-generated catch block 313 | e.printStackTrace(); 314 | } 315 | 316 | return testId; 317 | } 318 | 319 | } 320 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/database/DbConnexion.java: -------------------------------------------------------------------------------- 1 | package database; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.sql.Statement; 9 | import java.util.logging.Level; 10 | 11 | import utils.Constants; 12 | import utils.Utils; 13 | 14 | public class DbConnexion { 15 | 16 | private static Connection connection = null; 17 | 18 | public DbConnexion() { 19 | } 20 | 21 | static { 22 | try { 23 | Class.forName(Constants.JDBC_DRIVER_NAME); 24 | } catch (ClassNotFoundException e) { 25 | Utils.getLogger(Level.SEVERE, "Le driver de la classe n'a pas été trouvé !"); 26 | } 27 | } 28 | 29 | public static Connection getConnection() throws SQLException { 30 | //I added resources folder on my project built path, it's work on eclipse and on jar 31 | String jarPath = "jdbc:sqlite::resource:" + Constants.DB_PATH; 32 | System.out.println(jarPath); 33 | connection = DriverManager.getConnection(jarPath); 34 | Utils.getLogger(Level.INFO, "Connection à la base de donnée effectuer avec succès !"); 35 | 36 | return connection; 37 | } 38 | 39 | public static void closeConnection(Connection con) throws SQLException { 40 | if (con != null) { 41 | con.close(); 42 | } 43 | } 44 | 45 | public static void closePrepaerdStatement(PreparedStatement stmt) throws SQLException { 46 | if (stmt != null) { 47 | stmt.close(); 48 | } 49 | } 50 | 51 | public static void closeResultSet(ResultSet rs) throws SQLException { 52 | if (rs != null) { 53 | rs.close(); 54 | } 55 | } 56 | 57 | private static boolean isDbConnected(Connection con) { 58 | // final String CHECK_SQL_QUERY = "SELECT 1"; 59 | try { 60 | if (!con.isClosed() || con != null) { 61 | return true; 62 | } 63 | } catch (SQLException e) { 64 | return false; 65 | } 66 | return false; 67 | } 68 | 69 | /* 70 | * public void getConnection() throws SQLException{ try { 71 | * 72 | * Class.forName("org.sqlite.JDBC"); connection = 73 | * DriverManager.getConnection("jdbc:sqlite:" + DBPath); statement = 74 | * connection.createStatement(); 75 | * 76 | * Utils.getLogger(Level.INFO, "Connexion a " + DBPath + 77 | * " effectuer avec succès"); 78 | * 79 | * } catch (ClassNotFoundException notFoundException) { 80 | * notFoundException.printStackTrace(); Utils.getLogger(Level.SEVERE, 81 | * "Erreur de connexion à la base de donnée "); } catch (SQLException 82 | * sqlException) { sqlException.printStackTrace(); Utils.getLogger(Level.SEVERE, 83 | * "Erreur de connexion à la base de donnée "); } } 84 | * 85 | * public void close() { try { connection.close(); statement.close(); } catch 86 | * (SQLException e) { e.printStackTrace(); } } 87 | * 88 | */ 89 | 90 | } 91 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/service/AESEncryption.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.MessageDigest; 5 | import java.security.NoSuchAlgorithmException; 6 | import java.util.Arrays; 7 | import java.util.Base64; 8 | 9 | import javax.crypto.Cipher; 10 | import javax.crypto.spec.SecretKeySpec; 11 | 12 | import utils.Constants; 13 | 14 | public class AESEncryption { 15 | 16 | private static SecretKeySpec secretKey; 17 | private static byte[] key; 18 | 19 | public static void setKey(String myKey) { 20 | MessageDigest sha = null; 21 | try { 22 | key = myKey.getBytes("UTF-8"); 23 | sha = MessageDigest.getInstance("SHA-1"); 24 | key = sha.digest(key); 25 | key = Arrays.copyOf(key, 16); 26 | secretKey = new SecretKeySpec(key, "AES"); 27 | } catch (NoSuchAlgorithmException e) { 28 | e.printStackTrace(); 29 | } catch (UnsupportedEncodingException e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | 34 | public static String encrypt(String strToEncrypt) { 35 | try { 36 | String secret = Constants.SECRET_KEY; 37 | setKey(secret); 38 | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); 39 | cipher.init(Cipher.ENCRYPT_MODE, secretKey); 40 | return Base64.getEncoder().encodeToString(cipher.doFinal(strToEncrypt.getBytes("UTF-8"))); 41 | } catch (Exception e) { 42 | System.out.println("Error while encrypting: " + e.toString()); 43 | } 44 | return null; 45 | } 46 | 47 | public static String decrypt(String strToDecrypt) { 48 | try { 49 | String secret = Constants.SECRET_KEY; 50 | setKey(secret); 51 | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); 52 | cipher.init(Cipher.DECRYPT_MODE, secretKey); 53 | return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))); 54 | } catch (Exception e) { 55 | System.out.println("Error while decrypting: " + e.toString()); 56 | } 57 | return null; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/service/PasswordHash.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import java.security.SecureRandom; 4 | import java.util.Base64; 5 | 6 | import javax.crypto.SecretKey; 7 | import javax.crypto.SecretKeyFactory; 8 | import javax.crypto.spec.PBEKeySpec; 9 | 10 | public class PasswordHash { 11 | 12 | // The higher the number of iterations the more 13 | // expensive computing the hash is for us and 14 | // also for an attacker. 15 | 16 | private static final int iterations = 20*1000; 17 | private static final int saltLen = 32; 18 | private static final int desiredKeyLen = 256; 19 | 20 | /** Computes a salted PBKDF2 hash of given plaintext password 21 | suitable for storing in a database. 22 | Empty passwords are not supported. */ 23 | public static String getSaltedHash(String password) throws Exception { 24 | byte[] salt = SecureRandom.getInstance("SHA1PRNG").generateSeed(saltLen); 25 | // store the salt with the password 26 | //return Base64.encodeBase64String(salt) + "$" + hash(password, salt); 27 | return Base64.getEncoder().encodeToString(salt)+ "$" + hash(password, salt); 28 | } 29 | 30 | /** Checks whether given plaintext password corresponds 31 | to a stored salted hash of the password. */ 32 | public static boolean checkPassword(String password, String stored) throws Exception{ 33 | String[] saltAndHash = stored.split("\\$"); 34 | if (saltAndHash.length != 2) { 35 | throw new IllegalStateException( 36 | "The stored password must have the form 'salt$hash'"); 37 | } 38 | //String hashOfInput = hash(password, Base64.decodeBase64(saltAndHash[0])); 39 | String hashOfInput = hash(password, Base64.getDecoder().decode(saltAndHash[0])); 40 | 41 | return hashOfInput.equals(saltAndHash[1]); 42 | } 43 | 44 | // using PBKDF2 from Sun, an alternative is https://github.com/wg/scrypt 45 | // cf. http://www.unlimitednovelty.com/2012/03/dont-use-bcrypt.html 46 | private static String hash(String password, byte[] salt) throws Exception { 47 | if (password == null || password.length() == 0) 48 | throw new IllegalArgumentException("Empty passwords are not supported."); 49 | SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 50 | SecretKey key = f.generateSecret(new PBEKeySpec( 51 | password.toCharArray(), salt, iterations, desiredKeyLen)); 52 | //return Base64.encodeBase64String(key.getEncoded()); 53 | return Base64.getEncoder().encodeToString(key.getEncoded()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/AdminUI.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JTextField; 7 | 8 | import bean.AccountBean; 9 | import bean.AccountItemView; 10 | import bean.UserBean; 11 | import dao.AccountDaoImpl; 12 | import utils.Constants; 13 | import utils.Utils; 14 | 15 | import javax.swing.JLabel; 16 | import javax.swing.JPanel; 17 | 18 | import java.awt.BorderLayout; 19 | import java.awt.Color; 20 | import java.awt.Font; 21 | import java.awt.GridBagLayout; 22 | import java.awt.Panel; 23 | import java.awt.ScrollPane; 24 | import java.awt.event.ActionEvent; 25 | import java.awt.event.ActionListener; 26 | import java.awt.event.MouseEvent; 27 | import java.awt.event.MouseListener; 28 | import java.net.URL; 29 | import java.sql.SQLException; 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | 33 | import javax.swing.border.LineBorder; 34 | 35 | import javax.swing.border.EtchedBorder; 36 | import javax.swing.DefaultListModel; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JSeparator; 39 | import javax.swing.SwingConstants; 40 | import java.awt.Cursor; 41 | import java.awt.Desktop; 42 | import java.awt.Dimension; 43 | 44 | import javax.swing.JScrollBar; 45 | import javax.swing.JScrollPane; 46 | import javax.swing.JPasswordField; 47 | import javax.swing.JButton; 48 | import javax.swing.JList; 49 | import javax.swing.AbstractListModel; 50 | 51 | public class AdminUI extends JFrame implements ActionListener, MouseListener { 52 | 53 | public JFrame frame; 54 | JLabel userNameLbl; 55 | JLabel userEmailLbl; 56 | private final JPanel panel = new JPanel(); 57 | private JTextField nomCompletEditTxtFld; 58 | private JTextField usernameEditTxtFld; 59 | private JPasswordField passwordEditTxtFld; 60 | private JTextField urlEditTxtFld; 61 | private JLabel idAccountEditLbl; 62 | JLabel userIconLbl; 63 | JLabel lblPasswordManager; 64 | JLabel scoreSecuriteLbl; 65 | JLabel scoreSecuritePourcentageLbl; 66 | JLabel disconnectLbl; 67 | JLabel nbreCompteEnregistrerLbl; 68 | JLabel chiffreNbreCompteEnregistrerLbl; 69 | JLabel lblWeAreHappy; 70 | JLabel githubIconLbl; 71 | JLabel fbIconLbl; 72 | JLabel twitterIconLbl; 73 | JLabel iconeTextCompteEnregistrerLbl; 74 | JLabel compteEnregistrerLbl; 75 | JLabel lblCompte; 76 | JButton ajouterEditBtn; 77 | JButton clearEditBtn; 78 | JLabel iconViewOrHidePasswordEditLbl; 79 | JLabel iconGeneratePasswordEditLbl; 80 | JPanel panelViewAllItems; 81 | 82 | UserBean user = new UserBean(); 83 | List accounts = new ArrayList(); 84 | 85 | /** 86 | * Launch the application. 87 | */ 88 | public static void main(String[] args) { 89 | EventQueue.invokeLater(new Runnable() { 90 | public void run() { 91 | try { 92 | AdminUI window = new AdminUI(); 93 | window.frame.setVisible(true); 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | /** 102 | * Create the application. 103 | */ 104 | public AdminUI() { 105 | initialize(); 106 | } 107 | 108 | public AdminUI(UserBean userBean) { 109 | user = userBean; 110 | initialize(); 111 | userNameLbl.setText(userBean.getNameUser()); 112 | userEmailLbl.setText(userBean.getEmailUser()); 113 | } 114 | 115 | /** 116 | * Initialize the contents of the frame. 117 | */ 118 | private void initialize() { 119 | frame = new JFrame(); 120 | frame.setResizable(false); 121 | frame.getContentPane().setBackground(new Color(230, 230, 250)); 122 | frame.setBounds(100, 100, 1200, 650); 123 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 124 | frame.getContentPane().setLayout(null); 125 | panel.setBackground(new Color(255, 255, 255)); 126 | panel.setBounds(0, 8, 1200, 150); 127 | frame.getContentPane().add(panel); 128 | panel.setLayout(null); 129 | 130 | userIconLbl = new JLabel(""); 131 | userIconLbl.setHorizontalAlignment(SwingConstants.CENTER); 132 | userIconLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/user.png"))); 133 | userIconLbl.setBounds(1016, 13, 60, 60); 134 | panel.add(userIconLbl); 135 | 136 | userNameLbl = new JLabel("DIARRA SOUMAILA A"); 137 | userNameLbl.setHorizontalAlignment(SwingConstants.CENTER); 138 | userNameLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 139 | userNameLbl.setForeground(new Color(112, 128, 144)); 140 | userNameLbl.setBounds(917, 86, 259, 20); 141 | panel.add(userNameLbl); 142 | 143 | userEmailLbl = new JLabel("diarra176@gmail.com"); 144 | userEmailLbl.setHorizontalAlignment(SwingConstants.CENTER); 145 | userEmailLbl.setForeground(new Color(60, 179, 113)); 146 | userEmailLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 147 | userEmailLbl.setBounds(917, 115, 259, 17); 148 | panel.add(userEmailLbl); 149 | 150 | JSeparator separator = new JSeparator(); 151 | separator.setOrientation(SwingConstants.VERTICAL); 152 | separator.setBounds(895, 0, 10, 150); 153 | panel.add(separator); 154 | 155 | JLabel label = new JLabel(""); 156 | label.setHorizontalAlignment(SwingConstants.CENTER); 157 | label.setBounds(78, 24, 64, 64); 158 | panel.add(label); 159 | label.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/pm_logo64.png"))); 160 | label.setForeground(Color.WHITE); 161 | label.setFont(new Font("Tahoma", Font.BOLD, 14)); 162 | label.setBorder(null); 163 | label.setAlignmentX(0.5f); 164 | 165 | lblPasswordManager = new JLabel("\r\nPassword Manager\r\n"); 166 | lblPasswordManager.setForeground(new Color(112, 128, 144)); 167 | lblPasswordManager.setFont(new Font("Tahoma", Font.BOLD, 16)); 168 | lblPasswordManager.setBounds(31, 99, 154, 20); 169 | panel.add(lblPasswordManager); 170 | 171 | JSeparator separator_1 = new JSeparator(); 172 | separator_1.setOrientation(SwingConstants.VERTICAL); 173 | separator_1.setBounds(208, 0, 10, 150); 174 | panel.add(separator_1); 175 | 176 | JLabel lblBienvenue = new JLabel("SOUMGRAPHIC PASSWORD MANAGER DASHBOARD"); 177 | lblBienvenue.setForeground(new Color(112, 128, 144)); 178 | lblBienvenue.setFont(new Font("Tahoma", Font.BOLD, 16)); 179 | lblBienvenue.setBounds(273, 29, 424, 20); 180 | panel.add(lblBienvenue); 181 | 182 | JLabel lblNewLabel_3 = new JLabel(""); 183 | lblNewLabel_3.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/dashboard.png"))); 184 | lblNewLabel_3.setBounds(230, 24, 30, 30); 185 | panel.add(lblNewLabel_3); 186 | 187 | JSeparator separator_4 = new JSeparator(); 188 | separator_4.setBounds(214, 61, 688, 12); 189 | panel.add(separator_4); 190 | 191 | scoreSecuriteLbl = new JLabel("Score de sécurité"); 192 | scoreSecuriteLbl.setForeground(new Color(112, 128, 144)); 193 | scoreSecuriteLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 194 | scoreSecuriteLbl.setBounds(228, 88, 105, 17); 195 | panel.add(scoreSecuriteLbl); 196 | 197 | scoreSecuritePourcentageLbl = new JLabel("74%"); 198 | scoreSecuritePourcentageLbl.setFont(new Font("Tahoma", Font.BOLD, 18)); 199 | scoreSecuritePourcentageLbl.setForeground(new Color(112, 128, 144)); 200 | scoreSecuritePourcentageLbl.setBounds(259, 111, 44, 22); 201 | panel.add(scoreSecuritePourcentageLbl); 202 | 203 | JSeparator separator_5 = new JSeparator(); 204 | separator_5.setOrientation(SwingConstants.VERTICAL); 205 | separator_5.setBounds(355, 72, 10, 78); 206 | panel.add(separator_5); 207 | 208 | disconnectLbl = new JLabel(""); 209 | disconnectLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 210 | disconnectLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/logout.png"))); 211 | disconnectLbl.setHorizontalAlignment(SwingConstants.CENTER); 212 | disconnectLbl.setBounds(812, 77, 64, 64); 213 | disconnectLbl.addMouseListener(this); 214 | panel.add(disconnectLbl); 215 | 216 | JSeparator separator_6 = new JSeparator(); 217 | separator_6.setOrientation(SwingConstants.VERTICAL); 218 | separator_6.setBounds(790, 71, 10, 78); 219 | panel.add(separator_6); 220 | 221 | nbreCompteEnregistrerLbl = new JLabel("Nombre de compte enregistré"); 222 | nbreCompteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 223 | nbreCompteEnregistrerLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 224 | nbreCompteEnregistrerLbl.setBounds(377, 86, 183, 17); 225 | panel.add(nbreCompteEnregistrerLbl); 226 | 227 | chiffreNbreCompteEnregistrerLbl = new JLabel("10"); 228 | chiffreNbreCompteEnregistrerLbl.setVerticalAlignment(SwingConstants.TOP); 229 | chiffreNbreCompteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 230 | chiffreNbreCompteEnregistrerLbl.setFont(new Font("Tahoma", Font.BOLD, 18)); 231 | chiffreNbreCompteEnregistrerLbl.setBounds(457, 111, 22, 22); 232 | panel.add(chiffreNbreCompteEnregistrerLbl); 233 | 234 | JSeparator separator_8 = new JSeparator(); 235 | separator_8.setOrientation(SwingConstants.VERTICAL); 236 | separator_8.setBounds(572, 72, 10, 78); 237 | panel.add(separator_8); 238 | 239 | lblWeAreHappy = new JLabel("We are happy you like it !"); 240 | lblWeAreHappy.setHorizontalAlignment(SwingConstants.CENTER); 241 | lblWeAreHappy.setForeground(new Color(112, 128, 144)); 242 | lblWeAreHappy.setFont(new Font("Tahoma", Font.PLAIN, 14)); 243 | lblWeAreHappy.setBounds(595, 89, 183, 17); 244 | panel.add(lblWeAreHappy); 245 | 246 | githubIconLbl = new JLabel(""); 247 | githubIconLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 248 | githubIconLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/github_logo.png"))); 249 | githubIconLbl.setForeground(new Color(112, 128, 144)); 250 | githubIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 251 | githubIconLbl.setBounds(640, 115, 23, 23); 252 | githubIconLbl.addMouseListener(this); 253 | 254 | panel.add(githubIconLbl); 255 | 256 | fbIconLbl = new JLabel(""); 257 | fbIconLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 258 | fbIconLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/facebook.png"))); 259 | fbIconLbl.setForeground(new Color(112, 128, 144)); 260 | fbIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 261 | fbIconLbl.setBounds(675, 115, 24, 24); 262 | fbIconLbl.addMouseListener(this); 263 | panel.add(fbIconLbl); 264 | 265 | twitterIconLbl = new JLabel(""); 266 | twitterIconLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 267 | twitterIconLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/twitter.png"))); 268 | twitterIconLbl.setForeground(new Color(112, 128, 144)); 269 | twitterIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 270 | twitterIconLbl.setBounds(711, 116, 24, 24); 271 | twitterIconLbl.addMouseListener(this); 272 | panel.add(twitterIconLbl); 273 | 274 | JLabel lblNewLabel_2 = new JLabel(""); 275 | lblNewLabel_2.setBackground(new Color(60, 179, 113)); 276 | lblNewLabel_2.setOpaque(true); 277 | lblNewLabel_2.setBounds(0, 0, 1200, 8); 278 | frame.getContentPane().add(lblNewLabel_2); 279 | 280 | JPanel panel_1 = new JPanel(); 281 | panel_1.setLayout(null); 282 | panel_1.setBackground(new Color(255, 255, 255)); 283 | panel_1.setBounds(0, 179, 792, 125); 284 | frame.getContentPane().add(panel_1); 285 | 286 | JSeparator separator_3 = new JSeparator(); 287 | separator_3.setBounds(0, 58, 792, 12); 288 | panel_1.add(separator_3); 289 | 290 | iconeTextCompteEnregistrerLbl = new JLabel(""); 291 | iconeTextCompteEnregistrerLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/lock_pass.png"))); 292 | iconeTextCompteEnregistrerLbl.setBounds(12, 13, 32, 32); 293 | panel_1.add(iconeTextCompteEnregistrerLbl); 294 | 295 | compteEnregistrerLbl = new JLabel("Compte enregistré"); 296 | compteEnregistrerLbl.setFont(new Font("Tahoma", Font.BOLD, 17)); 297 | compteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 298 | compteEnregistrerLbl.setHorizontalAlignment(SwingConstants.CENTER); 299 | compteEnregistrerLbl.setBounds(56, 18, 167, 22); 300 | panel_1.add(compteEnregistrerLbl); 301 | 302 | lblCompte = new JLabel("Compte"); 303 | lblCompte.setFont(new Font("Tahoma", Font.BOLD, 14)); 304 | lblCompte.setForeground(new Color(112, 128, 144)); 305 | lblCompte.setBounds(12, 72, 56, 16); 306 | panel_1.add(lblCompte); 307 | 308 | JLabel lblMotDePasse = new JLabel("Mot de passe"); 309 | lblMotDePasse.setForeground(new Color(112, 128, 144)); 310 | lblMotDePasse.setFont(new Font("Tahoma", Font.BOLD, 14)); 311 | lblMotDePasse.setBounds(246, 73, 92, 17); 312 | panel_1.add(lblMotDePasse); 313 | 314 | JLabel lblUrl = new JLabel("URL"); 315 | lblUrl.setForeground(new Color(112, 128, 144)); 316 | lblUrl.setFont(new Font("Tahoma", Font.BOLD, 14)); 317 | lblUrl.setBounds(470, 73, 91, 17); 318 | panel_1.add(lblUrl); 319 | 320 | JSeparator separator_7 = new JSeparator(); 321 | separator_7.setBounds(0, 101, 792, 12); 322 | panel_1.add(separator_7); 323 | 324 | JLabel lblAction = new JLabel("Action"); 325 | lblAction.setForeground(new Color(112, 128, 144)); 326 | lblAction.setFont(new Font("Tahoma", Font.BOLD, 14)); 327 | lblAction.setBounds(655, 72, 45, 17); 328 | panel_1.add(lblAction); 329 | 330 | JLabel label_6 = new JLabel(""); 331 | label_6.setOpaque(true); 332 | label_6.setBackground(new Color(60, 179, 113)); 333 | label_6.setBounds(0, 171, 792, 8); 334 | frame.getContentPane().add(label_6); 335 | 336 | JLabel label_1 = new JLabel(""); 337 | label_1.setOpaque(true); 338 | label_1.setBackground(new Color(60, 179, 113)); 339 | label_1.setBounds(797, 170, 403, 9); 340 | frame.getContentPane().add(label_1); 341 | 342 | JPanel panel_2 = new JPanel(); 343 | panel_2.setLayout(null); 344 | panel_2.setBackground(new Color(255, 255, 255)); 345 | panel_2.setBounds(797, 179, 403, 436); 346 | frame.getContentPane().add(panel_2); 347 | 348 | JSeparator separator_2 = new JSeparator(); 349 | separator_2.setBounds(0, 58, 792, 12); 350 | panel_2.add(separator_2); 351 | 352 | JLabel label_3 = new JLabel(""); 353 | label_3.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/editing.png"))); 354 | label_3.setBounds(12, 13, 32, 32); 355 | panel_2.add(label_3); 356 | 357 | JLabel lblEditionDeCompte = new JLabel("Edition de compte"); 358 | lblEditionDeCompte.setHorizontalAlignment(SwingConstants.CENTER); 359 | lblEditionDeCompte.setForeground(new Color(112, 128, 144)); 360 | lblEditionDeCompte.setFont(new Font("Tahoma", Font.BOLD, 17)); 361 | lblEditionDeCompte.setBounds(56, 18, 167, 22); 362 | panel_2.add(lblEditionDeCompte); 363 | 364 | JLabel lblDescription = new JLabel("Description"); 365 | lblDescription.setForeground(new Color(60, 179, 113)); 366 | lblDescription.setFont(new Font("Tahoma", Font.BOLD, 14)); 367 | lblDescription.setBounds(12, 70, 282, 16); 368 | panel_2.add(lblDescription); 369 | 370 | nomCompletEditTxtFld = new JTextField(); 371 | nomCompletEditTxtFld.setForeground(new Color(60, 179, 113)); 372 | nomCompletEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 373 | nomCompletEditTxtFld.setColumns(10); 374 | nomCompletEditTxtFld.setCaretColor(new Color(60, 179, 113)); 375 | nomCompletEditTxtFld.setBorder(null); 376 | nomCompletEditTxtFld.setBackground(new Color(255, 255, 255)); 377 | nomCompletEditTxtFld.setBounds(12, 98, 350, 16); 378 | panel_2.add(nomCompletEditTxtFld); 379 | 380 | JSeparator separator_9 = new JSeparator(); 381 | separator_9.setForeground(new Color(60, 179, 113)); 382 | separator_9.setBackground(Color.WHITE); 383 | separator_9.setBounds(12, 115, 350, 12); 384 | panel_2.add(separator_9); 385 | 386 | JLabel lblUsername = new JLabel("Username *"); 387 | lblUsername.setForeground(new Color(60, 179, 113)); 388 | lblUsername.setFont(new Font("Tahoma", Font.BOLD, 14)); 389 | lblUsername.setBounds(12, 139, 282, 16); 390 | panel_2.add(lblUsername); 391 | 392 | usernameEditTxtFld = new JTextField(); 393 | usernameEditTxtFld.setForeground(new Color(60, 179, 113)); 394 | usernameEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 395 | usernameEditTxtFld.setColumns(10); 396 | usernameEditTxtFld.setCaretColor(new Color(60, 179, 113)); 397 | usernameEditTxtFld.setBorder(null); 398 | usernameEditTxtFld.setBackground(new Color(255, 255, 255)); 399 | usernameEditTxtFld.setBounds(12, 167, 350, 16); 400 | panel_2.add(usernameEditTxtFld); 401 | 402 | JSeparator separator_10 = new JSeparator(); 403 | separator_10.setForeground(new Color(60, 179, 113)); 404 | separator_10.setBackground(Color.WHITE); 405 | separator_10.setBounds(12, 184, 350, 12); 406 | panel_2.add(separator_10); 407 | 408 | JLabel lblMotDePasse_1 = new JLabel("Mot de passe *"); 409 | lblMotDePasse_1.setForeground(new Color(60, 179, 113)); 410 | lblMotDePasse_1.setFont(new Font("Tahoma", Font.BOLD, 14)); 411 | lblMotDePasse_1.setBounds(12, 208, 282, 16); 412 | panel_2.add(lblMotDePasse_1); 413 | 414 | passwordEditTxtFld = new JPasswordField(); 415 | passwordEditTxtFld.setForeground(new Color(60, 179, 113)); 416 | passwordEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 417 | passwordEditTxtFld.setCaretColor(new Color(60, 179, 113)); 418 | passwordEditTxtFld.setBorder(null); 419 | passwordEditTxtFld.setBackground(new Color(255, 255, 255)); 420 | passwordEditTxtFld.setBounds(12, 236, 275, 16); 421 | passwordEditTxtFld.setEchoChar('*'); 422 | panel_2.add(passwordEditTxtFld); 423 | 424 | JSeparator separator_11 = new JSeparator(); 425 | separator_11.setForeground(new Color(60, 179, 113)); 426 | separator_11.setBackground(Color.WHITE); 427 | separator_11.setBounds(12, 253, 350, 12); 428 | panel_2.add(separator_11); 429 | 430 | JSeparator separator_12 = new JSeparator(); 431 | separator_12.setForeground(new Color(60, 179, 113)); 432 | separator_12.setBackground(Color.WHITE); 433 | separator_12.setBounds(12, 322, 350, 12); 434 | panel_2.add(separator_12); 435 | 436 | urlEditTxtFld = new JTextField(); 437 | urlEditTxtFld.setForeground(new Color(60, 179, 113)); 438 | urlEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 439 | urlEditTxtFld.setColumns(10); 440 | urlEditTxtFld.setCaretColor(new Color(60, 179, 113)); 441 | urlEditTxtFld.setBorder(null); 442 | urlEditTxtFld.setBackground(Color.WHITE); 443 | urlEditTxtFld.setBounds(12, 305, 350, 16); 444 | panel_2.add(urlEditTxtFld); 445 | 446 | JLabel lblUrl_1 = new JLabel("Url (sans http ou https) *"); 447 | lblUrl_1.setForeground(new Color(60, 179, 113)); 448 | lblUrl_1.setFont(new Font("Tahoma", Font.BOLD, 14)); 449 | lblUrl_1.setBounds(12, 277, 282, 16); 450 | panel_2.add(lblUrl_1); 451 | 452 | ajouterEditBtn = new JButton("Ajouter"); 453 | ajouterEditBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 454 | ajouterEditBtn.setForeground(new Color(60, 179, 113)); 455 | ajouterEditBtn.setFont(new Font("Tahoma", Font.BOLD, 14)); 456 | ajouterEditBtn.setFocusPainted(false); 457 | ajouterEditBtn.setContentAreaFilled(false); 458 | ajouterEditBtn.setBorder(new LineBorder(new Color(60, 179, 113))); 459 | ajouterEditBtn.setActionCommand("ajouterEditBtn"); 460 | ajouterEditBtn.setBounds(12, 356, 200, 40); 461 | ajouterEditBtn.addActionListener(this); 462 | panel_2.add(ajouterEditBtn); 463 | 464 | iconViewOrHidePasswordEditLbl = new JLabel(""); 465 | iconViewOrHidePasswordEditLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 466 | iconViewOrHidePasswordEditLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye.png"))); 467 | iconViewOrHidePasswordEditLbl.setForeground(new Color(112, 128, 144)); 468 | iconViewOrHidePasswordEditLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 469 | iconViewOrHidePasswordEditLbl.setBounds(303, 233, 23, 23); 470 | iconViewOrHidePasswordEditLbl.addMouseListener(this); 471 | panel_2.add(iconViewOrHidePasswordEditLbl); 472 | 473 | clearEditBtn = new JButton("Clear"); 474 | clearEditBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 475 | clearEditBtn.setForeground(new Color(60, 179, 113)); 476 | clearEditBtn.setFont(new Font("Tahoma", Font.BOLD, 14)); 477 | clearEditBtn.setFocusPainted(false); 478 | clearEditBtn.setContentAreaFilled(false); 479 | clearEditBtn.setBorder(new LineBorder(new Color(60, 179, 113))); 480 | clearEditBtn.setActionCommand("clearEditBtn"); 481 | clearEditBtn.addActionListener(this); 482 | clearEditBtn.setBounds(224, 356, 138, 40); 483 | panel_2.add(clearEditBtn); 484 | 485 | idAccountEditLbl = new JLabel(""); 486 | idAccountEditLbl.setForeground(new Color(60, 179, 113)); 487 | idAccountEditLbl.setFont(new Font("Tahoma", Font.BOLD, 14)); 488 | idAccountEditLbl.setBounds(306, 71, 56, 16); 489 | idAccountEditLbl.setVisible(false); 490 | panel_2.add(idAccountEditLbl); 491 | 492 | iconGeneratePasswordEditLbl = new JLabel(""); 493 | iconGeneratePasswordEditLbl.setToolTipText("Cliquer pour générer un mot de passe fort"); 494 | iconGeneratePasswordEditLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 495 | iconGeneratePasswordEditLbl.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/passgenerator.png"))); 496 | iconGeneratePasswordEditLbl.setForeground(new Color(112, 128, 144)); 497 | iconGeneratePasswordEditLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 498 | iconGeneratePasswordEditLbl.setBounds(338, 228, 24, 24); 499 | iconGeneratePasswordEditLbl.addMouseListener(this); 500 | panel_2.add(iconGeneratePasswordEditLbl); 501 | 502 | JPanel panelGeneralViewAllItems = new JPanel(); 503 | panelGeneralViewAllItems.setBackground(Color.WHITE); 504 | panelGeneralViewAllItems.setBounds(0, 302, 792, 313); 505 | 506 | // panelViewAllItems = createItemPanel(); 507 | 508 | JScrollPane spViewallItems = new JScrollPane(); 509 | spViewallItems.setBorder(null); 510 | spViewallItems.setBackground(Color.WHITE); 511 | spViewallItems.setViewportView(createItemPanel()); 512 | 513 | panelGeneralViewAllItems.setLayout(new BorderLayout()); 514 | panelGeneralViewAllItems.add(spViewallItems, BorderLayout.CENTER); 515 | 516 | frame.getContentPane().add(panelGeneralViewAllItems); 517 | 518 | } 519 | 520 | JPanel createItemPanelTest() { 521 | 522 | JPanel panelViewAllItems = new JPanel(); 523 | panelViewAllItems.setBackground(Color.WHITE); 524 | panelViewAllItems.setLayout(null); 525 | 526 | int j = 35; 527 | int k = 32; 528 | int z = 32; 529 | int length = 2; 530 | for (int i = 0; i < length; i++) { 531 | 532 | JLabel firstNameLbl = new JLabel("First name " + i); 533 | firstNameLbl.setBounds(131, j, 101, 16); 534 | 535 | JTextField firstNameTf = new JTextField(); 536 | firstNameTf.setBounds(291, k, 219, 22); 537 | 538 | panelViewAllItems.add(firstNameLbl); 539 | panelViewAllItems.add(firstNameTf); 540 | 541 | j = j + z; 542 | k = k + z; 543 | } 544 | 545 | panelViewAllItems.setPreferredSize(new Dimension(500, 1000)); 546 | 547 | return panelViewAllItems; 548 | } 549 | 550 | JPanel createItemPanel() { 551 | 552 | JPanel panel_3 = new JPanel(); 553 | panel_3.setLayout(null); 554 | panel_3.setBackground(Color.WHITE); 555 | panel_3.setBounds(0, 191, 792, 70); 556 | 557 | int debutCpUsername = 6; 558 | int debutCpPassword = 6; 559 | int debutCpIconViewPassword = 6; 560 | int debutCpUrl = 6; 561 | int debutCpIconEditUpdate = 16; 562 | int debutCpIconeDelete = 16; 563 | int debutCpEtatUrl = 32; 564 | int debutCpEtatPassword = 32; 565 | int debutCpNomComplet = 32; 566 | int debutCpSeparator = 58; 567 | int incrementNouvelleLigne = 67; 568 | int i; 569 | System.out.println("Name utilisateur est : " + userNameLbl.getText()); 570 | System.out.println("email utilisateur est : " + userEmailLbl.getText()); 571 | // System.out.println("User toString est " + user.toString()); 572 | 573 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 574 | 575 | try { 576 | accounts = accountDaoImpl.retrieveAllAccountsByUserId(user.getIdentifiantUser()); 577 | // Nombre d'enregistrement disponible pour l'utilisateur connecté 578 | chiffreNbreCompteEnregistrerLbl.setText(String.valueOf(accounts.size())); 579 | for (AccountBean accountBean : accounts) { 580 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) 581 | && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 582 | JTextField usernameItemTf; 583 | JPasswordField passwordItemTf; 584 | JTextField urlItemTf; 585 | JTextField etatUrlItemTf; 586 | JTextField etatPasswordItemTf; 587 | JTextField nomCompletItemTf; 588 | 589 | usernameItemTf = new JTextField(); 590 | usernameItemTf.setText(accountBean.getUsernameAccount()); 591 | usernameItemTf.setForeground(new Color(112, 128, 144)); 592 | usernameItemTf.setFont(new Font("Tahoma", Font.BOLD, 15)); 593 | usernameItemTf.setEditable(false); 594 | usernameItemTf.setColumns(10); 595 | usernameItemTf.setBorder(null); 596 | usernameItemTf.setBackground(Color.WHITE); 597 | usernameItemTf.setBounds(12, debutCpUsername, 211, 22); 598 | panel_3.add(usernameItemTf); 599 | 600 | passwordItemTf = new JPasswordField(); 601 | passwordItemTf.setText(accountBean.getPasswordAccount()); 602 | passwordItemTf.setForeground(new Color(112, 128, 144)); 603 | passwordItemTf.setFont(new Font("Tahoma", Font.BOLD, 15)); 604 | passwordItemTf.setEditable(false); 605 | passwordItemTf.setColumns(10); 606 | passwordItemTf.setEchoChar('*'); 607 | passwordItemTf.setBorder(null); 608 | passwordItemTf.setBackground(Color.WHITE); 609 | passwordItemTf.setBounds(246, debutCpPassword, 150, 22); 610 | panel_3.add(passwordItemTf); 611 | 612 | JLabel iconViewPasswordItem = new JLabel(""); 613 | iconViewPasswordItem.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 614 | iconViewPasswordItem.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye.png"))); 615 | iconViewPasswordItem.setForeground(new Color(112, 128, 144)); 616 | iconViewPasswordItem.setFont(new Font("Tahoma", Font.BOLD, 16)); 617 | iconViewPasswordItem.setBounds(408, debutCpIconViewPassword, 23, 23); 618 | panel_3.add(iconViewPasswordItem); 619 | 620 | urlItemTf = new JTextField(); 621 | urlItemTf.setText(accountBean.getUrlAccount()); 622 | urlItemTf.setForeground(new Color(112, 128, 144)); 623 | urlItemTf.setFont(new Font("Tahoma", Font.BOLD, 15)); 624 | urlItemTf.setEditable(false); 625 | urlItemTf.setColumns(10); 626 | urlItemTf.setBorder(null); 627 | urlItemTf.setBackground(Color.WHITE); 628 | urlItemTf.setBounds(470, debutCpUrl, 160, 22); 629 | panel_3.add(urlItemTf); 630 | 631 | // String message = "Item url " + i; 632 | 633 | JLabel iconEditupdateItem = new JLabel(""); 634 | iconEditupdateItem.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 635 | iconEditupdateItem.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/edit_icon.png"))); 636 | iconEditupdateItem.setBounds(655, debutCpIconEditUpdate, 30, 30); 637 | panel_3.add(iconEditupdateItem); 638 | 639 | JLabel iconeDeleteItem = new JLabel(""); 640 | iconeDeleteItem.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 641 | iconeDeleteItem.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/delete_icon.png"))); 642 | iconeDeleteItem.setBounds(704, debutCpIconeDelete, 30, 30); 643 | panel_3.add(iconeDeleteItem); 644 | 645 | etatUrlItemTf = new JTextField(); 646 | etatUrlItemTf.setText("Site fiable"); 647 | etatUrlItemTf.setForeground(new Color(112, 128, 144)); 648 | etatUrlItemTf.setFont(new Font("Tahoma", Font.PLAIN, 14)); 649 | etatUrlItemTf.setEditable(false); 650 | etatUrlItemTf.setColumns(10); 651 | etatUrlItemTf.setBorder(null); 652 | etatUrlItemTf.setBackground(Color.WHITE); 653 | etatUrlItemTf.setBounds(470, debutCpEtatUrl, 150, 22); 654 | panel_3.add(etatUrlItemTf); 655 | 656 | etatPasswordItemTf = new JTextField(); 657 | etatPasswordItemTf.setText("Faible"); 658 | etatPasswordItemTf.setForeground(new Color(112, 128, 144)); 659 | etatPasswordItemTf.setFont(new Font("Tahoma", Font.PLAIN, 14)); 660 | etatPasswordItemTf.setEditable(false); 661 | etatPasswordItemTf.setColumns(10); 662 | etatPasswordItemTf.setBorder(null); 663 | etatPasswordItemTf.setBackground(Color.WHITE); 664 | etatPasswordItemTf.setBounds(246, debutCpEtatPassword, 150, 22); 665 | panel_3.add(etatPasswordItemTf); 666 | 667 | passwordStrongTest(etatPasswordItemTf, passwordItemTf); 668 | 669 | nomCompletItemTf = new JTextField(); 670 | nomCompletItemTf.setText(accountBean.getNameAccount()); 671 | nomCompletItemTf.setForeground(new Color(112, 128, 144)); 672 | nomCompletItemTf.setFont(new Font("Tahoma", Font.PLAIN, 14)); 673 | nomCompletItemTf.setEditable(false); 674 | nomCompletItemTf.setColumns(10); 675 | nomCompletItemTf.setBorder(null); 676 | nomCompletItemTf.setBackground(Color.WHITE); 677 | nomCompletItemTf.setBounds(12, debutCpNomComplet, 211, 22); 678 | panel_3.add(nomCompletItemTf); 679 | 680 | JSeparator separatorItem = new JSeparator(); 681 | separatorItem.setBounds(0, debutCpSeparator, 759, 7); 682 | panel_3.add(separatorItem); 683 | 684 | urlItemTf.addMouseListener(new MouseListener() { 685 | 686 | @Override 687 | public void mouseReleased(MouseEvent e) { 688 | // TODO Auto-generated method stub 689 | 690 | } 691 | 692 | @Override 693 | public void mousePressed(MouseEvent e) { 694 | // TODO Auto-generated method stub 695 | 696 | } 697 | 698 | @Override 699 | public void mouseExited(MouseEvent e) { 700 | // TODO Auto-generated method stub 701 | 702 | } 703 | 704 | @Override 705 | public void mouseEntered(MouseEvent e) { 706 | // TODO Auto-generated method stub 707 | 708 | } 709 | 710 | @Override 711 | public void mouseClicked(MouseEvent e) { 712 | // Utils.showErrorMessage(frame, message); 713 | Utils.openWebpage("http://" + urlItemTf.getText()); 714 | } 715 | }); 716 | 717 | iconEditupdateItem.addMouseListener(new MouseListener() { 718 | 719 | @Override 720 | public void mouseReleased(MouseEvent e) { 721 | // TODO Auto-generated method stub 722 | 723 | } 724 | 725 | @Override 726 | public void mousePressed(MouseEvent e) { 727 | // TODO Auto-generated method stub 728 | 729 | } 730 | 731 | @Override 732 | public void mouseExited(MouseEvent e) { 733 | // TODO Auto-generated method stub 734 | 735 | } 736 | 737 | @Override 738 | public void mouseEntered(MouseEvent e) { 739 | // TODO Auto-generated method stub 740 | 741 | } 742 | 743 | @Override 744 | public void mouseClicked(MouseEvent e) { 745 | // TODO Auto-generated method stub 746 | idAccountEditLbl.setText(accountBean.getIdentifiantAccount()); 747 | nomCompletEditTxtFld.setText(nomCompletItemTf.getText()); 748 | usernameEditTxtFld.setText(usernameItemTf.getText()); 749 | passwordEditTxtFld.setText(passwordItemTf.getText()); 750 | urlEditTxtFld.setText(urlItemTf.getText()); 751 | 752 | ajouterEditBtn.setText("Mettre à jour "); 753 | ajouterEditBtn.setActionCommand("majEditBtn"); 754 | 755 | } 756 | }); 757 | 758 | iconeDeleteItem.addMouseListener(new MouseListener() { 759 | 760 | @Override 761 | public void mouseReleased(MouseEvent e) { 762 | // TODO Auto-generated method stub 763 | 764 | } 765 | 766 | @Override 767 | public void mousePressed(MouseEvent e) { 768 | // TODO Auto-generated method stub 769 | 770 | } 771 | 772 | @Override 773 | public void mouseExited(MouseEvent e) { 774 | // TODO Auto-generated method stub 775 | 776 | } 777 | 778 | @Override 779 | public void mouseEntered(MouseEvent e) { 780 | // TODO Auto-generated method stub 781 | 782 | } 783 | 784 | @Override 785 | public void mouseClicked(MouseEvent e) { 786 | // TODO Auto-generated method stub 787 | // Utils.showErrorMessage(frame, "Identifiant du compte " + 788 | // accountBean.getUsernameAccount() + " est " + 789 | // accountBean.getIdentifiantAccount()); 790 | deleteAccount(accountBean); 791 | } 792 | }); 793 | 794 | iconViewPasswordItem.addMouseListener(new MouseListener() { 795 | 796 | @Override 797 | public void mouseReleased(MouseEvent e) { 798 | // TODO Auto-generated method stub 799 | 800 | } 801 | 802 | @Override 803 | public void mousePressed(MouseEvent e) { 804 | // TODO Auto-generated method stub 805 | 806 | } 807 | 808 | @Override 809 | public void mouseExited(MouseEvent e) { 810 | // TODO Auto-generated method stub 811 | 812 | } 813 | 814 | @Override 815 | public void mouseEntered(MouseEvent e) { 816 | // TODO Auto-generated method stub 817 | 818 | } 819 | 820 | @Override 821 | public void mouseClicked(MouseEvent e) { 822 | // TODO Auto-generated method stub 823 | Utils.showOrHidePasswordTxtFields(passwordItemTf, iconViewPasswordItem, '*'); 824 | } 825 | }); 826 | 827 | debutCpUsername = debutCpUsername + incrementNouvelleLigne; 828 | debutCpPassword = debutCpPassword + incrementNouvelleLigne; 829 | debutCpIconViewPassword = debutCpIconViewPassword + incrementNouvelleLigne; 830 | debutCpUrl = debutCpUrl + incrementNouvelleLigne; 831 | debutCpIconEditUpdate = debutCpIconEditUpdate + incrementNouvelleLigne; 832 | debutCpIconeDelete = debutCpIconeDelete + incrementNouvelleLigne; 833 | debutCpEtatUrl = debutCpEtatUrl + incrementNouvelleLigne; 834 | debutCpEtatPassword = debutCpEtatPassword + incrementNouvelleLigne; 835 | debutCpNomComplet = debutCpNomComplet + incrementNouvelleLigne; 836 | debutCpSeparator = debutCpSeparator + incrementNouvelleLigne; 837 | } else { 838 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 839 | } 840 | } 841 | 842 | } catch (Exception e) { 843 | // TODO Auto-generated catch block 844 | e.printStackTrace(); 845 | } 846 | 847 | panel_3.setPreferredSize(new Dimension(0, 1000)); 848 | panel_3.revalidate(); 849 | panel_3.repaint(); 850 | 851 | return panel_3; 852 | } 853 | 854 | @Override 855 | public void actionPerformed(ActionEvent e) { 856 | // TODO Auto-generated method stub 857 | if ("ajouterEditBtn".equals(e.getActionCommand())) { 858 | ajoutDunNouveauCompte(); 859 | } else if ("majEditBtn".equals(e.getActionCommand())) { 860 | // Utils.showSuccessMessage(frame, idAccountEditLbl.getText()); 861 | majDunCompteExistant(); 862 | } else if ("clearEditBtn".equals(e.getActionCommand())) { 863 | clearAllTfEdit(); 864 | } 865 | } 866 | 867 | @Override 868 | public void mouseClicked(MouseEvent e) { 869 | // TODO Auto-generated method stub 870 | JLabel source = (JLabel) e.getSource(); 871 | if (githubIconLbl == source) { 872 | Utils.openWebpage(Constants.URL_GITHUB); 873 | } else if (fbIconLbl == source) { 874 | Utils.openWebpage(Constants.URL_FACEBOOK); 875 | } else if (twitterIconLbl == source) { 876 | Utils.openWebpage(Constants.URL_TWITTER); 877 | } else if (disconnectLbl == source) { 878 | userDisconnect(); 879 | } else if (iconViewOrHidePasswordEditLbl == source) { 880 | Utils.showOrHidePasswordTxtFields(passwordEditTxtFld, iconViewOrHidePasswordEditLbl, '*'); 881 | 882 | // iconViewOrHidePasswordEditLbl.getIcon().toString(); 883 | } else if (iconGeneratePasswordEditLbl == source) { 884 | passwordEditTxtFld.setText(Utils.generatePassword()); 885 | } 886 | } 887 | 888 | private void showOrHidePasswordTxtFields(JPasswordField passwordField) { 889 | // TODO Auto-generated method stub 890 | 891 | } 892 | 893 | @Override 894 | public void mousePressed(MouseEvent e) { 895 | // TODO Auto-generated method stub 896 | 897 | } 898 | 899 | @Override 900 | public void mouseReleased(MouseEvent e) { 901 | // TODO Auto-generated method stub 902 | } 903 | 904 | @Override 905 | public void mouseEntered(MouseEvent e) { 906 | // TODO Auto-generated method stub 907 | 908 | } 909 | 910 | @Override 911 | public void mouseExited(MouseEvent e) { 912 | // TODO Auto-generated method stub 913 | 914 | } 915 | 916 | private void majDunCompteExistant() { 917 | // TODO Auto-generated method stub 918 | if (verificationNulliteEtTailleDesChamps()) { 919 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 920 | // userBean.setIdentifiantUser("c858cfb2-e53b-43cf-bc81-66cb85b8fdd0"); 921 | // AccountBean accountBean = new 922 | // AccountBean("895a61c1-0f6c-495e-8bee-2d92cbfee28c","Assetou DIARRA KADI", 923 | // "setou.s@gmail.com", "12345678", "https://www.youtube.com/", userBean); 924 | AccountBean accountSelected = new AccountBean(); 925 | try { 926 | accountSelected.setIdentifiantAccount(idAccountEditLbl.getText().toString()); 927 | accountSelected.setUserBean(user); 928 | accountSelected.setNameAccount(nomCompletEditTxtFld.getText().toString()); 929 | accountSelected.setUsernameAccount(usernameEditTxtFld.getText().toString()); 930 | accountSelected.setPasswordAccount(passwordEditTxtFld.getText()); 931 | accountSelected.setUrlAccount(urlEditTxtFld.getText().toString()); 932 | accountSelected = accountDaoImpl.updateAccount(accountSelected); 933 | if ((accountSelected.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) 934 | && (accountSelected.getCallDbFunctionBean().isErrorRetour() == false)) { 935 | ajouterEditBtn.setActionCommand("ajouterEditBtn"); 936 | ajouterEditBtn.setText("Ajouter"); 937 | 938 | nomCompletEditTxtFld.setText(""); 939 | usernameEditTxtFld.setText(""); 940 | passwordEditTxtFld.setText(""); 941 | urlEditTxtFld.setText(""); 942 | 943 | refreshFrame(); 944 | 945 | System.out.println("Identifiant utilisateur " + accountSelected.getUserBean().getIdentifiantUser()); 946 | System.out 947 | .println("Message de retour " + accountSelected.getCallDbFunctionBean().getMessageRetour()); 948 | } else { 949 | System.out.println(accountSelected.getCallDbFunctionBean().getMessageRetour()); 950 | } 951 | 952 | } catch (Exception e) { 953 | // TODO Auto-generated catch block 954 | e.printStackTrace(); 955 | } 956 | } 957 | // Après la mise à jour d'un compte existant 958 | // Je rafraichis la fenetre d'affichage des items pour prendre en compte la 959 | // modification 960 | // Je fais un set de ajouterEditBtn.setActionCommand("ajouterEditBtn"); 961 | // Je fais un set de ajouterEditBtn.setText("Ajouter"); 962 | // Je fais un set "" de tous les champs. 963 | } 964 | 965 | private void ajoutDunNouveauCompte() { 966 | // TODO Auto-generated method stub 967 | if (verificationNulliteEtTailleDesChamps()) { 968 | // Je fais un set "" de tous les champs après un ajout. 969 | // nomCompletEditTxtFld 970 | UserBean userBean = new UserBean(); 971 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 972 | userBean.setIdentifiantUser(user.getIdentifiantUser()); 973 | AccountBean accountBean = new AccountBean(nomCompletEditTxtFld.getText(), usernameEditTxtFld.getText(), 974 | passwordEditTxtFld.getText(), urlEditTxtFld.getText(), userBean); 975 | try { 976 | accountBean = accountDaoImpl.insertAccount(accountBean); 977 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) 978 | && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 979 | System.out.println("Username du compte ajouter " + accountBean.getUsernameAccount()); 980 | System.out.println("Identifiant utilisateur " + accountBean.getUserBean().getIdentifiantUser()); 981 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 982 | 983 | nomCompletEditTxtFld.setText(""); 984 | usernameEditTxtFld.setText(""); 985 | passwordEditTxtFld.setText(""); 986 | urlEditTxtFld.setText(""); 987 | // accounts.add(accountBean); 988 | // panelViewAllItems.repaint(); 989 | // panelViewAllItems.revalidate(); 990 | // panelViewAllItems = createItemPanel(); 991 | 992 | refreshFrame(); 993 | 994 | // createItemPanel(); 995 | // Utils.refreshFrame(frame); 996 | // createItemPanel(); 997 | } else { 998 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 999 | } 1000 | 1001 | } catch (Exception e) { 1002 | // TODO Auto-generated catch block 1003 | e.printStackTrace(); 1004 | } 1005 | } 1006 | } 1007 | 1008 | public void clearAllTfEdit() { 1009 | nomCompletEditTxtFld.setText(""); 1010 | usernameEditTxtFld.setText(""); 1011 | passwordEditTxtFld.setText(""); 1012 | urlEditTxtFld.setText(""); 1013 | 1014 | ajouterEditBtn.setText("Ajouter "); 1015 | ajouterEditBtn.setActionCommand("ajouterEditBtn"); 1016 | } 1017 | 1018 | public void userDisconnect() { 1019 | int retourUser = Utils.showConfirmDialog(frame, 1020 | "Vous êtes sur le point de vous déconnecter, cliquez sur oui pour continuer !"); 1021 | if (retourUser == 0) { 1022 | AuthenticationUI windowAuthUI = new AuthenticationUI(); 1023 | frame.dispose(); 1024 | windowAuthUI.frame.setVisible(true); 1025 | } 1026 | } 1027 | 1028 | public void deleteAccount(AccountBean accountSelected) { 1029 | AccountDaoImpl accountDaoImpl = new AccountDaoImpl(); 1030 | AccountBean accountBean = new AccountBean(); 1031 | try { 1032 | accountBean = accountDaoImpl.deleteAccountById(accountSelected.getIdentifiantAccount()); 1033 | int retourUser = Utils.showConfirmDialog(frame, "Voulez vous supprimer le compte " 1034 | + accountSelected.getUsernameAccount() + ", cliquez sur oui pour continuer !"); 1035 | if (retourUser == 0) { 1036 | 1037 | if ((accountBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) 1038 | && (accountBean.getCallDbFunctionBean().isErrorRetour() == false)) { 1039 | refreshFrame(); 1040 | 1041 | System.out.println("Message de retour " + accountBean.getCallDbFunctionBean().getMessageRetour()); 1042 | } else { 1043 | System.out.println(accountBean.getCallDbFunctionBean().getMessageRetour()); 1044 | } 1045 | } 1046 | 1047 | } catch (Exception e) { 1048 | // TODO Auto-generated catch block 1049 | e.printStackTrace(); 1050 | } 1051 | } 1052 | 1053 | private boolean verificationNulliteEtTailleDesChamps() { 1054 | String nom = nomCompletEditTxtFld.getText().toString(); 1055 | String username = usernameEditTxtFld.getText().toString(); 1056 | String mdp = passwordEditTxtFld.getText().toString(); 1057 | String url = urlEditTxtFld.getText().toString(); 1058 | if ((!Utils.isNullOrEmpty(username) && (!Utils.isNullOrEmpty(mdp) && (!Utils.isNullOrEmpty(url))))) { 1059 | if (Utils.checkStringMinLength(username, 2)) { 1060 | if (Utils.checkStringMinLength(mdp, 6)) { 1061 | if (Utils.checkStringMinLength(url, 4)) { 1062 | return true; 1063 | } else { 1064 | Utils.showErrorMessage(frame, "L'url doit être au minimum 4 caractères !"); 1065 | return false; 1066 | } 1067 | } else { 1068 | Utils.showErrorMessage(frame, 1069 | "Le mot de passe doit être au minimum six caractères, vous pouvez générer un \nbon mot de passe en cliquant sur l'icone de génération à droite "); 1070 | return false; 1071 | } 1072 | 1073 | } else { 1074 | Utils.showErrorMessage(frame, "Le username doit être au minimum deux caractères"); 1075 | return false; 1076 | } 1077 | 1078 | } else { 1079 | Utils.showErrorMessage(frame, "Veuillez remplir les champs obligatoire suivie d'étoile !"); 1080 | return false; 1081 | } 1082 | } 1083 | 1084 | public void passwordStrongTest(JTextField textField, JPasswordField passwordField) { 1085 | String passwordFieldTxt = passwordField.getText(); 1086 | if (passwordFieldTxt.length() <= 6) { 1087 | textField.setText("Faible"); 1088 | } else if ((passwordFieldTxt.length() > 6) && (passwordFieldTxt.length() <= 10)) { 1089 | textField.setText("Moyen"); 1090 | } else if (passwordFieldTxt.length() > 10) { 1091 | textField.setText("Fort"); 1092 | } 1093 | } 1094 | 1095 | public void refreshFrame() { 1096 | AdminUI adminUI = new AdminUI(user); 1097 | frame.dispose(); 1098 | adminUI.frame.setVisible(true); 1099 | } 1100 | } 1101 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/AdminUI_OLD.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JTextField; 7 | 8 | import bean.AccountItemView; 9 | import bean.UserBean; 10 | 11 | import javax.swing.JLabel; 12 | import javax.swing.JPanel; 13 | import java.awt.Color; 14 | import java.awt.Font; 15 | import java.awt.GridBagLayout; 16 | import java.awt.event.MouseEvent; 17 | import java.awt.event.MouseListener; 18 | 19 | import javax.swing.border.LineBorder; 20 | import javax.swing.border.EtchedBorder; 21 | import javax.swing.DefaultListModel; 22 | import javax.swing.ImageIcon; 23 | import javax.swing.JSeparator; 24 | import javax.swing.SwingConstants; 25 | import java.awt.Cursor; 26 | import javax.swing.JScrollBar; 27 | import javax.swing.JScrollPane; 28 | import javax.swing.JPasswordField; 29 | import javax.swing.JButton; 30 | import javax.swing.JList; 31 | import javax.swing.AbstractListModel; 32 | 33 | public class AdminUI_OLD { 34 | 35 | public JFrame frame; 36 | JLabel userNameLbl; 37 | JLabel userEmailLbl; 38 | private final JPanel panel = new JPanel(); 39 | private JTextField passwordItemTxtFld; 40 | private JTextField usernameItemTxtFld; 41 | private JTextField urlItemTxtFld; 42 | private JTextField nomCompletItemTxtFld; 43 | private JTextField etatPasswordItemTxtFld; 44 | private JTextField etatUrlItemTxtFld; 45 | private JTextField nomCompletEditTxtFld; 46 | private JTextField usernameEditTxtFld; 47 | private JPasswordField passwordEditTxtFld; 48 | private JTextField urlEditTxtFld; 49 | private JTextField textField; 50 | private JTextField textField_1; 51 | private JTextField textField_2; 52 | private JTextField textField_3; 53 | private JTextField textField_4; 54 | private JTextField textField_5; 55 | 56 | /** 57 | * Launch the application. 58 | */ 59 | public static void main(String[] args) { 60 | EventQueue.invokeLater(new Runnable() { 61 | public void run() { 62 | try { 63 | AdminUI_OLD window = new AdminUI_OLD(); 64 | window.frame.setVisible(true); 65 | } catch (Exception e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | }); 70 | } 71 | 72 | /** 73 | * Create the application. 74 | */ 75 | public AdminUI_OLD() { 76 | initialize(); 77 | } 78 | 79 | public AdminUI_OLD(UserBean userBean) { 80 | initialize(); 81 | 82 | userNameLbl.setText(userBean.getNameUser()); 83 | userEmailLbl.setText(userBean.getEmailUser()); 84 | 85 | } 86 | 87 | /** 88 | * Initialize the contents of the frame. 89 | */ 90 | private void initialize() { 91 | frame = new JFrame(); 92 | frame.setResizable(false); 93 | frame.getContentPane().setBackground(new Color(230, 230, 250)); 94 | frame.setBounds(100, 100, 1200, 650); 95 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 96 | frame.getContentPane().setLayout(null); 97 | panel.setBackground(new Color(255, 255, 255)); 98 | panel.setBounds(0, 8, 1200, 150); 99 | frame.getContentPane().add(panel); 100 | panel.setLayout(null); 101 | 102 | JLabel userIconLbl = new JLabel(""); 103 | userIconLbl.setHorizontalAlignment(SwingConstants.CENTER); 104 | userIconLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/user.png"))); 105 | userIconLbl.setBounds(1016, 13, 60, 60); 106 | panel.add(userIconLbl); 107 | 108 | userNameLbl = new JLabel("DIARRA SOUMAILA A"); 109 | userNameLbl.setHorizontalAlignment(SwingConstants.CENTER); 110 | userNameLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 111 | userNameLbl.setForeground(new Color(112, 128, 144)); 112 | userNameLbl.setBounds(917, 86, 259, 20); 113 | panel.add(userNameLbl); 114 | 115 | userEmailLbl = new JLabel("diarra176@gmail.com"); 116 | userEmailLbl.setHorizontalAlignment(SwingConstants.CENTER); 117 | userEmailLbl.setForeground(new Color(60, 179, 113)); 118 | userEmailLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 119 | userEmailLbl.setBounds(917, 115, 259, 17); 120 | panel.add(userEmailLbl); 121 | 122 | JSeparator separator = new JSeparator(); 123 | separator.setOrientation(SwingConstants.VERTICAL); 124 | separator.setBounds(895, 0, 10, 150); 125 | panel.add(separator); 126 | 127 | JLabel label = new JLabel(""); 128 | label.setHorizontalAlignment(SwingConstants.CENTER); 129 | label.setBounds(78, 24, 64, 64); 130 | panel.add(label); 131 | label.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/pm_logo64.png"))); 132 | label.setForeground(Color.WHITE); 133 | label.setFont(new Font("Tahoma", Font.BOLD, 14)); 134 | label.setBorder(null); 135 | label.setAlignmentX(0.5f); 136 | 137 | JLabel lblPasswordManager = new JLabel("\r\nPassword Manager\r\n"); 138 | lblPasswordManager.setForeground(new Color(112, 128, 144)); 139 | lblPasswordManager.setFont(new Font("Tahoma", Font.BOLD, 16)); 140 | lblPasswordManager.setBounds(31, 99, 154, 20); 141 | panel.add(lblPasswordManager); 142 | 143 | JSeparator separator_1 = new JSeparator(); 144 | separator_1.setOrientation(SwingConstants.VERTICAL); 145 | separator_1.setBounds(208, 0, 10, 150); 146 | panel.add(separator_1); 147 | 148 | JLabel lblBienvenue = new JLabel("SOUMGRAPHIC PASSWORD MANAGER DASHBOARD"); 149 | lblBienvenue.setForeground(new Color(112, 128, 144)); 150 | lblBienvenue.setFont(new Font("Tahoma", Font.BOLD, 16)); 151 | lblBienvenue.setBounds(273, 29, 424, 20); 152 | panel.add(lblBienvenue); 153 | 154 | JLabel lblNewLabel_3 = new JLabel(""); 155 | lblNewLabel_3.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/dashboard.png"))); 156 | lblNewLabel_3.setBounds(230, 24, 30, 30); 157 | panel.add(lblNewLabel_3); 158 | 159 | JSeparator separator_4 = new JSeparator(); 160 | separator_4.setBounds(214, 61, 688, 12); 161 | panel.add(separator_4); 162 | 163 | JLabel scoreSecuriteLbl = new JLabel("Score de sécurité"); 164 | scoreSecuriteLbl.setForeground(new Color(112, 128, 144)); 165 | scoreSecuriteLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 166 | scoreSecuriteLbl.setBounds(228, 88, 105, 17); 167 | panel.add(scoreSecuriteLbl); 168 | 169 | JLabel scoreSecuritePourcentageLbl = new JLabel("74%"); 170 | scoreSecuritePourcentageLbl.setFont(new Font("Tahoma", Font.BOLD, 18)); 171 | scoreSecuritePourcentageLbl.setForeground(new Color(112, 128, 144)); 172 | scoreSecuritePourcentageLbl.setBounds(259, 111, 44, 22); 173 | panel.add(scoreSecuritePourcentageLbl); 174 | 175 | JSeparator separator_5 = new JSeparator(); 176 | separator_5.setOrientation(SwingConstants.VERTICAL); 177 | separator_5.setBounds(355, 72, 10, 78); 178 | panel.add(separator_5); 179 | 180 | JLabel disconnectLbl = new JLabel(""); 181 | disconnectLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 182 | disconnectLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/logout.png"))); 183 | disconnectLbl.setHorizontalAlignment(SwingConstants.CENTER); 184 | disconnectLbl.setBounds(812, 77, 64, 64); 185 | panel.add(disconnectLbl); 186 | 187 | JSeparator separator_6 = new JSeparator(); 188 | separator_6.setOrientation(SwingConstants.VERTICAL); 189 | separator_6.setBounds(790, 71, 10, 78); 190 | panel.add(separator_6); 191 | 192 | JLabel nbreCompteEnregistrerLbl = new JLabel("Nombre de compte enregistré"); 193 | nbreCompteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 194 | nbreCompteEnregistrerLbl.setFont(new Font("Tahoma", Font.PLAIN, 14)); 195 | nbreCompteEnregistrerLbl.setBounds(377, 86, 183, 17); 196 | panel.add(nbreCompteEnregistrerLbl); 197 | 198 | JLabel chiffreNbreCompteEnregistrerLbl = new JLabel("10"); 199 | chiffreNbreCompteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 200 | chiffreNbreCompteEnregistrerLbl.setFont(new Font("Tahoma", Font.BOLD, 18)); 201 | chiffreNbreCompteEnregistrerLbl.setBounds(457, 111, 22, 22); 202 | panel.add(chiffreNbreCompteEnregistrerLbl); 203 | 204 | JSeparator separator_8 = new JSeparator(); 205 | separator_8.setOrientation(SwingConstants.VERTICAL); 206 | separator_8.setBounds(572, 72, 10, 78); 207 | panel.add(separator_8); 208 | 209 | JLabel lblWeAreHappy = new JLabel("We are happy you like it !"); 210 | lblWeAreHappy.setHorizontalAlignment(SwingConstants.CENTER); 211 | lblWeAreHappy.setForeground(new Color(112, 128, 144)); 212 | lblWeAreHappy.setFont(new Font("Tahoma", Font.PLAIN, 14)); 213 | lblWeAreHappy.setBounds(595, 89, 183, 17); 214 | panel.add(lblWeAreHappy); 215 | 216 | JLabel githubIconLbl = new JLabel(""); 217 | githubIconLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/github_logo.png"))); 218 | githubIconLbl.setForeground(new Color(112, 128, 144)); 219 | githubIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 220 | githubIconLbl.setBounds(640, 115, 23, 23); 221 | panel.add(githubIconLbl); 222 | 223 | JLabel fbIconLbl = new JLabel(""); 224 | fbIconLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/facebook.png"))); 225 | fbIconLbl.setForeground(new Color(112, 128, 144)); 226 | fbIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 227 | fbIconLbl.setBounds(675, 115, 24, 24); 228 | panel.add(fbIconLbl); 229 | 230 | JLabel twitterIconLbl = new JLabel(""); 231 | twitterIconLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/twitter.png"))); 232 | twitterIconLbl.setForeground(new Color(112, 128, 144)); 233 | twitterIconLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 234 | twitterIconLbl.setBounds(711, 116, 24, 24); 235 | panel.add(twitterIconLbl); 236 | 237 | JLabel lblNewLabel_2 = new JLabel(""); 238 | lblNewLabel_2.setBackground(new Color(60, 179, 113)); 239 | lblNewLabel_2.setOpaque(true); 240 | lblNewLabel_2.setBounds(0, 0, 1200, 8); 241 | frame.getContentPane().add(lblNewLabel_2); 242 | 243 | JPanel panel_1 = new JPanel(); 244 | panel_1.setLayout(null); 245 | panel_1.setBackground(new Color(255, 255, 255)); 246 | panel_1.setBounds(0, 179, 792, 432); 247 | frame.getContentPane().add(panel_1); 248 | 249 | JSeparator separator_3 = new JSeparator(); 250 | separator_3.setBounds(0, 58, 792, 12); 251 | panel_1.add(separator_3); 252 | 253 | JLabel iconeTextCompteEnregistrerLbl = new JLabel(""); 254 | iconeTextCompteEnregistrerLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/lock_pass.png"))); 255 | iconeTextCompteEnregistrerLbl.setBounds(12, 13, 32, 32); 256 | panel_1.add(iconeTextCompteEnregistrerLbl); 257 | 258 | JLabel compteEnregistrerLbl = new JLabel("Compte enregistré"); 259 | compteEnregistrerLbl.setFont(new Font("Tahoma", Font.BOLD, 17)); 260 | compteEnregistrerLbl.setForeground(new Color(112, 128, 144)); 261 | compteEnregistrerLbl.setHorizontalAlignment(SwingConstants.CENTER); 262 | compteEnregistrerLbl.setBounds(56, 18, 167, 22); 263 | panel_1.add(compteEnregistrerLbl); 264 | 265 | JLabel lblCompte = new JLabel("Compte"); 266 | lblCompte.setFont(new Font("Tahoma", Font.BOLD, 14)); 267 | lblCompte.setForeground(new Color(112, 128, 144)); 268 | lblCompte.setBounds(12, 72, 56, 16); 269 | panel_1.add(lblCompte); 270 | 271 | JLabel lblMotDePasse = new JLabel("Mot de passe"); 272 | lblMotDePasse.setForeground(new Color(112, 128, 144)); 273 | lblMotDePasse.setFont(new Font("Tahoma", Font.BOLD, 14)); 274 | lblMotDePasse.setBounds(246, 73, 92, 17); 275 | panel_1.add(lblMotDePasse); 276 | 277 | JLabel lblUrl = new JLabel("URL"); 278 | lblUrl.setForeground(new Color(112, 128, 144)); 279 | lblUrl.setFont(new Font("Tahoma", Font.BOLD, 14)); 280 | lblUrl.setBounds(470, 73, 91, 17); 281 | panel_1.add(lblUrl); 282 | 283 | JSeparator separator_7 = new JSeparator(); 284 | separator_7.setBounds(0, 101, 792, 12); 285 | panel_1.add(separator_7); 286 | 287 | JScrollBar scrollBar = new JScrollBar(); 288 | scrollBar.setBackground(new Color(255, 255, 255)); 289 | scrollBar.setBounds(764, 125, 16, 53); 290 | panel_1.add(scrollBar); 291 | 292 | JLabel lblAction = new JLabel("Action"); 293 | lblAction.setForeground(new Color(112, 128, 144)); 294 | lblAction.setFont(new Font("Tahoma", Font.BOLD, 14)); 295 | lblAction.setBounds(655, 72, 45, 17); 296 | panel_1.add(lblAction); 297 | 298 | JLabel iconViewOrHidePasswordItemLbl = new JLabel(""); 299 | iconViewOrHidePasswordItemLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 300 | iconViewOrHidePasswordItemLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/eye.png"))); 301 | iconViewOrHidePasswordItemLbl.setForeground(new Color(112, 128, 144)); 302 | iconViewOrHidePasswordItemLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 303 | iconViewOrHidePasswordItemLbl.setBounds(408, 125, 23, 23); 304 | panel_1.add(iconViewOrHidePasswordItemLbl); 305 | 306 | passwordItemTxtFld = new JTextField(); 307 | passwordItemTxtFld.setFont(new Font("Tahoma", Font.BOLD, 15)); 308 | passwordItemTxtFld.setForeground(new Color(112, 128, 144)); 309 | passwordItemTxtFld.setBorder(null); 310 | passwordItemTxtFld.setBackground(new Color(255, 255, 255)); 311 | passwordItemTxtFld.setEditable(false); 312 | passwordItemTxtFld.setText("**********"); 313 | passwordItemTxtFld.setBounds(246, 125, 150, 22); 314 | panel_1.add(passwordItemTxtFld); 315 | passwordItemTxtFld.setColumns(10); 316 | 317 | usernameItemTxtFld = new JTextField(); 318 | usernameItemTxtFld.setText("soumgraphic@gmail.com"); 319 | usernameItemTxtFld.setForeground(new Color(112, 128, 144)); 320 | usernameItemTxtFld.setFont(new Font("Tahoma", Font.BOLD, 15)); 321 | usernameItemTxtFld.setEditable(false); 322 | usernameItemTxtFld.setColumns(10); 323 | usernameItemTxtFld.setBorder(null); 324 | usernameItemTxtFld.setBackground(Color.WHITE); 325 | usernameItemTxtFld.setBounds(12, 125, 211, 22); 326 | panel_1.add(usernameItemTxtFld); 327 | 328 | urlItemTxtFld = new JTextField(); 329 | urlItemTxtFld.setText("www.youtube.com"); 330 | urlItemTxtFld.setForeground(new Color(112, 128, 144)); 331 | urlItemTxtFld.setFont(new Font("Tahoma", Font.BOLD, 15)); 332 | urlItemTxtFld.setEditable(false); 333 | urlItemTxtFld.setColumns(10); 334 | urlItemTxtFld.setBorder(null); 335 | urlItemTxtFld.setBackground(Color.WHITE); 336 | urlItemTxtFld.setBounds(470, 125, 160, 22); 337 | panel_1.add(urlItemTxtFld); 338 | 339 | nomCompletItemTxtFld = new JTextField(); 340 | nomCompletItemTxtFld.setText("Soumaila Abdoulaye DIARRA"); 341 | nomCompletItemTxtFld.setForeground(new Color(112, 128, 144)); 342 | nomCompletItemTxtFld.setFont(new Font("Tahoma", Font.PLAIN, 14)); 343 | nomCompletItemTxtFld.setEditable(false); 344 | nomCompletItemTxtFld.setColumns(10); 345 | nomCompletItemTxtFld.setBorder(null); 346 | nomCompletItemTxtFld.setBackground(Color.WHITE); 347 | nomCompletItemTxtFld.setBounds(12, 151, 211, 22); 348 | panel_1.add(nomCompletItemTxtFld); 349 | 350 | etatPasswordItemTxtFld = new JTextField(); 351 | etatPasswordItemTxtFld.setText("Faible"); 352 | etatPasswordItemTxtFld.setForeground(new Color(112, 128, 144)); 353 | etatPasswordItemTxtFld.setFont(new Font("Tahoma", Font.PLAIN, 14)); 354 | etatPasswordItemTxtFld.setEditable(false); 355 | etatPasswordItemTxtFld.setColumns(10); 356 | etatPasswordItemTxtFld.setBorder(null); 357 | etatPasswordItemTxtFld.setBackground(Color.WHITE); 358 | etatPasswordItemTxtFld.setBounds(246, 151, 150, 22); 359 | panel_1.add(etatPasswordItemTxtFld); 360 | 361 | etatUrlItemTxtFld = new JTextField(); 362 | etatUrlItemTxtFld.setText("Site fiable"); 363 | etatUrlItemTxtFld.setForeground(new Color(112, 128, 144)); 364 | etatUrlItemTxtFld.setFont(new Font("Tahoma", Font.PLAIN, 14)); 365 | etatUrlItemTxtFld.setEditable(false); 366 | etatUrlItemTxtFld.setColumns(10); 367 | etatUrlItemTxtFld.setBorder(null); 368 | etatUrlItemTxtFld.setBackground(Color.WHITE); 369 | etatUrlItemTxtFld.setBounds(470, 151, 150, 22); 370 | panel_1.add(etatUrlItemTxtFld); 371 | 372 | JSeparator separatorItem = new JSeparator(); 373 | separatorItem.setBounds(0, 177, 752, 12); 374 | panel_1.add(separatorItem); 375 | 376 | JLabel iconeEditItemLbl = new JLabel(""); 377 | iconeEditItemLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 378 | iconeEditItemLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/edit_icon.png"))); 379 | iconeEditItemLbl.setBounds(655, 135, 30, 30); 380 | panel_1.add(iconeEditItemLbl); 381 | 382 | JLabel iconDeleteItemLbl = new JLabel(""); 383 | iconDeleteItemLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 384 | iconDeleteItemLbl.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/delete_icon.png"))); 385 | iconDeleteItemLbl.setBounds(704, 135, 30, 30); 386 | panel_1.add(iconDeleteItemLbl); 387 | 388 | JLabel identifiantItemHiddenTxtFld = new JLabel(""); 389 | identifiantItemHiddenTxtFld.setVisible(false); 390 | identifiantItemHiddenTxtFld.setForeground(new Color(112, 128, 144)); 391 | identifiantItemHiddenTxtFld.setFont(new Font("Tahoma", Font.BOLD, 16)); 392 | identifiantItemHiddenTxtFld.setBounds(408, 154, 23, 19); 393 | panel_1.add(identifiantItemHiddenTxtFld); 394 | 395 | JScrollPane spViewItem = new JScrollPane(); 396 | spViewItem.setBorder(null); 397 | spViewItem.setBounds(0, 341, 792, 91); 398 | spViewItem.getViewport().setBackground(Color.WHITE); 399 | panel_1.add(spViewItem); 400 | 401 | JPanel panel_3 = new JPanel(); 402 | panel_3.setLayout(null); 403 | panel_3.setBackground(Color.WHITE); 404 | panel_3.setBounds(0, 191, 792, 70); 405 | panel_1.add(panel_3); 406 | 407 | textField = new JTextField(); 408 | textField.setText("soumgraphic@gmail.com"); 409 | textField.setForeground(new Color(112, 128, 144)); 410 | textField.setFont(new Font("Tahoma", Font.BOLD, 15)); 411 | textField.setEditable(false); 412 | textField.setColumns(10); 413 | textField.setBorder(null); 414 | textField.setBackground(Color.WHITE); 415 | textField.setBounds(12, 6, 211, 22); 416 | panel_3.add(textField); 417 | 418 | textField_1 = new JTextField(); 419 | textField_1.setText("**********"); 420 | textField_1.setForeground(new Color(112, 128, 144)); 421 | textField_1.setFont(new Font("Tahoma", Font.BOLD, 15)); 422 | textField_1.setEditable(false); 423 | textField_1.setColumns(10); 424 | textField_1.setBorder(null); 425 | textField_1.setBackground(Color.WHITE); 426 | textField_1.setBounds(246, 6, 150, 22); 427 | panel_3.add(textField_1); 428 | 429 | JLabel label_2 = new JLabel(""); 430 | label_2.setForeground(new Color(112, 128, 144)); 431 | label_2.setFont(new Font("Tahoma", Font.BOLD, 16)); 432 | label_2.setBounds(408, 6, 23, 23); 433 | panel_3.add(label_2); 434 | 435 | textField_2 = new JTextField(); 436 | textField_2.setText("www.youtube.com"); 437 | textField_2.setForeground(new Color(112, 128, 144)); 438 | textField_2.setFont(new Font("Tahoma", Font.BOLD, 15)); 439 | textField_2.setEditable(false); 440 | textField_2.setColumns(10); 441 | textField_2.setBorder(null); 442 | textField_2.setBackground(Color.WHITE); 443 | textField_2.setBounds(470, 6, 160, 22); 444 | panel_3.add(textField_2); 445 | 446 | JLabel label_4 = new JLabel(""); 447 | label_4.setBounds(655, 16, 30, 30); 448 | panel_3.add(label_4); 449 | 450 | JLabel label_5 = new JLabel(""); 451 | label_5.setBounds(704, 16, 30, 30); 452 | panel_3.add(label_5); 453 | 454 | textField_3 = new JTextField(); 455 | textField_3.setText("Site fiable"); 456 | textField_3.setForeground(new Color(112, 128, 144)); 457 | textField_3.setFont(new Font("Tahoma", Font.PLAIN, 14)); 458 | textField_3.setEditable(false); 459 | textField_3.setColumns(10); 460 | textField_3.setBorder(null); 461 | textField_3.setBackground(Color.WHITE); 462 | textField_3.setBounds(470, 32, 150, 22); 463 | panel_3.add(textField_3); 464 | 465 | textField_4 = new JTextField(); 466 | textField_4.setText("Faible"); 467 | textField_4.setForeground(new Color(112, 128, 144)); 468 | textField_4.setFont(new Font("Tahoma", Font.PLAIN, 14)); 469 | textField_4.setEditable(false); 470 | textField_4.setColumns(10); 471 | textField_4.setBorder(null); 472 | textField_4.setBackground(Color.WHITE); 473 | textField_4.setBounds(246, 32, 150, 22); 474 | panel_3.add(textField_4); 475 | 476 | textField_5 = new JTextField(); 477 | textField_5.setText("Soumaila Abdoulaye DIARRA"); 478 | textField_5.setForeground(new Color(112, 128, 144)); 479 | textField_5.setFont(new Font("Tahoma", Font.PLAIN, 14)); 480 | textField_5.setEditable(false); 481 | textField_5.setColumns(10); 482 | textField_5.setBorder(null); 483 | textField_5.setBackground(Color.WHITE); 484 | textField_5.setBounds(12, 32, 211, 22); 485 | panel_3.add(textField_5); 486 | 487 | JSeparator separator_13 = new JSeparator(); 488 | separator_13.setBounds(0, 58, 752, 12); 489 | panel_3.add(separator_13); 490 | 491 | JLabel label_6 = new JLabel(""); 492 | label_6.setOpaque(true); 493 | label_6.setBackground(new Color(60, 179, 113)); 494 | label_6.setBounds(0, 171, 792, 8); 495 | frame.getContentPane().add(label_6); 496 | 497 | JLabel label_1 = new JLabel(""); 498 | label_1.setOpaque(true); 499 | label_1.setBackground(new Color(60, 179, 113)); 500 | label_1.setBounds(797, 170, 403, 9); 501 | frame.getContentPane().add(label_1); 502 | 503 | JPanel panel_2 = new JPanel(); 504 | panel_2.setLayout(null); 505 | panel_2.setBackground(new Color(255, 255, 255)); 506 | panel_2.setBounds(797, 179, 403, 432); 507 | frame.getContentPane().add(panel_2); 508 | 509 | JSeparator separator_2 = new JSeparator(); 510 | separator_2.setBounds(0, 58, 792, 12); 511 | panel_2.add(separator_2); 512 | 513 | JLabel label_3 = new JLabel(""); 514 | label_3.setIcon(new ImageIcon(AdminUI_OLD.class.getResource("/ui/images/editing.png"))); 515 | label_3.setBounds(12, 13, 32, 32); 516 | panel_2.add(label_3); 517 | 518 | JLabel lblEditionDeCompte = new JLabel("Edition de compte"); 519 | lblEditionDeCompte.setHorizontalAlignment(SwingConstants.CENTER); 520 | lblEditionDeCompte.setForeground(new Color(112, 128, 144)); 521 | lblEditionDeCompte.setFont(new Font("Tahoma", Font.BOLD, 17)); 522 | lblEditionDeCompte.setBounds(56, 18, 167, 22); 523 | panel_2.add(lblEditionDeCompte); 524 | 525 | JLabel label_7 = new JLabel("Nom"); 526 | label_7.setForeground(new Color(60, 179, 113)); 527 | label_7.setFont(new Font("Tahoma", Font.BOLD, 14)); 528 | label_7.setBounds(12, 70, 282, 16); 529 | panel_2.add(label_7); 530 | 531 | nomCompletEditTxtFld = new JTextField(); 532 | nomCompletEditTxtFld.setForeground(new Color(60, 179, 113)); 533 | nomCompletEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 534 | nomCompletEditTxtFld.setColumns(10); 535 | nomCompletEditTxtFld.setCaretColor(new Color(60, 179, 113)); 536 | nomCompletEditTxtFld.setBorder(null); 537 | nomCompletEditTxtFld.setBackground(new Color(255, 255, 255)); 538 | nomCompletEditTxtFld.setBounds(12, 98, 350, 16); 539 | panel_2.add(nomCompletEditTxtFld); 540 | 541 | JSeparator separator_9 = new JSeparator(); 542 | separator_9.setForeground(new Color(60, 179, 113)); 543 | separator_9.setBackground(Color.WHITE); 544 | separator_9.setBounds(12, 115, 350, 12); 545 | panel_2.add(separator_9); 546 | 547 | JLabel lblUsername = new JLabel("Username"); 548 | lblUsername.setForeground(new Color(60, 179, 113)); 549 | lblUsername.setFont(new Font("Tahoma", Font.BOLD, 14)); 550 | lblUsername.setBounds(12, 139, 282, 16); 551 | panel_2.add(lblUsername); 552 | 553 | usernameEditTxtFld = new JTextField(); 554 | usernameEditTxtFld.setForeground(new Color(60, 179, 113)); 555 | usernameEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 556 | usernameEditTxtFld.setColumns(10); 557 | usernameEditTxtFld.setCaretColor(new Color(60, 179, 113)); 558 | usernameEditTxtFld.setBorder(null); 559 | usernameEditTxtFld.setBackground(new Color(255, 255, 255)); 560 | usernameEditTxtFld.setBounds(12, 167, 350, 16); 561 | panel_2.add(usernameEditTxtFld); 562 | 563 | JSeparator separator_10 = new JSeparator(); 564 | separator_10.setForeground(new Color(60, 179, 113)); 565 | separator_10.setBackground(Color.WHITE); 566 | separator_10.setBounds(12, 184, 350, 12); 567 | panel_2.add(separator_10); 568 | 569 | JLabel label_9 = new JLabel("Mot de passe"); 570 | label_9.setForeground(new Color(60, 179, 113)); 571 | label_9.setFont(new Font("Tahoma", Font.BOLD, 14)); 572 | label_9.setBounds(12, 208, 282, 16); 573 | panel_2.add(label_9); 574 | 575 | passwordEditTxtFld = new JPasswordField(); 576 | passwordEditTxtFld.setForeground(new Color(60, 179, 113)); 577 | passwordEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 578 | passwordEditTxtFld.setCaretColor(new Color(60, 179, 113)); 579 | passwordEditTxtFld.setBorder(null); 580 | passwordEditTxtFld.setBackground(new Color(255, 255, 255)); 581 | passwordEditTxtFld.setBounds(12, 236, 350, 16); 582 | panel_2.add(passwordEditTxtFld); 583 | 584 | JSeparator separator_11 = new JSeparator(); 585 | separator_11.setForeground(new Color(60, 179, 113)); 586 | separator_11.setBackground(Color.WHITE); 587 | separator_11.setBounds(12, 253, 350, 12); 588 | panel_2.add(separator_11); 589 | 590 | JSeparator separator_12 = new JSeparator(); 591 | separator_12.setForeground(new Color(60, 179, 113)); 592 | separator_12.setBackground(Color.WHITE); 593 | separator_12.setBounds(12, 322, 350, 12); 594 | panel_2.add(separator_12); 595 | 596 | urlEditTxtFld = new JTextField(); 597 | urlEditTxtFld.setForeground(new Color(60, 179, 113)); 598 | urlEditTxtFld.setFont(new Font("Tahoma", Font.BOLD, 12)); 599 | urlEditTxtFld.setColumns(10); 600 | urlEditTxtFld.setCaretColor(new Color(60, 179, 113)); 601 | urlEditTxtFld.setBorder(null); 602 | urlEditTxtFld.setBackground(Color.WHITE); 603 | urlEditTxtFld.setBounds(12, 305, 350, 16); 604 | panel_2.add(urlEditTxtFld); 605 | 606 | JLabel lblUrl_1 = new JLabel("Url"); 607 | lblUrl_1.setForeground(new Color(60, 179, 113)); 608 | lblUrl_1.setFont(new Font("Tahoma", Font.BOLD, 14)); 609 | lblUrl_1.setBounds(12, 277, 282, 16); 610 | panel_2.add(lblUrl_1); 611 | 612 | JButton ajouterEditBtn = new JButton("Ajouter"); 613 | ajouterEditBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 614 | ajouterEditBtn.setForeground(new Color(60, 179, 113)); 615 | ajouterEditBtn.setFont(new Font("Tahoma", Font.BOLD, 14)); 616 | ajouterEditBtn.setFocusPainted(false); 617 | ajouterEditBtn.setContentAreaFilled(false); 618 | ajouterEditBtn.setBorder(new LineBorder(new Color(60, 179, 113))); 619 | ajouterEditBtn.setActionCommand("inscriptionBtn"); 620 | ajouterEditBtn.setBounds(12, 356, 350, 40); 621 | panel_2.add(ajouterEditBtn); 622 | 623 | ajouterEditBtn.setRolloverEnabled(true); 624 | 625 | 626 | } 627 | } 628 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/AuthenticationUI.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JPanel; 7 | import java.awt.Color; 8 | import javax.swing.JLabel; 9 | import java.awt.Font; 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import java.awt.event.MouseEvent; 13 | import java.awt.event.MouseListener; 14 | 15 | import javax.swing.JTextField; 16 | import javax.swing.JSeparator; 17 | import javax.swing.JPasswordField; 18 | import javax.swing.JRadioButton; 19 | import javax.swing.JButton; 20 | import javax.swing.border.LineBorder; 21 | import javax.swing.event.DocumentEvent; 22 | import javax.swing.event.DocumentListener; 23 | import javax.swing.text.Document; 24 | 25 | import bean.UserBean; 26 | import dao.UserDaoImpl; 27 | import utils.Constants; 28 | import utils.Utils; 29 | 30 | import javax.swing.ImageIcon; 31 | import java.awt.Component; 32 | import java.awt.Dimension; 33 | import java.awt.Cursor; 34 | 35 | public class AuthenticationUI extends JFrame implements ActionListener{ 36 | 37 | public JFrame frame; 38 | private JTextField emailTxtfield; 39 | private JPasswordField passwordTxtfield; 40 | private JButton connexionBtn; 41 | private JButton goToInscription; 42 | JLabel iconViewOrHidePasswordEditLbl; 43 | 44 | /** 45 | * Launch the application. 46 | */ 47 | public static void main(String[] args) { 48 | EventQueue.invokeLater(new Runnable() { 49 | public void run() { 50 | try { 51 | AuthenticationUI window = new AuthenticationUI(); 52 | window.frame.setVisible(true); 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | }); 58 | } 59 | 60 | /** 61 | * Create the application. 62 | */ 63 | public AuthenticationUI() { 64 | initialize(); 65 | } 66 | 67 | /** 68 | * Initialize the contents of the frame. 69 | */ 70 | private void initialize() { 71 | frame = new JFrame(); 72 | frame.setResizable(false); 73 | frame.setBounds(100, 100, 800, 500); 74 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 75 | frame.getContentPane().setLayout(null); 76 | 77 | JPanel panel = new JPanel(); 78 | panel.setBounds(394, 0, 406, 478); 79 | frame.getContentPane().add(panel); 80 | panel.setLayout(null); 81 | 82 | JLabel lblSoumgraphic = new JLabel("\nSoumgraphic Password Manager\n"); 83 | lblSoumgraphic.setForeground(new Color(112, 128, 144)); 84 | lblSoumgraphic.setFont(new Font("Tahoma", Font.BOLD, 16)); 85 | lblSoumgraphic.setBounds(80, 282, 272, 27); 86 | panel.add(lblSoumgraphic); 87 | 88 | JLabel label = new JLabel(""); 89 | label.setAlignmentX(0.5f); 90 | label.setBorder(null); 91 | //./assets/img/pm_logo.png 92 | label.setIcon(new ImageIcon(AuthenticationUI.class.getResource("/ui/images/pm_logo.png"))); 93 | label.setForeground(Color.WHITE); 94 | label.setFont(new Font("Tahoma", Font.BOLD, 14)); 95 | label.setBounds(141, 125, 133, 145); 96 | panel.add(label); 97 | 98 | JPanel panel_1 = new JPanel(); 99 | panel_1.setBackground(new Color(60, 179, 113)); 100 | panel_1.setBounds(0, 0, 395, 478); 101 | frame.getContentPane().add(panel_1); 102 | panel_1.setLayout(null); 103 | 104 | JLabel lblNewLabel = new JLabel("Heureux de vous revoir à nouveau !"); 105 | lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13)); 106 | lblNewLabel.setForeground(new Color(255, 255, 255)); 107 | lblNewLabel.setBounds(51, 75, 320, 16); 108 | panel_1.add(lblNewLabel); 109 | 110 | JLabel lblEnterYourDetails = new JLabel("Connexion à votre compte"); 111 | lblEnterYourDetails.setForeground(Color.WHITE); 112 | lblEnterYourDetails.setFont(new Font("Tahoma", Font.BOLD, 18)); 113 | lblEnterYourDetails.setBounds(51, 103, 282, 31); 114 | panel_1.add(lblEnterYourDetails); 115 | 116 | JSeparator separator_1 = new JSeparator(); 117 | separator_1.setForeground(Color.WHITE); 118 | separator_1.setBackground(Color.WHITE); 119 | separator_1.setBounds(51, 210, 320, 12); 120 | panel_1.add(separator_1); 121 | 122 | JLabel lblEmail = new JLabel("Email"); 123 | lblEmail.setForeground(Color.WHITE); 124 | lblEmail.setFont(new Font("Tahoma", Font.BOLD, 14)); 125 | lblEmail.setBounds(51, 165, 282, 16); 126 | panel_1.add(lblEmail); 127 | 128 | emailTxtfield = new JTextField(); 129 | emailTxtfield.setCaretColor(new Color(255, 255, 255)); 130 | emailTxtfield.setForeground(Color.WHITE); 131 | emailTxtfield.setFont(new Font("Tahoma", Font.BOLD, 12)); 132 | emailTxtfield.setColumns(10); 133 | emailTxtfield.setBorder(null); 134 | emailTxtfield.setBackground(new Color(60, 179, 113)); 135 | emailTxtfield.setBounds(51, 193, 320, 16); 136 | panel_1.add(emailTxtfield); 137 | 138 | JLabel lblPassword = new JLabel("Mot de passe"); 139 | lblPassword.setForeground(Color.WHITE); 140 | lblPassword.setFont(new Font("Tahoma", Font.BOLD, 14)); 141 | lblPassword.setBounds(51, 234, 282, 16); 142 | panel_1.add(lblPassword); 143 | 144 | JSeparator separator_2 = new JSeparator(); 145 | separator_2.setForeground(Color.WHITE); 146 | separator_2.setBackground(Color.WHITE); 147 | separator_2.setBounds(51, 279, 320, 12); 148 | panel_1.add(separator_2); 149 | 150 | passwordTxtfield = new JPasswordField(); 151 | passwordTxtfield.setBorder(null); 152 | passwordTxtfield.setCaretColor(new Color(255, 255, 255)); 153 | passwordTxtfield.setBackground(new Color(60, 179, 113)); 154 | passwordTxtfield.setForeground(new Color(255, 255, 255)); 155 | passwordTxtfield.setFont(new Font("Tahoma", Font.BOLD, 12)); 156 | passwordTxtfield.setBounds(51, 262, 282, 16); 157 | passwordTxtfield.setEchoChar('*'); 158 | panel_1.add(passwordTxtfield); 159 | 160 | connexionBtn = new JButton("Se connecter"); 161 | connexionBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 162 | connexionBtn.setFont(new Font("Tahoma", Font.BOLD, 14)); 163 | connexionBtn.setForeground(new Color(255, 255, 255)); 164 | connexionBtn.setContentAreaFilled(false); 165 | connexionBtn.setFocusPainted(false); 166 | connexionBtn.setBorder(new LineBorder(new Color(255, 255, 255))); 167 | connexionBtn.setBounds(51, 320, 320, 40); 168 | connexionBtn.setActionCommand("connexionBtn"); 169 | connexionBtn.addActionListener(this); 170 | panel_1.add(connexionBtn); 171 | 172 | goToInscription = new JButton("\nPas encore de compte ? Inscription\n"); 173 | goToInscription.setBorderPainted(false); 174 | goToInscription.setContentAreaFilled(false); 175 | goToInscription.setOpaque(false); 176 | goToInscription.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 177 | goToInscription.setFont(new Font("Tahoma", Font.BOLD, 12)); 178 | goToInscription.setBorder(null); 179 | goToInscription.setForeground(new Color(255, 255, 255)); 180 | goToInscription.setBounds(51, 381, 320, 21); 181 | goToInscription.setActionCommand("goToInscription"); 182 | goToInscription.addActionListener(this); 183 | panel_1.add(goToInscription); 184 | 185 | iconViewOrHidePasswordEditLbl = new JLabel(""); 186 | iconViewOrHidePasswordEditLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 187 | iconViewOrHidePasswordEditLbl.setIcon(new ImageIcon(AuthenticationUI.class.getResource("/ui/images/eye_white.png"))); 188 | iconViewOrHidePasswordEditLbl.setForeground(new Color(112, 128, 144)); 189 | iconViewOrHidePasswordEditLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 190 | iconViewOrHidePasswordEditLbl.setBounds(345, 259, 23, 23); 191 | panel_1.add(iconViewOrHidePasswordEditLbl); 192 | 193 | iconViewOrHidePasswordEditLbl.addMouseListener(new MouseListener() { 194 | 195 | @Override 196 | public void mouseReleased(MouseEvent e) { 197 | // TODO Auto-generated method stub 198 | 199 | } 200 | 201 | @Override 202 | public void mousePressed(MouseEvent e) { 203 | // TODO Auto-generated method stub 204 | 205 | } 206 | 207 | @Override 208 | public void mouseExited(MouseEvent e) { 209 | // TODO Auto-generated method stub 210 | 211 | } 212 | 213 | @Override 214 | public void mouseEntered(MouseEvent e) { 215 | // TODO Auto-generated method stub 216 | 217 | } 218 | 219 | @Override 220 | public void mouseClicked(MouseEvent e) { 221 | // TODO Auto-generated method stub 222 | Utils.showOrHidePasswordTxtFields(passwordTxtfield, iconViewOrHidePasswordEditLbl, '*'); 223 | } 224 | }); 225 | 226 | 227 | } 228 | 229 | @Override 230 | public void actionPerformed(ActionEvent e) { 231 | // TODO Auto-generated method stub 232 | if ("connexionBtn".equals(e.getActionCommand())) { 233 | connexion(); 234 | }else if("goToInscription".equals(e.getActionCommand())) { 235 | backToInscriptionWdw(); 236 | } 237 | } 238 | 239 | private void connexion() { 240 | String emailUser = emailTxtfield.getText().toString(); 241 | String passwordUser = passwordTxtfield.getText().toString(); 242 | if ((!Utils.isNullOrEmpty(emailUser)) && (!Utils.isNullOrEmpty(passwordUser))) { 243 | try { 244 | 245 | UserDaoImpl daoImpl = new UserDaoImpl(); 246 | UserBean userBean = new UserBean(); 247 | userBean = daoImpl.authenticationUser(emailUser.toLowerCase(), passwordUser); 248 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 249 | AdminUI adminUI = new AdminUI(userBean); 250 | frame.dispose(); 251 | adminUI.frame.setVisible(true); 252 | }else if((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.NOT_FOUND) && (userBean.getCallDbFunctionBean().isErrorRetour() == true)){ 253 | Utils.showErrorMessage(frame, userBean.getCallDbFunctionBean().getMessageRetour()); 254 | }else if((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.PASSWORD_ERROR) && (userBean.getCallDbFunctionBean().isErrorRetour() == true)) { 255 | Utils.showErrorMessage(frame, userBean.getCallDbFunctionBean().getMessageRetour()); 256 | }else { 257 | Utils.showErrorMessage(frame, "Une erreur est survenue lors de l'authentification, veuillez réessayer ultérieurement !"); 258 | } 259 | 260 | } catch (Exception e) { 261 | // TODO Auto-generated catch block 262 | e.printStackTrace(); 263 | } 264 | }else { 265 | Utils.showErrorMessage(frame, "Veuillez remplir les champs email et mot de passe !"); 266 | } 267 | } 268 | 269 | private void backToInscriptionWdw() { 270 | InscriptionUI windowInscUI = new InscriptionUI(); 271 | frame.dispose(); 272 | windowInscUI.frame.setVisible(true); 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/InscriptionUI.java: -------------------------------------------------------------------------------- 1 | package ui; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JPanel; 7 | import java.awt.Color; 8 | import javax.swing.JLabel; 9 | import javax.swing.JOptionPane; 10 | 11 | import java.awt.Font; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | import java.awt.event.MouseEvent; 15 | import java.awt.event.MouseListener; 16 | 17 | import javax.swing.JTextField; 18 | import javax.swing.JSeparator; 19 | import javax.swing.JPasswordField; 20 | import javax.swing.JRadioButton; 21 | import javax.swing.JButton; 22 | import javax.swing.border.LineBorder; 23 | import javax.swing.text.Utilities; 24 | 25 | import bean.UserBean; 26 | import dao.UserDaoImpl; 27 | import utils.Constants; 28 | import utils.Utils; 29 | 30 | import javax.naming.Context; 31 | import javax.swing.ImageIcon; 32 | import java.awt.Component; 33 | import java.awt.Dimension; 34 | import java.awt.Cursor; 35 | 36 | public class InscriptionUI extends JFrame implements ActionListener{ 37 | 38 | public JFrame frame; 39 | private JTextField nameTxtfield; 40 | private JTextField emailTxtfield; 41 | private JPasswordField passwordTxtfield; 42 | private JRadioButton notRobotRdBtn; 43 | 44 | /** 45 | * Launch the application. 46 | */ 47 | public static void main(String[] args) { 48 | EventQueue.invokeLater(new Runnable() { 49 | public void run() { 50 | try { 51 | InscriptionUI window = new InscriptionUI(); 52 | window.frame.setVisible(true); 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | }); 58 | } 59 | 60 | /** 61 | * Create the application. 62 | */ 63 | public InscriptionUI() { 64 | initialize(); 65 | } 66 | 67 | /** 68 | * Initialize the contents of the frame. 69 | */ 70 | private void initialize() { 71 | frame = new JFrame(); 72 | frame.setResizable(false); 73 | frame.setBounds(100, 100, 800, 500); 74 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 75 | frame.getContentPane().setLayout(null); 76 | 77 | JPanel panel = new JPanel(); 78 | panel.setBounds(394, 0, 406, 478); 79 | frame.getContentPane().add(panel); 80 | panel.setLayout(null); 81 | 82 | JLabel lblSoumgraphic = new JLabel("\nSoumgraphic Password Manager\n"); 83 | lblSoumgraphic.setForeground(new Color(112, 128, 144)); 84 | lblSoumgraphic.setFont(new Font("Tahoma", Font.BOLD, 16)); 85 | lblSoumgraphic.setBounds(80, 282, 272, 27); 86 | panel.add(lblSoumgraphic); 87 | 88 | JLabel label = new JLabel(""); 89 | label.setAlignmentX(0.5f); 90 | label.setBorder(null); 91 | //./assets/img/pm_logo.png 92 | label.setIcon(new ImageIcon(InscriptionUI.class.getResource("/ui/images/pm_logo.png"))); 93 | label.setForeground(Color.WHITE); 94 | label.setFont(new Font("Tahoma", Font.BOLD, 14)); 95 | label.setBounds(141, 125, 133, 145); 96 | panel.add(label); 97 | 98 | JPanel panel_1 = new JPanel(); 99 | panel_1.setBackground(new Color(60, 179, 113)); 100 | panel_1.setBounds(0, 0, 395, 478); 101 | frame.getContentPane().add(panel_1); 102 | panel_1.setLayout(null); 103 | 104 | JLabel lblNewLabel = new JLabel("Stocker et garder vos mots de passe en sécurité"); 105 | lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 13)); 106 | lblNewLabel.setForeground(new Color(255, 255, 255)); 107 | lblNewLabel.setBounds(51, 36, 320, 16); 108 | panel_1.add(lblNewLabel); 109 | 110 | JLabel lblEnterYourDetails = new JLabel("Renseignez vos coordonnées"); 111 | lblEnterYourDetails.setForeground(Color.WHITE); 112 | lblEnterYourDetails.setFont(new Font("Tahoma", Font.BOLD, 18)); 113 | lblEnterYourDetails.setBounds(51, 64, 282, 31); 114 | panel_1.add(lblEnterYourDetails); 115 | 116 | nameTxtfield = new JTextField(); 117 | nameTxtfield.setCaretColor(new Color(255, 255, 255)); 118 | nameTxtfield.setBorder(null); 119 | nameTxtfield.setBackground(new Color(60, 179, 113)); 120 | nameTxtfield.setForeground(new Color(255, 255, 255)); 121 | nameTxtfield.setFont(new Font("Tahoma", Font.BOLD, 12)); 122 | nameTxtfield.setBounds(51, 146, 320, 16); 123 | panel_1.add(nameTxtfield); 124 | nameTxtfield.setColumns(10); 125 | 126 | JLabel lblName = new JLabel("Nom *"); 127 | lblName.setForeground(Color.WHITE); 128 | lblName.setFont(new Font("Tahoma", Font.BOLD, 14)); 129 | lblName.setBounds(51, 118, 282, 16); 130 | panel_1.add(lblName); 131 | 132 | JSeparator separator = new JSeparator(); 133 | separator.setForeground(Color.WHITE); 134 | separator.setBackground(new Color(255, 255, 255)); 135 | separator.setBounds(51, 163, 320, 12); 136 | panel_1.add(separator); 137 | 138 | notRobotRdBtn = new JRadioButton("Je ne suis pas un robot *"); 139 | notRobotRdBtn.setBorder(null); 140 | notRobotRdBtn.setFont(new Font("Tahoma", Font.BOLD, 12)); 141 | notRobotRdBtn.setBackground(new Color(60, 179, 113)); 142 | notRobotRdBtn.setForeground(new Color(255, 255, 255)); 143 | notRobotRdBtn.setBounds(51, 325, 208, 23); 144 | panel_1.add(notRobotRdBtn); 145 | 146 | JSeparator separator_1 = new JSeparator(); 147 | separator_1.setForeground(Color.WHITE); 148 | separator_1.setBackground(Color.WHITE); 149 | separator_1.setBounds(51, 232, 320, 12); 150 | panel_1.add(separator_1); 151 | 152 | JLabel lblEmail = new JLabel("Email *"); 153 | lblEmail.setForeground(Color.WHITE); 154 | lblEmail.setFont(new Font("Tahoma", Font.BOLD, 14)); 155 | lblEmail.setBounds(51, 187, 282, 16); 156 | panel_1.add(lblEmail); 157 | 158 | emailTxtfield = new JTextField(); 159 | emailTxtfield.setCaretColor(new Color(255, 255, 255)); 160 | emailTxtfield.setForeground(Color.WHITE); 161 | emailTxtfield.setFont(new Font("Tahoma", Font.BOLD, 12)); 162 | emailTxtfield.setColumns(10); 163 | emailTxtfield.setBorder(null); 164 | emailTxtfield.setBackground(new Color(60, 179, 113)); 165 | emailTxtfield.setBounds(51, 215, 320, 16); 166 | panel_1.add(emailTxtfield); 167 | 168 | JLabel lblPassword = new JLabel("Mot de passe *"); 169 | lblPassword.setForeground(Color.WHITE); 170 | lblPassword.setFont(new Font("Tahoma", Font.BOLD, 14)); 171 | lblPassword.setBounds(51, 256, 282, 16); 172 | panel_1.add(lblPassword); 173 | 174 | JSeparator separator_2 = new JSeparator(); 175 | separator_2.setForeground(Color.WHITE); 176 | separator_2.setBackground(Color.WHITE); 177 | separator_2.setBounds(51, 301, 320, 12); 178 | panel_1.add(separator_2); 179 | 180 | passwordTxtfield = new JPasswordField(); 181 | passwordTxtfield.setBorder(null); 182 | passwordTxtfield.setCaretColor(new Color(255, 255, 255)); 183 | passwordTxtfield.setBackground(new Color(60, 179, 113)); 184 | passwordTxtfield.setForeground(new Color(255, 255, 255)); 185 | passwordTxtfield.setFont(new Font("Tahoma", Font.BOLD, 12)); 186 | passwordTxtfield.setBounds(51, 284, 282, 16); 187 | passwordTxtfield.setEchoChar('*'); 188 | panel_1.add(passwordTxtfield); 189 | 190 | JButton inscriptionBtn = new JButton("C'est parti !"); 191 | inscriptionBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 192 | inscriptionBtn.setFont(new Font("Tahoma", Font.BOLD, 14)); 193 | inscriptionBtn.setForeground(new Color(255, 255, 255)); 194 | inscriptionBtn.setContentAreaFilled(false); 195 | inscriptionBtn.setFocusPainted(false); 196 | inscriptionBtn.setBorder(new LineBorder(new Color(255, 255, 255))); 197 | inscriptionBtn.setBounds(51, 369, 320, 40); 198 | inscriptionBtn.setActionCommand("inscriptionBtn"); 199 | inscriptionBtn.addActionListener(this); 200 | panel_1.add(inscriptionBtn); 201 | 202 | JButton goToConnexionBtn = new JButton("\nVous avez déjà un compte ? Connexion\n"); 203 | goToConnexionBtn.setOpaque(false); 204 | goToConnexionBtn.setContentAreaFilled(false); 205 | goToConnexionBtn.setBorderPainted(false); 206 | goToConnexionBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 207 | goToConnexionBtn.setForeground(Color.WHITE); 208 | goToConnexionBtn.setFont(new Font("Tahoma", Font.BOLD, 12)); 209 | goToConnexionBtn.setBorder(null); 210 | goToConnexionBtn.setBounds(51, 421, 320, 21); 211 | goToConnexionBtn.setActionCommand("goToConnexionBtn"); 212 | goToConnexionBtn.addActionListener(this); 213 | panel_1.add(goToConnexionBtn); 214 | 215 | JLabel iconViewOrHidePasswordEditLbl = new JLabel(""); 216 | iconViewOrHidePasswordEditLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 217 | iconViewOrHidePasswordEditLbl.setIcon(new ImageIcon(InscriptionUI.class.getResource("/ui/images/eye_white.png"))); 218 | iconViewOrHidePasswordEditLbl.setForeground(new Color(112, 128, 144)); 219 | iconViewOrHidePasswordEditLbl.setFont(new Font("Tahoma", Font.BOLD, 16)); 220 | iconViewOrHidePasswordEditLbl.setBounds(345, 281, 23, 23); 221 | panel_1.add(iconViewOrHidePasswordEditLbl); 222 | 223 | iconViewOrHidePasswordEditLbl.addMouseListener(new MouseListener() { 224 | 225 | @Override 226 | public void mouseReleased(MouseEvent e) { 227 | // TODO Auto-generated method stub 228 | 229 | } 230 | 231 | @Override 232 | public void mousePressed(MouseEvent e) { 233 | // TODO Auto-generated method stub 234 | 235 | } 236 | 237 | @Override 238 | public void mouseExited(MouseEvent e) { 239 | // TODO Auto-generated method stub 240 | 241 | } 242 | 243 | @Override 244 | public void mouseEntered(MouseEvent e) { 245 | // TODO Auto-generated method stub 246 | 247 | } 248 | 249 | @Override 250 | public void mouseClicked(MouseEvent e) { 251 | // TODO Auto-generated method stub 252 | Utils.showOrHidePasswordTxtFields(passwordTxtfield, iconViewOrHidePasswordEditLbl, '*'); 253 | } 254 | }); 255 | } 256 | 257 | @Override 258 | public void actionPerformed(ActionEvent e) { 259 | // TODO Auto-generated method stub 260 | if ("inscriptionBtn".equals(e.getActionCommand())) { 261 | inscription(); 262 | }else if("goToConnexionBtn".equals(e.getActionCommand())) { 263 | backToConnexionWdw(); 264 | } 265 | } 266 | 267 | private void inscription() { 268 | String nameUser = nameTxtfield.getText().toString(); 269 | String emailUser = emailTxtfield.getText().toString(); 270 | String pwdUser = passwordTxtfield.getText().toString(); 271 | 272 | if (verificationNulliteEtTailleDesChamps(nameUser, emailUser, pwdUser)) { 273 | try { 274 | 275 | UserDaoImpl daoImpl = new UserDaoImpl(); 276 | UserBean userBean = new UserBean(nameUser, emailUser, pwdUser); 277 | userBean = daoImpl.insertUser(userBean); 278 | if ((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.COMPLETED_SUCCESSFULLY) && (userBean.getCallDbFunctionBean().isErrorRetour() == false)) { 279 | nameTxtfield.setText(""); 280 | emailTxtfield.setText(""); 281 | passwordTxtfield.setText(""); 282 | 283 | userBean.setPasswordUser(""); 284 | 285 | AdminUI adminUI = new AdminUI(userBean); 286 | frame.dispose(); 287 | adminUI.frame.setVisible(true); 288 | }else if((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.EMAIL_EXIST) && (userBean.getCallDbFunctionBean().isErrorRetour() == true)) { 289 | Utils.showErrorMessage(frame, userBean.getCallDbFunctionBean().getMessageRetour()); 290 | }else if((userBean.getCallDbFunctionBean().getCodeRetour() == Constants.UNKNOW_ERROR) && (userBean.getCallDbFunctionBean().isErrorRetour() == true)) { 291 | Utils.showErrorMessage(frame, userBean.getCallDbFunctionBean().getMessageRetour()); 292 | } 293 | 294 | } catch (Exception e) { 295 | // TODO Auto-generated catch block 296 | e.printStackTrace(); 297 | } 298 | } 299 | 300 | } 301 | 302 | private boolean verificationNulliteEtTailleDesChamps(String nameUser, String emailUser, String pwdUser) { 303 | if ((!Utils.isNullOrEmpty(nameUser) && (!Utils.isNullOrEmpty(emailUser) && (!Utils.isNullOrEmpty(pwdUser) )))) { 304 | if (Utils.checkStringMinLength(nameUser, 2)) { 305 | if (Utils.validateEmail(emailUser)) { 306 | if (Utils.checkStringMinLength(pwdUser, 6)) { 307 | if (notRobotRdBtn.isSelected()) { 308 | return true; 309 | }else { 310 | Utils.showErrorMessage(frame, "Etes vous un robot ? selectionnez ci dessous si vous ne l'êtes pas !"); 311 | return false; 312 | } 313 | }else { 314 | Utils.showErrorMessage(frame, "Le mot de passe doit être au minimum six caractères"); 315 | return false; 316 | } 317 | }else { 318 | Utils.showErrorMessage(frame, "Veuillez saisir un adresse email valide !"); 319 | return false; 320 | } 321 | 322 | }else { 323 | Utils.showErrorMessage(frame, "Le nom doit être au minimum deux caractères"); 324 | return false; 325 | } 326 | 327 | }else { 328 | Utils.showErrorMessage(frame, "Veuillez remplir tous les champs !"); 329 | return false; 330 | } 331 | } 332 | 333 | private void backToConnexionWdw() { 334 | AuthenticationUI windowAuthUI = new AuthenticationUI(); 335 | frame.dispose(); 336 | windowAuthUI.frame.setVisible(true); 337 | } 338 | 339 | 340 | } 341 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/cancel.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/dashboard.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/delete_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/delete_icon.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/edit_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/edit_icon.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/editing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/editing.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/eye.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/eye_invisible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/eye_invisible.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/eye_invisible_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/eye_invisible_white.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/eye_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/eye_white.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/facebook.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/github_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/github_logo.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/lock_pass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/lock_pass.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/logout.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/passgenerator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/passgenerator.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/pm_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/pm_logo.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/pm_logo64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/pm_logo64.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/twitter.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/user.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/d486ece311b6d673a06e82acd838c2fd9b636071/JavaSwingPasswordManager/src/ui/images/warning.png -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/test/UIEnd.java: -------------------------------------------------------------------------------- 1 | package ui.test; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Dimension; 5 | import java.awt.event.MouseEvent; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.WindowAdapter; 8 | import java.awt.event.WindowEvent; 9 | 10 | import javax.swing.JFrame; 11 | import javax.swing.JLabel; 12 | import javax.swing.JPanel; 13 | import javax.swing.JScrollPane; 14 | import javax.swing.JTextField; 15 | 16 | import utils.Utils; 17 | 18 | public class UIEnd extends JFrame { 19 | 20 | public UIEnd() { 21 | addWindowListener(new WindowAdapter() { 22 | public void windowClosing(WindowEvent we) { 23 | System.exit(0); 24 | } 25 | }); 26 | 27 | 28 | JPanel panel = createPanel(); 29 | 30 | JScrollPane sp = new JScrollPane(); 31 | sp.setViewportView(panel); 32 | 33 | getContentPane().setLayout(new BorderLayout()); 34 | getContentPane().add(sp, BorderLayout.CENTER); 35 | } 36 | 37 | public JPanel createPanel() { 38 | 39 | JPanel panelTxt = new JPanel(); 40 | panelTxt.setLayout(null); 41 | 42 | int j = 17; 43 | int z = 28; 44 | 45 | for (int i = 0; i < 50; i++) { 46 | 47 | JLabel lblNewLabel = new JLabel("New label " + i); 48 | lblNewLabel.setBounds(6, j, 100, 16); 49 | 50 | JTextField textField = new JTextField(); 51 | textField.setBounds(160, j, 270, 16); 52 | textField.setColumns(10); 53 | 54 | panelTxt.add(lblNewLabel); 55 | panelTxt.add(textField); 56 | 57 | j = j + z; 58 | } 59 | 60 | /* 61 | JPanel panel = new JPanel(); 62 | panel.setLayout(null); 63 | panel.add(panelTxt); 64 | 65 | JTextField txtLol = new JTextField(); 66 | txtLol.setText("Lol"); 67 | txtLol.setBounds(118, 17, 270, 16); 68 | txtLol.setColumns(10); 69 | panel.add(txtLol); 70 | 71 | panel.setPreferredSize(new Dimension(500, 800)); 72 | 73 | JLabel lblNewLabel = new JLabel("New label "); 74 | lblNewLabel.setBounds(6, 17, 100, 16); 75 | panel.add(lblNewLabel); 76 | 77 | */ 78 | panelTxt.setPreferredSize(new Dimension(380, 700)); 79 | 80 | return panelTxt; 81 | } 82 | 83 | public static void main(String []args) { 84 | UIEnd main = new UIEnd(); 85 | main.setSize(500, 800); 86 | main.setVisible(true); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/test/UITest2.java: -------------------------------------------------------------------------------- 1 | package ui.test; 2 | 3 | import java.awt.event.*; 4 | import javax.swing.border.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | public class UITest2 extends JFrame 9 | { 10 | public UITest2() { 11 | addWindowListener(new WindowAdapter() { 12 | public void windowClosing(WindowEvent we) { 13 | System.exit(0); 14 | } 15 | }); 16 | 17 | JPanel panel = createContactPanel(); 18 | 19 | JScrollPane sp = new JScrollPane(); 20 | sp.setViewportView(panel); 21 | 22 | getContentPane().setLayout(new BorderLayout()); 23 | getContentPane().add(sp, BorderLayout.CENTER); 24 | } 25 | 26 | public JPanel createContactPanel() { 27 | JLabel titleLbl = new JLabel("Title"); 28 | JLabel firstNameLbl = new JLabel("First name"); 29 | JLabel lastNameLbl = new JLabel("Last name"); 30 | JLabel addressLbl = new JLabel("Address"); 31 | JLabel cityLbl = new JLabel("City"); 32 | JLabel zipLbl = new JLabel("Postal code"); 33 | JLabel countryLbl = new JLabel("Country"); 34 | JLabel phoneLbl = new JLabel("Phone number"); 35 | JLabel faxLbl = new JLabel("Fax number"); 36 | JLabel emailLbl = new JLabel("E-mail"); 37 | JLabel birthdayLbl = new JLabel("Birthdate"); 38 | JLabel pickchoiceLbl = new JLabel("Pick a choice"); 39 | JLabel creditCardTypeLbl = new JLabel("Credit card type"); 40 | JLabel creditCardNumberLbl = new JLabel("Credit card number"); 41 | JLabel expirationLbl = new JLabel("Expiration date"); 42 | 43 | JComboBox titleCombo = new JComboBox( 44 | new String[] { "-", "Mr", "Mrs", "Miss" }); 45 | JTextField firstNameTf = new JTextField(); 46 | JTextField lastNameTf = new JTextField(); 47 | JTextField address1Tf = new JTextField(); 48 | JTextField address2Tf = new JTextField(); 49 | JTextField cityTf = new JTextField(); 50 | JTextField zipTf = new JTextField(); 51 | JTextField countryTf = new JTextField(); 52 | JTextField phoneTf = new JTextField(); 53 | JTextField faxTf = new JTextField(); 54 | JTextField emailTf = new JTextField(); 55 | JComboBox bd1Combo = new JComboBox(); 56 | for (int i=1; i<=12; i++) bd1Combo.addItem(""+i); 57 | JComboBox bd2Combo = new JComboBox(); 58 | for (int i=1; i<=31; i++) bd2Combo.addItem(""+i); 59 | JComboBox bd3Combo = new JComboBox(); 60 | for (int i=1900; i<2000; i++) bd3Combo.addItem(""+i); 61 | JComboBox referCombo = new JComboBox(); 62 | referCombo.addItem("Friend"); 63 | referCombo.addItem("Search engine"); 64 | referCombo.addItem("Print Media"); 65 | referCombo.addItem("Banner Add"); 66 | referCombo.addItem("Other"); 67 | JComboBox creditCardTypeCombo = new JComboBox(); 68 | creditCardTypeCombo.addItem("VISA"); 69 | creditCardTypeCombo.addItem("MasterCard"); 70 | creditCardTypeCombo.addItem("American Express"); 71 | JTextField creditCardNumberTf = new JTextField(); 72 | JComboBox expiration1Combo = new JComboBox(); 73 | for (int i=1; i<=12; i++) expiration1Combo.addItem(""+i); 74 | JComboBox expiration2Combo = new JComboBox(); 75 | for (int i=1; i<=31; i++) expiration2Combo.addItem(""+i); 76 | JComboBox expiration3Combo = new JComboBox(); 77 | for (int i=1900; i<=2000; i++) expiration3Combo.addItem(""+i); 78 | 79 | JPanel panelGeneral = new JPanel(); 80 | panelGeneral.setLayout(null); 81 | panelGeneral.add(titleLbl); 82 | panelGeneral.setBorder(new TitledBorder("General Information")); 83 | titleLbl.setBounds(20, 20, 150, 20); 84 | panelGeneral.add(firstNameLbl); 85 | firstNameLbl.setBounds(20, 50, 150, 20); 86 | panelGeneral.add(lastNameLbl); 87 | lastNameLbl.setBounds(20, 80, 150, 20); 88 | panelGeneral.add(addressLbl); 89 | addressLbl.setBounds(20, 110, 150, 20); 90 | panelGeneral.add(cityLbl); 91 | cityLbl.setBounds(20, 170, 150, 20); 92 | panelGeneral.add(zipLbl); 93 | zipLbl.setBounds(20, 200, 150, 20); 94 | panelGeneral.add(countryLbl); 95 | countryLbl.setBounds(20, 230, 150, 20); 96 | panelGeneral.add(phoneLbl); 97 | phoneLbl.setBounds(20, 260, 150, 20); 98 | panelGeneral.add(faxLbl); 99 | faxLbl.setBounds(20, 290, 150, 20); 100 | panelGeneral.add(emailLbl); 101 | emailLbl.setBounds(20, 320, 150, 20); 102 | panelGeneral.add(birthdayLbl); 103 | birthdayLbl.setBounds(20, 350, 150, 20); 104 | panelGeneral.add(titleCombo); 105 | titleCombo.setBounds(150, 20, 60, 20); 106 | panelGeneral.add(firstNameTf); 107 | firstNameTf.setBounds(150, 50, 200, 20); 108 | panelGeneral.add(lastNameTf); 109 | lastNameTf.setBounds(150, 80, 200, 20); 110 | panelGeneral.add(address1Tf); 111 | address1Tf.setBounds(150, 110, 200, 20); 112 | panelGeneral.add(address2Tf); 113 | address2Tf.setBounds(150, 140, 200, 20); 114 | panelGeneral.add(cityTf); 115 | cityTf.setBounds(150, 170, 200, 20); 116 | panelGeneral.add(zipTf); 117 | zipTf.setBounds(150, 200, 200, 20); 118 | panelGeneral.add(countryTf); 119 | countryTf.setBounds(150, 230, 200, 20); 120 | panelGeneral.add(phoneTf); 121 | phoneTf.setBounds(150, 260, 200, 20); 122 | panelGeneral.add(faxTf); 123 | faxTf.setBounds(150, 290, 200, 20); 124 | panelGeneral.add(emailTf); 125 | emailTf.setBounds(150, 320, 200, 20); 126 | panelGeneral.add(bd1Combo); 127 | bd1Combo.setBounds(150, 350, 60, 20); 128 | panelGeneral.add(bd2Combo); 129 | bd2Combo.setBounds(220, 350, 60, 20); 130 | panelGeneral.add(bd3Combo); 131 | bd3Combo.setBounds(290, 350, 60, 20); 132 | 133 | JPanel panelReferral = new JPanel(); 134 | panelReferral.setLayout(null); 135 | panelReferral.setBorder(new TitledBorder("Where did you hear about us?")); 136 | panelReferral.add(pickchoiceLbl); 137 | pickchoiceLbl.setBounds(20, 20, 150, 20); 138 | panelReferral.add(referCombo); 139 | referCombo.setBounds(150, 20, 100, 20); 140 | 141 | JPanel panelCreditCard = new JPanel(); 142 | panelCreditCard.setLayout(null); 143 | panelCreditCard.setBorder(new TitledBorder("Payment method")); 144 | panelCreditCard.add(creditCardTypeLbl); 145 | creditCardTypeLbl.setBounds(20, 20, 150, 20); 146 | panelCreditCard.add(creditCardNumberLbl); 147 | creditCardNumberLbl.setBounds(20, 50, 150, 20); 148 | panelCreditCard.add(expirationLbl); 149 | expirationLbl.setBounds(20, 80, 150, 20); 150 | 151 | panelCreditCard.add(creditCardTypeCombo); 152 | creditCardTypeCombo.setBounds(150, 20, 100, 20); 153 | panelCreditCard.add(creditCardNumberTf); 154 | creditCardNumberTf.setBounds(150, 50, 150, 20); 155 | panelCreditCard.add(expiration2Combo); 156 | expiration2Combo.setBounds(220, 80, 60, 20); 157 | panelCreditCard.add(expiration3Combo); 158 | expiration3Combo.setBounds(290, 80, 60, 20); 159 | 160 | JPanel panel = new JPanel(); 161 | panel.setLayout(null); 162 | panel.add(panelGeneral); 163 | panelGeneral.setBounds(10, 20, 370, 400); 164 | panel.add(panelReferral); 165 | panelReferral.setBounds(10, 430, 370, 50); 166 | panel.add(panelCreditCard); 167 | panelCreditCard.setBounds(10, 490, 370, 120); 168 | 169 | panel.setPreferredSize(new Dimension(380, 620)); 170 | 171 | return panel; 172 | } 173 | 174 | public static void main(String []args) { 175 | UITest2 main = new UITest2(); 176 | main.setSize(400, 400); 177 | main.setVisible(true); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/ui/test/UiTestScroll.java: -------------------------------------------------------------------------------- 1 | package ui.test; 2 | 3 | import java.awt.event.*; 4 | import javax.swing.border.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | public class UiTestScroll extends JFrame { 9 | private JTextField textField; 10 | private JTextField textField_1; 11 | public UiTestScroll() { 12 | addWindowListener(new WindowAdapter() { 13 | public void windowClosing(WindowEvent we) { 14 | System.exit(0); 15 | } 16 | }); 17 | 18 | JPanel panel = createContactPanel(); 19 | 20 | JScrollPane sp = new JScrollPane(); 21 | sp.setViewportView(panel); 22 | 23 | getContentPane().setLayout(new BorderLayout()); 24 | getContentPane().add(sp, BorderLayout.CENTER); 25 | } 26 | 27 | public JPanel createContactPanel() { 28 | JLabel titleLbl = new JLabel("Title"); 29 | titleLbl.setBounds(20, 20, 150, 20); 30 | 31 | JPanel panelGeneral = new JPanel(); 32 | panelGeneral.setLayout(null); 33 | panelGeneral.add(titleLbl); 34 | panelGeneral.setBorder(new TitledBorder("General Information")); 35 | 36 | /* 37 | 38 | JLabel firstNameLbl = new JLabel("First name "); 39 | firstNameLbl.setBounds(20, 50, 90, 20); 40 | 41 | JTextField firstNameTf = new JTextField(); 42 | firstNameTf.setBounds(122, 50, 236, 20); 43 | 44 | panelGeneral.add(firstNameLbl); 45 | panelGeneral.add(firstNameTf); 46 | 47 | textField = new JTextField(); 48 | textField.setBounds(122, 83, 236, 20); 49 | panelGeneral.add(textField); 50 | 51 | JLabel label = new JLabel("First name "); 52 | label.setBounds(20, 83, 90, 20); 53 | panelGeneral.add(label); 54 | 55 | textField_1 = new JTextField(); 56 | textField_1.setBounds(122, 116, 236, 20); 57 | panelGeneral.add(textField_1); 58 | 59 | JLabel label_1 = new JLabel("First name "); 60 | label_1.setBounds(20, 116, 90, 20); 61 | panelGeneral.add(label_1); 62 | 63 | */ 64 | 65 | int j = 50; 66 | int z = 33; 67 | int length = 11; 68 | for (int i = 0; i < length; i++) { 69 | 70 | JLabel firstNameLbl = new JLabel("First name " + i); 71 | firstNameLbl.setBounds(20, j, 90, 20); 72 | 73 | JTextField firstNameTf = new JTextField(); 74 | firstNameTf.setBounds(122, j, 236, 20); 75 | 76 | panelGeneral.add(firstNameLbl); 77 | panelGeneral.add(firstNameTf); 78 | 79 | j = j + z; 80 | } 81 | // Pour 50 txtField d'affichage 1700 de dimension était nécessaire donc 1700 / 50 donne 34 ce qui fait que 34 est nécessaire à chaque fois pour afficher 82 | //un text field au complet donc si on fait length multiplié par 34 sa doit nous donner directement l'affichage top des txtfield de length 83 | panelGeneral.setPreferredSize(new Dimension(350, (int) (length * 36))); // Pour les scroll 350 largeur, 2000 hauteur 84 | //panelGeneral.setPreferredSize(new Dimension(350, 1700)); 85 | 86 | //Pour gérer l'affichage je fais 87 | if (((int) (length * 34)) < 400) { 88 | panelGeneral.setPreferredSize(new Dimension(350, 400)); 89 | }else { 90 | panelGeneral.setPreferredSize(new Dimension(350, (int) (length * 33.5))); 91 | } 92 | 93 | return panelGeneral; 94 | } 95 | 96 | public static void main(String[] args) { 97 | UiTestScroll main = new UiTestScroll(); 98 | main.setSize(400, 400); 99 | main.setVisible(true); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class Constants { 4 | 5 | public static final String SECRET_KEY = "qUmLBxQ9{d5j.%]D*`"; 6 | public static final String JDBC_DRIVER_NAME = "org.sqlite.JDBC"; 7 | public static final String DB_PATH = "pwd_manager.db"; 8 | 9 | /* 10 | * Constante de la table User 11 | */ 12 | public static final String TABLE_PM_USER = "PM_USER"; 13 | public static final String U_ID = "U_ID"; 14 | public static final String U_NAME = "U_NAME"; 15 | public static final String U_EMAIL = "U_EMAIL"; 16 | public static final String U_PASSWORD = "U_PASSWORD"; 17 | public static final String U_CREATE_DATE = "U_CREATE_DATE"; 18 | public static final String U_LAST_UPDATE = "U_LAST_UPDATE"; 19 | 20 | /* 21 | * Constante de la table account 22 | */ 23 | public static final String TABLE_PM_ACCOUNT = "PM_ACCOUNT"; 24 | public static final String A_ID = "A_ID"; 25 | public static final String A_NAME = "A_NAME"; 26 | public static final String A_USERNAME = "A_USERNAME"; 27 | public static final String A_PASSWORD = "A_PASSWORD"; 28 | public static final String A_URL = "A_URL"; 29 | public static final String A_CREATE_DATE = "A_CREATE_DATE"; 30 | public static final String A_LAST_UPDATE = "A_LAST_UPDATE"; 31 | public static final String PM_USER_U_ID = "PM_USER_U_ID"; 32 | 33 | /* 34 | * Constante des retour de l'appel de la Base de donnée. 35 | */ 36 | public static final int COMPLETED_SUCCESSFULLY = 0; 37 | public static final int NOT_FOUND = 20; 38 | public static final int PASSWORD_ERROR = 25; 39 | public static final int UNKNOW_ERROR = 30; 40 | public static final int EMAIL_EXIST = 35; 41 | public static final int USER_ID_NOT_EXIST = 40; 42 | public static final int ACCOUNT_ID_NOT_EXIST = 45; 43 | 44 | /* 45 | * Social network links 46 | */ 47 | public static final String URL_GITHUB = "https://github.com/soumgraphic"; 48 | public static final String URL_FACEBOOK = "https://www.facebook.com/soumgraphic/"; 49 | public static final String URL_TWITTER = "https://twitter.com/soumailaadiarra"; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/utils/Guide des tailles des composants Item: -------------------------------------------------------------------------------- 1 | usernameItemTf.setBounds(12, 6, 211, 22); 2 | textField_2.setBounds(12, 73, 211, 22); => debutCpUsername = 6, incrementCpUsername = 67 3 | 4 | passwordItemTf.setBounds(246, 6, 150, 22); 5 | textField_4.setBounds(246, 73, 150, 22); debutCpPassword = 6, incrementCpPassword = 67 6 | 7 | iconViewPasswordItem.setBounds(408, 6, 23, 23); 8 | label.setBounds(408, 73, 23, 23); debutCpIconViewPassword = 6, incrementIconViewPassword = 67 9 | 10 | urlItemTf.setBounds(470, 6, 160, 22); 11 | textField_6.setBounds(470, 73, 160, 22); debutCpUrl = 6, incrementUrl = 67 12 | 13 | iconEditupdateItem.setBounds(655, 16, 30, 30); 14 | label_1.setBounds(655, 83, 30, 30); debutCpIconEditUpdate = 16, incrementIconEditUpdate = 67 15 | 16 | iconeDeleteItem.setBounds(704, 16, 30, 30); 17 | label_2.setBounds(704, 83, 30, 30); debutCpIconeDelete = 16, incrementIconeDelete = 67 18 | 19 | etatUrlItemTf.setBounds(470, 32, 150, 22); 20 | textField_7.setBounds(470, 99, 150, 22); debutCpEtatUrl = 32, incrementEtatUrl = 67 21 | 22 | etatPasswordItemTf.setBounds(246, 32, 150, 22); 23 | textField_5.setBounds(246, 99, 150, 22); debutCpEtatPassword = 32, incrementEtatPassword = 67 24 | 25 | nomCompletItemTf.setBounds(12, 32, 211, 22); 26 | textField_3.setBounds(12, 99, 211, 22); debutCpNomComplet = 32, incrementNomComplet = 67 27 | 28 | separatorItem.setBounds(0, 58, 734, 7); 29 | separator.setBounds(0, 125, 734, 7); debutCpSeparator = 58 30 | 31 | 32 | textField_2 = new JTextField(); 33 | textField_2.setText("soumgraphic@gmail.com"); 34 | textField_2.setForeground(new Color(112, 128, 144)); 35 | textField_2.setFont(new Font("Tahoma", Font.BOLD, 15)); 36 | textField_2.setEditable(false); 37 | textField_2.setColumns(10); 38 | textField_2.setBorder(null); 39 | textField_2.setBackground(Color.WHITE); 40 | textField_2.setBounds(12, 73, 211, 22); 41 | panel_3.add(textField_2); 42 | 43 | textField_3 = new JTextField(); 44 | textField_3.setText("Soumaila Abdoulaye DIARRA"); 45 | textField_3.setForeground(new Color(112, 128, 144)); 46 | textField_3.setFont(new Font("Tahoma", Font.PLAIN, 14)); 47 | textField_3.setEditable(false); 48 | textField_3.setColumns(10); 49 | textField_3.setBorder(null); 50 | textField_3.setBackground(Color.WHITE); 51 | textField_3.setBounds(12, 99, 211, 22); 52 | panel_3.add(textField_3); 53 | 54 | textField_4 = new JTextField(); 55 | textField_4.setText("**********"); 56 | textField_4.setForeground(new Color(112, 128, 144)); 57 | textField_4.setFont(new Font("Tahoma", Font.BOLD, 15)); 58 | textField_4.setEditable(false); 59 | textField_4.setColumns(10); 60 | textField_4.setBorder(null); 61 | textField_4.setBackground(Color.WHITE); 62 | textField_4.setBounds(246, 73, 150, 22); 63 | panel_3.add(textField_4); 64 | 65 | textField_5 = new JTextField(); 66 | textField_5.setText("Faible"); 67 | textField_5.setForeground(new Color(112, 128, 144)); 68 | textField_5.setFont(new Font("Tahoma", Font.PLAIN, 14)); 69 | textField_5.setEditable(false); 70 | textField_5.setColumns(10); 71 | textField_5.setBorder(null); 72 | textField_5.setBackground(Color.WHITE); 73 | textField_5.setBounds(246, 99, 150, 22); 74 | panel_3.add(textField_5); 75 | 76 | JSeparator separator = new JSeparator(); 77 | separator.setBounds(0, 125, 734, 7); 78 | panel_3.add(separator); 79 | 80 | JLabel label = new JLabel(""); 81 | label.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye.png"))); 82 | label.setForeground(new Color(112, 128, 144)); 83 | label.setFont(new Font("Tahoma", Font.BOLD, 16)); 84 | label.setBounds(408, 73, 23, 23); 85 | panel_3.add(label); 86 | 87 | textField_6 = new JTextField(); 88 | textField_6.setText("www.youtube.com"); 89 | textField_6.setForeground(new Color(112, 128, 144)); 90 | textField_6.setFont(new Font("Tahoma", Font.BOLD, 15)); 91 | textField_6.setEditable(false); 92 | textField_6.setColumns(10); 93 | textField_6.setBorder(null); 94 | textField_6.setBackground(Color.WHITE); 95 | textField_6.setBounds(470, 73, 160, 22); 96 | panel_3.add(textField_6); 97 | 98 | textField_7 = new JTextField(); 99 | textField_7.setText("Site fiable"); 100 | textField_7.setForeground(new Color(112, 128, 144)); 101 | textField_7.setFont(new Font("Tahoma", Font.PLAIN, 14)); 102 | textField_7.setEditable(false); 103 | textField_7.setColumns(10); 104 | textField_7.setBorder(null); 105 | textField_7.setBackground(Color.WHITE); 106 | textField_7.setBounds(470, 99, 150, 22); 107 | panel_3.add(textField_7); 108 | 109 | JLabel label_1 = new JLabel(""); 110 | label_1.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/edit_icon.png"))); 111 | label_1.setBounds(655, 83, 30, 30); 112 | panel_3.add(label_1); 113 | 114 | JLabel label_2 = new JLabel(""); 115 | label_2.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/delete_icon.png"))); 116 | label_2.setBounds(704, 83, 30, 30); 117 | panel_3.add(label_2); -------------------------------------------------------------------------------- /JavaSwingPasswordManager/src/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.util.Date; 4 | import java.awt.Desktop; 5 | import java.awt.Toolkit; 6 | import java.net.URL; 7 | import java.text.ParseException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Locale; 10 | import java.util.Random; 11 | import java.util.UUID; 12 | import java.util.logging.Level; 13 | import java.util.regex.Matcher; 14 | import java.util.regex.Pattern; 15 | 16 | import javax.swing.JOptionPane; 17 | import javax.swing.JPasswordField; 18 | import javax.swing.JTextField; 19 | 20 | import ui.AdminUI; 21 | 22 | import javax.swing.ImageIcon; 23 | import javax.swing.JButton; 24 | import javax.swing.JFrame; 25 | import javax.swing.JLabel; 26 | 27 | public class Utils { 28 | 29 | private final static java.util.logging.Logger log = java.util.logging.Logger.getLogger("logger"); 30 | 31 | public static java.util.logging.Logger getLogger(Level l, String message) { 32 | log.log(l, message); 33 | return log; 34 | } 35 | 36 | public static String generateUUID() { 37 | UUID uuid = UUID.randomUUID(); 38 | String randomUUIDString = uuid.toString(); 39 | 40 | return randomUUIDString; 41 | } 42 | 43 | public static java.sql.Date dateRetrieveConvert(String inputDate) { 44 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); 45 | Date date = null; 46 | try { 47 | date = df.parse(inputDate); 48 | } catch (ParseException e) { 49 | // TODO Auto-generated catch block 50 | e.printStackTrace(); 51 | } 52 | java.sql.Date sqlDate = new java.sql.Date(date.getTime()); 53 | 54 | return sqlDate; 55 | } 56 | 57 | public static void errorDbConnection() { 58 | getLogger(Level.SEVERE, 59 | "Erreur lors de la connexion à la base de donnée, veuillez vérifiez si la base de donée est bien démarré !"); 60 | } 61 | 62 | public static boolean isNullOrEmpty(String str) { 63 | if (str != null && !str.trim().isEmpty()) 64 | return false; 65 | return true; 66 | } 67 | 68 | public static boolean validateEmail(String email) { 69 | // Email Regex java 70 | final String EMAIL_REGEX = "^[\\w-\\+]+(\\.[\\w]+)*@[\\w-]+(\\.[\\w]+)*(\\.[a-z]{2,})$"; 71 | Pattern pattern; 72 | Matcher matcher; 73 | pattern = Pattern.compile(EMAIL_REGEX, Pattern.CASE_INSENSITIVE); 74 | matcher = pattern.matcher(email); 75 | return matcher.matches(); 76 | } 77 | 78 | public static boolean checkStringMinLength(String chaine, int minLength) { 79 | if (chaine.length() < minLength) { 80 | return false; 81 | } else { 82 | return true; 83 | } 84 | } 85 | 86 | public static void showErrorMessage(JFrame frame, String message) { 87 | final ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Utils.class.getResource("/ui/images/cancel.png"))); 88 | JOptionPane.showMessageDialog(frame, message + " :)", "Password Manager - Erreur", 89 | JOptionPane.INFORMATION_MESSAGE, icon); 90 | } 91 | 92 | public static int showConfirmDialog(JFrame frame, String message) { 93 | final ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Utils.class.getResource("/ui/images/warning.png"))); 94 | int input = JOptionPane.showConfirmDialog(frame, message, 95 | "Password Manager - Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, icon); 96 | return input; 97 | } 98 | 99 | public static void showSuccessMessage(JFrame frame, String message) { 100 | JOptionPane.showMessageDialog(frame, message, "Password Manager", 0); 101 | } 102 | 103 | public static void enableButton(JTextField textField, JButton button) { 104 | if (!isNullOrEmpty(textField.getText().toString())) { 105 | button.setEnabled(false); 106 | } else { 107 | button.setEnabled(true); 108 | } 109 | } 110 | 111 | public static void openWebpage(String urlString) { 112 | try { 113 | Desktop.getDesktop().browse(new URL(urlString).toURI()); 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | } 118 | 119 | public static final void showOrHidePasswordTxtFields(JPasswordField passwordField, JLabel labelForChangeIcon, char caractereCodagePass) { 120 | // TODO Auto-generated method stub 121 | String nomImage = labelForChangeIcon.getIcon().toString(); 122 | //Split le chemin et recupère la dernière occurence de nom 123 | nomImage = nomImage.substring(nomImage.lastIndexOf("/")+1); 124 | 125 | String pass = passwordField.getText().toString(); 126 | if (nomImage.equals("eye.png")) { 127 | passwordField.setEchoChar((char)0); 128 | labelForChangeIcon.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye_invisible.png"))); 129 | }else if (nomImage.equals("eye_invisible.png")) { 130 | passwordField.setEchoChar(caractereCodagePass); 131 | labelForChangeIcon.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye.png"))); 132 | }else if(nomImage.equals("eye_white.png")) { 133 | passwordField.setEchoChar((char)0); 134 | labelForChangeIcon.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye_invisible_white.png"))); 135 | } 136 | else if (nomImage.equals("eye_invisible_white.png")) { 137 | passwordField.setEchoChar(caractereCodagePass); 138 | labelForChangeIcon.setIcon(new ImageIcon(AdminUI.class.getResource("/ui/images/eye_white.png"))); 139 | } 140 | } 141 | 142 | public static void refreshFrame(JFrame frame) { 143 | //frame.invalidate(); 144 | //frame.validate(); 145 | frame.revalidate(); 146 | frame.repaint(); 147 | } 148 | 149 | public static String generatePassword() { 150 | String SALTCHARS = "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789+-*/=&\".-_+/*,'#"; 151 | StringBuilder salt = new StringBuilder(); 152 | Random rnd = new Random(); 153 | while (salt.length() < 18) { // length of the random string. 154 | int index = (int) (rnd.nextFloat() * SALTCHARS.length()); 155 | salt.append(SALTCHARS.charAt(index)); 156 | } 157 | String saltStr = salt.toString(); 158 | return saltStr; 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaSwingPasswordManager 2 | Secure password manager with java swing, sqlite and sha-256 3 | 4 | For test or use application you can download it and execute jar file [in this link](https://drive.google.com/file/d/17TvkUkG1mIR8S1WtJMeoo81UNAGd8Dhi/view?usp=sharing) 5 | 6 | ## Connexion page 7 | ![alt text](https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/master/JavaSwingPasswordManager/screenshots/Page%20connexion%20-%20pass%20manager.png) 8 | 9 | ## Inscription page 10 | ![alt text](https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/master/JavaSwingPasswordManager/screenshots/Page%20d'inscription%20-%20pass%20manager.png) 11 | 12 | ## Dashboard 13 | ![alt text](https://raw.githubusercontent.com/soumgraphic/JavaSwingPasswordManager/master/JavaSwingPasswordManager/screenshots/Page%20Admin%20-%20pass%20manager.png) 14 | --------------------------------------------------------------------------------