All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.factoryfx.microservice.rest.client.MicroserviceRestClientBuilder Maven / Gradle / Ivy

The newest version!
package io.github.factoryfx.microservice.rest.client;

import io.github.factoryfx.factory.FactoryBase;
import io.github.factoryfx.server.user.persistent.PasswordHash;


public class MicroserviceRestClientBuilder {


    /**
     * For user management
     * @param host host
     * @param port port
     * @param user user
     * @param passwordNotHashed password in clear text
     * @param serverRootClass  server class, cause type erasure
     * @param   Root client
     * @param  Root Server
     * @return client
     */
    public static , RS extends FactoryBase> MicroserviceRestClient build(String host, int port, String user, String passwordNotHashed, Class serverRootClass){
        MicroserviceRestClientFactory microserviceRestClientFactory = new MicroserviceRestClientFactory<>();
        microserviceRestClientFactory.port.set(port);
        microserviceRestClientFactory.host.set(host);
        microserviceRestClientFactory.user.set(user);
        microserviceRestClientFactory.passwordHash.set(new PasswordHash().hash(passwordNotHashed));
        return microserviceRestClientFactory.createClient();
    }

    /**
     *  For no user management
     * @param host host
     * @param port port
     * @param serverRootClass server class, cause type erasure
     * @param   Root client
     * @param  Root Server
     * @return client
     */
    public static , RS extends FactoryBase> MicroserviceRestClient build(String host, int port, Class serverRootClass){
        MicroserviceRestClientFactory microserviceRestClientFactory = new MicroserviceRestClientFactory<>();
        microserviceRestClientFactory.port.set(port);
        microserviceRestClientFactory.host.set(host);
        microserviceRestClientFactory.user.set(null);
        microserviceRestClientFactory.passwordHash.set(null);
        return microserviceRestClientFactory.createClient();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy