| | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.api.ConnectionSecurityProvider; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.core.networkgroups.NetworkGroup; |
| | | import org.opends.server.extensions.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.types.AbstractOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DereferencePolicy; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IntermediateResponse; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawFilter; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.SearchScope; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.DeleteChangeRecordEntry; |
| | | import org.opends.server.util.ModifyChangeRecordEntry; |
| | |
| | | // connection. |
| | | private static AtomicLong nextOperationID; |
| | | |
| | | // The connection security provider for this client connection. |
| | | private ConnectionSecurityProvider securityProvider; |
| | | |
| | | // The static connection for root-based connections. |
| | | private static InternalClientConnection rootConnection; |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(privType); |
| | | for (Privilege p : Privilege.getDefaultRootPrivileges()) |
| | | { |
| | | builder.add(new AttributeValue(privType, p.getName())); |
| | | builder.add(AttributeValues.create(privType, p.getName())); |
| | | } |
| | | attrList = new LinkedList<Attribute>(); |
| | | attrList.add(builder.toAttribute()); |
| | |
| | | |
| | | connectionID = nextConnectionID.getAndDecrement(); |
| | | operationList = new LinkedList<Operation>(); |
| | | |
| | | try |
| | | { |
| | | securityProvider = new InternalConnectionSecurityProvider(); |
| | | securityProvider.initializeConnectionSecurityProvider(null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | connectionID = nextConnectionID.getAndDecrement(); |
| | | operationList = new LinkedList<Operation>(); |
| | | |
| | | try |
| | | { |
| | | securityProvider = new InternalConnectionSecurityProvider(); |
| | | securityProvider.initializeConnectionSecurityProvider(null); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | @Override() |
| | | public boolean isSecure() |
| | | { |
| | | // Internal connections will generally be considered secure, but |
| | | // they may be declared insecure if they are accessed through some |
| | | // external mechanism (e.g., a DSML handler that runs the server |
| | | // in a Servlet engine and using internal operations for |
| | | // processing requests). |
| | | return securityProvider.isSecure(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the connection security provider for this client |
| | | * connection. |
| | | * |
| | | * @return The connection security provider for this client |
| | | * connection. |
| | | */ |
| | | @Override() |
| | | public ConnectionSecurityProvider getConnectionSecurityProvider() |
| | | { |
| | | return securityProvider; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Specifies the connection security provider for this client |
| | | * connection. |
| | | * |
| | | * @param securityProvider The connection security provider to use |
| | | * for communication on this client |
| | | * connection. |
| | | */ |
| | | @org.opends.server.types.PublicAPI( |
| | | stability=org.opends.server.types.StabilityLevel.PRIVATE, |
| | | mayInstantiate=false, |
| | | mayExtend=false, |
| | | mayInvoke=false) |
| | | @Override() |
| | | public void setConnectionSecurityProvider(ConnectionSecurityProvider |
| | | securityProvider) |
| | | { |
| | | this.securityProvider = securityProvider; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the human-readable name of the security mechanism that |
| | | * is used to protect communication with this client. |
| | | * |
| | | * @return The human-readable name of the security mechanism that |
| | | * is used to protect communication with this client, or |
| | | * <CODE>null</CODE> if no security is in place. |
| | | */ |
| | | @Override() |
| | | public String getSecurityMechanism() |
| | | { |
| | | return securityProvider.getSecurityMechanismName(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates that the data in the provided buffer has been read from |
| | | * the client and should be processed. The contents of the provided |
| | |
| | | public AddOperation processAdd(String rawEntryDN, |
| | | List<RawAttribute> rawAttributes) |
| | | { |
| | | return processAdd(new ASN1OctetString(rawEntryDN), rawAttributes, |
| | | return processAdd(ByteString.valueOf(rawEntryDN), rawAttributes, |
| | | null); |
| | | } |
| | | |
| | |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | String ocName = v.getStringValue(); |
| | | String ocName = v.getValue().toString(); |
| | | String lowerName = toLowerCase(ocName); |
| | | ObjectClass oc = DirectoryServer.getObjectClass(lowerName, |
| | | true); |
| | |
| | | public BindOperation processSimpleBind(String rawBindDN, |
| | | String password) |
| | | { |
| | | return processSimpleBind(new ASN1OctetString(rawBindDN), |
| | | new ASN1OctetString(password), |
| | | return processSimpleBind(ByteString.valueOf(rawBindDN), |
| | | ByteString.valueOf(password), |
| | | null); |
| | | } |
| | | |
| | |
| | | String password, |
| | | List<Control> controls) |
| | | { |
| | | return processSimpleBind(new ASN1OctetString(rawBindDN), |
| | | new ASN1OctetString(password), controls); |
| | | return processSimpleBind(ByteString.valueOf(rawBindDN), |
| | | ByteString.valueOf(password), controls); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public BindOperation processSASLBind(ByteString rawBindDN, |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials) |
| | | ByteString saslCredentials) |
| | | { |
| | | return processSASLBind(rawBindDN, saslMechanism, saslCredentials, |
| | | null); |
| | |
| | | */ |
| | | public BindOperation processSASLBind(ByteString rawBindDN, |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials, |
| | | ByteString saslCredentials, |
| | | List<Control> controls) |
| | | { |
| | | if (controls == null) |
| | |
| | | */ |
| | | public BindOperation processSASLBind(DN bindDN, |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials) |
| | | ByteString saslCredentials) |
| | | { |
| | | return processSASLBind(bindDN, saslMechanism, saslCredentials, |
| | | null); |
| | |
| | | */ |
| | | public BindOperation processSASLBind(DN bindDN, |
| | | String saslMechanism, |
| | | ASN1OctetString saslCredentials, |
| | | ByteString saslCredentials, |
| | | List<Control> controls) |
| | | { |
| | | if (controls == null) |
| | |
| | | String attributeType, |
| | | String assertionValue) |
| | | { |
| | | return processCompare(new ASN1OctetString(rawEntryDN), |
| | | return processCompare(ByteString.valueOf(rawEntryDN), |
| | | attributeType, |
| | | new ASN1OctetString(assertionValue), null); |
| | | ByteString.valueOf(assertionValue), null); |
| | | } |
| | | |
| | | |
| | |
| | | String assertionValue, |
| | | List<Control> controls) |
| | | { |
| | | return processCompare(new ASN1OctetString(rawEntryDN), |
| | | return processCompare(ByteString.valueOf(rawEntryDN), |
| | | attributeType, |
| | | new ASN1OctetString(assertionValue), |
| | | ByteString.valueOf(assertionValue), |
| | | controls); |
| | | } |
| | | |
| | |
| | | */ |
| | | public DeleteOperation processDelete(String rawEntryDN) |
| | | { |
| | | return processDelete(new ASN1OctetString(rawEntryDN), null); |
| | | return processDelete(ByteString.valueOf(rawEntryDN), null); |
| | | } |
| | | |
| | | |
| | |
| | | public DeleteOperation processDelete(String rawEntryDN, |
| | | List<Control> controls) |
| | | { |
| | | return processDelete(new ASN1OctetString(rawEntryDN), controls); |
| | | return processDelete(ByteString.valueOf(rawEntryDN), controls); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public ExtendedOperation processExtendedOperation( |
| | | String requestOID, |
| | | ASN1OctetString requestValue) |
| | | ByteString requestValue) |
| | | { |
| | | return processExtendedOperation(requestOID, requestValue, null); |
| | | } |
| | |
| | | */ |
| | | public ExtendedOperation processExtendedOperation( |
| | | String requestOID, |
| | | ASN1OctetString requestValue, |
| | | ByteString requestValue, |
| | | List<Control> controls) |
| | | { |
| | | if (controls == null) |
| | |
| | | public ModifyOperation processModify(String rawEntryDN, |
| | | List<RawModification> rawModifications) |
| | | { |
| | | return processModify(new ASN1OctetString(rawEntryDN), |
| | | return processModify(ByteString.valueOf(rawEntryDN), |
| | | rawModifications, null); |
| | | } |
| | | |
| | |
| | | List<RawModification> rawModifications, |
| | | List<Control> controls) |
| | | { |
| | | return processModify(new ASN1OctetString(rawEntryDN), |
| | | return processModify(ByteString.valueOf(rawEntryDN), |
| | | rawModifications, controls); |
| | | } |
| | | |
| | |
| | | String rawNewRDN, |
| | | boolean deleteOldRDN) |
| | | { |
| | | return processModifyDN(new ASN1OctetString(rawEntryDN), |
| | | new ASN1OctetString(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, null, null); |
| | | } |
| | | |
| | |
| | | boolean deleteOldRDN, |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(new ASN1OctetString(rawEntryDN), |
| | | new ASN1OctetString(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, null, controls); |
| | | } |
| | | |
| | |
| | | boolean deleteOldRDN, |
| | | String rawNewSuperior) |
| | | { |
| | | return processModifyDN(new ASN1OctetString(rawEntryDN), |
| | | new ASN1OctetString(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, |
| | | new ASN1OctetString(rawNewSuperior), null); |
| | | ByteString.valueOf(rawNewSuperior), null); |
| | | } |
| | | |
| | | |
| | |
| | | String rawNewSuperior, |
| | | List<Control> controls) |
| | | { |
| | | return processModifyDN(new ASN1OctetString(rawEntryDN), |
| | | new ASN1OctetString(rawNewRDN), |
| | | return processModifyDN(ByteString.valueOf(rawEntryDN), |
| | | ByteString.valueOf(rawNewRDN), |
| | | deleteOldRDN, |
| | | new ASN1OctetString(rawNewSuperior), |
| | | ByteString.valueOf(rawNewSuperior), |
| | | controls); |
| | | } |
| | | |
| | |
| | | le.getErrorMessage(), le); |
| | | } |
| | | |
| | | return processSearch(new ASN1OctetString(rawBaseDN), scope, |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, |
| | | rawFilter); |
| | | } |
| | | |
| | |
| | | le.getErrorMessage(), le); |
| | | } |
| | | |
| | | return processSearch(new ASN1OctetString(rawBaseDN), scope, |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, |
| | | derefPolicy, sizeLimit, timeLimit, typesOnly, |
| | | rawFilter, attributes, controls, |
| | | searchListener); |
| | |
| | | // Internal operations will not be limited. |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public int getSSF() { |
| | | //Always return strongest value. |
| | | return 256; |
| | | } |
| | | } |
| | | |