@NotNull @Override public TokenProvider getTokenProvider(final Root root) { List<TokenProvider> providers = Lists.transform(getConfigurations(), new Function<TokenConfiguration, TokenProvider>() { @Override public TokenProvider apply(TokenConfiguration tokenConfiguration) { return tokenConfiguration.getTokenProvider(root); } }); return CompositeTokenProvider.newInstance(providers); } }
@SuppressWarnings("UnusedDeclaration") protected void bindTokenConfiguration(@Nonnull TokenConfiguration reference) { tokenConfiguration.addConfiguration(initConfiguration(reference)); }
@SuppressWarnings("UnusedDeclaration") protected void unbindTokenConfiguration(@NotNull TokenConfiguration reference) { tokenConfiguration.removeConfiguration(reference); }
CompositeTokenConfiguration tc = new CompositeTokenConfiguration(); tc.setDefaultConfig(initializeConfiguration(new TokenConfigurationImpl(), securityProvider, rootProvider, treeProvider)); tokenConfiguration = tc;
@Before public void before() throws Exception { super.before(); credentialsSupport = getCredentialsSupport(); // NOTE: should be replaced by proper OSGi setup CompositeTokenConfiguration composite = ((CompositeTokenConfiguration) getSecurityProvider().getConfiguration(TokenConfiguration.class)); tc = (TokenConfigurationImpl) composite.getDefaultConfig(); tc.bindCredentialsSupport(credentialsSupport); }
@Before public void before() { compositeConfiguration = new CompositeTokenConfiguration(createSecurityProvider()); }
@Test public void testGetTokenProvider() { CompositeTokenConfiguration ctc = (CompositeTokenConfiguration) compositeConfiguration; Root root = Mockito.mock(Root.class); TokenProvider tp = ctc.getTokenProvider(root); assertNotNull(tp); assertFalse(tp instanceof CompositeTokenProvider); TokenConfiguration tc = createTokenConfiguration(); setDefault(tc); tp = ctc.getTokenProvider(root); assertNotNull(tp); assertFalse(tp instanceof CompositeTokenProvider); addConfiguration(tc); tp = ctc.getTokenProvider(root); assertNotNull(tp); assertFalse(tp instanceof CompositeTokenProvider); addConfiguration(createTokenConfiguration()); tp = ctc.getTokenProvider(root); assertNotNull(tp); assertTrue(tp instanceof CompositeTokenProvider); }
CompositeTokenConfiguration tc = new CompositeTokenConfiguration(); tc.setDefaultConfig(initializeConfiguration(new TokenConfigurationImpl(), securityProvider, rootProvider, treeProvider)); tokenConfiguration = tc;
@Override @Before public void before() throws Exception { super.before(); userId = getTestUser().getID(); credentialsSupport = new TestCredentialsSupport(userId); CompositeTokenConfiguration composite = ((CompositeTokenConfiguration) getSecurityProvider().getConfiguration(TokenConfiguration.class)); tc = (TokenConfigurationImpl) composite.getDefaultConfig(); tc.bindCredentialsSupport(credentialsSupport); }
@Test public void testEmptyConstructor() { TokenConfiguration composite = new CompositeTokenConfiguration(); assertEquals(TokenConfiguration.NAME, composite.getName()); }
@Nonnull @Override public TokenProvider getTokenProvider(final Root root) { List<TokenProvider> providers = Lists.transform(getConfigurations(), new Function<TokenConfiguration, TokenProvider>() { @Override public TokenProvider apply(TokenConfiguration tokenConfiguration) { return tokenConfiguration.getTokenProvider(root); } }); return CompositeTokenProvider.newInstance(providers); } }
@SuppressWarnings("UnusedDeclaration") protected void unbindTokenConfiguration(@NotNull TokenConfiguration reference) { tokenConfiguration.removeConfiguration(reference); }
@SuppressWarnings("UnusedDeclaration") protected void bindTokenConfiguration(@NotNull TokenConfiguration reference) { tokenConfiguration.addConfiguration(initConfiguration(reference)); }
@Test public void testBindUnbindTokenConfiguration() throws Exception { Field f = registration.getClass().getDeclaredField("tokenConfiguration"); f.setAccessible(true); assertTrue(f.get(registration) instanceof CompositeTokenConfiguration); TokenConfiguration tc = mockConfiguration(TokenConfiguration.class); registration.bindTokenConfiguration(tc, PROPS); CompositeTokenConfiguration composite = (CompositeTokenConfiguration) f.get(registration); assertEquals(1, composite.getConfigurations().size()); assertTrue(composite.getConfigurations().contains(tc)); registration.unbindTokenConfiguration(tc, PROPS); composite = (CompositeTokenConfiguration) f.get(registration); assertTrue(composite.getConfigurations().isEmpty()); }
@SuppressWarnings("UnusedDeclaration") protected void unbindTokenConfiguration(@Nonnull TokenConfiguration reference) { tokenConfiguration.removeConfiguration(reference); }
@SuppressWarnings("UnusedDeclaration") protected void bindTokenConfiguration(@NotNull TokenConfiguration reference) { tokenConfiguration.addConfiguration(initConfiguration(reference)); }