Write your own Auth
You are here: Home:Write your own:Auth
See also:
- Write your own Listener
- Write your own Deduplication
- Write your own Consumer
Why you want to do that
You need a different method of authentication
How to implement
Extend AbstractAuth class and implement the login function
Sample code
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import io.vertx.core.Future;
import net.wissel.salesforce.vertx.config.AuthConfig;
public class Basic extends AbstractAuth{
@Override
protected Future<AuthInfo> login() {
AuthConfig ac = this.getAuthConfig();
String userCredentials = String.valueOf(ac.getSfdcUser())+":"+String.valueOf(ac.getSfdcPassword());
String token = "Basic " + Base64.getEncoder().encodeToString(userCredentials.getBytes(StandardCharsets.UTF_8));
AuthInfo ai = new AuthInfo(ac.getServerURL(), token);
this.setCachedAuthInfo(ai);
return Future.succeededFuture(ai);
}
}
An asynchronous login (like the SOAP API) returns the composed future chain instead, e.g. return client.post(...).sendBuffer(body).compose(this::extractAuthInfo);