[1335] | 1 | package org.expeditee.auth.account;
|
---|
| 2 |
|
---|
[1363] | 3 | import java.io.File;
|
---|
[1335] | 4 | import java.io.FileNotFoundException;
|
---|
| 5 | import java.io.IOException;
|
---|
[1363] | 6 | import java.nio.file.Path;
|
---|
| 7 | import java.nio.file.Paths;
|
---|
[1335] | 8 | import java.security.KeyStoreException;
|
---|
| 9 | import java.security.NoSuchAlgorithmException;
|
---|
[1363] | 10 | import java.security.SecureRandom;
|
---|
[1335] | 11 | import java.security.cert.CertificateException;
|
---|
| 12 | import java.sql.SQLException;
|
---|
[1363] | 13 | import java.util.Base64;
|
---|
| 14 | import java.util.Collection;
|
---|
| 15 | import java.util.HashMap;
|
---|
| 16 | import java.util.Iterator;
|
---|
[1335] | 17 | import java.util.Map;
|
---|
[1340] | 18 | import java.util.Properties;
|
---|
[1363] | 19 | import java.util.Scanner;
|
---|
[1335] | 20 |
|
---|
| 21 | import javax.crypto.SecretKey;
|
---|
[1363] | 22 | import javax.crypto.spec.SecretKeySpec;
|
---|
[1340] | 23 | import javax.mail.Message;
|
---|
| 24 | import javax.mail.MessagingException;
|
---|
| 25 | import javax.mail.PasswordAuthentication;
|
---|
| 26 | import javax.mail.Session;
|
---|
| 27 | import javax.mail.Transport;
|
---|
[1363] | 28 | import javax.mail.internet.AddressException;
|
---|
[1340] | 29 | import javax.mail.internet.InternetAddress;
|
---|
| 30 | import javax.mail.internet.MimeMessage;
|
---|
[1335] | 31 |
|
---|
| 32 | import org.expeditee.auth.AuthenticatorBrowser;
|
---|
[1363] | 33 | import org.expeditee.auth.mail.Mail;
|
---|
| 34 | import org.expeditee.auth.mail.Mail.MailEntry;
|
---|
[1335] | 35 | import org.expeditee.auth.tags.AuthenticationTag;
|
---|
[1389] | 36 | import org.expeditee.encryption.CryptographyConstants;
|
---|
[1335] | 37 | import org.expeditee.gui.DisplayController;
|
---|
[1363] | 38 | import org.expeditee.gui.Frame;
|
---|
[1335] | 39 | import org.expeditee.gui.FrameIO;
|
---|
| 40 | import org.expeditee.gui.MessageBay;
|
---|
[1363] | 41 | import org.expeditee.items.Text;
|
---|
| 42 | import org.expeditee.settings.UserSettings;
|
---|
| 43 | import org.expeditee.settings.identity.passwordrecovery.Colleagues;
|
---|
| 44 | import org.expeditee.settings.identity.secrets.KeyList;
|
---|
| 45 | import org.expeditee.stats.Formatter;
|
---|
[1335] | 46 |
|
---|
[1363] | 47 | import com.codahale.shamir.Scheme;
|
---|
| 48 |
|
---|
[1357] | 49 | public class Password implements CryptographyConstants {
|
---|
[1363] | 50 | /**
|
---|
| 51 | * Changes the recorded password for a user in the key store; given the username signaling whose password to change, along with the existing and new password.
|
---|
[1335] | 52 | */
|
---|
[1336] | 53 | public static void changePassword(Map<AuthenticationTag, String> userdata) throws NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, IOException, ClassNotFoundException, SQLException {
|
---|
| 54 | String username = userdata.get(AuthenticationTag.Username);
|
---|
| 55 | String password = userdata.get(AuthenticationTag.Password);
|
---|
| 56 | String newpassword = userdata.get(AuthenticationTag.NewPassword);
|
---|
[1335] | 57 |
|
---|
| 58 | final SecretKey key = AuthenticatorBrowser.getInstance().getSecretKey(username, password);
|
---|
| 59 | if (key == null) {
|
---|
| 60 | MessageBay.errorMessage("The username + existing password combination was incorrect.");
|
---|
| 61 | } else {
|
---|
| 62 | AuthenticatorBrowser.getInstance().putKey(username, newpassword, key);
|
---|
| 63 | MessageBay.displayMessage("Password changed successfully.");
|
---|
| 64 | DisplayController.setCurrentFrame(FrameIO.LoadFrame("multiuser1"), true);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
[1340] | 67 |
|
---|
[1363] | 68 | /**
|
---|
| 69 | * Generates a intergalaictic number for a specified user and emails that number using the specified email.
|
---|
| 70 | * @param userData
|
---|
| 71 | */
|
---|
[1340] | 72 | public static void generateAndDeliverIntergalacticNumber(Map<AuthenticationTag, String> userData) {
|
---|
| 73 | String username = userData.get(AuthenticationTag.Username);
|
---|
| 74 | String email = userData.get(AuthenticationTag.Email);
|
---|
| 75 | try {
|
---|
| 76 | // Generate message text.
|
---|
| 77 | String intergalacticNumber = AuthenticatorBrowser.getInstance().newIntergalacticNumber(username, email);
|
---|
| 78 | String nl = System.getProperty("line.separator");
|
---|
| 79 | StringBuilder sb = new StringBuilder();
|
---|
| 80 | sb.append("You are receiving this email because someone is attempting to reset your Expeditee password." + nl);
|
---|
| 81 | sb.append("If you did not make this request then no action is required." + nl);
|
---|
| 82 | sb.append("If it was you who made this request, the following string of characters is your intergalactic number: " + intergalacticNumber + nl);
|
---|
| 83 |
|
---|
[1363] | 84 | sendEmail(email, sb);
|
---|
[1340] | 85 | } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | ClassNotFoundException
|
---|
| 86 | | IOException | SQLException | MessagingException e) {
|
---|
| 87 | e.printStackTrace();
|
---|
| 88 | }
|
---|
[1336] | 89 | }
|
---|
[1348] | 90 |
|
---|
[1363] | 91 | /**
|
---|
| 92 | * Confirms that the specified intergalaictic number matches the one of file for the specified username.
|
---|
| 93 | * Passing this test it then alerts the users pw colleagues through a one-off secure Expeditee message.
|
---|
| 94 | * @param tags
|
---|
| 95 | */
|
---|
[1368] | 96 | public static void confirmIntergalacticNumberAndAlertTrustedUsers(Map<AuthenticationTag, String> tags) {
|
---|
[1363] | 97 | // Confirm intergalactic numbers match
|
---|
| 98 | String username = tags.get(AuthenticationTag.Username);
|
---|
| 99 | String intergalacticNumber = tags.get(AuthenticationTag.IntergalacticNumber);
|
---|
| 100 | boolean match = false;
|
---|
| 101 | try {
|
---|
| 102 | match = AuthenticatorBrowser.getInstance().confirmIntergalaticNumber(username, intergalacticNumber);
|
---|
| 103 | } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | ClassNotFoundException
|
---|
| 104 | | IOException | SQLException e) {
|
---|
| 105 | e.printStackTrace();
|
---|
| 106 | return;
|
---|
| 107 | }
|
---|
| 108 | if (!match) {
|
---|
| 109 | MessageBay.errorMessage("The provided identity number does not match the one stored on file.");
|
---|
| 110 | return;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | // Get colleagues to distribute messages too.
|
---|
| 114 | String[] colleagues = getPasswordColleaguesFromUsername(username);
|
---|
| 115 | // Send secure message to colleague one
|
---|
| 116 | String colleagueOne = colleagues[0];
|
---|
| 117 | String time = Formatter.getDateTime();
|
---|
| 118 | String topic = "Password Recovery for " + username;
|
---|
| 119 | String message = "Your colleague " + username + " would like you to help them recover access to their account.";
|
---|
| 120 | Map<String, String> options = new HashMap<String, String>();
|
---|
| 121 | options.put("Provide assistance", "AuthEmailPasswordShare " + username);
|
---|
| 122 | MailEntry mail = new MailEntry(time, username, colleagueOne, topic, message, options);
|
---|
| 123 | Mail.sendOneOffMail(mail, colleagueOne, Base64.getDecoder().decode(intergalacticNumber));
|
---|
| 124 |
|
---|
| 125 | // Send secure message to colleague two
|
---|
| 126 | String colleagueTwo = colleagues[1];
|
---|
| 127 | Mail.sendOneOffMail(mail, colleagueTwo, Base64.getDecoder().decode(intergalacticNumber));
|
---|
| 128 |
|
---|
| 129 | String nl = System.getProperty("line.separator");
|
---|
| 130 | StringBuilder sb = new StringBuilder();
|
---|
| 131 | sb.append("You are receiving this email because one of your Expeditee contacts has sent you a one-off secure message." + nl);
|
---|
| 132 | sb.append("When you log into Expeditee and check your mail it will be there waiting for you." + nl);
|
---|
| 133 | sb.append("You will need the following key to read this message: " + nl);
|
---|
| 134 | sb.append(intergalacticNumber);
|
---|
| 135 | try {
|
---|
| 136 | // Send email with key to colleague one
|
---|
| 137 | String colleagueOneEmail = colleagues[2];
|
---|
| 138 | sendEmail(colleagueOneEmail, sb);
|
---|
| 139 | // Send email with key to colleague two
|
---|
| 140 | String colleagueTwoEmail = colleagues[3];
|
---|
| 141 | sendEmail(colleagueTwoEmail, sb);
|
---|
[1367] | 142 |
|
---|
[1368] | 143 | MessageBay.displayMessage("Identity confirmed. Your trusted contacts have been notified via one-off secure Expeditee message. "
|
---|
[1367] | 144 | + "You will recieve an email message with a password share from each once they have completed their part of the process. Enter them below.");
|
---|
[1363] | 145 | } catch (MessagingException e) {
|
---|
| 146 | e.printStackTrace();
|
---|
| 147 | }
|
---|
[1348] | 148 | }
|
---|
[1363] | 149 |
|
---|
| 150 | private static String[] getPasswordColleaguesFromUsername(String username) {
|
---|
| 151 | Path credentialsFilePath = Paths.get(FrameIO.PROFILE_PATH).resolve(username).resolve("pwcolleagues.inf");
|
---|
| 152 | String fileName = null;
|
---|
| 153 | if (credentialsFilePath.toFile().exists()) {
|
---|
| 154 | try (Scanner in = new Scanner(credentialsFilePath)) {
|
---|
| 155 | fileName = in.nextLine();
|
---|
| 156 | } catch (IOException e) {
|
---|
[1368] | 157 | MessageBay.errorMessage("Unable to find trusted users contact frame for specified user, are they registered on this computer?");
|
---|
[1363] | 158 | return null;
|
---|
| 159 | }
|
---|
| 160 | } else {
|
---|
[1368] | 161 | MessageBay.errorMessage("Unable to find trusted users contact frame for specified user, are they registered on this computer?");
|
---|
[1363] | 162 | return null;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | int number = Integer.parseInt(fileName.replace(".exp", ""));
|
---|
| 166 | Frame pwColleagueFrame = FrameIO.LoadFrame(username + number, FrameIO.PROFILE_PATH);
|
---|
| 167 | Collection<Text> textItems = pwColleagueFrame.getTextItems();
|
---|
[1472] | 168 | textItems.removeIf(text -> !text.getText().startsWith("User_"));
|
---|
[1363] | 169 |
|
---|
| 170 | String[] ret = new String[4];
|
---|
| 171 | Iterator<Text> it = textItems.iterator();
|
---|
| 172 | while(it.hasNext()) {
|
---|
| 173 | String content = it.next().getText().toLowerCase().trim();
|
---|
[1472] | 174 | if (content.contains("user_one:")) {
|
---|
| 175 | ret[0] = content.replace("user_one:", "").trim();
|
---|
| 176 | } else if (content.contains("user_two:")) {
|
---|
| 177 | ret[1] = content.replace("user_two:", "").trim();
|
---|
[1363] | 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | // find colleague one email
|
---|
| 182 | Path credentialsDirectoryPath = UserSettings.PublicAndPrivateResources
|
---|
| 183 | ? Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username)
|
---|
| 184 | : Paths.get(FrameIO.PARENT_FOLDER);
|
---|
| 185 | credentialsDirectoryPath = credentialsDirectoryPath.resolve("contacts").resolve(ret[0] + "-credentials");
|
---|
| 186 | try (Scanner in = new Scanner(credentialsDirectoryPath.resolve("credentials.inf").toFile())) {
|
---|
| 187 | int parseInt = Integer.parseInt(in.nextLine().replace(".exp", ""));
|
---|
| 188 | Frame frame = FrameIO.LoadFrame(ret[0] + "-credentials" + parseInt, credentialsDirectoryPath.toAbsolutePath().getParent().toString() + File.separator);
|
---|
| 189 | textItems = frame.getTextItems();
|
---|
| 190 | textItems.removeIf(text -> !text.getText().startsWith("Email:"));
|
---|
| 191 | ret[2] = textItems.iterator().next().getText().replace("Email:", "").trim();
|
---|
| 192 | } catch (FileNotFoundException e) {
|
---|
| 193 | MessageBay.errorMessage("You do not appear to have contact with your nominated password colleague: " + ret[0]);
|
---|
| 194 | return null;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 | // find colleague two email
|
---|
| 199 | credentialsDirectoryPath = UserSettings.PublicAndPrivateResources
|
---|
| 200 | ? Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username)
|
---|
| 201 | : Paths.get(FrameIO.PARENT_FOLDER);
|
---|
| 202 | credentialsDirectoryPath = credentialsDirectoryPath.resolve("contacts").resolve(ret[1] + "-credentials");
|
---|
| 203 | try (Scanner in = new Scanner(credentialsDirectoryPath.resolve("credentials.inf").toFile())) {
|
---|
| 204 | int parseInt = Integer.parseInt(in.nextLine().replace(".exp", ""));
|
---|
| 205 | Frame frame = FrameIO.LoadFrame(ret[1] + "-credentials" + parseInt, credentialsDirectoryPath.toAbsolutePath().getParent().toString() + File.separator);
|
---|
| 206 | textItems = frame.getTextItems();
|
---|
| 207 | textItems.removeIf(text -> !text.getText().startsWith("Email:"));
|
---|
| 208 | ret[3] = textItems.iterator().next().getText().replace("Email:", "").trim();
|
---|
| 209 | } catch (FileNotFoundException e) {
|
---|
| 210 | MessageBay.errorMessage("You do not appear to have contact with your nominated password colleague: " + ret[1]);
|
---|
| 211 | return null;
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | return ret;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 |
|
---|
| 218 | public static void sendEmail(String email, StringBuilder sb) throws MessagingException, AddressException {
|
---|
| 219 | // Establish properties for email.
|
---|
| 220 | Properties properties = System.getProperties();
|
---|
| 221 | properties.setProperty("mail.transport.protocol", "smtp");
|
---|
| 222 | properties.setProperty("mail.smtp.host", "smtp.gmail.com");
|
---|
| 223 | properties.setProperty("mail.smtp.port", "465");
|
---|
| 224 | properties.setProperty("mail.smtp.starttls.enable", "true");
|
---|
| 225 | properties.setProperty("mail.smtp.auth", "true");
|
---|
| 226 | properties.setProperty("mail.smtp.debug", "true");
|
---|
| 227 | properties.setProperty("mail.smtp.auth", "true");
|
---|
| 228 | properties.setProperty("mail.smtp.socketFactory.port", "465");
|
---|
| 229 | properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
---|
| 230 | properties.setProperty("mail.smtp.socketFactory.fallback", "false");
|
---|
| 231 |
|
---|
| 232 | Session session = Session.getDefaultInstance(properties, new javax.mail.Authenticator() {
|
---|
| 233 | @Override
|
---|
| 234 | protected PasswordAuthentication getPasswordAuthentication() {
|
---|
[1472] | 235 | //return new PasswordAuthentication("noreply.expeditee", "intergalacticnumber");
|
---|
| 236 | return new PasswordAuthentication("noreply.expeditee", "exped!tee");
|
---|
[1363] | 237 | };
|
---|
| 238 | });
|
---|
| 239 |
|
---|
| 240 | // construct email message
|
---|
| 241 | final MimeMessage message = new MimeMessage(session);
|
---|
| 242 | message.setFrom(new InternetAddress("[email protected]"));
|
---|
| 243 | message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
|
---|
| 244 | message.setSubject("Expeditee Password Recovery");
|
---|
| 245 | message.setText(sb.toString());
|
---|
| 246 |
|
---|
| 247 | // send email message
|
---|
| 248 | Transport.send(message);
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | public static void setPWColleagues(String colleagueOne, String colleagueTwo) {
|
---|
| 252 | // Get needed text items.
|
---|
| 253 | Frame pwRecoveryFrame = FrameIO.LoadFrame(UserSettings.UserName.get() + AuthenticatorBrowser.PASSWORD_RECOVERY_FRAME);
|
---|
| 254 | Collection<Text> textItems = pwRecoveryFrame.getTextItems();
|
---|
[1472] | 255 | textItems.removeIf(t -> !t.getText().toLowerCase().startsWith("user_"));
|
---|
[1363] | 256 |
|
---|
| 257 | // Find colleague one and two text items. Set appropriate values.
|
---|
| 258 | Iterator<Text> it = textItems.iterator();
|
---|
| 259 | while (it.hasNext()) {
|
---|
| 260 | Text text = it.next();
|
---|
[1472] | 261 | if (text.getText().toLowerCase().startsWith("user_one:")) {
|
---|
| 262 | text.setText("User_one: " + colleagueOne);
|
---|
[1419] | 263 | Colleagues.User_One.set(colleagueOne);
|
---|
[1472] | 264 | } else if (text.getText().toLowerCase().startsWith("user_two:")) {
|
---|
| 265 | text.setText("User_two:" + colleagueTwo);
|
---|
[1419] | 266 | Colleagues.User_Two.set(colleagueTwo);
|
---|
[1363] | 267 | }
|
---|
| 268 | }
|
---|
| 269 | FrameIO.ForceSaveFrame(pwRecoveryFrame);
|
---|
| 270 |
|
---|
| 271 | // Key to split and distribute
|
---|
| 272 | String fullKey = KeyList.PersonalKey.get().getData().get(0);
|
---|
| 273 | byte[] keyBytes = Base64.getDecoder().decode(fullKey);
|
---|
| 274 |
|
---|
| 275 | // Initialise Shamir
|
---|
| 276 | int totalShares = 2;
|
---|
| 277 | int requiredShares = 2;
|
---|
| 278 | Scheme scheme = new Scheme(new SecureRandom(), totalShares, requiredShares);
|
---|
| 279 |
|
---|
| 280 | // Create shares
|
---|
| 281 | Map<Integer, byte[]> shares = scheme.split(keyBytes);
|
---|
| 282 | String colleagueOneShare = Base64.getEncoder().encodeToString(shares.get(1));
|
---|
| 283 | String colleagueTwoShare = Base64.getEncoder().encodeToString(shares.get(2));
|
---|
| 284 |
|
---|
| 285 | // Distribute share zero to colleague one
|
---|
| 286 | String time = org.expeditee.stats.Formatter.getDateTime();
|
---|
| 287 | String sender = UserSettings.UserName.get();
|
---|
| 288 | String topic = "Please help me secure my Expeditee account.";
|
---|
| 289 | String message = "Run the below action to store a secret key that will help me recover access to my account should I ever loose it.";
|
---|
| 290 | Map<String, String> options = new HashMap<String, String>();
|
---|
| 291 | options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + colleagueOneShare);
|
---|
| 292 | MailEntry mail = new MailEntry(time, sender, colleagueOne, topic, message, options);
|
---|
| 293 | Mail.sendMail(mail, colleagueOne);
|
---|
| 294 |
|
---|
| 295 | // Distribute share one to colleague two
|
---|
| 296 | options = new HashMap<String, String>();
|
---|
| 297 | options.put("Store Secret Key for " + sender, "AuthAddSecretKey " + sender + "PersonalKeyShare " + colleagueTwoShare);
|
---|
| 298 | mail = new MailEntry(time, sender, colleagueTwo, topic, message, options);
|
---|
| 299 | Mail.sendMail(mail, colleagueTwo);
|
---|
| 300 |
|
---|
[1367] | 301 | MessageBay.displayMessage("You PW Colleagues have been set to " + colleagueOne + " and " + colleagueTwo + ". "
|
---|
| 302 | + "They have been sent a Expeditee mail that they can use to store a share of your secret key.");
|
---|
[1363] | 303 | }
|
---|
| 304 |
|
---|
| 305 | public static void emailPasswordShare(String colleagueName) {
|
---|
| 306 | Path credentialsDirectoryPath = Paths.get(FrameIO.CONTACTS_PATH).resolve(colleagueName + "-credentials");
|
---|
| 307 | String colleagueEmail = null;
|
---|
| 308 | try (Scanner in = new Scanner(credentialsDirectoryPath.resolve("credentials.inf").toFile())) {
|
---|
| 309 | int parseInt = Integer.parseInt(in.nextLine().replace(".exp", ""));
|
---|
| 310 | Frame frame = FrameIO.LoadFrame(colleagueName + "-credentials" + parseInt, credentialsDirectoryPath.toAbsolutePath().getParent().toString() + File.separator);
|
---|
| 311 | Collection<Text> textItems = frame.getTextItems();
|
---|
| 312 | textItems.removeIf(text -> !text.getText().startsWith("Email:"));
|
---|
| 313 | colleagueEmail = textItems.iterator().next().getText().replace("Email:", "").trim();
|
---|
| 314 | } catch (FileNotFoundException e) {
|
---|
| 315 | MessageBay.errorMessage("You do not appear to have contact with: " + colleagueName);
|
---|
| 316 | return;
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 | Frame secretsFrame = FrameIO.LoadFrame(UserSettings.UserName.get() + AuthenticatorBrowser.SECRETS_FRAME);
|
---|
| 320 | Collection<Text> textItems = secretsFrame.getTextItems();
|
---|
| 321 | textItems.removeIf(text -> !text.getText().toLowerCase().equals(colleagueName + "personalkeyshare"));
|
---|
| 322 | String key = textItems.iterator().next().getData().get(0);
|
---|
| 323 |
|
---|
| 324 | String nl = System.getProperty("line.separator");
|
---|
| 325 | StringBuilder sb = new StringBuilder();
|
---|
| 326 | sb.append("In responce to your request for assistance regaining access to your Expeditee account, your colleague " + UserSettings.UserName.get() + " has provided you with the following key share:" + nl);
|
---|
| 327 | sb.append(key + nl);
|
---|
| 328 |
|
---|
| 329 | try {
|
---|
| 330 | sendEmail(colleagueEmail, sb);
|
---|
[1367] | 331 | MessageBay.displayMessage("Your share of " + colleagueName + "'s password has been sent to their public email address.");
|
---|
[1363] | 332 | } catch (MessagingException e) {
|
---|
| 333 | MessageBay.errorMessage("An error occured sending a email to your colleage " + colleagueName + " with the email " + colleagueEmail);
|
---|
| 334 | }
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 | public static void regainAccountAccess(Map<AuthenticationTag, String> userData) {
|
---|
| 338 | // Store shares in map
|
---|
| 339 | Map<Integer, byte[]> contributingParts = new HashMap<Integer, byte[]>();
|
---|
| 340 | contributingParts.put(1, Base64.getDecoder().decode(userData.get(AuthenticationTag.PasswordSliceOne)));
|
---|
| 341 | contributingParts.put(2, Base64.getDecoder().decode(userData.get(AuthenticationTag.PasswordSliceTwo)));
|
---|
| 342 |
|
---|
| 343 | // initialise shamir
|
---|
| 344 | int totalShares = 2;
|
---|
| 345 | int requiredShares = 2;
|
---|
| 346 | Scheme scheme = new Scheme(new SecureRandom(), totalShares, requiredShares);
|
---|
| 347 |
|
---|
| 348 | // perform joining
|
---|
| 349 | byte[] join = scheme.join(contributingParts);
|
---|
| 350 |
|
---|
| 351 | try {
|
---|
| 352 | AuthenticatorBrowser.getInstance().putKey(userData.get(AuthenticationTag.Username), userData.get(AuthenticationTag.NewPassword), new SecretKeySpec(join, SymmetricAlgorithm));
|
---|
| 353 | } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | ClassNotFoundException
|
---|
| 354 | | IOException | SQLException e) {
|
---|
| 355 | e.printStackTrace();
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | MessageBay.displayMessage("Your new password has been set.");
|
---|
| 359 | }
|
---|
[1335] | 360 | }
|
---|