source: trunk/src/org/expeditee/auth/Actions.java@ 1367

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

Feedback for various functions in the password recovery process.

File size: 25.0 KB
Line 
1package org.expeditee.auth;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.io.IOException;
6import java.nio.file.Files;
7import java.nio.file.Path;
8import java.nio.file.Paths;
9import java.nio.file.StandardCopyOption;
10import java.security.InvalidKeyException;
11import java.security.KeyFactory;
12import java.security.KeyStoreException;
13import java.security.NoSuchAlgorithmException;
14import java.security.PrivateKey;
15import java.security.PublicKey;
16import java.security.SecureRandom;
17import java.security.cert.CertificateException;
18import java.security.spec.InvalidKeySpecException;
19import java.security.spec.PKCS8EncodedKeySpec;
20import java.sql.SQLException;
21import java.text.ParseException;
22import java.util.Base64;
23import java.util.Collection;
24import java.util.HashMap;
25import java.util.List;
26import java.util.Map;
27import java.util.Optional;
28import java.util.Random;
29import java.util.Scanner;
30import java.util.stream.Collectors;
31
32import javax.crypto.BadPaddingException;
33import javax.crypto.IllegalBlockSizeException;
34import javax.crypto.NoSuchPaddingException;
35import javax.crypto.SecretKey;
36import javax.crypto.spec.SecretKeySpec;
37
38import org.expeditee.agents.ExistingFramesetException;
39import org.expeditee.agents.InvalidFramesetNameException;
40import org.expeditee.auth.account.Authenticate;
41import org.expeditee.auth.account.Authenticate.AuthenticationResult;
42import org.expeditee.auth.account.Create;
43import org.expeditee.auth.account.Create.CreateResult;
44import org.expeditee.auth.account.Password;
45import org.expeditee.auth.mail.Mail;
46import org.expeditee.auth.mail.Mail.MailEntry;
47import org.expeditee.auth.mail.gui.MailBay;
48import org.expeditee.auth.tags.AuthenticationTag;
49import org.expeditee.gio.gesture.StandardGestureActions;
50import org.expeditee.gui.DisplayController;
51import org.expeditee.gui.Frame;
52import org.expeditee.gui.FrameIO;
53import org.expeditee.gui.MessageBay;
54import org.expeditee.items.Item;
55import org.expeditee.items.Text;
56import org.expeditee.settings.UserSettings;
57import org.expeditee.settings.identity.secrets.KeyList;
58import org.expeditee.stats.Formatter;
59import org.ngikm.cryptography.CryptographyConstants;
60
61public class Actions implements CryptographyConstants {
62
63 // Start Debug Actions
64 public static void SendTestMessage(String colleagueName) throws InvalidKeySpecException, NoSuchAlgorithmException, FileNotFoundException, KeyStoreException, CertificateException, ClassNotFoundException, IOException, SQLException {
65 String time = org.expeditee.stats.Formatter.getDateTime();
66 String sender = UserSettings.UserName.get();
67 String topic = "Test Message";
68 String message = "This is a test message.";
69 Map<String, String> options = new HashMap<String, String>();
70 options.put("Neat", "Beep");
71 MailEntry mail = new MailEntry(time, sender, colleagueName, topic, message, options);
72 Mail.sendMail(mail, colleagueName);
73 MessageBay.displayMessage("Test message sent.");
74 }
75
76 public static void SendTestMessageHemi(String param) {
77 String time = Formatter.getDateTime();
78 String sender = UserSettings.UserName.get();
79 String recipient = param.split(" ")[0];
80 String message = param.split(" ")[1];
81 Map<String, String> options = new HashMap<String, String>();
82 options.put("Accept", "beep");
83 options.put("Reject", "beep");
84 MailEntry mail = new MailEntry(time, sender, recipient, "Have a key", message, options);
85 Mail.sendMail(mail, recipient);
86 MessageBay.displayMessage("Test message sent.");
87 }
88
89 public static void SendTestOneOffMessage(String colleagueName) {
90 String time = Formatter.getDateTime();
91 String sender = UserSettings.UserName.get();
92 String topic = "Test Message";
93 String message = "This is a test message.";
94 Map<String, String> options = new HashMap<String, String>();
95 options.put("Neat", "Beep");
96 MailEntry mail = new MailEntry(time, sender, colleagueName, topic, message, options);
97 Random rand = new SecureRandom();
98 byte[] key = new byte[16];
99 rand.nextBytes(key);
100 System.out.println(Base64.getEncoder().encodeToString(key));
101 Mail.sendOneOffMail(mail, colleagueName, key);
102 }
103
104 private static String userbackup = "authadmin";
105 public static void ToggleAuth() {
106 String backup = UserSettings.UserName.get();
107 UserSettings.UserName.set(userbackup);
108 userbackup = backup;
109 }
110 // End Debug Actions
111
112 // Start Misc Auth Actions
113 /**
114 * Action ran by user to read a message using a single use distributed Symmetric key
115 * @param cursor The content on the cursor should be a text item whose content is the
116 * Symmetric key to use, represented as a Base64 encoded string.
117 * @param actionItem The action item will contain the encrypted message in its data.
118 */
119 public static void AuthOneOffSecureMessage(Text cursor, Text actionItem) {
120 byte[] keyBytes = Base64.getDecoder().decode(cursor.getText());
121 SecretKey key = new SecretKeySpec(keyBytes, SymmetricAlgorithm);
122 List<String> data = actionItem.getData();
123 Mail.decryptOneOffSecureMessage(key, data);
124 StandardGestureActions.Refresh();
125 }
126
127 /**
128 * Display Expeditee Mail
129 * @throws IOException
130 * @throws SQLException
131 * @throws ClassNotFoundException
132 * @throws CertificateException
133 * @throws NoSuchAlgorithmException
134 * @throws FileNotFoundException
135 * @throws KeyStoreException
136 * @throws ParseException
137 * @throws InvalidKeySpecException
138 * @throws BadPaddingException
139 * @throws IllegalBlockSizeException
140 * @throws NoSuchPaddingException
141 * @throws InvalidKeyException
142 */
143 public static void ToggleBay() throws KeyStoreException, FileNotFoundException, NoSuchAlgorithmException, CertificateException, ClassNotFoundException, SQLException, IOException, ParseException, InvalidKeySpecException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
144 if (!AuthenticatorBrowser.isAuthenticated()) return;
145 if (!DisplayController.isMailMode()) {
146 MailBay.ensureLink();
147 Mail.clear();
148 String keyEncoded = KeyList.PrivateKey.get().getData().get(0);
149 byte[] keyBytes = Base64.getDecoder().decode(keyEncoded);
150 PrivateKey key = KeyFactory.getInstance(AsymmetricAlgorithm).generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
151 Mail.checkMail(key);
152 }
153 DisplayController.ToggleMailMode();
154 }
155
156 /**
157 * Action used to navigate the authorised user back to their desktop.
158 */
159 public static void AuthGoToDesktop() {
160 if (AuthenticatorBrowser.Authenticated) {
161 DisplayController.setCurrentFrame(FrameIO.LoadFrame(UserSettings.HomeFrame.get()), true);
162 } else {
163 MessageBay.displayMessage("Please Login to proceed to your home frame.");
164 DisplayController.setCurrentFrame(FrameIO.LoadFrame("authentication1"), true);
165 }
166 }
167
168 /**
169 * Action used to navigate to multiuser1 (multiuser abilities) if authenticated and authentication1 (login) is not so.
170 */
171 public static void AuthGotoAccountManagement() {
172 if (AuthenticatorBrowser.Authenticated) {
173 DisplayController.setCurrentFrame(FrameIO.LoadFrame("multiuser1"), true);
174 } else {
175 MessageBay.displayMessage("Please Login to proceed to account managment.");
176 DisplayController.setCurrentFrame(FrameIO.LoadFrame("authentication1"), true);
177 }
178 }
179
180 /**
181 * Gets all items on a specified frame that contain the specified data.
182 */
183 public static Collection<Item> getByData(Frame frame, String data) {
184 Collection<Item> allItems = frame.getAllItems();
185 allItems.removeIf(i -> i.getData() == null || !i.hasData(data));
186 return allItems;
187 }
188
189 /**
190 * Gets all items on a specified frame that contains the specified content.
191 */
192 public static Collection<Item> getByContent(Frame frame, String content) {
193 Collection<Item> allItems = frame.getAllItems();
194 allItems.removeIf(i -> i.getText().compareTo(content) != 0);
195 return allItems;
196 }
197 // End Misc Auth Actions
198
199 // Start Regain Account Access Actions
200 /**
201 * Action ran by user to specify who their password colleagues are. These are the
202 * individuals who will be consulted if and when the user needs to regain access
203 * to their account.
204 * @param colleagueOne
205 * @param colleagueTwo
206 */
207 public static void AuthSetPWColleagues(String colleagueOne, String colleagueTwo) {
208 Password.setPWColleagues(colleagueOne, colleagueTwo);
209 }
210
211 /**
212 * Action ran by user to oblige with a request from colleague who has nominated the
213 * user as a pw colleague. Will email (not Expeditee mail) the colleague the password
214 * share that the user has stored on their secrets frame.
215 * @param colleagueName
216 */
217 public static void AuthEmailPasswordShare(String colleagueName) {
218 Password.emailPasswordShare(colleagueName);
219 }
220
221 /**
222 * Action ran by user to regain access to their account by providing:
223 * their username
224 * two password shares obtained from pw colleagues
225 * their desired new password
226 */
227 public static void AuthRegainAccountAccess() {
228 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
229 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false,
230 AuthenticationTag.Username, AuthenticationTag.NewPassword, AuthenticationTag.NewPasswordAgain,
231 AuthenticationTag.PasswordSliceOne, AuthenticationTag.PasswordSliceTwo);
232 if (userdata.isPresent()) {
233 // Confirm new requested passwords match
234 Map<AuthenticationTag, String> userData = userdata.get();
235 if (!userData.get(AuthenticationTag.NewPassword).equals(userData.get(AuthenticationTag.NewPasswordAgain))) {
236 MessageBay.errorMessage("The passwords you have provided do not match.");
237 return;
238 }
239
240 Password.regainAccountAccess(userData);
241 }
242 }
243
244 /**
245 * Actions used to generate and deliver an intergalactic number to a users public email
246 * address after they have began the password recovery process.
247 */
248 public static void AuthDistributeIntergalacticNumber() {
249 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
250 Optional<Map<AuthenticationTag, String>> userdata =
251 AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username);
252 if (userdata.isPresent()) {
253 Map<AuthenticationTag, String> userData = userdata.get();
254 String username = userData.get(AuthenticationTag.Username);
255 String email = getEmailFromUsername(username);
256 userData.put(AuthenticationTag.Email, email);
257 Password.generateAndDeliverIntergalacticNumber(userData);
258 MessageBay.displayMessage("A identity number has been sent to the email "
259 + "associated with your account. Enter it below to proceed.");
260 }
261 }
262
263 /**
264 * Action used by user to submit their intergalactic number along with their username
265 * in order to confirm that they own the public email address registered to their account.
266 * This is part of the process of recoverying access to an account.
267 */
268 public static void AuthSubmitIntergalacticNumber() {
269 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
270 Optional<Map<AuthenticationTag, String>> userdata =
271 AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username,
272 AuthenticationTag.IntergalacticNumber);
273 if (userdata.isPresent()) {
274 Password.confirmIntergalacticNumberAndAlertColleagues(userdata.get());
275 }
276 }
277 // End Regain Account Access Actions
278
279 // Start Create Account Actions
280 /**
281 * Action used to created a new user account.
282 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
283 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
284 * @throws SQLException
285 * @throws IOException
286 * @throws ExistingFramesetException
287 * @throws InvalidFramesetNameException
288 * @throws ClassNotFoundException
289 * @throws FileNotFoundException
290 * @throws CertificateException
291 * @throws NoSuchAlgorithmException
292 * @throws KeyStoreException
293 * @throws BadPaddingException
294 * @throws IllegalBlockSizeException
295 * @throws NoSuchPaddingException
296 * @throws InvalidKeySpecException
297 * @throws InvalidKeyException
298 * @throws ParseException
299 * @throws Exception
300 */
301 public static void AuthCreateAccount() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, ClassNotFoundException, InvalidFramesetNameException, ExistingFramesetException, IOException, SQLException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ParseException {
302 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
303 Optional<Map<AuthenticationTag, String>> userdata =
304 AuthenticationTag.fetchUserData(textItems, false,
305 AuthenticationTag.Username,
306 AuthenticationTag.Password,
307 AuthenticationTag.PasswordAgain,
308 AuthenticationTag.Email,
309 AuthenticationTag.EmailAgain);
310
311 if (userdata.isPresent()) {
312 Map<AuthenticationTag, String> userData = userdata.get();
313
314 // A profile already existing with 'username' means an account cannot be created with that username.
315 if (FrameIO.getProfilesList().contains(userData.get(AuthenticationTag.Username))) {
316 MessageBay.errorMessage("A Expeditee profile with this username already exists, please choose another.");
317 return;
318 }
319
320 // The chosen username must be a valid frameset name.
321 if (!FrameIO.isValidFramesetName(userData.get(AuthenticationTag.Username))) {
322 MessageBay.errorMessage("The provided username must begin and end with a letter and contain only letters and numbers inbetween, please choose another.");
323 return;
324 }
325
326 // The passwords provided must match
327 if (userData.get(AuthenticationTag.Password).compareTo(userData.get(AuthenticationTag.PasswordAgain)) != 0) {
328 MessageBay.errorMessage("The provided passwords do not match, please fix this and try again.");
329 return;
330 }
331
332 // The emails provided must match
333 if (userData.get(AuthenticationTag.Email).compareTo(userData.get(AuthenticationTag.EmailAgain)) != 0) {
334 MessageBay.errorMessage("The provided emails do not match, please fix this and try again.");
335 return;
336 }
337
338 CreateResult result = Create.createAccount(userData);
339 if (result == CreateResult.SuccessCreateAccount) {
340 Authenticate.login(userData);
341 AuthenticatorBrowser.Authenticated = true;
342 } else {
343 MessageBay.errorMessage(result.toString());
344 }
345 } else {
346 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
347 }
348 }
349 // End Create Account Actions
350
351 // Start Account Login Actions
352 /**
353 * Action used to start authentication as a specified user.
354 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
355 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
356 * @throws Exception
357 */
358 public static void AuthLogin() {
359 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
360 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
361 if (userdata.isPresent()) {
362 AuthenticationResult result = Authenticate.login(userdata.get());
363 if (result == AuthenticationResult.SuccessLogin) {
364 MessageBay.displayMessage(result.toString());
365 AuthenticatorBrowser.Authenticated = true;
366 } else {
367 MessageBay.errorMessage(result.toString());
368 }
369 } else {
370 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
371 }
372 }
373
374 /**
375 * Action used by the user to log out of their account.
376 */
377 public static void AuthLogout() {
378 MessageBay.displayMessage(Authenticate.logout().toString());
379 }
380 // End Account Login Actions
381
382 // Start Change Access Actions
383 /**
384 * Action used to change the currently authenticated users password.
385 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
386 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
387 * Will fail if no user is currently logged in.
388 * @throws IOException
389 * @throws CertificateException
390 * @throws FileNotFoundException
391 * @throws KeyStoreException
392 * @throws NoSuchAlgorithmException
393 * @throws SQLException
394 * @throws ClassNotFoundException
395 */
396 public static void AuthChangePassword() throws NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, IOException, ClassNotFoundException, SQLException {
397 final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
398
399 if (!AuthenticatorBrowser.Authenticated) {
400 MessageBay.errorMessage("You must be logged in to perform this action.");
401 } else {
402 final Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Password, AuthenticationTag.NewPassword, AuthenticationTag.NewPasswordAgain);
403 if (userdata.isPresent()) {
404 final Map<AuthenticationTag, String> userData = userdata.get();
405 if (userData.get(AuthenticationTag.NewPassword).compareTo(userData.get(AuthenticationTag.NewPasswordAgain)) != 0) {
406 MessageBay.errorMessage("The provided passwords do not match, please fix this and try again.");
407 } else {
408 userData.put(AuthenticationTag.Username, UserSettings.UserName.get());
409 Password.changePassword(userData);
410 }
411 } else {
412 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
413 }
414 }
415 }
416 // End Change Access Actions
417
418 // Start Private Helper Functions.
419 /**
420 * Gets the public email address associated with the specified username.
421 * @param username
422 * @return
423 */
424 private static String getEmailFromUsername(String username) {
425 Path credentialsDirPath = Paths.get(FrameIO.PROFILE_PATH).resolve(username).resolve(username + "-credentials");
426 Path credentialsFilePath = credentialsDirPath.resolve("credentials.inf");
427 String fileName = null;
428 if (credentialsFilePath.toFile().exists()) {
429 try (Scanner in = new Scanner(credentialsFilePath)) {
430 fileName = in.nextLine();
431 } catch (IOException e) {
432 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
433 return null;
434 }
435 } else {
436 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
437 return null;
438 }
439
440 int number = Integer.parseInt(fileName.replace(".exp", ""));
441 Frame credentialsFrame = FrameIO.LoadFrame(username + number, FrameIO.PROFILE_PATH);
442 Collection<Text> textItems = credentialsFrame.getTextItems();
443 textItems.removeIf(text -> !text.getText().startsWith("Email: "));
444 if (textItems.isEmpty()) {
445 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
446 return null;
447 } else {
448 Text emailText = textItems.iterator().next();
449 String email = emailText.getText().replace("Email: ", "");
450 return email;
451 }
452 }
453 // End Private Helper Functions.
454
455 // Start Future Functionality
456 public static void AuthShareFrameset() throws IOException {
457 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
458
459 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Frameset);
460 if (userdata.isPresent()) {
461 Map<AuthenticationTag, String> userData = userdata.get();
462 FrameIO.SuspendCache();
463 Frame toShare = FrameIO.LoadFrame(userData.get(AuthenticationTag.Frameset) + 1);
464 FrameIO.ResumeCache();
465
466 if (toShare == null) {
467 MessageBay.errorMessage("Insufficient information provided to complete this action.");
468 return;
469 }
470
471 shareFrameset(toShare);
472 }
473 }
474
475 /*
476 * Function to share a specified frameset.
477 * Currently, this moves the frameset to the 'Shared By Me' directory and then relies on the user to use Google Drive functionality to share it appropriately.
478 */
479 private static void shareFrameset(Frame toShare) throws IOException {
480 File destinationDir = new File(FrameIO.SHARED_FRAMESETS_PATH + File.separator + toShare.getFramesetName());
481 File sourceDir = new File(toShare.getFramesetPath());
482
483 if (destinationDir.exists()) {
484 MessageBay.errorMessage("A frameset by this name already exists.");
485 return;
486 }
487
488 destinationDir.mkdir();
489 List<Path> files = Files.walk(sourceDir.toPath()).collect(Collectors.toList());
490 Files.move(files.get(0), destinationDir.toPath(), StandardCopyOption.ATOMIC_MOVE);
491
492 MessageBay.displayMessage("The frameset " + toShare.getFramesetName() + " has been moved to " + destinationDir + ". Google Drive functionality can now be used to share it with colleagues.");
493 }
494
495 /**
496 * Action used to start the process of formalising the password recovery process.
497 * @throws SQLException
498 * @throws IOException
499 * @throws ClassNotFoundException
500 * @throws CertificateException
501 * @throws NoSuchAlgorithmException
502 * @throws FileNotFoundException
503 * @throws KeyStoreException
504 * @throws InvalidKeySpecException
505 */
506 public static void AuthSubmitPWColleagues() throws InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, ClassNotFoundException, IOException, SQLException {
507 Frame currentFrame = DisplayController.getCurrentFrame();
508 Collection<Text> textItems = currentFrame.getTextItems();
509
510 if (!AuthenticatorBrowser.Authenticated) {
511 MessageBay.errorMessage("You must be logged in to perform this action.");
512 return;
513 }
514
515 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.ColleagueOne, AuthenticationTag.ColleagueTwo);
516 if (userdata.isPresent()) {
517 Map<AuthenticationTag, String> userData = userdata.get();
518 String colleagueOne = userData.get(AuthenticationTag.ColleagueOne);
519 Path colleagueOnePath = Paths.get(FrameIO.CONTACTS_PATH).resolve(colleagueOne + "-credentials");
520 String colleagueTwo = userData.get(AuthenticationTag.ColleagueTwo);
521 Path colleagueTwoPath = Paths.get(FrameIO.CONTACTS_PATH).resolve(colleagueTwo + "-credentials");
522 if (!colleagueOnePath.toFile().exists()) {
523 MessageBay.errorMessage("Your nominated colleague: " + colleagueOne + " must exist in your contacts.");
524 } else if (!colleagueTwoPath.toFile().exists()) {
525 MessageBay.errorMessage("Your nominated colleague: " + colleagueTwo + " must exist in your contacts.");
526 } else {
527 userData.put(AuthenticationTag.Username, UserSettings.UserName.get());
528 boolean success = submitPWColleagues(userData);
529 if (success) {
530 Collection<Item> toShow = getByData(currentFrame, "ShowOnProgress");
531 for (Item i: toShow) {
532 i.setVisible(true);
533 }
534 currentFrame.change();
535 MessageBay.displayMessage("-------Messages sent-------");
536 }
537 FrameIO.SaveFrame(currentFrame);
538 DisplayController.requestRefresh(false);
539 }
540 }
541 }
542
543 /*
544 * Function to submit a request to specified contacts to be the current users pw colleagues.
545 */
546 private static boolean submitPWColleagues(Map<AuthenticationTag, String> userData) throws InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, ClassNotFoundException, IOException, SQLException {
547 String colleagueOne = userData.get(AuthenticationTag.ColleagueOne);
548 String colleagueTwo = userData.get(AuthenticationTag.ColleagueTwo);
549 PublicKey colleagueOneKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueOne);
550 PublicKey colleagueTwoKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueTwo);
551 if (colleagueOneKey == null) {
552 MessageBay.errorMessage("Unable to get public key for colleague: " + colleagueOne);
553 return false;
554 } else if (colleagueTwoKey == null) {
555 MessageBay.errorMessage("Unable to get public key for colleague: " + colleagueTwo);
556 return false;
557 } else {
558 String time = org.expeditee.stats.Formatter.getDateTime();
559 String sender = userData.get(AuthenticationTag.Username);
560 String topic = "You have received a request for cooperation from your colleague " + sender;
561 String message = "Should " + sender + " forget their password, they would like your help recoverying it.";
562 Map<String, String> arguments = new HashMap<String, String>();
563 arguments.put("I agree to assist " + sender + " if they loose access to their account.", "AuthConfirmPasswordColleagueRelationship " + sender);
564 arguments.put("I wish to excuse myself from this responsibility.", "AuthDenyPasswordColleagueRelationship " + sender);
565 MailEntry mail = new MailEntry(time, sender, colleagueOne, topic, message, arguments);
566 Mail.sendMail(mail, colleagueOne);
567 mail = new MailEntry(time, sender, colleagueTwo, topic, message, arguments);
568 Mail.sendMail(mail, colleagueTwo);
569 AuthenticatorBrowser.getInstance().markRequestedColleagues(UserSettings.UserName.get());
570 return true;
571 }
572 }
573 // End Future Functionality
574}
Note: See TracBrowser for help on using the repository browser.