| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.OperationType; |
| | | import org.opends.server.types.RawAttribute; |
| | |
| | | objectClasses = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new add operation with the provided information. |
| | | * |
| | | * @param clientConnection The client connection with which this |
| | | * operation is associated. |
| | | * @param operationID The operation ID for this operation. |
| | | * @param messageID The message ID of the request with which |
| | | * this operation is associated. |
| | | * @param requestControls The set of controls included in the request. |
| | | * @param entryDN The DN for the entry. |
| | | * @param objectClasses The set of objectclasses for the entry. |
| | | * @param userAttributes The set of user attributes for the entry. |
| | | * @param operationalAttributes The set of operational attributes for the |
| | | * entry. |
| | | * @param clientConnection |
| | | * The client connection with which this operation is associated. |
| | | * @param operationID |
| | | * The operation ID for this operation. |
| | | * @param messageID |
| | | * The message ID of the request with which this operation is associated. |
| | | * @param requestControls |
| | | * The set of controls included in the request. |
| | | * @param entry |
| | | * The entry to add. |
| | | */ |
| | | public AddOperationBasis(ClientConnection clientConnection, long operationID, |
| | | int messageID, List<Control> requestControls, |
| | | DN entryDN, Map<ObjectClass,String> objectClasses, |
| | | Map<AttributeType,List<Attribute>> userAttributes, |
| | | Map<AttributeType,List<Attribute>> operationalAttributes) |
| | | int messageID, List<Control> requestControls, Entry entry) |
| | | { |
| | | super(clientConnection, operationID, messageID, requestControls); |
| | | |
| | | |
| | | this.entryDN = entryDN; |
| | | this.objectClasses = objectClasses; |
| | | this.userAttributes = userAttributes; |
| | | this.operationalAttributes = operationalAttributes; |
| | | this.entryDN = entry.getName(); |
| | | this.objectClasses = entry.getObjectClasses(); |
| | | this.userAttributes = entry.getUserAttributes(); |
| | | this.operationalAttributes = entry.getOperationalAttributes(); |
| | | |
| | | rawEntryDN = ByteString.valueOfUtf8(entryDN.toString()); |
| | | |
| | |
| | | * Processes an internal add operation with the provided |
| | | * information. |
| | | * |
| | | * @param entryDN The entry DN for the add |
| | | * operation. |
| | | * @param objectClasses The set of object classes for the |
| | | * add operation. |
| | | * @param userAttributes The set of user attributes for the |
| | | * add operation. |
| | | * @param operationalAttributes The set of operational attributes |
| | | * for the add operation. |
| | | * |
| | | * @return A reference to the add operation that was processed and |
| | | * contains information about the result of the processing. |
| | | */ |
| | | public AddOperation processAdd(DN entryDN, |
| | | Map<ObjectClass,String> objectClasses, |
| | | Map<AttributeType,List<Attribute>> |
| | | userAttributes, |
| | | Map<AttributeType,List<Attribute>> |
| | | operationalAttributes) |
| | | { |
| | | return processAdd(entryDN, objectClasses, userAttributes, |
| | | operationalAttributes, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal add operation with the provided |
| | | * information. |
| | | * |
| | | * @param entryDN The entry DN for the add |
| | | * operation. |
| | | * @param objectClasses The set of object classes for the |
| | | * add operation. |
| | | * @param userAttributes The set of user attributes for the |
| | | * add operation. |
| | | * @param operationalAttributes The set of operational attributes |
| | | * for the add operation. |
| | | * @param controls The set of controls to include in |
| | | * the request. |
| | | * |
| | | * @return A reference to the add operation that was processed and |
| | | * contains information about the result of the processing. |
| | | */ |
| | | public AddOperation processAdd(DN entryDN, |
| | | Map<ObjectClass,String> objectClasses, |
| | | Map<AttributeType,List<Attribute>> |
| | | userAttributes, |
| | | Map<AttributeType,List<Attribute>> |
| | | operationalAttributes, |
| | | List<Control> controls) |
| | | { |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(this, nextOperationID(), |
| | | nextMessageID(), controls, entryDN, |
| | | objectClasses, userAttributes, |
| | | operationalAttributes); |
| | | addOperation.setInternalOperation(true); |
| | | |
| | | addOperation.run(); |
| | | return addOperation; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal add operation with the provided |
| | | * information. |
| | | * |
| | | * @param entry The entry to be added. |
| | | * |
| | | * @return A reference to the add operation that was processed and |
| | |
| | | */ |
| | | public AddOperation processAdd(Entry entry, List<Control> controls) |
| | | { |
| | | return processAdd(entry.getName(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes(), |
| | | controls); |
| | | AddOperationBasis addOperation = new AddOperationBasis(this, nextOperationID(), nextMessageID(), controls, entry); |
| | | addOperation.setInternalOperation(true); |
| | | addOperation.run(); |
| | | return addOperation; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | return processAdd(addRecord.getDN(), objectClasses, userAttrs, opAttrs); |
| | | // TODO JNR can we directly pass e instead of addEntry()? |
| | | Entry addEntry = new Entry(addRecord.getDN(), objectClasses, userAttrs, opAttrs); |
| | | return processAdd(addEntry, null); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private AddOperationBasis newAddOperationBasis(Entry e, List<Control> controls) |
| | | { |
| | | return new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), controls, |
| | | e.getName(), e.getObjectClasses(), e.getUserAttributes(), e.getOperationalAttributes()); |
| | | return new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), controls, e); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | package org.opends.server.protocols.jmx; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import javax.net.ssl.TrustManagerFactory; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.server.config.meta.JMXConnectionHandlerCfgDefn; |
| | | import org.forgerock.opendj.server.config.server.JMXConnectionHandlerCfg; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.JMXMBean; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DeleteOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.InitializationUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | @AfterClass |
| | | public void afterClass() throws Exception |
| | | { |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | |
| | | DeleteOperation deleteOperation = conn.processDelete(DN |
| | | .valueOf("cn=Privileged User,o=test")); |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(DN.valueOf("cn=Privileged User,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | deleteOperation = conn.processDelete(DN |
| | | .valueOf("cn=Unprivileged JMX User,o=test")); |
| | | deleteOperation = getRootConnection().processDelete(DN.valueOf("cn=Unprivileged JMX User,o=test")); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-use-ssl: false", "ds-cfg-listen-port: " |
| | | + serverJmxPort, "cn: JMX Connection Handler"); |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperationBasis addOp = new AddOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | newJmxConnectionJmx.getName(), newJmxConnectionJmx |
| | | .getObjectClasses(), newJmxConnectionJmx |
| | | .getUserAttributes(), newJmxConnectionJmx |
| | | .getOperationalAttributes()); |
| | | AddOperationBasis addOp = new AddOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), null, newJmxConnectionJmx); |
| | | addOp.run(); |
| | | Thread.sleep(200); |
| | | OpendsJmxConnector newJmxConnector = connect( |
| | |
| | | // cleanup client connection |
| | | connector.close(); |
| | | jmxcDisabled.close(); |
| | | DeleteOperationBasis delOp = new DeleteOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | newJmxConnectionJmx.getName()); |
| | | DeleteOperationBasis delOp = new DeleteOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), null, newJmxConnectionJmx.getName()); |
| | | delOp.run(); |
| | | } |
| | | |
| | |
| | | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | | // with a root connection so we can do other things with it. |
| | | AddOperationBasis addOp = new AddOperationBasis( |
| | | conn, conn.nextOperationID(), conn.nextMessageID(), controls, |
| | | e.getName(), e.getObjectClasses(), e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperationBasis addOp = new AddOperationBasis(conn, conn.nextOperationID(), conn.nextMessageID(), controls, e); |
| | | assertSuccess(hasProxyPrivilege, addOp); |
| | | if (!hasProxyPrivilege) |
| | | { |
| | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | | // with a root connection so we can do other things with it. |
| | | DN authDN = conn.getAuthenticationInfo().getAuthenticationDN(); |
| | | AddOperationBasis addOp = new AddOperationBasis( |
| | | conn, conn.nextOperationID(), conn.nextMessageID(), controls, |
| | | e.getName(), e.getObjectClasses(), e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperationBasis addOp = new AddOperationBasis(conn, conn.nextOperationID(), conn.nextMessageID(), controls, e); |
| | | assertSuccess(hasProxyPrivilege, authDN, addOp); |
| | | if (!hasProxyPrivilege) |
| | | { |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RawAttribute; |
| | |
| | | assertEquals(msg.toString(), generatedMsg.toString()); |
| | | |
| | | //Create an Add operation and generate and Add msg from it |
| | | AddOperation addOpB = new AddOperationBasis(conn, |
| | | 1, 1, null, dn, objectClassList, userAttList, opList); |
| | | Entry e = new Entry(dn, objectClassList, userAttList, opList); |
| | | AddOperation addOpB = new AddOperationBasis(conn, 1, 1, null, e); |
| | | LocalBackendAddOperation localAddOp = new LocalBackendAddOperation(addOpB); |
| | | OperationContext opCtx = new AddContext(csn, "thisIsaUniqueID", |
| | | "parentUniqueId"); |
| | |
| | | t1 = System.nanoTime(); |
| | | |
| | | // create op |
| | | AddOperation addOpB = new AddOperationBasis(connection, |
| | | 1, 1, null, dn, objectClassList, userAttList, opList); |
| | | Entry e = new Entry(dn, objectClassList, userAttList, opList); |
| | | AddOperation addOpB = new AddOperationBasis(connection, 1, 1, null, e); |
| | | LocalBackendAddOperation addOp = new LocalBackendAddOperation(addOpB); |
| | | OperationContext opCtx = new AddContext(csn, "thisIsaUniqueID", |
| | | "parentUniqueId"); |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.GlobalCfgDefn.DisabledPrivilege; |
| | | import org.forgerock.opendj.server.config.meta.RootDNCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskBackend; |
| | |
| | | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | | // with a root connection so we can do other things with it. |
| | | AddOperation addOperation = new AddOperationBasis(conn, nextOperationID(), nextMessageID(), |
| | | controls, e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = new AddOperationBasis(conn, nextOperationID(), nextMessageID(), controls, e); |
| | | addOperation.run(); |
| | | assertProxyPrivilege(addOperation.getResultCode(), hasProxyPrivilege); |
| | | |
| | |
| | | |
| | | // Try to add the entry. If this fails with the proxy control, then add it |
| | | // with a root connection so we can do other things with it. |
| | | AddOperation addOperation = |
| | | new AddOperationBasis(conn, nextOperationID(), nextMessageID(), |
| | | controls, e.getName(), e.getObjectClasses(), |
| | | e.getUserAttributes(), e.getOperationalAttributes()); |
| | | AddOperation addOperation = new AddOperationBasis(conn, nextOperationID(), nextMessageID(), controls, e); |
| | | addOperation.run(); |
| | | assertProxyPrivilege(addOperation.getResultCode(), hasProxyPrivilege); |
| | | |