Search in sources :

Example 1 with Server

use of org.talend.sdk.component.maven.Server 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;
}
Also used : DecryptedServer(org.talend.sdk.component.api.DecryptedServer) Server(org.talend.sdk.component.maven.Server) MavenDecrypter(org.talend.sdk.component.maven.MavenDecrypter)

Example 2 with Server

use of org.talend.sdk.component.maven.Server 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));
}
Also used : Statement(org.junit.runners.model.Statement) Stream(java.util.stream.Stream) TestRule(org.junit.rules.TestRule) BaseMavenDecrypter(org.talend.sdk.component.base.BaseMavenDecrypter) Optional.ofNullable(java.util.Optional.ofNullable) DecryptedServer(org.talend.sdk.component.api.DecryptedServer) Server(org.talend.sdk.component.maven.Server) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Description(org.junit.runner.Description) DecryptedServer(org.talend.sdk.component.api.DecryptedServer) Server(org.talend.sdk.component.maven.Server) DecryptedServer(org.talend.sdk.component.api.DecryptedServer)

Example 3 with Server

use of org.talend.sdk.component.maven.Server in project component-runtime by Talend.

the class Github method main.

public static void main(final String[] args) {
    final Server server = new MavenDecrypter().find("github");
    final Collection<Contributor> contributors = new Github(server.getUsername(), server.getPassword()).load();
    System.out.println(contributors);
}
Also used : Server(org.talend.sdk.component.maven.Server) MavenDecrypter(org.talend.sdk.component.maven.MavenDecrypter)

Aggregations

Server (org.talend.sdk.component.maven.Server)3 DecryptedServer (org.talend.sdk.component.api.DecryptedServer)2 MavenDecrypter (org.talend.sdk.component.maven.MavenDecrypter)2 Optional.ofNullable (java.util.Optional.ofNullable)1 Stream (java.util.stream.Stream)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 TestRule (org.junit.rules.TestRule)1 Description (org.junit.runner.Description)1 Statement (org.junit.runners.model.Statement)1 BaseMavenDecrypter (org.talend.sdk.component.base.BaseMavenDecrypter)1