Search in sources :

Example 1 with CompareRequestImpl

use of org.apache.directory.api.ldap.model.message.CompareRequestImpl in project directory-ldap-api by apache.

the class LdapNetworkConnection method compare.

/**
 * {@inheritDoc}
 */
@Override
public boolean compare(Dn dn, String attributeName, Value value) throws LdapException {
    CompareRequest compareRequest = new CompareRequestImpl();
    compareRequest.setName(dn);
    compareRequest.setAttributeId(attributeName);
    if (value.isHumanReadable()) {
        compareRequest.setAssertionValue(value.getValue());
    } else {
        compareRequest.setAssertionValue(value.getBytes());
    }
    CompareResponse compareResponse = compare(compareRequest);
    return processResponse(compareResponse);
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) CompareRequestImpl(org.apache.directory.api.ldap.model.message.CompareRequestImpl)

Example 2 with CompareRequestImpl

use of org.apache.directory.api.ldap.model.message.CompareRequestImpl in project directory-ldap-api by apache.

the class LdapNetworkConnection method compare.

/**
 * {@inheritDoc}
 */
@Override
public boolean compare(Dn dn, String attributeName, String value) throws LdapException {
    CompareRequest compareRequest = new CompareRequestImpl();
    compareRequest.setName(dn);
    compareRequest.setAttributeId(attributeName);
    compareRequest.setAssertionValue(value);
    CompareResponse compareResponse = compare(compareRequest);
    return processResponse(compareResponse);
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) CompareRequestImpl(org.apache.directory.api.ldap.model.message.CompareRequestImpl)

Example 3 with CompareRequestImpl

use of org.apache.directory.api.ldap.model.message.CompareRequestImpl in project directory-ldap-api by apache.

the class InitCompareRequest method action.

/**
 * {@inheritDoc}
 */
public void action(LdapMessageContainer<CompareRequestDecorator> container) {
    // Now, we can allocate the CompareRequest Object
    CompareRequest internalCompareRequest = new CompareRequestImpl();
    internalCompareRequest.setMessageId(container.getMessageId());
    CompareRequestDecorator compareRequest = new CompareRequestDecorator(container.getLdapCodecService(), internalCompareRequest);
    container.setMessage(compareRequest);
    LOG.debug("Compare Request");
}
Also used : CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) CompareRequestImpl(org.apache.directory.api.ldap.model.message.CompareRequestImpl) CompareRequestDecorator(org.apache.directory.api.ldap.codec.decorators.CompareRequestDecorator)

Example 4 with CompareRequestImpl

use of org.apache.directory.api.ldap.model.message.CompareRequestImpl in project directory-ldap-api by apache.

the class LdapNetworkConnection method compare.

/**
 * {@inheritDoc}
 */
@Override
public boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException {
    CompareRequest compareRequest = new CompareRequestImpl();
    compareRequest.setName(dn);
    compareRequest.setAttributeId(attributeName);
    compareRequest.setAssertionValue(value);
    CompareResponse compareResponse = compare(compareRequest);
    return processResponse(compareResponse);
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) CompareRequestImpl(org.apache.directory.api.ldap.model.message.CompareRequestImpl)

Example 5 with CompareRequestImpl

use of org.apache.directory.api.ldap.model.message.CompareRequestImpl in project directory-fortress-core by apache.

the class LdapDataProvider method compareNode.

/**
 * This method uses the compare ldap func to assert audit record into the directory server's configured audit
 * logger.
 *
 * This is for one reason - to force the ldap server to maintain an audit trail on checkAccess api.
 *
 * Use proxy authz control (RFC4370) to assert the caller's id onto the record.
 *
 * @param connection is LdapConnection object used for all communication with host.
 * @param dn         contains address of distinguished name to begin ldap search
 * @param userDn     dn for user node
 * @param attribute  attribute used for compare
 * @return true if compare operation succeeds
 * @throws LdapException                thrown in the event of error in ldap client or server code.
 * @throws UnsupportedEncodingException in the event the server cannot perform the operation.
 */
protected boolean compareNode(LdapConnection connection, String dn, String userDn, Attribute attribute) throws LdapException, UnsupportedEncodingException {
    COUNTERS.incrementCompare();
    CompareRequest compareRequest = new CompareRequestImpl();
    compareRequest.setName(new Dn(dn));
    compareRequest.setAttributeId(attribute.getId());
    compareRequest.setAssertionValue(attribute.getString());
    // Assert the end user's dn onto the reqest using proxy authZ control so openldap can log who the user was (for authZ audit trail)
    ProxiedAuthz proxiedAuthzControl = new ProxiedAuthzImpl();
    proxiedAuthzControl.setAuthzId("dn: " + userDn);
    compareRequest.addControl(proxiedAuthzControl);
    CompareResponse response = connection.compare(compareRequest);
    return response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS;
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) CompareRequest(org.apache.directory.api.ldap.model.message.CompareRequest) ProxiedAuthz(org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz) CompareRequestImpl(org.apache.directory.api.ldap.model.message.CompareRequestImpl) ProxiedAuthzImpl(org.apache.directory.api.ldap.model.message.controls.ProxiedAuthzImpl) Dn(org.apache.directory.api.ldap.model.name.Dn)

Aggregations

CompareRequest (org.apache.directory.api.ldap.model.message.CompareRequest)5 CompareRequestImpl (org.apache.directory.api.ldap.model.message.CompareRequestImpl)5 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)4 CompareRequestDecorator (org.apache.directory.api.ldap.codec.decorators.CompareRequestDecorator)1 ProxiedAuthz (org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz)1 ProxiedAuthzImpl (org.apache.directory.api.ldap.model.message.controls.ProxiedAuthzImpl)1 Dn (org.apache.directory.api.ldap.model.name.Dn)1