| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.Operation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Debug.*; |
| | |
| | | assert debugEnter(CLASS_NAME, "initializeTask"); |
| | | |
| | | |
| | | // FIXME -- Do we need any special authorization here? |
| | | |
| | | |
| | | // See if the entry contains a shutdown message. If so, then use it. |
| | | // Otherwise, use a default message. |
| | | Entry taskEntry = getTaskEntry(); |
| | |
| | | valueString.equals("on") || valueString.equals("1")); |
| | | } |
| | | } |
| | | |
| | | |
| | | // If the client connection is available, then make sure the associated |
| | | // client has either the SERVER_SHUTDOWN or SERVER_RESTART privilege, based |
| | | // on the appropriate action. |
| | | Operation operation = getOperation(); |
| | | if (operation != null) |
| | | { |
| | | ClientConnection clientConnection = operation.getClientConnection(); |
| | | if (restart) |
| | | { |
| | | if (! clientConnection.hasPrivilege(Privilege.SERVER_RESTART, |
| | | operation)) |
| | | { |
| | | int msgID = MSGID_TASK_SHUTDOWN_INSUFFICIENT_RESTART_PRIVILEGES; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | message, msgID); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (! clientConnection.hasPrivilege(Privilege.SERVER_SHUTDOWN, |
| | | operation)) |
| | | { |
| | | int msgID = MSGID_TASK_SHUTDOWN_INSUFFICIENT_SHUTDOWN_PRIVILEGES; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | message, msgID); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |