Changing password logic - old password, new password, retype password

I have a MainFrame class which has a Change Password button. The action for the button is:
          // Change password
          aListener = new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                   ChangeMyPassword cmp = new ChangeMyPassword(
                                 MainFrame.this);
                   cmp.dispose();          
          changePasswordButton.addActionListener(aListener);When the user press the Change Password button, it pass control to the ChangeMyPassword class which as a submit button and a cancel button. When the user press the submit button, it should validate the old password (i.e. compare it to the password in the text file), validate the new password match the retype password:
          // submit button
          ActionListener aListener = new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    // Retrieve the password.
                    char[] pw = oldPasswordField.getPassword();
                    oldPassword = new String(pw).trim();
                    pw = newPasswordField.getPassword();
                    newPassword = new String(pw).trim();
                    pw = retypePasswordField.getPassword();
                    retypePassword = new String(pw).trim();
                    // Hide, but don't dispose of, this window ...
                    // we need to give the client code a chance to
                    // retrieve the user's typed response via
                    // the getPassword() method first.
                    ChangeMyPassword.this.setVisible(false);
          submitButton.addActionListener(aListener);I have a Student class which compare the old password with the password in the text file. The student class constructor takes the student id to identify which student text file it should call.
The problem is that the ChangeMyPassword does not know about student id (because I am getting these from the text field in MainFrame class). So how can I call the validatePassword method in Student class?
     public boolean validatePassword(String pw) {
          if (pw == null) return false;
          if (pw.equals(password)) return true;
          else return false;
     }

I don�t understand why it does not update the text file with the new password.
The submit button has the action in ChangeMyPassword class:
          // submit button
          ActionListener aListener = new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    // Retrieve the password.
                    char[] pw = oldPasswordField.getPassword();
                    oldPassword = new String(pw).trim();
                    pw = newPasswordField.getPassword();
                    newPassword = new String(pw).trim();
                    pw = retypePasswordField.getPassword();
                    retypePassword = new String(pw).trim();
                    Student theStudent = new Student(id);
                    if(theStudent.validatePassword(oldPassword)){
                        if(validateChangePassword()){
                             // write the new password to file
                             theStudent.setPassword(getNewPassword());
                             // Let the user know that the
                             // password succeeded.
                             JOptionPane.showMessageDialog(null,
                              "Password change successfully.",
                              "Password Changed",
                              JOptionPane.INFORMATION_MESSAGE);
                        }else{
                             JOptionPane.showMessageDialog(null,
                                        "You have used an invalid user name or password; please try again.",
                                        "Authentication failed",
                                        JOptionPane.WARNING_MESSAGE);
                   }else{
                        JOptionPane.showMessageDialog(null,
                                   "You have used an invalid user name or password; please try again.",
                                   "Authentication failed",
                                   JOptionPane.WARNING_MESSAGE);                        
                    // Hide, but don't dispose of, this window ...
                    // we need to give the client code a chance to
                    // retrieve the user's typed response via
                    // the getPassword() method first.
                    ChangeMyPassword.this.setVisible(false);
          submitButton.addActionListener(aListener);Validate password method in Student class:
     public boolean validatePassword(String pw) {
          if (pw == null) return false;
          if (pw.equals(password)) return true;
          else return false;
     }Validate change password method in ChangeMyPassword class:
     public boolean validateChangePassword(){
          if(newPassword.equals(retypePassword))return true;
          else return false;
     }When the user press the Change Password button the action performed in the MainFrame class is:
          // Change password
          aListener = new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    String id = ssnField.getText();
                   ChangeMyPassword cmp = new ChangeMyPassword(MainFrame.this, id);
                   boolean success = currentUser.persist();
                   cmp.dispose();          
          changePasswordButton.addActionListener(aListener);Now remember that I set the password that should be written in ChangeMyPassword class as you can see above. Now that I called the persist method, it should write all the details back to the text. For some reason it not doing that and I don�t understand why.
The persist method:
     public boolean persist() {
          FileOutputStream fos = null;
          PrintWriter pw = null;
          try {
               // Attempt to create the ssn.dat file.  Note that
               // it will overwrite one if it already exists.
               fos = new FileOutputStream("C://Files//" + getSsn() + ".dat");
               pw = new PrintWriter(fos);
               // First, we output the header record as a tab-delimited
               // record.
               pw.println(getSsn() + "\t" + getName() + "\t" +
                       getMajor() + "\t" + getDegree() + "\t" + getPassword());
               // Then, we output one record for every Section that
               // the Student is enrolled in.
               for (int i = 0; i < attends.size(); i++) {
                    Section s = (Section) attends.elementAt(i);
                    pw.println(s.getFullSectionNo());
               pw.close();
               fos.close(); //? needed?
          catch (IOException e) {
               // Signal that an error has occurred.
               return false;
          // All is well!
          return true;
     }

Similar Messages

  • New user - how do i change permissions from old to new user?

    I've got a new employee. I need to switch all permissions of files from one employee to the new guy. Any EASY way to do this? Files/folders are in many different sharing points and folders.
    Thanks!!!

    A easy, but dirty, way to do this is to change your old employee's UID to something else and change your new employee's UID to the one you just replaced. If you do this as you create the new account, everything might just work out fine. It will truly transfer ownership of everything to the new user.

  • Changing current production SID to new SID.

    Hello there,
    I have a question on changing current SID name to new SID name. We are planning on moving our current production hardware to new better hardware and change the PRD(old) to PRD(new). Is anyone out there (customers) who had done this before, and what would be the ramifications? I  know we have to run BDLS in order to change current logical systems to new logical systems. Are there any issues in doing so in Production system? Any input is appreciated.
    Thanks,
    Santosh

    Santosh
    you can do that easily just by installing SAP system on new hardware and then restoring this backup to new system,that should not be an issue,it is just like doing system copy
    but
    SAP has strongly recommended not to run BDLS conversions on Production systems database,so I would suggest you to first approach SAP,raise a message with them and ask their recommendations
    Let me know of any questions
    Rohit

  • Changed my AppleID and password - now can't log-in to iCloud with my deleted account.  It does not accept my passwords - old or new.  I cannot delete my old iCloud on phone

    iPhone 5S on iOS7 -
    I changed my AppleID and password online. 
    My iPhone keeps prompting me to log-in to iCloud with my deleted account.  It does not accept my passwords - old or new.  I cannot delete my old iCloud account because it requires that I enter

    Hi suefrombenton,
    Please see this previous discussion on how to change an Apple ID on an iOS device -
    How do I change my Apple ID on my iPad? | Apple Support Communities
    https://discussions.apple.com/thread/4431720
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • HT204053 I changed my AppleID in System Preferences, but the old ID comes up under iCloud and I get an error box saying my "ID or password are incorrect".  How do I get rid of the old ID which now doesn't work with either my old or new password??

    I changed my AppleID in System Preferences, but the old ID comes up under iCloud and I get an error box saying my "ID or password are incorrect".  How do I get rid of the old ID which now doesn't work with either my old or new password??

    Yes that makes sense, however have you updated it at My Apple ID before trying to change it in your system preferences > iCloud settings, you must do that first.

  • Mobil email requires a new password but I didnt have to change from the old password

    mobil email requires a new password but I didnt have to change from the old password
    I just paid $7 and it will not take my old password
    I went to live.com and Microsoft didn't make me change passwords.
    So give me $7 credit or the phone number of Mobil Email as there is no way to contact them
    thanks
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Message was edited by: Verizon Moderator

    1 hour with customer service just now  wasted 1 hour for a cancer cure as this is a 1984 Era why do this to me.... now I have no mobil email as after a hour he your employee gave up...
    wow
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Edited by:  Verizon Moderator

  • I had to set up a new email ID, because I no longer had access to my old email address and Adobe was forcing me to change password, but I could not access the verification email. Now I cannot read my books under my new ID, even though I got Adobe support

    I had to set up a new email ID, because I no longer had access to my old email address and Adobe was forcing me to change password, but I could not access the verification email. Now I cannot read my books under my new ID, even though I got Adobe support to set up my new ID.

    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact AppleCare(or Apple ID Support), upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • HT1933 I have old email address's I used for iTune music purchases and cannot change password on several old accounts. Now some of the music I purchased I can not download and authorize it on my device. What can I do password security does not match my bi

    I have old email address's I used for iTune music purchases and cannot change password on several old accounts. Now some of the music I purchased I can not download and authorize it on my device. What can I do password security does not match my birthdate on two of the accounts. Apple can not send me email with a password authorization on several current accounts that I have with them. How can I contact Apple with this annoying problem I can not fix.

    settings - app/iTunes store - sign out and sign back in with your new id.
    Note - if your older apps needs an update it will use your old apple id and password, as Apps are tied to the apple id that was used to purchase it.
    You can't merge apple id.

  • Time Capsule backup cannot be seen on new MAC after resetting Time Capsule and changing password.

    I have backed up my MAC to Time Capsule with Time Machine, erased HDD and clean installed OX Yosemite. After installation I have to reconfigure Wi Fi, so I reset my Time Capsule changed password. Now I cannot see my previous back up on reinstalled MAC. Neither on TM nor on the Manual search. In finder appeared new disk. I am pretty sure that old files are still there. Can anybody suggest how to retrieve them.

    This sounds like classic Yosemite.
    What you did is fine.. there is no way to delete the backups via the reset button.
    What I would suggest is a new clean setup of the TC again.. use a full factory reset.
    Factory reset universal
    Power off the TC.. ie pull the power cord or power off at the wall.. wait 10sec.. hold in the reset button.. be gentle.. power on again still holding in reset.. and keep holding it in for another 10sec. You may need some help as it is hard to both hold in reset and apply power. It will show success by rapidly blinking the front led. Release the reset.. and wait a couple of min for the TC to reset and come back with factory settings. If the front LED doesn’t blink rapidly you missed it and simply try again. The reset is fairly fragile in these.. press it so you feel it just click and no more.. I have seen people bend the lever or even break it. I use a toothpick as tool.
    N.B. None of your files on the hard disk of the TC are deleted.. this simply clears out the router settings of the TC.
    Redo the setup from the airport utility in the Yosemite computer..
    Do not use the recommend names.. use really short names.. no spaces and pure alphanumeric.
    eg TCgenx and TCwifi for basestation and wireless names.
    You can also setup wireless password as before but I strongly recommend 8-20 character pure alphanumeric mixed case and numbers.. no characters outside of that.
    Then mount the TC manually in finder.
    Go, Connect to server.
    Type in the TC IP address if at all possible.. it is more likely to be reliable than using name.
    SMB://10.0.1.1 (replace with your IP but it should be static.. that is default)
    Or
    SMB://TCgenx.local (use whatever name you have given it.. plus the domain which is always local)
    when asked for the disk password supply it and save in the keychain. Then open the disk in finder and you should see your sparsebundle in there.. from migrate assistant you should now be able to see your backup.

  • HT201342 How do you change passwords in email accounts??? Just got new iPhone and no record of previous passwords.....

    How do you change passwords in email accounts?? Have new iPhone and no record of previous passwords. Dumb I know but I'm in a real bind.....

    See http://support.apple.com/kb/HT5787.  (Your iCloud ID is also an Apple ID.)  If you don't have access to your old email account and can't use security question authentication to reset your password, you'll have to do one of the following to turn off Find My iPhone so you can chang the iCloud account on your phone:
    If you still have access to your old email address, go to https//appleid.apple.com, click Manage my Apple ID and sign in with your iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email account and verify it.  Then edit the name of the account to change it back to your old email address.  You should then be able to turn off Find My iPhone with your password. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back and change your primary email address and iCloud ID back to the way it was.  You will then be able to go to Settings>iCloud and sign in with your current ID and password to reconnect to your iCloud account.
    If you don't have access to your old email address, you will have to contact Apple to get them to reset the password for it so you can disable Find My iPhone and sign into your iCloud account.  You will have to prove your identity to them in order to do so.  You can either contact iTunes support for assistance with this (https://ssl.apple.com/emea/support/itunes/contact.html), or contact Apple Support (http://www.apple.com/support/icloud/contact/).

  • Customize change password logic

    Hi guys,
    We are working on EP 6.0, We need to make our own change password logic for first time user login. ( e.g  new password should be > 10 long,  if he makes a number of unsuccesful operation, his account will be locked , etc...)
    For current change password logic, the system calls some .class file provided by SAP.
    Can we change the logic of orginal .class ? if not, how can we create our own and use it?
    Regards,
    Guo Feng

    Hi Feng,
    You could take a look at the Blog I once posted with its attached Wiki Page where I placed the Source code. You will find it here:
    A Change Password Application
    However I customized it for a different reason. You can modify the application to add in your business logic.
    Let me know if you need more help.
    Hope this helped.
    Prem

  • My itunes account was disabled for some reason.  I changed password in iforgot and still didn't work.  I could log in but not make purchases from the store so I set up a new login/account .  Is there any way to move my music to the new account?

    My itunes account was disabled for some reason.  I changed password in iforgot and still didn't work.  I could log in and see my music but not make purchases from the store or even redeem an itunes gift card so I set up a new login/account with another email account of mine. On the new account I can redeem my gift card and download items onto my ipad2.  Is there any way to move my music to the new account?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • ITunes is updated and works fine and I am able to log onto my account. When I go to purchase a song, I get the error message "Your Apple ID has been disabled". I've tried different methods: changing passwords, making a new account with another email addre

    iTunes is updated and works fine and I am able to log onto my account. When I go to purchase a song, I get the error message "Your Apple ID has been disabled". I've tried different methods: changing passwords, making a new account with another email address, and emailing itunes tech support. I am curious as to how many others have been experiencing the same issue. When I googled the error, it seemed like it was happening extremely often with many people.
    We all love their products, but they always come with a lot of issues and horrible customer support.
    My apple Id is [email protected]

    My Iphone 4 is telling me the same thing and I believe I figured out what the problem is.  I had some fraudulent charges on my itunes account, so I call my bank and disputed the charges.  Right after I did that, I started getting the message "Your apple ID has been disabled."  I just realized today that the charges are not fraudulent, they are "in app purchases."  One of my daughters downloaded the game Top Girl which is FREE, but in the game Top Girl you use money in the game to purchase things.  It just so happens that the money you use to purchase things is real money MY Money!!!.  My daughter thought she was using play money in the game and had no idea she was using real money.  She spent $106.00 buying stuff.  Now I have to call the bank and tell them to release the hold and pay Itunes.  I'm hoping this solves the problem.  Here is the link to learn how to disable "in app purchase" on your iphone or ipad.
    http://www.ikidapps.com/2010/12/parents-avoid-accidental-app-purchases-how-to-tu rn-off-in-app-purchasing.html

  • I changed my Apple ID/ email address. But iCloud won't let me change from my old one. I don't remember my password to my old one. How do I fix this?

    I changed my Apple ID/ email address. But iCloud won't let me change from my old one. I don't remember my password to my old one. How do I fix this?

    Hello Brookeg189,
    You may be able to use the password for your existing iCloud account to get past this dialog.
    iOS 7: If you're asked for the password to your previous Apple ID when signing out of iCloud
    http://support.apple.com/kb/TS5223
    Cheers,
    Allen

  • Change Password in New BT Mail

    How do I change password in the new BT Email.
    Thanks & Regards.
    Jai P Mandal △

    What about this?
    http://bt.custhelp.com/app/answers/detail/a_id/48826/kw/change%20password%20BT%20email/c/346,6769,70...

Maybe you are looking for