1 | package org.expeditee.auth.account;
|
---|
2 |
|
---|
3 | import java.io.FileNotFoundException;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.security.KeyStoreException;
|
---|
6 | import java.security.NoSuchAlgorithmException;
|
---|
7 | import java.security.cert.CertificateException;
|
---|
8 | import java.sql.SQLException;
|
---|
9 | import java.util.Map;
|
---|
10 |
|
---|
11 | import javax.crypto.SecretKey;
|
---|
12 |
|
---|
13 | import org.expeditee.auth.AuthenticatorBrowser;
|
---|
14 | import org.expeditee.auth.tags.AuthenticationTag;
|
---|
15 | import org.expeditee.gui.DisplayController;
|
---|
16 | import org.expeditee.gui.FrameIO;
|
---|
17 | import org.expeditee.gui.MessageBay;
|
---|
18 |
|
---|
19 | public 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 | }
|
---|