CAS Credentials

15 views
Skip to first unread message

Jeffrey Ramsay

unread,
Feb 5, 2018, 8:31:47 AM2/5/18
to CAS Community
Is it possible to extend the CAS Credential class to accept three authentication parameters for authentication? I'm interested in something analogous to windows domain support because I will have the same credentials in multiple user stores (domains) however, there will be attribute differences between the identities.

If anyone has done something similar, I'm interesting in hearing about it. I started with the following and it's modeled after the RememberMe implementation but I'm unable to use it to replace the default UsernamePasswordCredential class.

//DatabaseUsernamePasswordCredential.java:
package org.apereo.cas.authentication;

import org.apache.commons.lang3.builder.HashCodeBuilder;

public class DatabaseUsernamePasswordCredential extends UsernamePasswordCredential implements DatabaseCredential {

    private static final long serialVersionUID = -6799997659431302397L;

    private String database;

    @Override
    public String getDatabase() {
        return this.database;
    }

    public void setDatabase(final String database) {
        this.database = database;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (!super.equals(o)) {
            return false;
        }
        if (getClass() != o.getClass()) {
            return false;
        }
        final DatabaseUsernamePasswordCredential that = (DatabaseUsernamePasswordCredential) o;
        return this.database != null ? this.database.equals(that.database) : that.database == null;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder()
                .appendSuper(super.hashCode())
                .append(this.database)
                .toHashCode();
    }
}

//DatabaseCredential.java:
package org.apereo.cas.authentication;

public interface DatabaseCredential extends Credential {

    public static final String AUTHENTICATION_ATTRIBUTE_DATABASE = "database";

    public String getDatabase();
}

Thanks,
-Jeff
Reply all
Reply to author
Forward
0 new messages