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

waffle.shiro.WaffleFqnPrincipal Maven / Gradle / Ivy

There is a newer version: 1.8.1
Show newest version
/*******************************************************************************
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     David M. Carr
 *******************************************************************************/

package waffle.shiro;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import waffle.windows.auth.IWindowsAccount;
import waffle.windows.auth.IWindowsIdentity;

public class WaffleFqnPrincipal implements Serializable {
    private static final long serialVersionUID = 1;
    private final String fqn;
    private final Set groupFqns = new HashSet();

    WaffleFqnPrincipal(IWindowsIdentity identity) {
        fqn = identity.getFqn();
        for (IWindowsAccount group : identity.getGroups()) {
            groupFqns.add(group.getFqn());
        }
    }

    /**
     * Returns the fully qualified name of the user
     */
    public String getFqn() {
        return fqn;
    }

    /**
     * Returns the fully qualified names of all groups that the use belongs to
     */
    public Set getGroupFqns() {
        return Collections.unmodifiableSet(groupFqns);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof WaffleFqnPrincipal) {
            return fqn.equals(((WaffleFqnPrincipal) obj).fqn);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return fqn.hashCode();
    }

    @Override
    public String toString() {
        return "{" + getClass().getSimpleName() + ":" + fqn + "}";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy