Java Code Examples for javax.security.auth.message.config.AuthConfigFactory#removeRegistration()

The following examples show how to use javax.security.auth.message.config.AuthConfigFactory#removeRegistration() . 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: TestAuthConfigFactoryImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private void doTestResistration(String layer, String appContext, String expectedRegId) {
    AuthConfigFactory factory = new AuthConfigFactoryImpl();
    AuthConfigProvider acp1 = new SimpleAuthConfigProvider(null, null);
    SimpleRegistrationListener listener = new SimpleRegistrationListener(layer, appContext);

    String regId = factory.registerConfigProvider(acp1, layer, appContext, null);
    Assert.assertEquals(expectedRegId, regId);

    factory.getConfigProvider(layer, appContext, listener);
    factory.removeRegistration(regId);
    Assert.assertTrue(listener.wasCorrectlyCalled());

    listener.reset();
    factory.registerConfigProvider(acp1, layer, appContext, null);
    factory.getConfigProvider(layer, appContext, listener);
    // Replace it
    AuthConfigProvider acp2 = new SimpleAuthConfigProvider(null, null);
    factory.registerConfigProvider(acp2, layer, appContext, null);
    Assert.assertTrue(listener.wasCorrectlyCalled());
}
 
Example 2
Source File: TestAuthConfigFactoryImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testRemovePersistentRegistration() {
        AuthConfigFactory factory = new AuthConfigFactoryImpl();
        factory.registerConfigProvider(
                SimpleAuthConfigProvider.class.getName(), null, "L_1", "AC_1", null);
        String registrationId2 = factory.registerConfigProvider(
                SimpleAuthConfigProvider.class.getName(), null, "L_2", "AC_2", null);

        factory.removeRegistration(registrationId2);
        factory.refresh();

        String[] registrationIds = factory.getRegistrationIDs(null);
        for (String registrationId : registrationIds) {
            Assert.assertNotEquals(registrationId2, registrationId);
        }
}
 
Example 3
Source File: TestAuthConfigFactoryImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testDetachListenerNonexistingRegistration() {
    AuthConfigFactory factory = new AuthConfigFactoryImpl();
    AuthConfigProvider acp1 = new SimpleAuthConfigProvider(null, null);
    String registrationId = factory.registerConfigProvider(acp1, "L_1", "AC_1", null);

    SimpleRegistrationListener listener1 = new SimpleRegistrationListener("L_1", "AC_1");
    factory.getConfigProvider("L_1", "AC_1", listener1);

    factory.removeRegistration(registrationId);
    String[] registrationIds = factory.detachListener(listener1, "L_1", "AC_1");
    Assert.assertTrue(registrationIds.length == 0);
}
 
Example 4
Source File: TestAuthConfigFactoryImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testRegistrationNullListener() {
    AuthConfigFactory factory = new AuthConfigFactoryImpl();
    AuthConfigProvider acp1 = new SimpleAuthConfigProvider(null, null);
    String registrationId = factory.registerConfigProvider(acp1, "L_1", "AC_1", null);

    factory.getConfigProvider("L_1", "AC_1", null);

    boolean result = factory.removeRegistration(registrationId);
    Assert.assertTrue(result);
}
 
Example 5
Source File: JaspiDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void removeRegistration(final OperationContext context) {
    final String registrationId = REGISTRATION_MAP.remove(context.getCurrentAddressValue());
    if (registrationId != null) {
        AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory();
        authConfigFactory.removeRegistration(registrationId);
    }
}