use of org.talend.sdk.component.api.DecryptedServer in project component-runtime by Talend.
the class BaseMavenDecrypter method createInstance.
public Server createInstance(final DecryptedServer config) {
if (config.alwaysTryLookup()) {
try {
return new MavenDecrypter().find(config.value());
} catch (final IllegalArgumentException iae) {
if (ifActive(config.conditions())) {
throw iae;
}
}
} else if (ifActive(config.conditions())) {
return new MavenDecrypter().find(config.value());
}
final Server server = new Server();
server.setUsername(config.defaultUsername());
server.setPassword(config.defaultPassword());
return server;
}
use of org.talend.sdk.component.api.DecryptedServer in project component-runtime by Talend.
the class MavenDecrypterRule method doInject.
private void doInject(final Object instance, final Class<?> base) {
Stream.of(base.getDeclaredFields()).filter(f -> f.isAnnotationPresent(DecryptedServer.class)).forEach(f -> {
final DecryptedServer annotation = f.getAnnotation(DecryptedServer.class);
final Server server = decrypter.createInstance(annotation);
if (!f.isAccessible()) {
f.setAccessible(true);
}
try {
f.set(instance, server);
} catch (final IllegalAccessException e) {
throw new IllegalStateException(e);
}
});
ofNullable(base.getSuperclass()).filter(s -> s != Object.class).ifPresent(c -> doInject(instance, c));
}
Aggregations