use of io.apiman.common.util.crypt.IDataEncrypter in project apiman by apiman.
the class AesDataEncrypterTest method dataEncrypterWithKey.
@Test
public void dataEncrypterWithKey() {
Map<String, String> config = new HashMap<>();
config.put("secretKey", "a2a0aa80-84Zd2a6");
IDataEncrypter dataEncrypter = new AesDataEncrypter(config);
String result = dataEncrypter.encrypt("Hello, world.", encryptionCtx);
assertNotNull(result);
assertEquals("$CRYPT::XtwdsXC3Tv6vlQXQQPrxdg==", result);
result = dataEncrypter.decrypt(result, encryptionCtx);
assertEquals("Hello, world.", result);
}
use of io.apiman.common.util.crypt.IDataEncrypter in project apiman by apiman.
the class AesDataEncrypterTest method dataEncrypterWithDifferentKey.
@Test
public void dataEncrypterWithDifferentKey() {
Map<String, String> config = new HashMap<>();
config.put("secretKey", "H2a9a780-m4Zd2a0");
IDataEncrypter dataEncrypter = new AesDataEncrypter(config);
String result = dataEncrypter.encrypt("Hello, world.", encryptionCtx);
assertNotNull(result);
assertEquals("$CRYPT::dLklbimUARc6EfsrxpSG2Q==", result);
result = dataEncrypter.decrypt(result, encryptionCtx);
assertEquals("Hello, world.", result);
}
use of io.apiman.common.util.crypt.IDataEncrypter in project apiman by apiman.
the class AesDataEncrypterTest method dataEncrypterWithoutKey.
@Test(expected = RuntimeException.class)
public void dataEncrypterWithoutKey() {
Map<String, String> config = new HashMap<>();
IDataEncrypter dataEncrypter = new AesDataEncrypter(config);
dataEncrypter.encrypt("Hello, world.", encryptionCtx);
}
use of io.apiman.common.util.crypt.IDataEncrypter in project apiman by apiman.
the class ManagerApiMicroServiceCdiFactory method provideDataEncrypter.
@Produces
@ApplicationScoped
public static IDataEncrypter provideDataEncrypter(ManagerApiMicroServiceConfig config, IPluginRegistry pluginRegistry, @New DefaultDataEncrypter defaultEncrypter) {
try {
IDataEncrypter encrypter = createCustomComponent(IDataEncrypter.class, config.getDataEncrypterType(), config.getDataEncrypterProperties(), pluginRegistry, defaultEncrypter);
CurrentDataEncrypter.instance = encrypter;
return encrypter;
} catch (Throwable t) {
// $NON-NLS-1$
throw new RuntimeException("Error or unknown data encrypter type: " + config.getDataEncrypterType(), t);
}
}
use of io.apiman.common.util.crypt.IDataEncrypter in project apiman by apiman.
the class ConfigDrivenEngineFactory method createDataEncrypter.
/**
* @see io.apiman.gateway.engine.impl.AbstractEngineFactory#createDataEncrypter(io.apiman.gateway.engine.IPluginRegistry)
*/
@Override
protected IDataEncrypter createDataEncrypter(IPluginRegistry pluginRegistry) {
try {
Class<? extends IDataEncrypter> c = engineConfig.getDataEncrypterClass(pluginRegistry);
Map<String, String> config = engineConfig.getDataEncrypterConfig();
IDataEncrypter encrypter = create(c, config);
return encrypter;
} catch (RuntimeException e) {
if ("No IDataEncrypter class configured.".equals(e.getMessage())) {
// $NON-NLS-1$
// $NON-NLS-1$ //$NON-NLS-2$
LOGGER.info("NOTE: No explicit Data Encrypter found. Falling back to the Default. [" + e.getMessage() + "]");
return new DefaultDataEncrypter();
} else {
throw e;
}
}
}
Aggregations