Project

General

Profile

« Previous | Next » 

Revision 8486

Added by Jing Tao almost 11 years ago

Complete the method - handleUseradd.

View differences:

src/edu/ucsb/nceas/metacat/authentication/AuthFile.java
646 646
            }
647 647
            description = map.get(DASHD);
648 648
            authFile.addGroup(groupName, description);
649
            System.out.println("Successfully add a group "+groupName+" to the file authentication system");
649
            System.out.println("Successfully added a group "+groupName+" to the file authentication system");
650 650
        } else {
651 651
            printError(argus);
652 652
            System.exit(1);
......
656 656
    /*
657 657
     * Handle the userAdd action in the main method
658 658
     */
659
    private static void  handleUserAdd(AuthFile authFile,String[]argus) throws UnsupportedEncodingException{
659
    private static void  handleUserAdd(AuthFile authFile,String[]argus) throws UnsupportedEncodingException, AuthenticationException{
660 660
        boolean inputPassword = false;
661 661
        boolean passingHashedPassword = false;
662 662
        boolean hasDN = false;
......
721 721
            }
722 722
        } 
723 723
        
724
        String dn = null;
725
        String plainPassword = null;
726
        String hashedPassword = null;
724 727
        if(!hasDN) {
725 728
            System.out.println("The \"-dn user-distinguish-name\" is requried in the useradd command ."); 
726 729
            System.exit(1);
730
        } else {
731
            dn = map.get(DN);
727 732
        }
728 733
        
729
        String plainPassword = null;
734
       
730 735
        if(inputPassword && passingHashedPassword) {
731 736
            System.out.println("Error: you can choose either \"-i\"(input a password) or \"-d dashed-passpwrd\"(pass through a hashed passwprd) in the useradd command.");
732 737
            System.exit(1);
......
735 740
            System.exit(1);
736 741
        } else if(inputPassword) {
737 742
            plainPassword = inputPassword();
743
            //System.out.println("============the plain password is "+plainPassword);
744
        } else if(passingHashedPassword) {
745
            hashedPassword = map.get(H);
738 746
        }
739
        //System.out.println("============the plain password is "+plainPassword);
747
        
748
        String group = map.get(G);
749
        String[] groups = null;
750
        if(group != null && !group.trim().equals("")) {
751
            groups = new String[1];
752
            groups[0]=group;
753
        }
754
        String email = map.get(E);
755
        String surname = map.get(S);
756
        String givenname = map.get(F);
757
        String organization = map.get(O);
758
        authFile.addUser(dn, groups, plainPassword, hashedPassword, email, surname, givenname, organization);
759
        System.out.println("Successfully added a user "+dn+" to the file authentication system ");
740 760
    }
741 761
    
742 762
    

Also available in: Unified diff