source: trunk/src/org/expeditee/auth/account/Password.java@ 1335

Last change on this file since 1335 was 1335, checked in by bln4, 5 years ago

Update to change password functionality, mostly cosmetic frame update.

File size: 1.5 KB
Line 
1package org.expeditee.auth.account;
2
3import java.io.FileNotFoundException;
4import java.io.IOException;
5import java.security.KeyStoreException;
6import java.security.NoSuchAlgorithmException;
7import java.security.cert.CertificateException;
8import java.sql.SQLException;
9import java.util.Map;
10
11import javax.crypto.SecretKey;
12
13import org.expeditee.auth.AuthenticatorBrowser;
14import org.expeditee.auth.tags.AuthenticationTag;
15import org.expeditee.gui.DisplayController;
16import org.expeditee.gui.FrameIO;
17import org.expeditee.gui.MessageBay;
18
19public class Password {
20 /*
21 * Changes the recorded password for a user in the key store.
22 */
23 public static void changePassword(final Map<AuthenticationTag, String> userdata) throws NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, IOException, ClassNotFoundException, SQLException {
24 final String username = userdata.get(AuthenticationTag.Username);
25 final String password = userdata.get(AuthenticationTag.Password);
26 final String newpassword = userdata.get(AuthenticationTag.NewPassword);
27
28 final SecretKey key = AuthenticatorBrowser.getInstance().getSecretKey(username, password);
29 if (key == null) {
30 MessageBay.errorMessage("The username + existing password combination was incorrect.");
31 } else {
32 AuthenticatorBrowser.getInstance().putKey(username, newpassword, key);
33 MessageBay.displayMessage("Password changed successfully.");
34 DisplayController.setCurrentFrame(FrameIO.LoadFrame("multiuser1"), true);
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.