0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
0N/A * (the "License"). You may not use this file except in compliance
0N/A * with the License.
0N/A *
6983N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6983N/A * or http://forgerock.org/license/CDDLv1.0.html.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
6983N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
6983N/A * If applicable, add the following below this CDDL HEADER, with the
6983N/A * fields enclosed by brackets "[]" replaced with your own identifying
6983N/A * information:
0N/A * Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A *
0N/A *
3231N/A * Copyright 2006-2008 Sun Microsystems, Inc.
5464N/A * Portions Copyright 2011 ForgeRock AS
0N/A */
0N/Apackage org.opends.server.extensions;
2334N/A
0N/A
0N/A
2334N/Aimport org.opends.server.admin.std.server.AnonymousSASLMechanismHandlerCfg;
0N/Aimport org.opends.server.api.SASLMechanismHandler;
0N/Aimport org.opends.server.config.ConfigException;
0N/Aimport org.opends.server.core.BindOperation;
0N/Aimport org.opends.server.core.DirectoryServer;
5464N/Aimport org.opends.server.types.*;
0N/A
2334N/Aimport static org.opends.messages.ExtensionMessages.*;
1280N/Aimport static org.opends.server.loggers.ErrorLogger.*;
0N/Aimport static org.opends.server.util.ServerConstants.*;
0N/A
0N/A
0N/A
0N/A/**
0N/A * This class provides an implementation of a SASL mechanism, as defined in RFC
0N/A * 4505, that does not perform any authentication. That is, anyone attempting
0N/A * to bind with this SASL mechanism will be successful and will be given the
0N/A * rights of an unauthenticated user. The request may or may not include a set
0N/A * of SASL credentials which will serve as trace information. If provided,
0N/A * then that trace information will be written to the server error log.
0N/A */
0N/Apublic class AnonymousSASLMechanismHandler
2334N/A extends SASLMechanismHandler<AnonymousSASLMechanismHandlerCfg>
0N/A{
0N/A /**
0N/A * Creates a new instance of this SASL mechanism handler. No initialization
0N/A * should be done in this method, as it should all be performed in the
0N/A * <CODE>initializeSASLMechanismHandler</CODE> method.
0N/A */
0N/A public AnonymousSASLMechanismHandler()
0N/A {
0N/A super();
0N/A }
0N/A
0N/A
0N/A
0N/A /**
761N/A * {@inheritDoc}
0N/A */
761N/A @Override()
2334N/A public void initializeSASLMechanismHandler(AnonymousSASLMechanismHandlerCfg
1008N/A configuration)
0N/A throws ConfigException, InitializationException
0N/A {
0N/A // No real implementation is required. Simply register with the Directory
0N/A // Server for the ANONYMOUS mechanism.
0N/A DirectoryServer.registerSASLMechanismHandler(SASL_MECHANISM_ANONYMOUS,
0N/A this);
0N/A }
0N/A
0N/A
0N/A
221N/A /**
761N/A * {@inheritDoc}
221N/A */
761N/A @Override()
221N/A public void finalizeSASLMechanismHandler()
221N/A {
221N/A DirectoryServer.deregisterSASLMechanismHandler(SASL_MECHANISM_ANONYMOUS);
221N/A }
221N/A
221N/A
221N/A
0N/A
0N/A /**
761N/A * {@inheritDoc}
0N/A */
761N/A @Override()
0N/A public void processSASLBind(BindOperation bindOperation)
0N/A {
0N/A // See if the client provided SASL credentials including trace information.
1711N/A // If so, then write it to the access log as additional log information, and
1711N/A // as an informational message to the error log.
0N/A ByteString saslCredentials = bindOperation.getSASLCredentials();
0N/A if (saslCredentials != null)
0N/A {
4134N/A String credString = saslCredentials.toString();
0N/A if (credString.length() > 0)
0N/A {
5464N/A bindOperation.addAdditionalLogItem(AdditionalLogItem.quotedKeyValue(
5464N/A getClass(), "trace", credString));
2086N/A logError(INFO_SASLANONYMOUS_TRACE.
2086N/A get(bindOperation.getConnectionID(), bindOperation.getOperationID(),
2086N/A credString));
0N/A
0N/A }
0N/A }
0N/A
0N/A
0N/A // Authenticate the client anonymously and indicate that the bind was
0N/A // successful.
0N/A AuthenticationInfo authInfo = new AuthenticationInfo();
761N/A bindOperation.setAuthenticationInfo(authInfo);
0N/A bindOperation.setResultCode(ResultCode.SUCCESS);
0N/A }
0N/A
0N/A
0N/A
0N/A /**
761N/A * {@inheritDoc}
0N/A */
761N/A @Override()
0N/A public boolean isPasswordBased(String mechanism)
0N/A {
0N/A // This is not a password-based mechanism.
0N/A return false;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
761N/A * {@inheritDoc}
0N/A */
761N/A @Override()
0N/A public boolean isSecure(String mechanism)
0N/A {
0N/A // This is not a secure mechanism.
0N/A return false;
0N/A }
0N/A}
0N/A