Project

General

Profile

« Previous | Next » 

Revision 4984

Added by daigle over 15 years ago

Created new AuthStub class to always authenticate.

View differences:

lib/style/common/searchWorkflow.js
112 112
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
113 113
		pathExpr += "<value>" + sfElement.value + "</value>";
114 114
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
115
		pathExpr += "</queryterm>"; 		
115
		pathExpr += "</queryterm>";		
116 116
	} else if (sfElement.name == 'workflow-id') {
117 117
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
118
		pathExpr += "<value>" + sfElement.value + "</value>";
119
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
120
		pathExpr += "</queryterm>"; 		
121
	} else if (sfElement.name == 'workflow-lsid') {
122
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
123
		pathExpr += "<value>workflowLSID</value>";
124
		pathExpr += "<pathexpr>property/property/@name</pathexpr>";
118
		pathExpr += "<value>entityId</value>";
119
		pathExpr += "<pathexpr>/entity/property/@name</pathexpr>";
125 120
		pathExpr += "</queryterm>"; 
126 121
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
127 122
		pathExpr += "<value>" + sfElement.value + "</value>";
128
		pathExpr += "<pathexpr>property/property/@value</pathexpr>";
123
		pathExpr += "<pathexpr>/entity/property/@value</pathexpr>";
129 124
		pathExpr += "</queryterm>";		
130 125
	} else if (sfElement.name == 'workflow-run-id') {
131 126
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
lib/metacat.properties
120 120
######## Authentication and LDAP ##############################################
121 121

  
122 122
auth.class=edu.ucsb.nceas.metacat.AuthLdap
123
// Use AuthStub to test and guarantee authentication
124
//auth.class=edu.ucsb.nceas.metacat.AuthStub
123 125
auth.timeoutMinutes=180
124 126
# auth.administrators=uid=jones,o=NCEAS,dc=ecoinformatics,dc=org
125 127
auth.administrators=
......
392 394
sitemap.interval=86400000
393 395

  
394 396
######## Workflow engine section              #########################################
395
executionEngine.endPointAddress=http://chico1.dyndns.org/axis2/services/KeplerWebService
397
executionEngine.endPointAddress=http://localhost:8080/axis2/services/KeplerWebService
396 398

  
397 399
######## junit test section  ################
398 400

  
src/edu/ucsb/nceas/metacat/AuthStub.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: An implementation of the AuthInterface interface that
4
 *             allows Metacat to use the LDAP protocol for
5
 *             directory services
6
 *  Copyright: 2000 Regents of the University of California and the
7
 *             National Center for Ecological Analysis and Synthesis
8
 *    Authors: Matt Jones
9
 *
10
 *   '$Author: daigle $'
11
 *     '$Date: 2008-11-10 15:22:04 -0800 (Mon, 10 Nov 2008) $'
12
 * '$Revision: 4547 $'
13
 *
14
 * This program is free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 */
28

  
29
package edu.ucsb.nceas.metacat;
30

  
31
import java.net.ConnectException;
32

  
33
import org.apache.log4j.Logger;
34

  
35
import edu.ucsb.nceas.metacat.service.PropertyService;
36
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
37

  
38
import java.lang.InstantiationException;
39
import java.util.HashMap;
40
import java.util.Vector;
41

  
42
/**
43
 * An implementation of the AuthInterface interface that
44
 * allows Metacat to use the LDAP protocol for directory services.
45
 * The LDAP authentication service is used to determine if a user
46
 * is authenticated, and whether they are a member of a particular group.
47
 */
48
public class AuthStub implements AuthInterface {
49
	
50

  
51
  private static Logger logMetacat = Logger.getLogger(AuthTest.class);
52
  
53
    /**
54
	 * Construct an AuthTest
55
	 */
56
	public AuthStub() throws InstantiationException {	
57
	}
58

  
59
  /**
60
	 * Determine if a user/password are valid according to the authentication
61
	 * service.
62
	 * 
63
	 * @param user
64
	 *            the name of the principal to authenticate
65
	 * @param password
66
	 *            the password to use for authentication
67
	 * @returns boolean true if authentication successful, false otherwise
68
	 */
69
  
70
  public boolean authenticate(String user, String password) throws ConnectException {
71
	  return true;
72
  }
73
  
74
  /**
75
   * Get all users from the authentication service
76
   *
77
   * @param user the user for authenticating against the service
78
   * @param password the password for authenticating against the service
79
   * @returns string array of all of the user names
80
   */
81
  public String[][] getUsers(String user, String password) throws 
82
    ConnectException {
83
    String[][] users = new String[1][1];
84
    
85
    users[0][0] = "bogusUser";
86
    
87
    return users;
88
  }
89

  
90
  
91
  /**
92
   * Get all users from the authentication service
93
   *
94
   * @param user the user for authenticating against the service
95
   * @param password the password for authenticating against the service
96
   * @returns string array of all of the user names
97
   */
98
  public String[] getUserInfo(String user, String password) throws 
99
    ConnectException {
100
    String[] userinfo = new String[3];
101

  
102
    userinfo[0] = "bogusUser";
103
    userinfo[1] = "bogusOrg";
104
    userinfo[2] = "bogusEmail";
105

  
106
    return userinfo;
107
  }
108

  
109
  /**
110
   * Get the users for a particular group from the authentication service
111
   *
112
   * @param user the user for authenticating against the service
113
   * @param password the password for authenticating against the service
114
   * @param group the group whose user list should be returned
115
   * @returns string array of the user names belonging to the group
116
   */
117
  public String[] getUsers(String user, String password, String group) throws 
118
    ConnectException {
119
    String[] users = null;
120

  
121
    users[0] = "bogusUser";
122

  
123
    return users;
124
  }
125

  
126
  /**
127
   * Get all groups from the authentication service
128
   *
129
   * @param user the user for authenticating against the service
130
   * @param password the password for authenticating against the service
131
   * @returns string array of the group names
132
   */
133
  public String[][] getGroups(String user, String password) throws 
134
    ConnectException {
135
    return getGroups(user, password, null);
136
  }
137

  
138
  /**
139
   * Get the groups for a particular user from the authentication service
140
   *
141
   * @param user the user for authenticating against the service
142
   * @param password the password for authenticating against the service
143
   * @param foruser the user whose group list should be returned
144
   * @returns string array of the group names
145
   */
146
  public String[][] getGroups(String user, String password, 
147
    String foruser) throws ConnectException {
148
    
149
    //build and return the groups array
150
    String groups[][] = new String[1][2];
151
    
152
    groups[0][1] = "bogusGroup";
153
    groups[0][1] = "bogusGroupDesc";
154

  
155
    return groups;
156

  
157
  }
158

  
159
  /**
160
   * Get attributes describing a user or group
161
   *
162
   * @param foruser the user for which the attribute list is requested
163
   * @returns HashMap a map of attribute name to a Vector of values
164
   */
165
  public HashMap<String,Vector<String>> getAttributes(String foruser) throws ConnectException {
166
    return getAttributes(null, null, foruser);
167
  }
168

  
169
  /**
170
   * Get attributes describing a user or group
171
   *
172
   * @param user the user for authenticating against the service
173
   * @param password the password for authenticating against the service
174
   * @param foruser the user whose attributes should be returned
175
   * @returns HashMap a map of attribute name to a Vector of values
176
   */
177
  public HashMap<String,Vector<String>> getAttributes(String user, String password, 
178
    String foruser) throws ConnectException {
179
    HashMap<String,Vector<String>> attributes = new HashMap<String,Vector<String>>();
180
    
181
    Vector<String> attributeValues = new Vector<String>();
182
    attributeValues.add("bogusValue1");
183
    attributeValues.add("bogusValue2");
184
    	
185
    attributes.put("bogusAttributeName", attributeValues);
186

  
187
    return attributes;
188
  }
189

  
190
  /**
191
   * Get all groups and users from authentication scheme.
192
   * The output is formatted in XML.
193
   * @param user the user which requests the information
194
   * @param password the user's password
195
   */
196
  public String getPrincipals(String user, String password) throws 
197
    ConnectException {
198
    String out = new String();
199
   
200
    out += "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
201
    out += "<principals>\n";
202
    out += "  <authSystem URI=\"bogusAuthUrl>\n";
203
    out += "    <group>\n";
204
    out += "      <groupname>bogusTestGroup</groupname>\n";
205
    out += "      <description>bogusTestGroupDesc</description>\n";
206
    out += "      <user>\n";
207
    out += "        <username>bogusTestUser</username>\n";
208
    out += "        <name>bogusTestUserName</name>\n";
209
    out += "        <organization>bogusTestOrg</organization>\n";
210
    out += "        <organizationUnitName>bogusTestOrgUnit</organizationUnitName>\n";
211
    out += "        <email>bogusTestEmail</email>\n";
212
    out += "      </user>\n";
213
    out += "    </group>\n";
214
    out += "    <group>\n";
215
    out += "      <groupname>bogusOtherTestGroup</groupname>\n";
216
    out += "      <description>bogusOtherTestGroupDesc</description>\n";
217
    out += "      <user>\n";
218
    out += "        <username>bogusOtherTestUser</username>\n";
219
    out += "        <name>bogusOtherTestUserName</name>\n";
220
    out += "        <organization>bogusOtherTestOrg</organization>\n";
221
    out += "        <organizationUnitName>bogusOtherTestOrgUnit</organizationUnitName>\n";
222
    out += "        <email>bogusOtherTestEmail</email>\n";
223
    out += "      </user>\n";
224
    out += "    </group>\n";
225
    out += "  </authSystem>\n";
226
    out += "</principals>";
227
    
228
    return out;
229
  }
230
}
0 231

  
src/edu/ucsb/nceas/metacat/util/AuthUtil.java
445 445
			if (groups != null && accessString.startsWith("cn=")) {
446 446
				// is a group dn
447 447
				for (int j = 0; j < groups.length; j++) {
448
					if (groups[j].equals(accessString)) {
448
					if (groups[j] != null && groups[j].equals(accessString)) {
449 449
						return true;
450 450
					}
451 451
				}

Also available in: Unified diff