directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r604356 - in /directory/sandbox/akarasulu/tests-tools-utils: ./ src/ src/main/ src/main/java/ src/main/java/DiagnosticTrigger.java src/test/ src/test/java/ tests-tools-utils.iml
Date Sat, 15 Dec 2007 00:38:25 GMT
Author: akarasulu
Date: Fri Dec 14 16:38:23 2007
New Revision: 604356

URL: http://svn.apache.org/viewvc?rev=604356&view=rev
Log:
some personal tools used while debugging

Added:
    directory/sandbox/akarasulu/tests-tools-utils/
    directory/sandbox/akarasulu/tests-tools-utils/src/
    directory/sandbox/akarasulu/tests-tools-utils/src/main/
    directory/sandbox/akarasulu/tests-tools-utils/src/main/java/
    directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java   (with
props)
    directory/sandbox/akarasulu/tests-tools-utils/src/test/
    directory/sandbox/akarasulu/tests-tools-utils/src/test/java/
    directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml   (with props)

Added: directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java?rev=604356&view=auto
==============================================================================
--- directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java (added)
+++ directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java Fri
Dec 14 16:38:23 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
+import org.apache.directory.shared.ldap.message.extended.LaunchDiagnosticUiRequest;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import java.io.File;
+import java.io.FileReader;
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ * Simple tool to trigger the diagnostic console of ApacheDS of various
+ * remote server instances.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DiagnosticTrigger
+{
+    public static void main( String [] args ) throws Exception
+    {
+        File homeDir = new File( System.getProperty( "user.home" ) );
+        File confFile = new File( homeDir, ".adsdiag" );
+        if ( confFile.exists() )
+        {
+            Properties props = new Properties();
+            props.load( new FileReader( confFile ) );
+            execute( getDefaultHost( props ), getDefaultPort( props ), getDefaultPassword(
props ) );
+        }
+        else
+        {
+            throw new IllegalStateException( "Cannot continue without properties file: "
+                    + confFile.getAbsolutePath() );
+        }
+    }
+
+
+    public static int getDefaultPort( Properties props )
+    {
+        return Integer.parseInt( props.getProperty( getDefaultHost( props ) + ".port" ) );
+    }
+
+
+    public static String getDefaultPassword( Properties props )
+    {
+        return props.getProperty( getDefaultHost( props ) + ".password" );
+    }
+    
+
+    public static String getDefaultHost( Properties props )
+    {
+        return props.getProperty( "default" );
+    }
+
+
+    private static void execute( String host, int port, String password ) throws NamingException
+    {
+        Hashtable<String, Object> env = new Hashtable<String, Object>();
+        env.put( JndiPropertyConstants.JNDI_FACTORY_INITIAL, "com.sun.jndi.ldap.LdapCtxFactory"
);
+        env.put( JndiPropertyConstants.JNDI_PROVIDER_URL, "ldap://" + host + ":" + port );
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( JndiPropertyConstants.JNDI_SECURITY_CREDENTIALS, password );
+        env.put( JndiPropertyConstants.JNDI_SECURITY_AUTHENTICATION, "simple" );
+
+        LdapContext ctx = new InitialLdapContext( env, null );
+        ctx.extendedOperation( new LaunchDiagnosticUiRequest( 3 ) );
+        ctx.close();
+    }
+}

Propchange: directory/sandbox/akarasulu/tests-tools-utils/src/main/java/DiagnosticTrigger.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml?rev=604356&view=auto
==============================================================================
--- directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml (added)
+++ directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml Fri Dec 14 16:38:23
2007
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <exclude-output />
+    <output-test url="file://$MODULE_DIR$/target/classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="apacheds-server-tools" />
+    <orderEntryProperties />
+  </component>
+  <component name="POM File Configuration" pomFile="" />
+</module>
+

Propchange: directory/sandbox/akarasulu/tests-tools-utils/tests-tools-utils.iml
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message