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

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

It is now possible to complete the process of recovering access to a Expeditee account. Further work, in the form of frames in the authentication frameset, are to follow.
A refactoring/tidy up has also been completed.

File size: 24.7 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 DisplayController.setCurrentFrame(FrameIO.LoadFrame(UserSettings.HomeFrame.get()), true);
161 }
162
163 /**
164 * Action used to navigate to multiuser1 (multiuser abilities) if authenticated and authentication1 (login) is not so.
165 */
166 public static void AuthGotoAccountManagement() {
167 if (AuthenticatorBrowser.Authenticated) {
168 DisplayController.setCurrentFrame(FrameIO.LoadFrame("multiuser1"), false);
169 } else {
170 DisplayController.setCurrentFrame(FrameIO.LoadFrame("authentication1"), false);
171 }
172 }
173
174 /**
175 * Gets all items on a specified frame that contain the specified data.
176 */
177 public static Collection<Item> getByData(Frame frame, String data) {
178 Collection<Item> allItems = frame.getAllItems();
179 allItems.removeIf(i -> i.getData() == null || !i.hasData(data));
180 return allItems;
181 }
182
183 /**
184 * Gets all items on a specified frame that contains the specified content.
185 */
186 public static Collection<Item> getByContent(Frame frame, String content) {
187 Collection<Item> allItems = frame.getAllItems();
188 allItems.removeIf(i -> i.getText().compareTo(content) != 0);
189 return allItems;
190 }
191 // End Misc Auth Actions
192
193 // Start Regain Account Access Actions
194 /**
195 * Action ran by user to specify who their password colleagues are. These are the
196 * individuals who will be consulted if and when the user needs to regain access
197 * to their account.
198 * @param colleagueOne
199 * @param colleagueTwo
200 */
201 public static void AuthSetPWColleagues(String colleagueOne, String colleagueTwo) {
202 Password.setPWColleagues(colleagueOne, colleagueTwo);
203 }
204
205 /**
206 * Action ran by user to oblige with a request from colleague who has nominated the
207 * user as a pw colleague. Will email (not Expeditee mail) the colleague the password
208 * share that the user has stored on their secrets frame.
209 * @param colleagueName
210 */
211 public static void AuthEmailPasswordShare(String colleagueName) {
212 Password.emailPasswordShare(colleagueName);
213 }
214
215 /**
216 * Action ran by user to regain access to their account by providing:
217 * their username
218 * two password shares obtained from pw colleagues
219 * their desired new password
220 */
221 public static void AuthRegainAccountAccess() {
222 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
223 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false,
224 AuthenticationTag.Username, AuthenticationTag.NewPassword, AuthenticationTag.NewPasswordAgain,
225 AuthenticationTag.PasswordSliceOne, AuthenticationTag.PasswordSliceTwo);
226 if (userdata.isPresent()) {
227 // Confirm new requested passwords match
228 Map<AuthenticationTag, String> userData = userdata.get();
229 if (!userData.get(AuthenticationTag.NewPassword).equals(userData.get(AuthenticationTag.NewPasswordAgain))) {
230 return;
231 }
232
233 Password.regainAccountAccess(userData);
234 }
235 }
236
237 /**
238 * Actions used to generate and deliver an intergalactic number to a users public email
239 * address after they have began the password recovery process.
240 */
241 public static void AuthDistributeIntergalacticNumber() {
242 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
243 Optional<Map<AuthenticationTag, String>> userdata =
244 AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username);
245 if (userdata.isPresent()) {
246 Map<AuthenticationTag, String> userData = userdata.get();
247 String username = userData.get(AuthenticationTag.Username);
248 String email = getEmailFromUsername(username);
249 userData.put(AuthenticationTag.Email, email);
250 Password.generateAndDeliverIntergalacticNumber(userData);
251 MessageBay.displayMessage("A identity number has been sent to the email "
252 + "associated with your account. Enter it below to proceed.");
253 }
254 }
255
256 /**
257 * Action used by user to submit their intergalactic number along with their username
258 * in order to confirm that they own the public email address registered to their account.
259 * This is part of the process of recoverying access to an account.
260 */
261 public static void AuthSubmitIntergalacticNumber() {
262 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
263 Optional<Map<AuthenticationTag, String>> userdata =
264 AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username,
265 AuthenticationTag.IntergalacticNumber);
266 if (userdata.isPresent()) {
267 Password.confirmIntergalacticNumberAndAlertColleagues(userdata.get());
268 }
269 }
270 // End Regain Account Access Actions
271
272 // Start Create Account Actions
273 /**
274 * Action used to created a new user account.
275 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
276 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
277 * @throws SQLException
278 * @throws IOException
279 * @throws ExistingFramesetException
280 * @throws InvalidFramesetNameException
281 * @throws ClassNotFoundException
282 * @throws FileNotFoundException
283 * @throws CertificateException
284 * @throws NoSuchAlgorithmException
285 * @throws KeyStoreException
286 * @throws BadPaddingException
287 * @throws IllegalBlockSizeException
288 * @throws NoSuchPaddingException
289 * @throws InvalidKeySpecException
290 * @throws InvalidKeyException
291 * @throws ParseException
292 * @throws Exception
293 */
294 public static void AuthCreateAccount() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, ClassNotFoundException, InvalidFramesetNameException, ExistingFramesetException, IOException, SQLException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ParseException {
295 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
296 Optional<Map<AuthenticationTag, String>> userdata =
297 AuthenticationTag.fetchUserData(textItems, false,
298 AuthenticationTag.Username,
299 AuthenticationTag.Password,
300 AuthenticationTag.PasswordAgain,
301 AuthenticationTag.Email,
302 AuthenticationTag.EmailAgain);
303
304 if (userdata.isPresent()) {
305 Map<AuthenticationTag, String> userData = userdata.get();
306
307 // A profile already existing with 'username' means an account cannot be created with that username.
308 if (FrameIO.getProfilesList().contains(userData.get(AuthenticationTag.Username))) {
309 MessageBay.errorMessage("A Expeditee profile with this username already exists, please choose another.");
310 return;
311 }
312
313 // The chosen username must be a valid frameset name.
314 if (!FrameIO.isValidFramesetName(userData.get(AuthenticationTag.Username))) {
315 MessageBay.errorMessage("The provided username must begin and end with a letter and contain only letters and numbers inbetween, please choose another.");
316 return;
317 }
318
319 // The passwords provided must match
320 if (userData.get(AuthenticationTag.Password).compareTo(userData.get(AuthenticationTag.PasswordAgain)) != 0) {
321 MessageBay.errorMessage("The provided passwords do not match, please fix this and try again.");
322 return;
323 }
324
325 // The emails provided must match
326 if (userData.get(AuthenticationTag.Email).compareTo(userData.get(AuthenticationTag.EmailAgain)) != 0) {
327 MessageBay.errorMessage("The provided emails do not match, please fix this and try again.");
328 return;
329 }
330
331 CreateResult result = Create.createAccount(userData);
332 if (result == CreateResult.SuccessCreateAccount) {
333 Authenticate.login(userData);
334 AuthenticatorBrowser.Authenticated = true;
335 } else {
336 MessageBay.errorMessage(result.toString());
337 }
338 } else {
339 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
340 }
341 }
342 // End Create Account Actions
343
344 // Start Account Login Actions
345 /**
346 * Action used to start authentication as a specified user.
347 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
348 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
349 * @throws Exception
350 */
351 public static void AuthLogin() {
352 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
353 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Username, AuthenticationTag.Password);
354 if (userdata.isPresent()) {
355 AuthenticationResult result = Authenticate.login(userdata.get());
356 if (result == AuthenticationResult.SuccessLogin) {
357 MessageBay.displayMessage(result.toString());
358 AuthenticatorBrowser.Authenticated = true;
359 } else {
360 MessageBay.errorMessage(result.toString());
361 }
362 } else {
363 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
364 }
365 }
366
367 /**
368 * Action used by the user to log out of their account.
369 */
370 public static void AuthLogout() {
371 MessageBay.displayMessage(Authenticate.logout().toString());
372 }
373 // End Account Login Actions
374
375 // Start Change Access Actions
376 /**
377 * Action used to change the currently authenticated users password.
378 * Attempts to use content from text items on frame, will default to java properties if they cannot be found.
379 * Will fail if it cannot find content from text items on frame and all required java properties are not present.
380 * Will fail if no user is currently logged in.
381 * @throws IOException
382 * @throws CertificateException
383 * @throws FileNotFoundException
384 * @throws KeyStoreException
385 * @throws NoSuchAlgorithmException
386 * @throws SQLException
387 * @throws ClassNotFoundException
388 */
389 public static void AuthChangePassword() throws NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, IOException, ClassNotFoundException, SQLException {
390 final Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
391
392 if (!AuthenticatorBrowser.Authenticated) {
393 MessageBay.errorMessage("You must be logged in to perform this action.");
394 } else {
395 final Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Password, AuthenticationTag.NewPassword, AuthenticationTag.NewPasswordAgain);
396 if (userdata.isPresent()) {
397 final Map<AuthenticationTag, String> userData = userdata.get();
398 if (userData.get(AuthenticationTag.NewPassword).compareTo(userData.get(AuthenticationTag.NewPasswordAgain)) != 0) {
399 MessageBay.errorMessage("The provided passwords do not match, please fix this and try again.");
400 } else {
401 userData.put(AuthenticationTag.Username, UserSettings.UserName.get());
402 Password.changePassword(userData);
403 }
404 } else {
405 MessageBay.errorMessage("Please fill out all the supplied text boxes.");
406 }
407 }
408 }
409 // End Change Access Actions
410
411 // Start Private Helper Functions.
412 /**
413 * Gets the public email address associated with the specified username.
414 * @param username
415 * @return
416 */
417 private static String getEmailFromUsername(String username) {
418 Path credentialsDirPath = Paths.get(FrameIO.PROFILE_PATH).resolve(username).resolve(username + "-credentials");
419 Path credentialsFilePath = credentialsDirPath.resolve("credentials.inf");
420 String fileName = null;
421 if (credentialsFilePath.toFile().exists()) {
422 try (Scanner in = new Scanner(credentialsFilePath)) {
423 fileName = in.nextLine();
424 } catch (IOException e) {
425 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
426 return null;
427 }
428 } else {
429 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
430 return null;
431 }
432
433 int number = Integer.parseInt(fileName.replace(".exp", ""));
434 Frame credentialsFrame = FrameIO.LoadFrame(username + number, FrameIO.PROFILE_PATH);
435 Collection<Text> textItems = credentialsFrame.getTextItems();
436 textItems.removeIf(text -> !text.getText().startsWith("Email: "));
437 if (textItems.isEmpty()) {
438 MessageBay.errorMessage("Unable to locate public email for specified user, are they registered on this computer?");
439 return null;
440 } else {
441 Text emailText = textItems.iterator().next();
442 String email = emailText.getText().replace("Email: ", "");
443 return email;
444 }
445 }
446 // End Private Helper Functions.
447
448 // Start Future Functionality
449 public static void AuthShareFrameset() throws IOException {
450 Collection<Text> textItems = DisplayController.getCurrentFrame().getTextItems();
451
452 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.Frameset);
453 if (userdata.isPresent()) {
454 Map<AuthenticationTag, String> userData = userdata.get();
455 FrameIO.SuspendCache();
456 Frame toShare = FrameIO.LoadFrame(userData.get(AuthenticationTag.Frameset) + 1);
457 FrameIO.ResumeCache();
458
459 if (toShare == null) {
460 MessageBay.errorMessage("Insufficient information provided to complete this action.");
461 return;
462 }
463
464 shareFrameset(toShare);
465 }
466 }
467
468 /*
469 * Function to share a specified frameset.
470 * 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.
471 */
472 private static void shareFrameset(Frame toShare) throws IOException {
473 File destinationDir = new File(FrameIO.SHARED_FRAMESETS_PATH + File.separator + toShare.getFramesetName());
474 File sourceDir = new File(toShare.getFramesetPath());
475
476 if (destinationDir.exists()) {
477 MessageBay.errorMessage("A frameset by this name already exists.");
478 return;
479 }
480
481 destinationDir.mkdir();
482 List<Path> files = Files.walk(sourceDir.toPath()).collect(Collectors.toList());
483 Files.move(files.get(0), destinationDir.toPath(), StandardCopyOption.ATOMIC_MOVE);
484
485 MessageBay.displayMessage("The frameset " + toShare.getFramesetName() + " has been moved to " + destinationDir + ". Google Drive functionality can now be used to share it with colleagues.");
486 }
487
488 /**
489 * Action used to start the process of formalising the password recovery process.
490 * @throws SQLException
491 * @throws IOException
492 * @throws ClassNotFoundException
493 * @throws CertificateException
494 * @throws NoSuchAlgorithmException
495 * @throws FileNotFoundException
496 * @throws KeyStoreException
497 * @throws InvalidKeySpecException
498 */
499 public static void AuthSubmitPWColleagues() throws InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, ClassNotFoundException, IOException, SQLException {
500 Frame currentFrame = DisplayController.getCurrentFrame();
501 Collection<Text> textItems = currentFrame.getTextItems();
502
503 if (!AuthenticatorBrowser.Authenticated) {
504 MessageBay.errorMessage("You must be logged in to perform this action.");
505 return;
506 }
507
508 Optional<Map<AuthenticationTag, String>> userdata = AuthenticationTag.fetchUserData(textItems, false, AuthenticationTag.ColleagueOne, AuthenticationTag.ColleagueTwo);
509 if (userdata.isPresent()) {
510 Map<AuthenticationTag, String> userData = userdata.get();
511 String colleagueOne = userData.get(AuthenticationTag.ColleagueOne);
512 Path colleagueOnePath = Paths.get(FrameIO.CONTACTS_PATH).resolve(colleagueOne + "-credentials");
513 String colleagueTwo = userData.get(AuthenticationTag.ColleagueTwo);
514 Path colleagueTwoPath = Paths.get(FrameIO.CONTACTS_PATH).resolve(colleagueTwo + "-credentials");
515 if (!colleagueOnePath.toFile().exists()) {
516 MessageBay.errorMessage("Your nominated colleague: " + colleagueOne + " must exist in your contacts.");
517 } else if (!colleagueTwoPath.toFile().exists()) {
518 MessageBay.errorMessage("Your nominated colleague: " + colleagueTwo + " must exist in your contacts.");
519 } else {
520 userData.put(AuthenticationTag.Username, UserSettings.UserName.get());
521 boolean success = submitPWColleagues(userData);
522 if (success) {
523 Collection<Item> toShow = getByData(currentFrame, "ShowOnProgress");
524 for (Item i: toShow) {
525 i.setVisible(true);
526 }
527 currentFrame.change();
528 MessageBay.displayMessage("-------Messages sent-------");
529 }
530 FrameIO.SaveFrame(currentFrame);
531 DisplayController.requestRefresh(false);
532 }
533 }
534 }
535
536 /*
537 * Function to submit a request to specified contacts to be the current users pw colleagues.
538 */
539 private static boolean submitPWColleagues(Map<AuthenticationTag, String> userData) throws InvalidKeySpecException, NoSuchAlgorithmException, KeyStoreException, FileNotFoundException, CertificateException, ClassNotFoundException, IOException, SQLException {
540 String colleagueOne = userData.get(AuthenticationTag.ColleagueOne);
541 String colleagueTwo = userData.get(AuthenticationTag.ColleagueTwo);
542 PublicKey colleagueOneKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueOne);
543 PublicKey colleagueTwoKey = AuthenticatorBrowser.getInstance().getPublicKey(colleagueTwo);
544 if (colleagueOneKey == null) {
545 MessageBay.errorMessage("Unable to get public key for colleague: " + colleagueOne);
546 return false;
547 } else if (colleagueTwoKey == null) {
548 MessageBay.errorMessage("Unable to get public key for colleague: " + colleagueTwo);
549 return false;
550 } else {
551 String time = org.expeditee.stats.Formatter.getDateTime();
552 String sender = userData.get(AuthenticationTag.Username);
553 String topic = "You have received a request for cooperation from your colleague " + sender;
554 String message = "Should " + sender + " forget their password, they would like your help recoverying it.";
555 Map<String, String> arguments = new HashMap<String, String>();
556 arguments.put("I agree to assist " + sender + " if they loose access to their account.", "AuthConfirmPasswordColleagueRelationship " + sender);
557 arguments.put("I wish to excuse myself from this responsibility.", "AuthDenyPasswordColleagueRelationship " + sender);
558 MailEntry mail = new MailEntry(time, sender, colleagueOne, topic, message, arguments);
559 Mail.sendMail(mail, colleagueOne);
560 mail = new MailEntry(time, sender, colleagueTwo, topic, message, arguments);
561 Mail.sendMail(mail, colleagueTwo);
562 AuthenticatorBrowser.getInstance().markRequestedColleagues(UserSettings.UserName.get());
563 return true;
564 }
565 }
566 // End Future Functionality
567}
Note: See TracBrowser for help on using the repository browser.