Author: akarasulu
Date: Tue Jan 17 21:42:32 2006
New Revision: 370058
URL: http://svn.apache.org/viewcvs?rev=370058&view=rev
Log:
setup for launching diagnostic ui
Added:
directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/
directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
Modified:
directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
Modified: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java?rev=370058&r1=370057&r2=370058&view=diff
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
(original)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/LdapProtocolProvider.java
Tue Jan 17 21:42:32 2006
@@ -72,6 +72,7 @@
import org.apache.ldap.server.protocol.support.ModifyHandler;
import org.apache.ldap.server.protocol.support.SearchHandler;
import org.apache.ldap.server.protocol.support.UnbindHandler;
+import org.apache.ldap.server.protocol.support.extended.LaunchDiagnosticUiHandler;
import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoSession;
@@ -223,6 +224,7 @@
}
this.codecFactory = new ProtocolCodecFactoryImpl( copy );
+ addExtendedOperationHandler( new LaunchDiagnosticUiHandler() );
}
/**
Added: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java?rev=370058&view=auto
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
(added)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
Tue Jan 17 21:42:32 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.ldap.server.protocol.support.extended;
+
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.ldap.common.message.ExtendedRequest;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.message.extended.LaunchDiagnosticUiRequest;
+import org.apache.ldap.common.message.extended.LaunchDiagnosticUiResponse;
+import org.apache.ldap.server.DirectoryService;
+import org.apache.ldap.server.jndi.ServerLdapContext;
+import org.apache.ldap.server.partition.DirectoryPartitionNexus;
+import org.apache.ldap.server.protocol.ExtendedOperationHandler;
+import org.apache.ldap.server.protocol.SessionRegistry;
+import org.apache.mina.common.IoSession;
+
+
+public class LaunchDiagnosticUiHandler implements ExtendedOperationHandler
+{
+ public String getOid()
+ {
+ return LaunchDiagnosticUiRequest.OID;
+ }
+
+
+ public void handleExtendedOperation( IoSession session, SessionRegistry registry, ExtendedRequest
req ) throws NamingException
+ {
+ LdapContext ctx = registry.getLdapContext( session, null, false );
+ if ( ctx instanceof ServerLdapContext )
+ {
+ ServerLdapContext slc = ( ServerLdapContext ) ctx;
+ DirectoryService service = slc.getService();
+
+ if ( ! slc.getPrincipal().getName().equalsIgnoreCase( DirectoryPartitionNexus.ADMIN_PRINCIPAL
) )
+ {
+ session.write( new LaunchDiagnosticUiResponse( req.getMessageId(), ResultCodeEnum.INSUFFICIENTACCESSRIGHTS
) );
+ return;
+ }
+
+ session.write( new LaunchDiagnosticUiResponse( req.getMessageId() ) );
+
+ // Launch UI here using the provider, session registry and directory service
+ }
+
+ session.write( new LaunchDiagnosticUiResponse( req.getMessageId(), ResultCodeEnum.OPERATIONSERROR
) );
+ }
+}
|