- revert Revision: 5370 commit so that related changes land on the trunk from the branch instead of direct commit.
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided operation search filter is allowed |
| | | * based on the access control configuration. This method should not |
| | | * alter the provided operation in any way. |
| | | * |
| | | * @param operation |
| | | * The operation for which to make the determination. |
| | | * @param entry |
| | | * The entry for which to make the determination. |
| | | * @param filter |
| | | * The filter to check access on. |
| | | * @return {@code true} if the operation should be allowed by the |
| | | * access control configuration, or {@code false} if not. |
| | | * @throws DirectoryException |
| | | * If an error occurred while performing the access |
| | | * control check. For example, if an attribute could not |
| | | * be decoded. Care must be taken not to expose any |
| | | * potentially sensitive information in the exception. |
| | | */ |
| | | public abstract boolean isAllowed(Operation operation, Entry entry, |
| | | SearchFilter filter) throws DirectoryException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided search result entry may be sent to |
| | | * the client. Implementations <b>must not under any |
| | | * circumstances</b> modify the search entry in any way. |
| | |
| | | |
| | | |
| | | /** |
| | | * Filter the contents of the provided entry such that it no longer |
| | | * contains any attributes or values that the client is not |
| | | * permitted to access. |
| | | * |
| | | * @param operation |
| | | * The operation with which the provided entry is |
| | | * associated. |
| | | * @param entry |
| | | * The entry to be filtered. |
| | | * @return Returns the entry with filtered attributes and values |
| | | * removed. |
| | | */ |
| | | public abstract SearchResultEntry filterEntry( |
| | | Operation operation, Entry entry); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided search result reference may be |
| | | * sent to the client based on the access control configuration. |
| | | * |
| | |
| | | |
| | | |
| | | |
| | | /* |
| | | * TODO Rename this method. Needs to be changed in SearchOperation. I |
| | | * find the name of the filterEntry method to be misleading because it |
| | | * works on a search operation but has nothing to do with the search |
| | | * filter. Something like "removeDisallowedAttributes" would be |
| | | * clearer. |
| | | */ |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * Checks access on each attribute in an entry. It removes those |
| | | * attributes that fail access check. |
| | | * |
| | | * @param operation |
| | | * The search operation class containing information to check |
| | | * access on. |
| | | * @param entry |
| | | * The entry containing the attributes. |
| | | * @return The entry to return minus filtered attributes. |
| | | */ |
| | | @Override |
| | | public SearchResultEntry filterEntry(SearchOperation operation, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SearchResultEntry filterEntry(Operation operation, Entry entry) |
| | | { |
| | | AciLDAPOperationContainer operationContainer = |
| | | new AciLDAPOperationContainer(operation, (ACI_READ), entry); |
| | | return accessAllowedAttrs(operationContainer); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public void finalizeAccessControlHandler() |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isAllowed(Operation operation, Entry entry, |
| | | SearchFilter filter) throws DirectoryException |
| | | { |
| | | AciLDAPOperationContainer operationContainer = |
| | | new AciLDAPOperationContainer(operation, (ACI_READ), entry); |
| | | return testFilter(operationContainer, filter); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean mayProxy(Entry proxyUser, Entry proxiedUser, |
| | | Operation op) |
| | | { |
| | |
| | | private List<Modification> modifications; |
| | | |
| | | /** |
| | | * Constructor interface for all currently supported LDAP operations. |
| | | * @param operation The compare operation to evaluate. |
| | | * @param rights The rights of a compare operation. |
| | | * @param entry The entry for evaluation. |
| | | */ |
| | | public AciLDAPOperationContainer(Operation operation, |
| | | int rights, Entry entry) |
| | | { |
| | | super(operation, rights, entry); |
| | | this.searchEntry = new SearchResultEntry(entry); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Constructor interface for the compare operation. |
| | | * @param operation The compare operation to evaluate. |
| | | * @param rights The rights of a compare operation. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isAllowed(Operation operation, Entry entry, |
| | | SearchFilter filter) throws DirectoryException |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean maySend(SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SearchResultEntry filterEntry(Operation operation, Entry entry) |
| | | { |
| | | // No implementation required. |
| | | return new SearchResultEntry(entry); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean maySend(DN dn, SearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | | { |
| | |
| | | |
| | | if (oid.equals(OID_LDAP_ASSERTION)) |
| | | { |
| | | // RFC 4528 mandates support for Add operation basically |
| | | // suggesting an asertion on self. As daft as it may be |
| | | // we gonna have to support this for RFC compliance. |
| | | LDAPAssertionRequestControl assertControl = |
| | | getRequestControl(LDAPAssertionRequestControl.DECODER); |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, entry, filter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, addedEntry); |
| | | // FIXME -- Check access controls on the entry to see if it should |
| | | // be returned or if any attributes need to be stripped |
| | | // out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(addedEntry); |
| | | LDAPPostReadResponseControl responseControl = |
| | | new LDAPPostReadResponseControl(searchEntry); |
| | | addResponseControl(responseControl); |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, entry, filter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, entry, filter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! filter.matchesEntry(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, entryCopy); |
| | | // FIXME -- Check access controls on the entry to see if it should |
| | | // be returned or if any attributes need to be stripped |
| | | // out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(entryCopy); |
| | | LDAPPreReadResponseControl responseControl = |
| | | new LDAPPreReadResponseControl(preReadRequest.isCritical(), |
| | | searchEntry); |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, currentEntry, filter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! filter.matchesEntry(currentEntry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, entry); |
| | | // FIXME -- Check access controls on the entry to see if it should |
| | | // be returned or if any attributes need to be stripped |
| | | // out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(entry); |
| | | LDAPPreReadResponseControl responseControl = |
| | | new LDAPPreReadResponseControl(preReadRequest.isCritical(), |
| | | searchEntry); |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, entry); |
| | | // FIXME -- Check access controls on the entry to see if it should |
| | | // be returned or if any attributes need to be stripped |
| | | // out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(entry); |
| | | LDAPPostReadResponseControl responseControl = |
| | | new LDAPPostReadResponseControl(searchEntry); |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter filter = assertControl.getSearchFilter(); |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, currentEntry, filter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! filter.matchesEntry(currentEntry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, entry); |
| | | // FIXME -- Check access controls on the entry to see if it should be |
| | | // returned or if any attributes need to be stripped out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(entry); |
| | | LDAPPreReadResponseControl responseControl = |
| | | new LDAPPreReadResponseControl(preReadRequest.isCritical(), |
| | | searchEntry); |
| | |
| | | } |
| | | } |
| | | |
| | | // Check access controls on the entry and strip out |
| | | // any not allowed attributes. |
| | | SearchResultEntry searchEntry = |
| | | AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().filterEntry(this, entry); |
| | | // FIXME -- Check access controls on the entry to see if it should be |
| | | // returned or if any attributes need to be stripped out.. |
| | | SearchResultEntry searchEntry = new SearchResultEntry(entry); |
| | | LDAPPostReadResponseControl responseControl = |
| | | new LDAPPostReadResponseControl(searchEntry); |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter assertionFilter = assertControl.getSearchFilter(); |
| | | Entry entry; |
| | | try |
| | |
| | | ERR_SEARCH_NO_SUCH_ENTRY_FOR_ASSERTION.get()); |
| | | } |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, entry, assertionFilter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! assertionFilter.matchesEntry(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |
| | |
| | | |
| | | try |
| | | { |
| | | // FIXME -- We need to determine whether the current user has |
| | | // permission to make this determination. |
| | | SearchFilter assertionFilter = assertControl.getSearchFilter(); |
| | | Entry entry; |
| | | try |
| | |
| | | ERR_SEARCH_NO_SUCH_ENTRY_FOR_ASSERTION.get()); |
| | | } |
| | | |
| | | // Check if the current user has permission to make |
| | | // this determination. |
| | | if (!AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(this, entry, assertionFilter)) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |
| | | |
| | | if (! assertionFilter.matchesEntry(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.ASSERTION_FAILED, |