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

io.castle.client.internal.utils.VerdictBuilder Maven / Gradle / Ivy

Go to download

Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users on potential account hijacks.

There is a newer version: 2.4.2
Show newest version
package io.castle.client.internal.utils;

import io.castle.client.model.AuthenticateAction;
import io.castle.client.model.Verdict;

public class VerdictBuilder {
    private AuthenticateAction action;
    private String userId;
    private boolean failover;
    private String failoverReason;

    private VerdictBuilder() {
    }

    public static VerdictBuilder success() {
        return new VerdictBuilder()
                .withFailover(false);
    }

    public static VerdictBuilder failover(String failoverReason) {
        return new VerdictBuilder()
                .withFailover(true)
                .withFailoverReason(failoverReason);
    }

    public VerdictBuilder withAction(AuthenticateAction action) {
        this.action = action;
        return this;
    }

    public VerdictBuilder withUserId(String userId) {
        this.userId = userId;
        return this;
    }

    public Verdict build() {
        Verdict verdict = new Verdict();
        verdict.setAction(action);
        verdict.setUserId(userId);
        verdict.setFailover(failover);
        verdict.setFailoverReason(failoverReason);
        return verdict;
    }


    public VerdictBuilder withFailover(boolean failover) {
        this.failover = failover;
        return this;
    }

    public VerdictBuilder withFailoverReason(String failoverReason) {
        this.failoverReason = failoverReason;
        return this;
    }

    public static Verdict fromTransport(VerdictTransportModel transport) {
        return success()
                .withAction(transport.getAction())
                .withUserId(transport.getUserId())
                .build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy