geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vamsavardhana Reddy" <c1vams...@gmail.com>
Subject Re: svn commit: r475164 - in /geronimo/server/trunk/applications/console: geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/ geronimo-console-framework/src/main/webapp/WEB-INF/data/ geronimo-console-standard/src/main/java/org/apache/gero
Date Wed, 15 Nov 2006 09:14:48 GMT
Source headers of newly added files are not in line with new ASF source
header and copyright notice policy.  See GERONIMO-2537.

--vamsi

On 11/15/06, ccardona@apache.org <ccardona@apache.org> wrote:
>
> Author: ccardona
> Date: Wed Nov 15 00:57:58 2006
> New Revision: 475164
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=475164
> Log:
> GERONIMO-1823 Add Embedded LDAP Server Viewer Portlet
>
> Added:
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/help.jsp
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp
> Modified:
>
>     geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/Head.jsp
>
>     geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
>
>     geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/dwr.xml
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml
>
>     geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/Head.jsp
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/Head.jsp?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/Head.jsp
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/aggregation/Head.jsp
> Wed Nov 15 00:57:58 2006
> @@ -44,6 +44,7 @@
>          dojo.require("dojo.widget.SortableTable");
>          dojo.require("dojo.widget.ComboBox");
>          dojo.require("dojo.widget.Tooltip");
> +        dojo.require("dojo.widget.validate");
>         // Includes Dojo source for debugging
>         // dojo.hostenv.writeIncludes();
>      </script>
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/pageregistry.xml
> Wed Nov 15 00:57:58 2006
> @@ -608,4 +608,19 @@
>          </fragment>
>      </fragment>
>
> +    <fragment name="LDAPViewer" type="page">
> +        <navigation>
> +            <title>LDAP Viewer</title>
> +            <description>ico_filetree_16x16.gif View contents of an LDAP
> server</description>
> +        </navigation>
> +
> +        <fragment name="row1" type="row">
> +            <fragment name="col1" type="column">
> +                <fragment name="p1" type="portlet">
> +                    <property name="portlet" value="5.71"/>
> +                </fragment>
> +            </fragment>
> +        </fragment>
> +    </fragment>
> +
> </portal>
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-framework/src/main/webapp/WEB-INF/data/portletentityregistry.xml
> Wed Nov 15 00:57:58 2006
> @@ -148,6 +148,9 @@
>          <portlet id="70">
>              <definition-id>console-standard.ImportExport</definition-id>
>          </portlet>
> +        <portlet id="71">
> +            <definition-id>console-standard.LDAPViewer</definition-id>
> +        </portlet>
>          <portlet id="72">
>              <definition-id>console-standard.JMXViewer</definition-id>
>          </portlet>
>
> Added:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java?view=auto&rev=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java
> (added)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java
> Wed Nov 15 00:57:58 2006
> @@ -0,0 +1,446 @@
> +/**
>
> + *
>
> + * Copyright 2006 The Apache Software Foundation or its licensors, as
> applicable.
>
> + *
>
> + *  Licensed under the Apache License, Version 2.0 (the "License");
>
> + *  you may not use this file except in compliance with the License.
>
> + *  You may obtain a copy of the License at
>
> + *
>
> + *     http://www.apache.org/licenses/LICENSE-2.0
>
> + *
>
> + *  Unless required by applicable law or agreed to in writing, software
>
> + *  distributed under the License is distributed on an "AS IS" BASIS,
>
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>
> + *  See the License for the specific language governing permissions and
>
> + *  limitations under the License.
>
> + */
>
> +
>
> +package org.apache.geronimo.console.ldapmanager;
>
> +
>
> +import java.util.ArrayList;
>
> +import java.util.Collection;
>
> +import java.util.Enumeration;
>
> +import java.util.HashMap;
>
> +import java.util.Hashtable;
>
> +import java.util.List;
>
> +import java.util.Map;
>
> +
>
> +import javax.naming.Context;
>
> +import javax.naming.NameClassPair;
>
> +import javax.naming.NamingEnumeration;
>
> +import javax.naming.NamingException;
>
> +import javax.naming.directory.Attribute;
>
> +import javax.naming.directory.Attributes;
>
> +import javax.naming.directory.DirContext;
>
> +import javax.naming.directory.InitialDirContext;
>
> +import javax.naming.directory.SearchControls;
>
> +import javax.naming.directory.SearchResult;
>
> +import javax.servlet.http.HttpSession;
>
> +
>
> +import uk.ltd.getahead.dwr.WebContext;
>
> +import uk.ltd.getahead.dwr.WebContextFactory;
>
> +
>
> +/**
>
> + * The LDAP manager helper
>
> + */
>
> +public class LDAPManagerHelper {
>
> +    private final static String LDAP_VERSION_KEY = "
> java.naming.ldap.version";
>
> +
>
> +    private final static String SSL_VALUE = "ssl";
>
> +
>
> +    private final static String NONE_VALUE = "none";
>
> +
>
> +    private final static String INITIAL_CONTEXT_FACTORY_DEFAULT = "
> com.sun.jndi.ldap.LdapCtxFactory";
>
> +
>
> +    private final static String HOST_DEFAULT = "localhost";
>
> +
>
> +    private final static String PORT_DEFAULT = "1389";
>
> +
>
> +    private final static String BASE_DN_DEFAULT = "ou=system";
>
> +
>
> +    // LDAP Version: "3", "2"
>
> +    private final static String LDAP_VERSION_DEFAULT = "3";
>
> +
>
> +    // Security Protocol: "simple", "ssl", "sasl"
>
> +    private final static String SECURITY_PROTOCOL_DEFAULT = "simple";
>
> +
>
> +    // Security Authentication: "simple", "none", "strong"
>
> +    private final static String SECURITY_AUTHENTICATION_DEFAULT =
> "simple";
>
> +
>
> +    private final static String SECURITY_PRINCIPAL_DEFAULT = "uid=admin,
> ou=system";
>
> +
>
> +    private final static String SECURITY_CREDENTIALS_DEFAULT = "secret";
>
> +
>
> +    private final static String ONELEVEL_SCOPE = "onelevel";
>
> +
>
> +    private final static String SUBTREE_SCOPE = "subtree";
>
> +
>
> +    private final static String DIR_CONTEXT_KEY = "
> LDAPManagerHelper.dirContext";
>
> +
>
> +    private final static String DIR_ENV_KEY = "LDAPManagerHelper.dirEnv";
>
> +
>
> +    private final static String HOST_KEY = "LDAPManagerHelper.host";
>
> +
>
> +    private final static String PORT_KEY = "LDAPManagerHelper.port";
>
> +
>
> +    private final static String BASE_DN_KEY = "LDAPManagerHelper.baseDN";
>
> +
>
> +    private final static String SUCCESS_RESULT = "<SUCCESS>";
>
> +
>
> +    private DirContext dirContext;
>
> +
>
> +    private Hashtable dirEnv;
>
> +
>
> +    private String host;
>
> +
>
> +    private String port;
>
> +
>
> +    private String baseDN;
>
> +
>
> +    /**
>
> +     * Construct an LDAP manager helper using config data (default)
>
> +     */
>
> +    public LDAPManagerHelper() throws Exception {
>
> +        dirContext = (DirContext) getSessionAttribute(DIR_CONTEXT_KEY);
>
> +        if (dirContext == null) {
>
> +            // TODO: Get the default values from configuration / GBean
>
> +            String result = connect(INITIAL_CONTEXT_FACTORY_DEFAULT,
>
> +                    HOST_DEFAULT, PORT_DEFAULT, BASE_DN_DEFAULT,
>
> +                    LDAP_VERSION_DEFAULT, SECURITY_PROTOCOL_DEFAULT,
>
> +                    SECURITY_AUTHENTICATION_DEFAULT,
>
> +                    SECURITY_PRINCIPAL_DEFAULT,
> SECURITY_CREDENTIALS_DEFAULT);
>
> +            if (!SUCCESS_RESULT.equalsIgnoreCase(result)) {
>
> +                throw new Exception(result);
>
> +            }
>
> +        } else {
>
> +            dirEnv = (Hashtable) getSessionAttribute(DIR_ENV_KEY);
>
> +            host = (String) getSessionAttribute(HOST_KEY);
>
> +            port = (String) getSessionAttribute(PORT_KEY);
>
> +            baseDN = (String) getSessionAttribute(BASE_DN_KEY);
>
> +        }
>
> +    }
>
> +
>
> +    /**
>
> +     * Construct an LDAP manager helper using config data (partial)
>
> +     */
>
> +    public LDAPManagerHelper(String host, String port, String baseDN,
>
> +            String securityAuthentication, String userDN, String userPwd)
>
> +            throws Exception {
>
> +        connect(INITIAL_CONTEXT_FACTORY_DEFAULT, host, port, baseDN,
>
> +                LDAP_VERSION_DEFAULT, SECURITY_PROTOCOL_DEFAULT,
>
> +                securityAuthentication, userDN, userPwd);
>
> +    }
>
> +
>
> +    /**
>
> +     * Construct an LDAP manager helper using config data (all)
>
> +     */
>
> +    public LDAPManagerHelper(String initialContextFactory, String host,
>
> +            String port, String baseDN, String ldapVersion,
>
> +            String securityProtocol, String securityAuthentication,
>
> +            String securityPrincipal, String securityCredentials)
>
> +            throws Exception {
>
> +        connect(initialContextFactory, host, port, baseDN, ldapVersion,
>
> +                securityProtocol, securityAuthentication,
> securityPrincipal,
>
> +                securityCredentials);
>
> +    }
>
> +
>
> +    /**
>
> +     * Create a directory context using config data
>
> +     */
>
> +    public synchronized String connect(String initialContextFactory,
>
> +            String host, String port, String baseDN, String ldapVersion,
>
> +            String securityProtocol, String securityAuthentication,
>
> +            String securityPrincipal, String securityCredentials)
>
> +            throws Exception {
>
> +        String result = SUCCESS_RESULT;
>
> +
>
> +        Hashtable dirEnv = new Hashtable();
>
> +        dirEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> initialContextFactory);
>
> +        String providerURL = createLDAPURL(host, port, ""); // Empty Base
> DN
>
> +        dirEnv.put(Context.PROVIDER_URL, providerURL);
>
> +        dirEnv.put(LDAP_VERSION_KEY, ldapVersion);
>
> +        if (SSL_VALUE.equalsIgnoreCase(securityProtocol)) {
>
> +            dirEnv.put(Context.SECURITY_PROTOCOL, SSL_VALUE);
>
> +        }
>
> +        dirEnv.put(Context.SECURITY_AUTHENTICATION,
> securityAuthentication);
>
> +        if (!(NONE_VALUE.equalsIgnoreCase(securityAuthentication))) {
>
> +            // Either "simple" or "strong"
>
> +            dirEnv.put(Context.SECURITY_PRINCIPAL, securityPrincipal); //
> User DN
>
> +            dirEnv.put(Context.SECURITY_CREDENTIALS,
> securityCredentials); // Password
>
> +        }
>
> +
>
> +        try {
>
> +            DirContext newDirContext = new InitialDirContext(dirEnv);
>
> +            // Close old context
>
> +            if (dirContext != null) {
>
> +                dirContext.close();
>
> +            }
>
> +            // Save directory data to class vars
>
> +            this.dirContext = newDirContext;
>
> +            this.dirEnv = dirEnv;
>
> +            this.host = host;
>
> +            this.port = port;
>
> +            this.baseDN = baseDN;
>
> +            // Save directory data to session
>
> +            setSessionAttribute(DIR_CONTEXT_KEY, dirContext);
>
> +            setSessionAttribute(DIR_ENV_KEY, dirEnv);
>
> +            setSessionAttribute(HOST_KEY, host);
>
> +            setSessionAttribute(PORT_KEY, port);
>
> +            setSessionAttribute(BASE_DN_KEY, baseDN);
>
> +        } catch (NamingException e) {
>
> +            result = "Problem connecting to directory server: "
>
> +                    + e.getMessage();
>
> +        }
>
> +
>
> +        return result;
>
> +    }
>
> +
>
> +    /**
>
> +     * Return directory context environment
>
> +     */
>
> +    public Map getEnvironment() {
>
> +        Map env = new HashMap();
>
> +        env.put("host", host);
>
> +        env.put("port", port);
>
> +        String ldapVersion = (String) dirEnv.get(LDAP_VERSION_KEY);
>
> +        env.put("ldapVersion", ldapVersion);
>
> +        env.put("baseDN", baseDN);
>
> +        String securityProtocol = (String) dirEnv
>
> +                .get(Context.SECURITY_PROTOCOL);
>
> +        env.put("securityProtocol", securityProtocol);
>
> +        String securityAuthentication = (String) dirEnv
>
> +                .get(Context.SECURITY_AUTHENTICATION);
>
> +        env.put("securityAuthentication", securityAuthentication);
>
> +        String securityPrincipal = (String) dirEnv
>
> +                .get(Context.SECURITY_PRINCIPAL);
>
> +        env.put("securityPrincipal", securityPrincipal);
>
> +
>
> +        return env;
>
> +    }
>
> +
>
> +    /**
>
> +     * Returns the names bound in the named context
>
> +     */
>
> +    public Collection list(String name) throws Exception {
>
> +        ArrayList result = new ArrayList();
>
> +
>
> +        try {
>
> +            NamingEnumeration list = dirContext.list(name); // can't be
> ""
>
> +
>
> +            while (list.hasMore()) {
>
> +                NameClassPair ncp = (NameClassPair) list.next();
>
> +                String childName = ncp.getName();
>
> +                String dn = childName + ", " + name;
>
> +                String[] pair = { childName, dn };
>
> +                result.add(pair);
>
> +            }
>
> +        } catch (NamingException e) {
>
> +            throw new Exception("Problem getting directory list: "
>
> +                    + e.getMessage());
>
> +        }
>
> +
>
> +        return result;
>
> +    }
>
> +
>
> +    /**
>
> +     * Returns the names bound in the base DN context
>
> +     */
>
> +    public Collection listBaseDN() throws Exception {
>
> +        return list(baseDN);
>
> +    }
>
> +
>
> +    /**
>
> +     * Enumerates the names bound in the named context and return result
> as JSON
>
> +     */
>
> +    public String listJSON(String name) throws Exception {
>
> +        return listJSON(name, null);
>
> +    }
>
> +
>
> +    /**
>
> +     * Enumerates the names bound in the named context and return result
> as JSON
>
> +     */
>
> +    public String listJSON(String name, String commonFields) throws
> Exception {
>
> +        // JSON: [{title:"Title1",isFolder:true}, {title:"Title2"}]
>
> +
>
> +        StringBuffer json = new StringBuffer();
>
> +        List list = (List) list(name);
>
> +
>
> +        json.append('[');
>
> +        int size = list.size();
>
> +        for (int i = 0; i < size; i++) {
>
> +            String[] entry = (String[]) list.get(i);
>
> +            json.append("{title:\"");
>
> +            json.append(entry[0]);
>
> +            json.append("\",widgetId:\"");
>
> +            json.append(entry[1]);
>
> +            json.append("\"");
>
> +            if (commonFields != null) { // TODO: Do additional testing
>
> +                json.append(commonFields);
>
> +            }
>
> +            json.append("}");
>
> +            if ((i + 1) < size) {
>
> +                json.append(',');
>
> +            }
>
> +        }
>
> +        json.append("]");
>
> +
>
> +        return json.toString();
>
> +    }
>
> +
>
> +    /**
>
> +     * Return the attributes of an LDAP entry
>
> +     */
>
> +    public Collection getAttributes(String name) throws Exception {
>
> +        ArrayList result = new ArrayList();
>
> +        try {
>
> +            Attributes attribs = dirContext.getAttributes(name);
>
> +            NamingEnumeration attributes = attribs.getAll();
>
> +            while (attributes.hasMore()) {
>
> +                Attribute attribute = (Attribute) attributes.next();
>
> +                String id = attribute.getID();
>
> +                NamingEnumeration values = attribute.getAll();
>
> +                while (values.hasMore()) {
>
> +                    String value = values.next().toString();
>
> +                    String[] pair = { id, value };
>
> +                    result.add(pair);
>
> +                }
>
> +            }
>
> +        } catch (NamingException e) {
>
> +            throw new Exception("Problem retrieving attributes: "
>
> +                    + e.getMessage());
>
> +        }
>
> +        return result;
>
> +    }
>
> +
>
> +    /**
>
> +     * Execute an LDAP search
>
> +     */
>
> +    public Collection search(String searchDN, String filter, String
> searchScope)
>
> +            throws Exception {
>
> +        ArrayList result = new ArrayList();
>
> +        try {
>
> +            String ldapURL = createLDAPURL(host, port, searchDN);
>
> +            SearchControls sc = new SearchControls();
>
> +            if (ONELEVEL_SCOPE.equalsIgnoreCase(searchScope)) {
>
> +                sc.setSearchScope(SearchControls.ONELEVEL_SCOPE);
>
> +            } else if (SUBTREE_SCOPE.equalsIgnoreCase(searchScope)) {
>
> +                sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
>
> +            } else {
>
> +                // Default to one level scope
>
> +                sc.setSearchScope(SearchControls.ONELEVEL_SCOPE);
>
> +            }
>
> +            // Filter: "(objectclass=*)"
>
> +            boolean isSearchDNAdded = false;
>
> +            NamingEnumeration ne = dirContext.search(ldapURL, filter,
> sc);
>
> +            while (ne.hasMore()) {
>
> +                SearchResult sr = (SearchResult) ne.next();
>
> +                String name = sr.getName();
>
> +                String dn = null;
>
> +                if (name.length() > 0) {
>
> +                    dn = name + "," + searchDN;
>
> +                    result.add(dn);
>
> +                } else if ((name.length() == 0) && !isSearchDNAdded) {
>
> +                    dn = searchDN;
>
> +                    result.add(dn);
>
> +                    isSearchDNAdded = true;
>
> +                }
>
> +            }
>
> +        } catch (NamingException e) {
>
> +            throw new Exception("Problem performing directory search: "
>
> +                    + e.getMessage());
>
> +        }
>
> +        return result;
>
> +    }
>
> +
>
> +    /**
>
> +     * Close directory context
>
> +     */
>
> +    public void close() throws Exception {
>
> +        try {
>
> +            dirContext.close();
>
> +        } catch (NamingException e) {
>
> +            throw new Exception("Problem closing directory context: "
>
> +                    + e.getMessage());
>
> +        }
>
> +    }
>
> +
>
> +    /**
>
> +     * Return base DN of this directory context
>
> +     */
>
> +    public String getBaseDN() {
>
> +        return baseDN;
>
> +    }
>
> +
>
> +    /**
>
> +     * Create an LDAP url using host, port, and base DN
>
> +     */
>
> +    private String createLDAPURL(String host, String port, String baseDN)
> {
>
> +        StringBuffer url = new StringBuffer();
>
> +        url.append("ldap://");
>
> +        url.append(host);
>
> +        url.append(':');
>
> +        url.append(port);
>
> +        if ((baseDN != null) && (baseDN.length() >= 3)) {
>
> +            if (!baseDN.startsWith("/")) {
>
> +                url.append('/');
>
> +            }
>
> +            url.append(baseDN);
>
> +        }
>
> +        return url.toString();
>
> +    }
>
> +
>
> +    /**
>
> +     * Get the HTTP session
>
> +     */
>
> +    private HttpSession getSession() {
>
> +        WebContext ctx = WebContextFactory.get();
>
> +        HttpSession session = ctx.getSession();
>
> +        return session;
>
> +    }
>
> +
>
> +    /**
>
> +     * Set an HTTP session attribute
>
> +     */
>
> +    private void setSessionAttribute(String name, Object value) {
>
> +        getSession().setAttribute(name, value);
>
> +    }
>
> +
>
> +    /**
>
> +     * Get an HTTP session attribute
>
> +     */
>
> +    private Object getSessionAttribute(String name) {
>
> +        return getSession().getAttribute(name);
>
> +    }
>
> +
>
> +    /**
>
> +     * Dump HTTP session attributes
>
> +     */
>
> +    private void dumpSession() {
>
> +        System.out.println("--- dumpSession()");
>
> +        WebContext ctx = WebContextFactory.get();
>
> +        HttpSession session = ctx.getSession();
>
> +        Enumeration attribNames = session.getAttributeNames();
>
> +        while (attribNames.hasMoreElements()) {
>
> +            String attribName = (String) attribNames.nextElement();
>
> +            System.out.print("--- session: " + attribName + " = ");
>
> +            Object attribValue = session.getAttribute(attribName);
>
> +            System.out.println(attribValue);
>
> +        }
>
> +    }
>
> +
>
> +    /**
>
> +     * Dump search enumeration
>
> +     */
>
> +    private void printSearchEnumeration(NamingEnumeration ne) {
>
> +        try {
>
> +            while (ne.hasMore()) {
>
> +                SearchResult sr = (SearchResult) ne.next();
>
> +                System.out.println("-->" + sr.getName());
>
> +                System.out.println(sr.getAttributes());
>
> +            }
>
> +        } catch (NamingException e) {
>
> +            e.printStackTrace();
>
> +        }
>
> +    }
>
> +
>
> +}
>
>
> Added:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java?view=auto&rev=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java
> (added)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java
> Wed Nov 15 00:57:58 2006
> @@ -0,0 +1,113 @@
> +/**
>
> + *
>
> + * Copyright 2006 The Apache Software Foundation or its licensors, as
> applicable.
>
> + *
>
> + *  Licensed under the Apache License, Version 2.0 (the "License");
>
> + *  you may not use this file except in compliance with the License.
>
> + *  You may obtain a copy of the License at
>
> + *
>
> + *     http://www.apache.org/licenses/LICENSE-2.0
>
> + *
>
> + *  Unless required by applicable law or agreed to in writing, software
>
> + *  distributed under the License is distributed on an "AS IS" BASIS,
>
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>
> + *  See the License for the specific language governing permissions and
>
> + *  limitations under the License.
>
> + */
>
> +
>
> +package org.apache.geronimo.console.ldapmanager;
>
> +
>
> +import java.io.IOException;
>
> +import java.io.PrintWriter;
>
> +
>
> +import javax.portlet.ActionRequest;
>
> +import javax.portlet.ActionResponse;
>
> +import javax.portlet.PortletConfig;
>
> +import javax.portlet.PortletContext;
>
> +import javax.portlet.PortletException;
>
> +import javax.portlet.PortletRequestDispatcher;
>
> +import javax.portlet.RenderRequest;
>
> +import javax.portlet.RenderResponse;
>
> +import javax.portlet.WindowState;
>
> +
>
> +import org.apache.geronimo.console.BasePortlet;
>
> +
>
> +/**
>
> + * The LDAP manager portlet
>
> + */
>
> +public class LDAPManagerPortlet extends BasePortlet {
>
> +    private static final String VIEWLDAPSERVER_ACTION = "viewLDAPServer";
>
> +
>
> +    private static final String VIEWLDAPSERVER_JSP =
> "/WEB-INF/view/ldapmanager/viewLDAPServer.jsp";
>
> +
>
> +    private static final String HELP_JSP =
> "/WEB-INF/view/ldapmanager/help.jsp";
>
> +
>
> +    private PortletRequestDispatcher viewLDAPServerView;
>
> +
>
> +    private PortletRequestDispatcher helpView;
>
> +
>
> +    private static LDAPManagerHelper helper = null /* new
> LDAPManagerHelper() */;
>
> +
>
> +    /**
>
> +     * Process an action request
>
> +     */
>
> +    public void processAction(ActionRequest actionRequest,
>
> +            ActionResponse actionResponse) throws PortletException,
> IOException {
>
> +    }
>
> +
>
> +    /**
>
> +     * Serve up the view mode
>
> +     */
>
> +    protected void doView(RenderRequest renderRequest,
>
> +            RenderResponse renderResponse) throws IOException,
> PortletException {
>
> +        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState()))
> {
>
> +            return;
>
> +        } else if (WindowState.NORMAL.equals(renderRequest.getWindowState()))
> {
>
> +            String action = renderRequest.getParameter("action");
>
> +            if (action == null) {
>
> +                action = VIEWLDAPSERVER_ACTION;
>
> +            }
>
> +            if (VIEWLDAPSERVER_ACTION.equals(action)) {
>
> +                viewLDAPServerView.include(renderRequest,
> renderResponse);
>
> +            } else {
>
> +                renderResponse.setContentType("text/html");
>
> +                PrintWriter out = renderResponse.getWriter();
>
> +                String errorMsg = "Invalid action message: " + action;
>
> +                out.println(errorMsg);
>
> +            }
>
> +        } else if (WindowState.MAXIMIZED.equals(
> renderRequest.getWindowState())) {
>
> +            renderResponse.setContentType("text/html");
>
> +            PrintWriter out = renderResponse.getWriter();
>
> +            String errorMsg = "Invalid window state: "
>
> +                    + renderRequest.getWindowState();
>
> +            out.println(errorMsg);
>
> +        }
>
> +    }
>
> +
>
> +    /**
>
> +     * Serve up the help mode
>
> +     */
>
> +    protected void doHelp(RenderRequest renderRequest,
>
> +            RenderResponse renderResponse) throws PortletException,
> IOException {
>
> +        helpView.include(renderRequest, renderResponse);
>
> +    }
>
> +
>
> +    /**
>
> +     * Portlet is being placed into service
>
> +     */
>
> +    public void init(PortletConfig portletConfig) throws PortletException
> {
>
> +        super.init(portletConfig);
>
> +        PortletContext pc = portletConfig.getPortletContext();
>
> +        viewLDAPServerView = pc.getRequestDispatcher(VIEWLDAPSERVER_JSP);
>
> +        helpView = pc.getRequestDispatcher(HELP_JSP);
>
> +    }
>
> +
>
> +    /**
>
> +     * Portlet is being taken out of service
>
> +     */
>
> +    public void destroy() {
>
> +        viewLDAPServerView = null;
>
> +        helpView = null;
>
> +        super.destroy();
>
> +    }
>
> +}
>
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/dwr.xml
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/dwr.xml?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/dwr.xml
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/dwr.xml
> Wed Nov 15 00:57:58 2006
> @@ -15,5 +15,8 @@
>      <create creator="new" javascript="JMXHelper">
>        <param name="class" value="
> org.apache.geronimo.console.jmxmanager.JMXManagerHelper"/>
>      </create>
> +    <create creator="new" javascript="LDAPHelper">
> +      <param name="class" value="
> org.apache.geronimo.console.ldapmanager.LDAPManagerHelper"/>
> +    </create>
>    </allow>
> </dwr>
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/portlet.xml
> Wed Nov 15 00:57:58 2006
> @@ -1137,5 +1137,29 @@
>          </portlet-info>
>      </portlet>
>
> +    <portlet>
> +        <description>Portlet for viewing LDAP server
> contents</description>
> +        <portlet-name>LDAPViewer</portlet-name>
> +        <display-name>LDAP Viewer Portlet</display-name>
> +
> +        <portlet-class>
> org.apache.geronimo.console.ldapmanager.LDAPManagerPortlet</portlet-class>
> +
> +        <expiration-cache>-1</expiration-cache>
> +
> +        <supports>
> +            <mime-type>text/html</mime-type>
> +            <portlet-mode>VIEW</portlet-mode>
> +            <portlet-mode>HELP</portlet-mode>
> +        </supports>
> +
> +        <supported-locale>en</supported-locale>
> +
> +        <portlet-info>
> +            <title>LDAP Viewer</title>
> +            <short-title>LDAP Viewer</short-title>
> +            <keywords>LDAP Viewer</keywords>
> +        </portlet-info>
> +    </portlet>
> +
>      <!-- End of console portlets -->
> </portlet-app>
>
> Added:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/help.jsp
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/help.jsp?view=auto&rev=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/help.jsp
> (added)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/help.jsp
> Wed Nov 15 00:57:58 2006
> @@ -0,0 +1,27 @@
> +<%--
>
> +  Copyright 2006 The Apache Software Foundation or its licensors, as
> applicable.
>
> +
>
> +  Licensed under the Apache License, Version 2.0 (the "License");
>
> +  you may not use this file except in compliance with the License.
>
> +  You may obtain a copy of the License at
>
> +
>
> +      http://www.apache.org/licenses/LICENSE-2.0
>
> +
>
> +  Unless required by applicable law or agreed to in writing, software
>
> +  distributed under the License is distributed on an "AS IS" BASIS,
>
> +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>
> +  See the License for the specific language governing permissions and
>
> +  limitations under the License.
>
> +--%>
>
> +
>
> +<!-- LDAP Viewer portlet help page -->
>
> +
>
> +<p>The LDAP viewer portlet can be used to do the following:
>
> +<ul>
>
> +    <li>Connect to any LDAP server and explore its contents (default is
> the Embedded LDAP server - Apache DS)
>
> +    <li>View the attributes of an entry
>
> +    <li>Do an LDAP search on a particular entry
>
> +    <li>Refresh any entry to get the latest data from the directory
> server
>
> +    <li>View the LDAP connection environment data
>
> +</ul>
>
> +<p>Note: Right-click to any tree node to view the context menu for
> performing different actions.
>
>
> Added:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp?view=auto&rev=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp
> (added)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp
> Wed Nov 15 00:57:58 2006
> @@ -0,0 +1,648 @@
> +<%--
>
> +  Copyright 2006 The Apache Software Foundation or its licensors, as
> applicable.
>
> +
>
> +  Licensed under the Apache License, Version 2.0 (the "License");
>
> +  you may not use this file except in compliance with the License.
>
> +  You may obtain a copy of the License at
>
> +
>
> +      http://www.apache.org/licenses/LICENSE-2.0
>
> +
>
> +  Unless required by applicable law or agreed to in writing, software
>
> +  distributed under the License is distributed on an "AS IS" BASIS,
>
> +  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>
> +  See the License for the specific language governing permissions and
>
> +  limitations under the License.
>
> +--%>
>
> +
>
> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>
> +<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
>
> +<%@ page import="org.apache.geronimo.console.util.PortletManager" %>
>
> +<portlet:defineObjects/>
>
> +
>
> +<%
>
> +    // LDAP icon
>
> +    String consoleFrameworkContext =
> PortletManager.getConsoleFrameworkServletPath(request);
>
> +    String ldapIconURI = consoleFrameworkContext +
> "/../images/ico_filetree_16x16.gif";
>
> +%>
>
> +
>
> +<!-- DOJO Stuff -->
>
> +<script>
>
> +/* Global vars */
>
> +var _selectedNode = null; // Selected tree node
>
> +var _baseDN = null;       // Base distinguised name
>
> +
>
> +/* Get selected node */
>
> +function getSelectedNode() {
>
> +    var tree = dojo.widget.byId('ldapTree');
>
> +    var selectedNode = tree.selector.selectedNode;
>
> +    return selectedNode;
>
> +}
>
> +
>
> +/* Select tab */
>
> +function selectTab(tabID) {
>
> +    var mainTabContainer = dojo.widget.byId('mainTabContainer');
>
> +    var tab = dojo.widget.byId(tabID);
>
> +    mainTabContainer.selectTab(tab);
>
> +}
>
> +
>
> +/* Init stuff */
>
> +dojo.addOnLoad(
>
> +    function() {
>
> +        /* Init LDAP tree */
>
> +        LDAPHelper.getBaseDN(<portlet:namespace/>initLDAPTree);
>
> +
>
> +        /* Init LDAP connection info tab */
>
> +        if (_baseDN != null) {
>
> +            LDAPHelper.getEnvironment
> (<portlet:namespace/>initConnectInfoTab);
>
> +        }
>
> +
>
> +        /* Tree click event handler */
>
> +        var treeController = dojo.widget.manager.getWidgetById
> ('treeController');
>
> +        dojo.event.connect(
>
> +            'before',
>
> +            treeController,
>
> +            'onTreeClick',
>
> +            {
>
> +                beforeTreeClick: function(evt) {
>
> +                    var selectedNode = evt.source;
>
> +                    if ((selectedNode.state == 'UNCHECKED') && (
> selectedNode.isExpanded == false)) {
>
> +                        // Add children
>
> +                        _selectedNode = selectedNode;
>
> +                        LDAPHelper.list(<portlet:namespace/>updateLDAPTree,
> _selectedNode.widgetId);
>
> +                    }
>
> +                }
>
> +            },
>
> +            'beforeTreeClick'
>
> +        );
>
> +
>
> +               /* Tree node title click event handler */
>
> +               var tree = dojo.widget.manager.getWidgetById('ldapTree');
>
> +               dojo.event.topic.subscribe(
>
> +                       tree.eventNames.titleClick,
>
> +                       function(message) {
>
> +                           var dn = message.source.widgetId;
>
> +                           LDAPHelper.getAttributes(<portlet:namespace/>updateAttributesTable,
> dn);
>
> +                       }
>
> +               );
>
> +
>
> +        /* Tree context menu event handler: 'Refresh' */
>
> +               dojo.event.topic.subscribe(
>
> +                   'treeContextMenuRefresh/engage',
>
> +                       function (menuItem) {
>
> +                           var selectedNode = getSelectedNode();
>
> +                if (selectedNode == null) {
>
> +                    alert('Please select a tree node.');
>
> +                    return;
>
> +                }
>
> +                           if ((selectedNode.state == 'UNCHECKED') && (
> selectedNode.isExpanded == false)) {
>
> +                               // Unchecked tree node, do nothing
>
> +                } else {
>
> +                    // Remove children
>
> +                    var treeController = dojo.widget.byId
> ('treeController');
>
> +                           var children = selectedNode.children;
>
> +                           while (children.length > 0) {
>
> +                               var node = children[0];
>
> +                               treeController.removeNode(node);
>
> +                        node.destroy();
>
> +                           }
>
> +                           // Add children
>
> +                           _selectedNode = selectedNode;
>
> +                           LDAPHelper.list(<portlet:namespace/>updateLDAPTree,
> _selectedNode.widgetId);
>
> +               }
>
> +            }
>
> +               );
>
> +
>
> +        /* Tree context menu event handler: 'Search...' */
>
> +               dojo.event.topic.subscribe(
>
> +                   'treeContextMenuSearch/engage',
>
> +                       function (menuItem) {
>
> +                           var selectedNode = getSelectedNode();
>
> +                if (selectedNode == null) {
>
> +                    alert('Please select a tree node.');
>
> +                    return;
>
> +                }
>
> +                           selectTab('searchTab');
>
> +                           // Set Search DN
>
> +                           document.LDAPSearchForm.searchDN.value =
> selectedNode.widgetId;
>
> +                       }
>
> +               );
>
> +
>
> +        /* Tree context menu event handler: 'View Entry' */
>
> +               dojo.event.topic.subscribe(
>
> +                   'treeContextMenuViewEntry/engage',
>
> +                       function (menuItem) {
>
> +                           var selectedNode = getSelectedNode();
>
> +                if (selectedNode == null) {
>
> +                    alert('Please select a tree node.');
>
> +                    return;
>
> +                }
>
> +                           selectTab('attributesTab');
>
> +            }
>
> +               );
>
> +
>
> +        /* Tree context menu event handler: 'Connect Info' */
>
> +               dojo.event.topic.subscribe(
>
> +                   'treeContextMenuConnectInfo/engage',
>
> +                       function (menuItem) {
>
> +                           var selectedNode = getSelectedNode();
>
> +                if (selectedNode == null) {
>
> +                    alert('Please select a tree node.');
>
> +                    return;
>
> +                }
>
> +                           selectTab('connectInfoTab');
>
> +            }
>
> +               );
>
> +    }
>
> +);
>
> +
>
> +/* Anonymous bind checkbox clicked even handler */
>
> +function anonBindChkboxClicked() {
>
> +    var isAnonBind = document.LDAPConnectForm.anonBind.checked;
>
> +    document.LDAPConnectForm.userDN.disabled = isAnonBind;
>
> +    document.LDAPConnectForm.password.disabled = isAnonBind;
>
> +}
>
> +
>
> +/* Restore Default button clicked event handler */
>
> +function restoreDefaultBtnClicked() {
>
> +    // Restore default connection properties (Embedded Apache DS)
>
> +    document.LDAPConnectForm.host.value = 'localhost';
>
> +    document.LDAPConnectForm.port.value = '1389';
>
> +    document.LDAPConnectForm.ldapVersion[0].checked = true;
>
> +    document.LDAPConnectForm.ldapVersion[1].checked = false;
>
> +    document.LDAPConnectForm.baseDN.value = 'ou=system';
>
> +    document.LDAPConnectForm.ssl.checked = false;
>
> +    document.LDAPConnectForm.anonBind.checked = false;
>
> +    document.LDAPConnectForm.userDN.value = 'uid=admin, ou=system';
>
> +    document.LDAPConnectForm.password.value = '';
>
> +    document.LDAPConnectForm.userDN.disabled = false;
>
> +    document.LDAPConnectForm.password.disabled = false;
>
> +}
>
> +
>
> +/* Connect button clicked event handler */
>
> +function connectBtnClicked() {
>
> +    // TODO: Add validation
>
> +    var initialContextFactory = 'com.sun.jndi.ldap.LdapCtxFactory';
>
> +    var host = document.LDAPConnectForm.host.value;
>
> +    var port = document.LDAPConnectForm.port.value;
>
> +    var ldapVersion;
>
> +    if (document.LDAPConnectForm.ldapVersion[0].checked) {
>
> +        ldapVersion = '3';
>
> +    } else {
>
> +        ldapVersion = '2';
>
> +    }
>
> +    var baseDN = document.LDAPConnectForm.baseDN.value;
>
> +    var securityProtocol = '';
>
> +    if (document.LDAPConnectForm.ssl.checked) {
>
> +        securityProtocol = 'ssl';
>
> +    }
>
> +    var securityAuthentication = 'simple';
>
> +    var securityPrincipal;
>
> +    var securityCredentials;
>
> +    if (document.LDAPConnectForm.anonBind.checked) {
>
> +        securityAuthentication = 'none';
>
> +        securityPrincipal = '';
>
> +        securityCredentials = '';
>
> +    } else {
>
> +        securityAuthentication = 'simple';
>
> +        securityPrincipal = document.LDAPConnectForm.userDN.value;
>
> +        securityCredentials = document.LDAPConnectForm.password.value;
>
> +    }
>
> +
>
> +    // DEBUG: Connect Info
>
> +    var connectInfoStr =
>
> +        'initialContextFactory:' + initialContextFactory +
>
> +        '\nhost:' + host +
>
> +        '\nport:' + port +
>
> +        '\nldapVersion:' + ldapVersion +
>
> +        '\nbaseDN:' + baseDN +
>
> +        '\nsecurityProtocol:' + securityProtocol +
>
> +        '\nsecurityAuthentication:' + securityAuthentication +
>
> +        '\nsecurityPrincipal:' + securityPrincipal +
>
> +        '\nsecurityCredentials:' + securityCredentials;
>
> +    // alert(connectInfoStr);
>
> +
>
> +    // Connect to new LDAP server
>
> +    LDAPHelper.connect(
>
> +        function(result) {
>
> +            // TODO: Check result
>
> +            if (result == '<SUCCESS>') {
>
> +                window.location = '<portlet:actionURL />';
>
> +            } else {
>
> +                // Display error
>
> +                alert(result + '\n** Make sure LDAP server is running
> and/or connection properties are correct.');
>
> +            }
>
> +        },
>
> +        initialContextFactory,
>
> +        host,
>
> +        port,
>
> +        baseDN,
>
> +        ldapVersion,
>
> +        securityProtocol,
>
> +        securityAuthentication,
>
> +        securityPrincipal,
>
> +        securityCredentials
>
> +    );
>
> +}
>
> +
>
> +/* Search button clicked event handler */
>
> +function searchBtnClicked() {
>
> +    var searchDN = document.LDAPSearchForm.searchDN.value;
>
> +    var filter = document.LDAPSearchForm.filter.value;
>
> +    var scope;
>
> +    if (document.LDAPSearchForm.searchScope[0].checked) {
>
> +        scope = 'onelevel';
>
> +    } else {
>
> +        scope = 'subtree';
>
> +    }
>
> +    LDAPHelper.search(<portlet:namespace/>updateSearchResultTable,
> searchDN, filter, scope);
>
> +}
>
> +
>
> +/* Clear result button clicked event handler */
>
> +function clearResultBtnClicked() {
>
> +    DWRUtil.removeAllRows('searchResultTableBody');
>
> +    DWRUtil.setValue('searchResultCount', '');
>
> +}
>
> +</script>
>
> +
>
> +<style>
>
> +body .dojoHtmlSplitterPanePanel {
>
> +       background: white;
>
> +       overflow: auto;
>
> +}
>
> +
>
> +span.invalid, span.missing, span.range {
>
> +       display: inline;
>
> +       margin-left: 1em;
>
> +       font-weight: bold;
>
> +       font-style: italic;
>
> +       font-family: Arial, Verdana, sans-serif;
>
> +       color: #f66;
>
> +       font-size: 0.9em;
>
> +}
>
> +</style>
>
> +
>
> +<!-- DWR Stuff -->
>
> +<% String dwrForwarderServlet =
> PortletManager.getConsoleFrameworkServletPath(request) + "/../dwr"; %>
>
> +<script type='text/javascript' src='<%= dwrForwarderServlet
> %>/interface/LDAPHelper.js'></script>
>
> +<script type='text/javascript' src='<%= dwrForwarderServlet
> %>/engine.js'></script>
>
> +<script type='text/javascript' src='<%= dwrForwarderServlet
> %>/util.js'></script>
>
> +
>
> +<script>
>
> +/* Sync calls */
>
> +DWREngine.setAsync(false);
>
> +
>
> +/* Generic error handler */
>
> +DWREngine.setErrorHandler(
>
> +    function (errorString) {
>
> +        alert('Error: ' + errorString + '\n** Make sure LDAP server is
> running and/or connection properties are correct.');
>
> +        selectTab('connectInfoTab');
>
> +    }
>
> +);
>
> +
>
> +/* Table render option */
>
> +var tableOption = {
>
> +    rowCreator: function(options) {
>
> +        var row = document.createElement('tr');
>
> +        return row;
>
> +    },
>
> +    cellCreator: function(options) {
>
> +        var td = document.createElement('td');
>
> +        if ((options.rowIndex % 2) == 0) {
>
> +            td.style.backgroundColor = '#FFFFFF';
>
> +        } else {
>
> +            td.style.backgroundColor = '#F2F2F2';
>
> +        }
>
> +        return td;
>
> +    }
>
> +}
>
> +
>
> +/* Update attributes table */
>
> +function <portlet:namespace/>updateAttributesTable(attributes) {
>
> +    DWRUtil.removeAllRows('attributesTableBody');
>
> +    DWRUtil.addRows(
>
> +        'attributesTableBody',
>
> +        attributes,
>
> +        [
>
> +            function(attribute) { /* Attribute Name Column */
>
> +                return attribute[0];
>
> +            },
>
> +            function(attribute) { /* Attribute Value Column */
>
> +                return attribute[1];
>
> +            }
>
> +        ],
>
> +        tableOption
>
> +    );
>
> +}
>
> +
>
> +/* Update search result table */
>
> +function <portlet:namespace/>updateSearchResultTable(searchResult) {
>
> +    DWRUtil.removeAllRows('searchResultTableBody');
>
> +    DWRUtil.addRows(
>
> +        'searchResultTableBody',
>
> +        searchResult,
>
> +        [
>
> +            function(dn) { /* Distinguished Name Column */
>
> +                return dn;
>
> +            }
>
> +        ],
>
> +        tableOption
>
> +    );
>
> +    DWRUtil.setValue('searchResultCount', searchResult.length + ' entries
> returned...');
>
> +}
>
> +
>
> +/* Update LDAP tree */
>
> +function <portlet:namespace/>updateLDAPTree(entries) {
>
> +    for (var i = 0; i < entries.length; i++) {
>
> +        var entry = entries[i];
>
> +        var newNode = dojo.widget.createWidget(
>
> +            'TreeNode',
>
> +            {title: entry[0], widgetId: entry[1], isFolder: true,
> childIconSrc:'<%= ldapIconURI %>'}
>
> +        );
>
> +               _selectedNode.addChild(newNode);
>
> +    }
>
> +    _selectedNode.state = 'LOADED';
>
> +}
>
> +
>
> +/* Init LDAP tree */
>
> +function <portlet:namespace/>initLDAPTree(baseDN) {
>
> +    _baseDN = baseDN;
>
> +    var tree = dojo.widget.byId('ldapTree');
>
> +       var rootNode = dojo.widget.createWidget(
>
> +           'TreeNode',
>
> +           {title: baseDN, widgetId: baseDN, isFolder: true,
> childIconSrc:'<%= ldapIconURI %>'}
>
> +       );
>
> +       tree.addChild(rootNode);
>
> +    var controller = dojo.widget.byId('treeController');
>
> +    controller.expand(rootNode);
>
> +    _selectedNode = rootNode;
>
> +    LDAPHelper.list(<portlet:namespace/>updateLDAPTree,
> _selectedNode.widgetId);
>
> +
>
> +    // Select node
>
> +    var treeSelector = dojo.widget.byId("treeSelector");
>
> +    if (getSelectedNode() != null) {
>
> +        treeSelector.deselect();
>
> +    }
>
> +    treeSelector.doSelect(rootNode);
>
> +
>
> +    // Select attributes tab
>
> +    selectTab('attributesTab');
>
> +
>
> +    // Update attributes table
>
> +    var dn = rootNode.widgetId;
>
> +       LDAPHelper.getAttributes(<portlet:namespace/>updateAttributesTable,
> dn);
>
> +
>
> +       // Update Search tab's 'Search DN' field
>
> +       document.LDAPSearchForm.searchDN.value = baseDN;
>
> +}
>
> +
>
> +/* Init LDAP connection info tab */
>
> +function <portlet:namespace/>initConnectInfoTab(env) {
>
> +    var host = env['host'];
>
> +    document.LDAPConnectForm.host.value = host;
>
> +    var port = env['port'];
>
> +    document.LDAPConnectForm.port.value = port;
>
> +    var version = env['ldapVersion'];
>
> +    if (version == '3') {
>
> +        document.LDAPConnectForm.ldapVersion[0].checked = true;
>
> +    } else if (version == '2') {
>
> +        document.LDAPConnectForm.ldapVersion[1].checked = true;
>
> +    }
>
> +    var baseDN = env['baseDN'];
>
> +    document.LDAPConnectForm.baseDN.value = baseDN;
>
> +    var securityProtocol = env['securityProtocol'];
>
> +    if ((securityProtocol != null) && (securityProtocol == 'ssl')) {
>
> +        // SSL
>
> +        document.LDAPConnectForm.ssl.checked = true;
>
> +    }
>
> +    var securityAuthentication = env['securityAuthentication'];
>
> +    if ((securityAuthentication != null) && (securityAuthentication ==
> 'none')) {
>
> +        // Anonymous bind
>
> +        document.LDAPConnectForm.anonBind.checked = true;
>
> +        document.LDAPConnectForm.userDN.value = '';
>
> +    } else {
>
> +        var securityPrincipal = env['securityPrincipal'];
>
> +        document.LDAPConnectForm.userDN.value = securityPrincipal;
>
> +    }
>
> +}
>
> +
>
> +/* Prints 'LOADING' message while waiting for DWR method calls */
>
> +function init() {
>
> +    DWRUtil.useLoadingMessage();
>
> +}
>
> +
>
> +function callOnLoad(load) {
>
> +    if (window.addEventListener) {
>
> +        window.addEventListener('load', load, false);
>
> +    } else if (window.attachEvent) {
>
> +        window.attachEvent('onload', load);
>
> +    } else {
>
> +        window.onload = load;
>
> +    }
>
> +}
>
> +
>
> +callOnLoad(init);
>
> +</script>
>
> +
>
> +<div dojoType="TreeContextMenu" toggle="explode"
> contextMenuForWindow="false" widgetId="treeContextMenu">
>
> +       <div dojoType="TreeMenuItem" treeActions="refreshNode"
> widgetId="treeContextMenuRefresh" caption="Refresh" ></div>
>
> +       <div dojoType="TreeMenuItem" treeActions="searchNode"
> widgetId="treeContextMenuSearch" caption="Search..."></div>
>
> +       <div dojoType="TreeMenuItem" treeActions="viewEntry"
> widgetId="treeContextMenuViewEntry" caption="View Entry"></div>
>
> +       <div dojoType="TreeMenuItem" treeActions="viewConnectInfo"
> widgetId="treeContextMenuConnectInfo" caption="Connect Info"></div>
>
> +</div>
>
> +
>
> +<div dojoType="TreeSelector" widgetId="treeSelector"></div>
>
> +<div dojoType="TreeBasicController" widgetId="treeController"></div>
>
> +
>
> +<!-- Main layout container -->
>
> +<div dojoType="LayoutContainer"
>
> +       layoutChildPriority='left-right'
>
> +       id="mainLayout"
>
> +       style="height: 500px;">
>
> +
>
> +    <!-- Horizontal split container -->
>
> +       <div dojoType="SplitContainer"
>
> +               orientation="horizontal"
>
> +               sizerWidth="5"
>
> +               activeSizing="1"
>
> +               layoutAlign="client">
>
> +
>
> +               <!-- LDAP tree -->
>
> +        <div dojoType="Tree"
>
> +            toggle="fade"
>
> +            layoutAlign="flood"
>
> +                       sizeMin="60"
>
> +                       sizeShare="40"
>
> +            widgetId="ldapTree"
>
> +            selector="treeSelector"
>
> +            controller="treeController"
>
> +            expandLevel="0"
>
> +            menu="treeContextMenu"
>
> +            strictFolders="false">
>
> +            <!-- Nodes will be added programmatically -->
>
> +        </div>
>
> +
>
> +        <!-- Main tab container -->
>
> +       <div id="mainTabContainer"
>
> +           dojoType="TabContainer"
>
> +           selectedTab="attributesTab"
>
> +           style="overflow: auto"
>
> +           sizeShare="60">
>
> +
>
> +            <!-- Attributes tab -->
>
> +               <div id="attributesTab" dojoType="ContentPane" title="LDAP
> Entry Attributes" label="Attributes">
>
> +                <br>
>
> +                <table width="100%">
>
> +                    <tr>
>
> +                        <td class="DarkBackground" align="center"
> width="40%">Name</td>
>
> +                        <td class="DarkBackground" align="center"
> width="60%">Value</td>
>
> +                    </tr>
>
> +                    <tbody id="attributesTableBody">
>
> +                    </tbody>
>
> +                </table>
>
> +               </div> <!-- Attributes tab -->
>
> +
>
> +            <!-- Search tab -->
>
> +               <div id="searchTab" dojoType="ContentPane" title = ""
> label="Search">
>
> +                   <br>
>
> +                <form NAME="LDAPSearchForm">
>
> +                       <table>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Search DN:</td>
>
> +                            <td><input type="text" name="searchDN"
> value="" size="45"/></td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Filter:</td>
>
> +                            <td><input type="text" name="filter"
> value="(objectclass=*)" size="45"/></td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">&nbsp;Search
> scope:</td>
>
> +                            <td>
>
> +                                <INPUT type="radio" name="searchScope"
> value="onelevel" checked> One level
>
> +                                <INPUT type="radio" name="searchScope"
> value="subtree"> Sub-tree level
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td colspan="2">&nbsp;</td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td align="left" colspan="2">
>
> +                                &nbsp;<input type="button" value="Search"
> name="ldapSearch" onClick="searchBtnClicked()"/>
>
> +                                &nbsp;<input type="button" value="Clear
> Result" name="clearResult" onClick="clearResultBtnClicked()"/>
>
> +                                &nbsp;&nbsp;<span
> id='searchResultCount'></span>
>
> +                            </td>
>
> +                        </tr>
>
> +                    </table>
>
> +                </form>
>
> +                <hr>
>
> +                <table width="100%">
>
> +                  <tr>
>
> +                    <td class="DarkBackground" align="center">DN</td>
>
> +                  </tr>
>
> +                  <tbody id="searchResultTableBody">
>
> +                  </tbody>
>
> +                </table>
>
> +            </div> <!-- Search tab -->
>
> +
>
> +            <!-- Connection Info tab -->
>
> +               <div id="connectInfoTab" dojoType="ContentPane" title = ""
> label="Connect Info">
>
> +                   <br>
>
> +                <form NAME="LDAPConnectForm">
>
> +                       <table>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Host:</td>
>
> +                            <td>
>
> +                                <input type="text" name="host"
> value="localhost" size="40"
>
> +
> dojoType="ValidationTextbox"
>
> +                                                       required="true"
>
> +                                                       trim="true"
>
> +                                       uppercase: false,
>
> +                                       lowercase: false,
>
> +                                       ucFirst: false,
>
> +                                       digit: false,
>
> +
> missingMessage="<br>* Host is required." />
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Port:</td>
>
> +                            <td>
>
> +                                <input type="text" name="port"
> value="1389" size="40"
>
> +
> dojoType="IntegerTextbox"
>
> +                                                       required="true"
>
> +                                                       trim="true"
>
> +                                                       digit="true"
>
> +                                                       min="0"
>
> +                                                       max="65535"
>
> +
> missingMessage="<br>* Port is required."
>
> +                                    invalidMessage="<br>* The value
> entered is not valid."
>
> +                                    rangeMessage="<br>* This value is out
> of range use 0 - 65535." />
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Version:</td>
>
> +                            <td>
>
> +                                <INPUT type="radio" name="ldapVersion"
> value="3" checked> 3
>
> +                                <INPUT type="radio" name="ldapVersion"
> value="2"> 2
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Base DN:</td>
>
> +                            <td>
>
> +                                <input type="text" name="baseDN"
> value="ou=system" size="40"
>
> +
> dojoType="ValidationTextbox"
>
> +                                                       required="true"
>
> +                                                       trim="true"
>
> +
> missingMessage="<br>* Base DN is required." />
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">SSL:</td>
>
> +                            <td><input type="checkbox" name="ssl"
> value="" size="40"></td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">&nbsp;Anonymous
> Bind:</td>
>
> +                            <td><input type="checkbox" name="anonBind"
> value="" size="40" onclick="javascript:anonBindChkboxClicked()"></td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">User DN:</td>
>
> +                            <td>
>
> +                                <input type="text" name="userDN"
> value="uid=admin, ou=system" size="40"
>
> +
> dojoType="ValidationTextbox"
>
> +                                                       required="true"
>
> +                                                       trim="true"
>
> +
> missingMessage="<br>* User DN is required." />
>
> +                            </td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td nowrap align="right">Password:</td>
>
> +                            <td><input type="password" name="password"
> value="" size="40"></td>
>
> +                        </tr>
>
> +                        <tr>
>
> +                            <td align="right" colspan="2">
>
> +                                &nbsp;<input type="button" value="Restore
> Default" name="defaultLDAP" onClick="restoreDefaultBtnClicked()"/>
>
> +                                &nbsp;<input type="button"
> value="Connect" name="connectLDAP" onClick="connectBtnClicked()"/>
>
> +                            </td>
>
> +                        </tr>
>
> +                    </table>
>
> +                </form>
>
> +            </div> <!-- Connection Info tab -->
>
> +
>
> +            <!-- Help tab -->
>
> +               <!--
>
> +               <div id="helpTab" dojoType="ContentPane" title="Help
> Information" label="Help">
>
> +                <br>
>
> +                <p>The LDAP viewer portlet can be used to do the
> following:
>
> +                <ul>
>
> +                    <li>Connect to any LDAP server and explore its
> contents (default is the Embedded LDAP server - Apache DS)
>
> +                    <li>View the attributes of an entry
>
> +                    <li>Do an LDAP search on a particular entry
>
> +                    <li>Refresh any entry to get the latest data from the
> directory server
>
> +                    <li>View the LDAP connection environment data
>
> +                </ul>
>
> +                <p>Note: Right-click to any tree node to view the context
> menu for performing different actions.
>
> +               </div>
>
> +               -->
>
> +               <!-- Help tab -->
>
> +
>
> +        </div> <!-- Main tab container -->
>
> +       </div>  <!-- Horizontal split container -->
>
> +</div> <!-- Main layout container -->
>
>
> Modified:
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml?view=diff&rev=475164&r1=475163&r2=475164
>
> ==============================================================================
> ---
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml
> (original)
> +++
> geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/web.xml
> Wed Nov 15 00:57:58 2006
> @@ -780,9 +780,27 @@
>              <param-value>console-standard.JMXViewer</param-value>
>          </init-param>
>      </servlet>
> +    <servlet>
> +        <description>Automated generated Portlet Wrapper</description>
> +        <display-name>Pluto Wrapper for LDAP Viewer
> Portlet</display-name>
> +        <servlet-name>LDAPViewer</servlet-name>
> +        <servlet-class>org.apache.pluto.core.PortletServlet
> </servlet-class>
> +        <init-param>
> +            <param-name>portlet-class</param-name>
> +            <param-value>
> org.apache.geronimo.console.ldapmanager.LDAPManagerPortlet</param-value>
> +        </init-param>
> +        <init-param>
> +            <param-name>portlet-guid</param-name>
> +            <param-value>console-standard.LDAPViewer</param-value>
> +        </init-param>
> +    </servlet>
>
> <!-- [INSERT FRAGMENT HERE] -->
>
> +    <servlet-mapping>
> +        <servlet-name>LDAPViewer</servlet-name>
> +        <url-pattern>/LDAPViewer/*</url-pattern>
> +    </servlet-mapping>
>      <servlet-mapping>
>          <servlet-name>JMXViewer</servlet-name>
>          <url-pattern>/JMXViewer/*</url-pattern>
>
>
>

Mime
View raw message