use of com.google.inject.TypeLiteral in project xades4j by luisgoncalves.
the class DefaultVerificationBindingsModule method configure.
@Override
protected void configure() {
bind(MessageDigestEngineProvider.class).to(DefaultMessageDigestProvider.class);
bind(TimeStampVerificationProvider.class).to(DefaultTimeStampVerificationProvider.class);
bind(SignaturePolicyDocumentProvider.class).toInstance(new SignaturePolicyDocumentProvider() {
@Override
public InputStream getSignaturePolicyDocumentStream(ObjectIdentifier sigPolicyId) {
return null;
}
});
// QualifyingPropertiesVerifier is not configurable but the individual
// verifiers may have dependencies.
bind(QualifyingPropertiesVerifier.class).to(QualifyingPropertiesVerifierImpl.class);
bind(QualifyingPropertyVerifiersMapper.class).to(QualifyingPropertyVerifiersMapperImpl.class);
// customGlobalStructureVerifiers.add(new CustomPropertiesDataObjsStructureVerifier()
// {
// @Override
// public void verifiy(DataGetter<PropertyDataObject> dataObjsGetter) throws PropertyDataStructureException
// {
// if (dataObjsGetter.getOfType(SigningCertificateData.class).isEmpty())
// throw new PropertyDataStructureException("property is required and isn't present", SigningCertificateProperty.PROP_NAME);
// }
// });
// QualifyingPropertyVerifiersMapperImpl relies on the injector to get
// the individual verifiers, so they need to be bound.
// - SignedSignatureProperties
bindBuiltInVerifier(SigningTimeData.class, SigningTimeVerifier.class);
bindBuiltInVerifier(SignerRoleData.class, SignerRoleVerifier.class);
bindBuiltInVerifier(SignatureProdPlaceData.class, SigProdPlaceVerifier.class);
bindBuiltInVerifier(SigningCertificateData.class, SigningCertificateVerifier.class);
bindBuiltInVerifier(SignaturePolicyData.class, SignaturePolicyVerifier.class);
// - SignedDataObjectProperties
bindBuiltInVerifier(CommitmentTypeData.class, CommitmentTypeVerifier.class);
bindBuiltInVerifier(DataObjectFormatData.class, DataObjFormatVerifier.class);
bindBuiltInVerifier(AllDataObjsTimeStampData.class, AllDataObjsTimeStampVerifier.class);
bindBuiltInVerifier(IndividualDataObjsTimeStampData.class, IndivDataObjsTimeStampVerifier.class);
// - UnsignedSignatureProperties
bindBuiltInVerifier(SignatureTimeStampData.class, SignatureTimeStampVerifier.class);
bindBuiltInVerifier(CompleteCertificateRefsData.class, CompleteCertRefsVerifier.class);
bindBuiltInVerifier(CompleteRevocationRefsData.class, CompleteRevocRefsVerifier.class);
MapBinder<QName, QualifyingPropertyVerifier> unkownElemsBinder = MapBinder.newMapBinder(binder(), QName.class, QualifyingPropertyVerifier.class);
unkownElemsBinder.addBinding(new QName(QualifyingProperty.XADES_XMLNS, CounterSignatureProperty.PROP_NAME)).to(CounterSignatureVerifier.class);
// Verification based on XML elements names.
bind(new TypeLiteral<QualifyingPropertyVerifier<GenericDOMData>>() {
}).to(GenericDOMDataVerifier.class);
// Ensure empty sets when no bindings are defined
Multibinder.newSetBinder(binder(), RawSignatureVerifier.class);
Multibinder.newSetBinder(binder(), CustomSignatureVerifier.class);
Multibinder.newSetBinder(binder(), CustomPropertiesDataObjsStructureVerifier.class);
}
use of com.google.inject.TypeLiteral in project xades4j by luisgoncalves.
the class DefaultVerificationBindingsModule method bindBuiltInVerifier.
private <TData extends PropertyDataObject> void bindBuiltInVerifier(Class<TData> dataObjectClass, Class<? extends QualifyingPropertyVerifier<TData>> verifierClass) {
ParameterizedType pt = Types.newParameterizedType(QualifyingPropertyVerifier.class, dataObjectClass);
TypeLiteral<QualifyingPropertyVerifier<TData>> tl = (TypeLiteral<QualifyingPropertyVerifier<TData>>) TypeLiteral.get(pt);
bind(tl).to(verifierClass);
bind(tl).annotatedWith(BuiltIn.class).to(verifierClass);
}
use of com.google.inject.TypeLiteral in project cdap by caskdata.
the class DatasetServiceTestBase method initializeAndStartService.
protected static void initializeAndStartService(CConfiguration cConf) throws Exception {
// TODO: this whole method is a mess. Streamline it!
injector = Guice.createInjector(new ConfigModule(cConf), new DiscoveryRuntimeModule().getInMemoryModules(), new NonCustomLocationUnitTestModule().getModule(), new NamespaceClientRuntimeModule().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionInMemoryModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new AbstractModule() {
@Override
protected void configure() {
bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Singleton.class);
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
// through the injector, we only need RemoteDatasetFramework in these tests
bind(RemoteDatasetFramework.class);
bind(OwnerStore.class).to(InMemoryOwnerStore.class);
bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
}
});
AuthorizationEnforcer authEnforcer = injector.getInstance(AuthorizationEnforcer.class);
AuthenticationContext authenticationContext = injector.getInstance(AuthenticationContext.class);
DiscoveryService discoveryService = injector.getInstance(DiscoveryService.class);
discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
dsFramework = injector.getInstance(RemoteDatasetFramework.class);
// Tx Manager to support working with datasets
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
TransactionSystemClient txSystemClient = injector.getInstance(TransactionSystemClient.class);
TransactionSystemClientService txSystemClientService = new DelegatingTransactionSystemClientService(txSystemClient);
NamespacedLocationFactory namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
SystemDatasetInstantiatorFactory datasetInstantiatorFactory = new SystemDatasetInstantiatorFactory(locationFactory, dsFramework, cConf);
// ok to pass null, since the impersonator won't actually be called, if kerberos security is not enabled
Impersonator impersonator = new DefaultImpersonator(cConf, null);
DatasetAdminService datasetAdminService = new DatasetAdminService(dsFramework, cConf, locationFactory, datasetInstantiatorFactory, new NoOpMetadataStore(), impersonator);
ImmutableSet<HttpHandler> handlers = ImmutableSet.<HttpHandler>of(new DatasetAdminOpHTTPHandler(datasetAdminService));
MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
opExecutorService = new DatasetOpExecutorService(cConf, discoveryService, metricsCollectionService, handlers);
opExecutorService.startAndWait();
Map<String, DatasetModule> defaultModules = injector.getInstance(Key.get(new TypeLiteral<Map<String, DatasetModule>>() {
}, Constants.Dataset.Manager.DefaultDatasetModules.class));
ImmutableMap<String, DatasetModule> modules = ImmutableMap.<String, DatasetModule>builder().putAll(defaultModules).putAll(DatasetMetaTableUtil.getModules()).build();
registryFactory = injector.getInstance(DatasetDefinitionRegistryFactory.class);
inMemoryDatasetFramework = new InMemoryDatasetFramework(registryFactory, modules);
DiscoveryExploreClient exploreClient = new DiscoveryExploreClient(discoveryServiceClient, authenticationContext);
ExploreFacade exploreFacade = new ExploreFacade(exploreClient, cConf);
namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
namespaceAdmin.create(NamespaceMeta.DEFAULT);
ownerAdmin = injector.getInstance(OwnerAdmin.class);
NamespaceQueryAdmin namespaceQueryAdmin = injector.getInstance(NamespaceQueryAdmin.class);
TransactionExecutorFactory txExecutorFactory = new DynamicTransactionExecutorFactory(txSystemClient);
DatasetTypeManager typeManager = new DatasetTypeManager(cConf, locationFactory, txSystemClientService, txExecutorFactory, inMemoryDatasetFramework, impersonator);
DatasetOpExecutor opExecutor = new InMemoryDatasetOpExecutor(dsFramework);
DatasetInstanceManager instanceManager = new DatasetInstanceManager(txSystemClientService, txExecutorFactory, inMemoryDatasetFramework);
DatasetTypeService noAuthTypeService = new DefaultDatasetTypeService(typeManager, namespaceAdmin, namespacedLocationFactory, cConf, impersonator, txSystemClientService, inMemoryDatasetFramework, defaultModules);
DatasetTypeService typeService = new AuthorizationDatasetTypeService(noAuthTypeService, authEnforcer, authenticationContext);
instanceService = new DatasetInstanceService(typeService, noAuthTypeService, instanceManager, opExecutor, exploreFacade, namespaceQueryAdmin, ownerAdmin, authEnforcer, authenticationContext);
service = new DatasetService(cConf, discoveryService, discoveryServiceClient, metricsCollectionService, opExecutor, new HashSet<DatasetMetricsReporter>(), typeService, instanceService);
// Start dataset service, wait for it to be discoverable
service.startAndWait();
waitForService(Constants.Service.DATASET_EXECUTOR);
waitForService(Constants.Service.DATASET_MANAGER);
// this usually happens while creating a namespace, however not doing that in data fabric tests
Locations.mkdirsIfNotExists(namespacedLocationFactory.get(NamespaceId.DEFAULT));
}
use of com.google.inject.TypeLiteral in project joynr by bmwcarit.
the class CcMessageRouterTest method setUp.
@Before
public void setUp() throws Exception {
when(middlewareMessagingStubFactoryMock.create(any(ChannelAddress.class))).thenReturn(messagingStubMock);
AbstractModule mockModule = new AbstractModule() {
private Long msgRetryIntervalMs = 10L;
// message runnables + cleanup thread
private int numberOfThreads = maximumParallelSends + 1;
private long routingTableGracePeriodMs = 30000;
private long routingTableCleanupIntervalMs = 60000;
@Override
protected void configure() {
bind(MessageRouter.class).to(CcMessageRouter.class);
bind(RoutingTable.class).toInstance(routingTable);
bind(AddressManager.class).toInstance(addressManager);
bind(MulticastReceiverRegistry.class).toInstance(multicastReceiverRegistry);
bind(ShutdownNotifier.class).toInstance(shutdownNotifier);
bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_SEND_MSG_RETRY_INTERVAL_MS)).toInstance(msgRetryIntervalMs);
bind(Integer.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_MESSAGING_MAXIMUM_PARALLEL_SENDS)).toInstance(maximumParallelSends);
bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_ROUTING_TABLE_GRACE_PERIOD_MS)).toInstance(routingTableGracePeriodMs);
bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_ROUTING_TABLE_CLEANUP_INTERVAL_MS)).toInstance(routingTableCleanupIntervalMs);
bindConstant().annotatedWith(Names.named(ClusterControllerRuntimeModule.PROPERTY_ACCESSCONTROL_ENABLE)).to(false);
bind(AccessController.class).toInstance(Mockito.mock(AccessController.class));
bind(StatusReceiver.class).toInstance(statusReceiver);
MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
}, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
}, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
messagingStubFactory.addBinding(ChannelAddress.class).toInstance(middlewareMessagingStubFactoryMock);
MapBinder<Class<? extends Address>, IMessagingSkeleton> messagingSkeletonFactory;
messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
}, new TypeLiteral<IMessagingSkeleton>() {
}, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
messagingSkeletonFactory.addBinding(ChannelAddress.class).toInstance(messagingSkeletonMock);
Multibinder.newSetBinder(binder(), new TypeLiteral<MulticastAddressCalculator>() {
});
}
@Provides
@Named(MessageRouter.SCHEDULEDTHREADPOOL)
ScheduledExecutorService provideMessageSchedulerThreadPoolExecutor() {
ThreadFactory schedulerNamedThreadFactory = new ThreadFactoryBuilder().setNameFormat("joynr.MessageScheduler-scheduler-%d").build();
ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(numberOfThreads, schedulerNamedThreadFactory);
scheduler.setKeepAliveTime(100, TimeUnit.SECONDS);
scheduler.allowCoreThreadTimeOut(true);
return scheduler;
}
};
testModule = Modules.override(mockModule).with(new TestGlobalAddressModule());
Injector injector = Guice.createInjector(testModule);
messageRouter = injector.getInstance(MessageRouter.class);
ObjectMapper objectMapper = new ObjectMapper();
messageFactory = new MutableMessageFactory(objectMapper, new HashSet<JoynrMessageProcessor>());
// toParticipantId is globally visible
final boolean isGloballyVisible = true;
final long expiryDateMs = Long.MAX_VALUE;
final boolean isSticky = true;
final boolean allowUpdate = false;
routingTable.put(toParticipantId, channelAddress, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
Request request = new Request("noMethod", new Object[] {}, new String[] {}, "requestReplyId");
joynrMessage = messageFactory.createRequest(fromParticipantId, toParticipantId, request, new MessagingQos());
joynrMessage.setLocalMessage(true);
}
use of com.google.inject.TypeLiteral in project joynr by bmwcarit.
the class JeeJoynrIntegrationModule method configure.
@Override
protected void configure() {
bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(scheduledExecutorService);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(JoynrInjectionConstants.JOYNR_SCHEDULER_CLEANUP)).toInstance(scheduledExecutorService);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(LocalCapabilitiesDirectory.JOYNR_SCHEDULER_CAPABILITIES_FRESHNESS)).toInstance(scheduledExecutorService);
bind(ExecutorService.class).toInstance(scheduledExecutorService);
MapBinder<Class<? extends Address>, IMessagingSkeleton> messagingSkeletonFactory;
messagingSkeletonFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
}, new TypeLiteral<IMessagingSkeleton>() {
}, Names.named(MessagingSkeletonFactory.MIDDLEWARE_MESSAGING_SKELETONS));
MapBinder<Class<? extends Address>, AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>> messagingStubFactory;
messagingStubFactory = MapBinder.newMapBinder(binder(), new TypeLiteral<Class<? extends Address>>() {
}, new TypeLiteral<AbstractMiddlewareMessagingStubFactory<? extends IMessagingStub, ? extends Address>>() {
}, Names.named(MessagingStubFactory.MIDDLEWARE_MESSAGING_STUB_FACTORIES));
Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
install(new JeeHttpMessagingModule(messagingSkeletonFactory, messagingStubFactory));
install(new HttpBridgeEndpointRegistryClientModule());
install(new JeeMqttMessageSendingModule(messagingSkeletonFactory, messagingStubFactory));
}
Aggregations