Project

General

Profile

« Previous | Next » 

Revision 4729

Added by daigle over 15 years ago

Add back the auth.base variable to metacat.properties. Use this variable when creating ldap distinguished name.

View differences:

MetacatHelper.java
24 24

  
25 25
package edu.ucsb.nceas.metacat.advancedsearch;
26 26

  
27
import edu.ucsb.nceas.metacat.AuthLdap;
28
import edu.ucsb.nceas.metacat.service.PropertyService;
29
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
30

  
27 31
import javax.servlet.ServletContext;
28 32
import javax.servlet.http.HttpServletRequest;
29 33
import javax.servlet.http.HttpSession;
30 34

  
35
import org.apache.log4j.Logger;
31 36

  
37

  
32 38
/**
33 39
 * @author dcosta
34 40
 * 
......
36 42
 * classes interact with Metacat.
37 43
 */
38 44
public class MetacatHelper {
39
  
45

  
46
	private static Logger logMetacat = Logger.getLogger(AuthLdap.class);
47
	
40 48
  /**
41
   * Constructs a DN (Distinguished Name) string for the ecoinformatics.org
42
   * LDAP.
43
   * 
44
   * @param username       The LDAP uid, e.g. "dcosta"
45
   * @param organization   The LDAP organization, e.g. "LTER"
46
   * @return DN            The distinguished name string.
47
   */
48
  public String constructDN(final String username, final String organization) {
49
    final String DN = "uid=" + username + 
50
                      ",o=" + organization + 
51
                      ",dc=ecoinformatics,dc=org";    
52
    
53
    return DN;
54
  }
49
	 * Constructs a DN (Distinguished Name) string for the ecoinformatics.org
50
	 * LDAP.
51
	 * 
52
	 * @param username
53
	 *            The LDAP uid, e.g. "dcosta"
54
	 * @param organization
55
	 *            The LDAP organization, e.g. "LTER"
56
	 * @return DN The distinguished name string.
57
	 */
58
	public String constructDN(final String username, final String organization) {
59
		String DC;
60
		try {
61
			DC = PropertyService.getProperty("auth.base");
62
		} catch (PropertyNotFoundException pnfe) {
63
			DC = "dc=ecoinformatics,dc=org";
64
			logMetacat.error("Could not find property: auth.base.  Setting to: " +
65
					"dc=ecoinformatics,dc=org : " + pnfe.getMessage());
66
		}
67
		final String DN = "uid=" + username + ",o=" + organization
68
				+ "," + DC;
69

  
70
		return DN;
71
	}
55 72
  
56 73

  
57 74
  /**
58
   * Constructs a URL to the metacat servlet.
59
   * 
60
   * @param serverName   A server name, e.g. "prairie.lternet.edu"
61
   * @param serverPort   A server port, e.g. 8080. If no port is required in
62
   *                     the URL, pass a 0 and the argument will be ignored.
63
   * @param contextString The context under which metacat is running, e.g. "knb".
64
   * @return metacatURL  The URL to the metacat servlet.
65
   */
75
	 * Constructs a URL to the metacat servlet.
76
	 * 
77
	 * @param serverName
78
	 *            A server name, e.g. "prairie.lternet.edu"
79
	 * @param serverPort
80
	 *            A server port, e.g. 8080. If no port is required in the URL,
81
	 *            pass a 0 and the argument will be ignored.
82
	 * @param contextString
83
	 *            The context under which metacat is running, e.g. "knb".
84
	 * @return metacatURL The URL to the metacat servlet.
85
	 */
66 86
  public String constructMetacatURL(final String serverName, 
67 87
                                    final int serverPort,
68 88
                                    final String contextString) {

Also available in: Unified diff