Project

General

Profile

« Previous | Next » 

Revision 8493

Added by Jing Tao over 10 years ago

Change to use AuthFile constructor.

View differences:

AuthFile.java
51 51
/**
52 52
 * This an authentication class base on a username/password file.
53 53
 * It is an alternative authentication mechanism of the ldap authentication.
54
 * This is a singleton class and the password file looks like:
54
 * The password file looks like:
55 55
 *<?xml version="1.0" encoding="UTF-8" ?>
56 56
 * <subjects>
57 57
 *  <users>
......
60 60
 *          <email>foo@foo.com</email>
61 61
 *          <surName>Smith</surName>
62 62
 *          <givenName>John</givenName>
63
 *          <organization>NCEAS</organization>
63 64
 *          <group>nceas-dev</group>
64 65
 *      </user>
65 66
 *  </users>
......
107 108
     * @return
108 109
     * @throws AuthenticationException
109 110
     */
110
    public static AuthFile getInstance() throws AuthenticationException {
111
    /*public static AuthFile getInstance() throws AuthenticationException {
111 112
        if(authFile == null) {
112 113
            authFile = new AuthFile();
113 114
        }
114 115
        return authFile;
115
    }
116
    }*/
116 117
    
117 118
    /**
118 119
     * Get the instance of the AuthFile from specified password file
119 120
     * @return
120 121
     * @throws AuthenticationException
121 122
     */
122
    public static AuthFile getInstance(String passwordFile) throws AuthenticationException {
123
    /*public static AuthFile getInstance(String passwordFile) throws AuthenticationException {
123 124
        passwordFilePath = passwordFile;
124 125
        if(authFile == null) {
125 126
            authFile = new AuthFile();
126 127
        }
127 128
        return authFile;
128
    }
129
    }*/
129 130
    
130 131
    /**
131 132
     * Constructor
132 133
     */
133
    private AuthFile() throws AuthenticationException {
134
    public AuthFile() throws AuthenticationException {
134 135
        try {
135 136
            init();
136 137
        } catch (Exception e) {
......
140 141
        
141 142
    }
142 143
    
144
    /**
145
     * 
146
     * @param passwordFile
147
     * @throws AuthenticationException
148
     */
149
    public  AuthFile (String passwordFile) throws AuthenticationException {
150
        passwordFilePath = passwordFile;
151
        try {
152
            init();
153
        } catch (Exception e) {
154
            e.printStackTrace();
155
            throw new AuthenticationException(e.getMessage());
156
        }
157
    }
158
    
143 159
    /*
144 160
     * Initialize the user/password configuration
145 161
     */
......
600 616
                System.exit(1);
601 617
            }
602 618
            PropertyService.getInstance(argus[0]);
603
            AuthFile authFile = AuthFile.getInstance();
619
            AuthFile authFile = new AuthFile();
604 620
            if(argus[1] != null && argus[1].equals(GROUPADD)) {
605 621
                handleGroupAdd(authFile,argus);
606 622
            } else if (argus[1] != null && argus[1].equals(USERADD)) {

Also available in: Unified diff