javax.naming.ldap.ExtendedRequest Java Examples

The following examples show how to use javax.naming.ldap.ExtendedRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractProvider.java    From ldapchai with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void preCheckExtendedOperation( final ExtendedRequest request )
        throws ChaiOperationException
{
    final boolean cacheFailures = "true".equalsIgnoreCase( this.getChaiConfiguration().getSetting( ChaiSetting.EXTENDED_OPERATION_FAILURE_CACHE ) );
    if ( cacheFailures )
    {
        final Map<String, Object> providerProps = this.getProviderProperties();
        final Map<String, Exception> cacheFailureMap = ( Map<String, Exception> ) providerProps.get( EXTENDED_FAILURE_CACHE_KEY );
        final String requestID = request.getID();
        if ( cacheFailureMap.containsKey( requestID ) )
        {
            LOGGER.debug( "previous extended operation request for " + requestID + " has failed, reissuing cached exception without attempting operation" );
            throw ( ChaiOperationException ) cacheFailureMap.get( requestID );
        }
    }
}
 
Example #2
Source File: AbstractProvider.java    From ldapchai with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void cacheExtendedOperationException( final ExtendedRequest request, final Exception e )
        throws ChaiOperationException
{
    final boolean cacheFailures = this.getChaiConfiguration().getBooleanSetting( ChaiSetting.EXTENDED_OPERATION_FAILURE_CACHE );
    if ( cacheFailures )
    {
        final ChaiOperationException opExcep = ChaiOperationException.forErrorMessage( e.getMessage() );
        if ( opExcep.getErrorCode() == ChaiError.UNSUPPORTED_OPERATION )
        {
            final Map<String, Object> providerProps = this.getProviderProperties();
            final Map<String, Exception> cacheFailureMap = ( Map<String, Exception> ) providerProps.get( EXTENDED_FAILURE_CACHE_KEY );
            final String requestID = request.getID();
            cacheFailureMap.put( requestID, opExcep );
            LOGGER.trace( "caching extended operation for " + requestID );
            throw opExcep;
        }
    }
}
 
Example #3
Source File: AbstractProvider.java    From ldapchai with GNU Lesser General Public License v2.1 5 votes vote down vote up
public final ExtendedResponse extendedOperation( final ExtendedRequest request )
{
    if ( request == null )
    {
        throw new NullPointerException( "request must not be null" );
    }

    return null;
}
 
Example #4
Source File: JNDIProviderImpl.java    From ldapchai with GNU Lesser General Public License v2.1 5 votes vote down vote up
@LdapOperation
@ModifyOperation
public final ExtendedResponse extendedOperation( final ExtendedRequest request )
        throws ChaiUnavailableException, ChaiOperationException

{
    activityPreCheck();

    getInputValidator().extendedOperation( request );

    preCheckExtendedOperation( request );

    final LdapContext ldapConnection = getLdapConnection();
    try
    {
        return ldapConnection.extendedOperation( request );
    }
    catch ( NamingException e )
    {
        cacheExtendedOperationException( request, e );

        // guaranteedb to throw ChaiException
        convertNamingException( e );
    }

    return null;
}
 
Example #5
Source File: RetryingLdapContext.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
public ExtendedResponse extendedOperation(final ExtendedRequest request) throws NamingException {
    return (ExtendedResponse) new LoggingRetryHandler(DEFAULT_EXCEPTION_CLASSES, this, getSchedule(), getMaxRetries()) {
            @Override
            public Object operation() throws NamingException {
                return ((LdapContext) getDelegate()).extendedOperation(request);
            }
        }.perform();
}
 
Example #6
Source File: LdapContextWrapper.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
@Override
public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException {

    return ldapContext.extendedOperation(request);
}
 
Example #7
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public ExtendedResponse extendedOperation(ExtendedRequest extendedRequest)
        throws NamingException {
    return getLdapContext().extendedOperation(extendedRequest);
}
 
Example #8
Source File: DelegatingLdapContext.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException {
    if (!(delegating instanceof LdapContext))
        throw Assert.unsupported();
    return ((LdapContext) delegating).extendedOperation(request);
}
 
Example #9
Source File: JavaStoredProcUtils.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Invoke a Stored Procedure
 *
 * @param ctx The execution context
 * @param procedureName The procedure to execute
 * @param arguments The procedure's arguments
 * @return The execution resut
 * @throws NamingException If we have had an error whil executing the stored procedure
 */
public static Object callStoredProcedure( LdapContext ctx, String procedureName, Object[] arguments )
    throws NamingException
{
    String language = "Java";

    Object responseObject;
    try
    {
        /**
         * Create a new stored procedure execution request.
         */
        StoredProcedureRequestImpl req = new StoredProcedureRequestImpl( 0, procedureName, language );

        /**
         * For each argument UTF-8-encode the type name
         * and Java-serialize the value
         * and add them to the request as a parameter object.
         */
        for ( int i = 0; i < arguments.length; i++ )
        {
            byte[] type;
            byte[] value;
            type = arguments[i].getClass().getName().getBytes( StandardCharsets.UTF_8 );
            value = SerializationUtils.serialize( ( Serializable ) arguments[i] );
            req.addParameter( type, value );
        }

        /**
         * Call the stored procedure via the extended operation
         * and get back its return value.
         */
        ExtendedRequest jndiReq = LdapApiServiceFactory.getSingleton().toJndi( req );
        ExtendedResponse resp = ctx.extendedOperation( jndiReq );

        /**
         * Restore a Java object from the return value.
         */
        byte[] responseStream = resp.getEncodedValue();
        responseObject = SerializationUtils.deserialize( responseStream );
    }
    catch ( Exception e )
    {
        NamingException ne = new NamingException();
        ne.setRootCause( e );
        throw ne;
    }

    return responseObject;
}
 
Example #10
Source File: ApacheLdapProviderImpl.java    From ldapchai with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void preCheckExtendedOperation( final ExtendedRequest request )
        throws ChaiOperationException
{
    super.preCheckExtendedOperation( request );
}
 
Example #11
Source File: ApacheLdapProviderImpl.java    From ldapchai with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void cacheExtendedOperationException( final ExtendedRequest request, final Exception e )
        throws ChaiOperationException
{
    super.cacheExtendedOperationException( request, e );
}
 
Example #12
Source File: WatchdogWrapper.java    From ldapchai with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public ExtendedResponse extendedOperation( final ExtendedRequest request )
        throws ChaiOperationException, ChaiUnavailableException, IllegalStateException
{
    return providerHolder.execute( chaiProvider -> chaiProvider.extendedOperation( request ) );
}
 
Example #13
Source File: InitialLdapContext.java    From entando-components with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedResponse extendedOperation(ExtendedRequest er) throws NamingException {
	ExtendedResponse extResponse = super.extendedOperation(er);
	this.setExtendedResponse(extResponse);
	return extResponse;
}
 
Example #14
Source File: DelegatingLdapContext.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
/**
 * @see javax.naming.ldap.LdapContext#extendedOperation(javax.naming.ldap.ExtendedRequest)
 */
public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException {
    this.assertOpen();
    return this.getDelegateLdapContext().extendedOperation(request);
}
 
Example #15
Source File: DelegatingLdapContext.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
/**
 * @see LdapContext#extendedOperation(ExtendedRequest)
 */
public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException {
    this.assertOpen();
    return this.getDelegateLdapContext().extendedOperation(request);
}
 
Example #16
Source File: ChaiProvider.java    From ldapchai with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Performs an extended operation against the server.  The extended operation must be understood by the server.
 *
 * @param request An ExtendedRequest bean that can be
 * @return An ExtendedResponse created in response to the request.
 * @throws ChaiOperationException   If an error is encountered during the operation
 * @throws ChaiUnavailableException If no directory servers are reachable
 * @throws IllegalStateException    If the underlying connection is not in an available state
 * @see ExtendedRequest
 * @see ExtendedResponse
 */
@ChaiProvider.LdapOperation
@ChaiProvider.ModifyOperation
ExtendedResponse extendedOperation( ExtendedRequest request )
        throws ChaiOperationException, ChaiUnavailableException, IllegalStateException;