001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.extensions;
028    
029    
030    
031    import java.nio.channels.SocketChannel;
032    
033    import org.opends.server.api.ClientConnection;
034    import org.opends.server.api.ConnectionSecurityProvider;
035    import org.opends.server.types.DirectoryException;
036    
037    
038    
039    
040    /**
041     * This provides an implementation of a connection security provider that is
042     * intended to be used for internal client connections.  It is exactly the same
043     * as the null connection security provider in that it doesn't actually protect
044     * anything, but the <CODE>isSecure</CODE> method always returns
045     * <CODE>true</CODE> because it is inherently secure by being an internal
046     * connection.
047     */
048    public class InternalConnectionSecurityProvider
049           extends NullConnectionSecurityProvider
050    {
051    
052    
053    
054      /**
055       * Creates a new instance of this internal connection security provider.
056       */
057      public InternalConnectionSecurityProvider()
058      {
059        super();
060      }
061    
062    
063    
064      /**
065       * Creates a new instance of this internal connection security provider with
066       * the provided information.
067       *
068       * @param  clientConnection  The client connection for this security provider
069       *                           instance.
070       * @param  socketChannel     The socket channel for this security provider
071       *                           instance.
072       */
073      protected InternalConnectionSecurityProvider(
074                     ClientConnection clientConnection, SocketChannel socketChannel)
075      {
076        super(clientConnection, socketChannel);
077      }
078    
079    
080    
081      /**
082       * {@inheritDoc}
083       */
084      public String getSecurityMechanismName()
085      {
086        return "INTERNAL";
087      }
088    
089    
090    
091      /**
092       * {@inheritDoc}
093       */
094      public boolean isSecure()
095      {
096        // Internal connections are inherently secure.
097        return true;
098      }
099    
100    
101    
102      /**
103       * Creates a new instance of this connection security provider that will be
104       * used to encode and decode all communication on the provided client
105       * connection.
106       *
107       * @param  clientConnection  The client connection with which this security
108       *                           provider will be associated.
109       * @param  socketChannel     The socket channel that may be used to
110       *                           communicate with the client.
111       *
112       * @return  The created connection security provider instance.
113       *
114       * @throws  DirectoryException  If a problem occurs while creating a new
115       *                              instance of this security provider for the
116       *                              given client connection.
117       */
118      public ConnectionSecurityProvider newInstance(ClientConnection
119                                                          clientConnection,
120                                                    SocketChannel socketChannel)
121             throws DirectoryException
122      {
123        return new InternalConnectionSecurityProvider(clientConnection,
124                                                      socketChannel);
125      }
126    }
127