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

net.dona.doip.client.PasswordAuthenticationInfo Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package net.dona.doip.client;

import com.google.gson.JsonObject;

/**
 * An {@link AuthenticationInfo} which provides a username and a password.
 */
public class PasswordAuthenticationInfo implements AuthenticationInfo {

    private final String username;
    private final String password;
    private final String asUserId;

    public PasswordAuthenticationInfo(String username, String password) {
        this(username, password, null);
    }

    public PasswordAuthenticationInfo(String username, String password, String asUserId) {
        this.username = username;
        this.password = password;
        this.asUserId = asUserId;
    }

    @Override
    public String getClientId() {
        return null;
    }

    @Override
    public JsonObject getAuthentication() {
        JsonObject authentication = new JsonObject();
        authentication.addProperty("username", username);
        authentication.addProperty("password", password);
        if (asUserId != null) {
            authentication.addProperty("asUserId", asUserId);
        }
        return authentication;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy