use of org.infinispan.commons.configuration.ClassAllowList in project infinispan by infinispan.
the class JavaSerializationTranscoderTest method setUp.
@BeforeClass(alwaysRun = true)
public void setUp() {
dataSrc = new Person("Joe");
Address address = new Address();
address.setCity("London");
dataSrc.setAddress(address);
transcoder = new JavaSerializationTranscoder(new ClassAllowList(Collections.singletonList(".*")));
supportedMediaTypes = transcoder.getSupportedMediaTypes();
}
use of org.infinispan.commons.configuration.ClassAllowList in project infinispan by infinispan.
the class JbossMarshallingModule method cacheManagerStarting.
@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
PERSISTENCE.jbossMarshallingDetected();
Marshaller userMarshaller = globalConfiguration.serialization().marshaller();
if (userMarshaller instanceof JBossUserMarshaller) {
// Core automatically registers a transcoder for the user marshaller
// Initialize the externalizers from the serialization configuration
((JBossUserMarshaller) userMarshaller).initialize(gcr);
} else {
// Register a JBoss Marshalling transcoder, ignoring any configured externalizers
ClassAllowList classAllowList = gcr.getComponent(EmbeddedCacheManager.class).getClassAllowList();
ClassLoader classLoader = globalConfiguration.classLoader();
GenericJBossMarshaller jbossMarshaller = new GenericJBossMarshaller(classLoader, classAllowList);
EncoderRegistry encoderRegistry = gcr.getComponent(EncoderRegistry.class);
encoderRegistry.registerTranscoder(new JBossMarshallingTranscoder(jbossMarshaller));
}
}
use of org.infinispan.commons.configuration.ClassAllowList in project infinispan by infinispan.
the class EncoderRegistryFactory method construct.
@Override
public Object construct(String componentName) {
ClassLoader classLoader = globalConfiguration.classLoader();
EncoderRegistryImpl encoderRegistry = new EncoderRegistryImpl();
ClassAllowList classAllowList = embeddedCacheManager.getClassAllowList();
encoderRegistry.registerEncoder(IdentityEncoder.INSTANCE);
encoderRegistry.registerEncoder(UTF8Encoder.INSTANCE);
encoderRegistry.registerEncoder(new JavaSerializationEncoder(classAllowList));
encoderRegistry.registerEncoder(new GlobalMarshallerEncoder(globalMarshaller.wired()));
// Default and binary transcoder use the user marshaller to convert data to/from a byte array
encoderRegistry.registerTranscoder(new DefaultTranscoder(userMarshaller));
encoderRegistry.registerTranscoder(new BinaryTranscoder(userMarshaller));
// Core transcoders are always available
encoderRegistry.registerTranscoder(new ProtostreamTranscoder(ctxRegistry, classLoader));
encoderRegistry.registerTranscoder(new JavaSerializationTranscoder(classAllowList));
// Wraps the GlobalMarshaller so that it can be used as a transcoder
// Keeps application/x-infinispan-marshalling available for backwards compatibility
encoderRegistry.registerTranscoder(new TranscoderMarshallerAdapter(globalMarshaller.wired()));
// Make the user marshaller's media type available as well
// As custom marshaller modules like Kryo and Protostuff do not define their own transcoder
encoderRegistry.registerTranscoder(new TranscoderMarshallerAdapter(userMarshaller));
encoderRegistry.registerWrapper(ByteArrayWrapper.INSTANCE);
encoderRegistry.registerWrapper(IdentityWrapper.INSTANCE);
return encoderRegistry;
}
use of org.infinispan.commons.configuration.ClassAllowList in project infinispan by infinispan.
the class PersistenceMockUtil method mockCache.
private static Cache mockCache(String nodeName, Configuration configuration, TimeService timeService, ClassAllowList allowList, ScheduledExecutorService timeoutScheduledExecutor) {
String cacheName = "mock-cache";
AdvancedCache cache = mock(AdvancedCache.class, RETURNS_DEEP_STUBS);
GlobalConfiguration gc = new GlobalConfigurationBuilder().transport().nodeName(nodeName).build();
Set<String> cachesSet = new HashSet<>();
EmbeddedCacheManager cm = mock(EmbeddedCacheManager.class);
when(cm.getCacheManagerConfiguration()).thenReturn(gc);
when(cm.getClassAllowList()).thenReturn(new ClassAllowList());
GlobalComponentRegistry gcr = new GlobalComponentRegistry(gc, cm, cachesSet, TestModuleRepository.defaultModuleRepository(), mock(ConfigurationManager.class));
BasicComponentRegistry gbcr = gcr.getComponent(BasicComponentRegistry.class);
gbcr.replaceComponent(TimeService.class.getName(), timeService, true);
gbcr.replaceComponent(KnownComponentNames.TIMEOUT_SCHEDULE_EXECUTOR, timeoutScheduledExecutor, false);
ComponentRegistry registry = new ComponentRegistry(cacheName, configuration, cache, gcr, configuration.getClass().getClassLoader());
when(cache.getCacheManager().getGlobalComponentRegistry()).thenReturn(gcr);
when(cache.getClassLoader()).thenReturn(PersistenceMockUtil.class.getClassLoader());
when(cache.getCacheManager().getCacheManagerConfiguration()).thenReturn(gc);
when(cache.getCacheManager().getClassAllowList()).thenReturn(allowList);
when(cache.getName()).thenReturn(cacheName);
when(cache.getAdvancedCache()).thenReturn(cache);
when(cache.getComponentRegistry()).thenReturn(registry);
when(cache.getStatus()).thenReturn(ComponentStatus.RUNNING);
when(cache.getCacheConfiguration()).thenReturn(configuration);
return cache;
}
use of org.infinispan.commons.configuration.ClassAllowList in project infinispan by infinispan.
the class BinaryTranscoderTest method prepare.
@BeforeClass
public static void prepare() {
final ClassAllowList allowList = new ClassAllowList();
allowList.addRegexps(".*");
marshaller = new JavaSerializationMarshaller(allowList);
binaryTranscoder = new BinaryTranscoder(marshaller);
}
Aggregations