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

com.evasion.sam.jaas.EvasionGroup Maven / Gradle / Ivy

There is a newer version: 2.0.0.2
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.sam.jaas;

import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Group;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author sebastien
 */
public class EvasionGroup implements Group, Serializable {

    private static final long serialVersionUID = 8957329341484952072L;
    private final Set members = new HashSet();
    private final String name;

    public EvasionGroup(String name) {
        super();
        this.name = name;
    }

    @Override
    public boolean addMember(Principal user) {
        return members.add(user);
    }

    @Override
    public boolean isMember(Principal member) {
        return members.contains(member);
    }

    @Override
    public Enumeration members() {
        return Collections.enumeration(members);
    }

    @Override
    public boolean removeMember(Principal user) {
        return members.remove(user);
    }

    @Override
    public String getName() {
        return name;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EvasionGroup other = (EvasionGroup) obj;
        if (name == null) {
            if (other.name != null) {
                return false;
            }
        } else if (!name.equals(other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return EvasionGroup.class.getName() + ": " + getName() + " " + members;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy