/*
 * $Id: VKCAclType.java,v 1.13 2005/01/17 23:40:10 jonyp Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCAclType.java,v $
 * Revision 1.13  2005/01/17 23:40:10  jonyp
 * deleted hashCode method
 *
 * Revision 1.12  2005/01/17 23:37:36  jonyp
 * added permString for unauthenticated/ldap-user/ldap-group
 *
 * Revision 1.11  2005/01/17 22:33:38  jonyp
 * added unauthenticated type
 *
 * Revision 1.10  2004/10/07 14:39:29  jonyp
 * added two new acltypes ldap-group/ldap-user
 *
 * Revision 1.9  2004/07/20 08:15:52  jonyp
 * added copyright info + cvs log
 *
 * Revision 1.8  2004/04/02 13:19:59  bigmac
 * *** empty log message ***
 *
 * Revision 1.7  2003/07/25 08:36:38  jonyp
 * test
 *
 *
 */


/**
 * Klasse representiert einen AclType VKC-System
 *
 */
package vkc.db.entities;

import java.io.Serializable;


public class VKCAclType implements Serializable {

    /**
     * Representieren die ACL Typen in der Datenbank
     * Es wird vorrausgesetzt, dass diese NAmen mit denen
     * in der Datenbank übereinstimmen !!!
     */
    public static final String USER = "user";
    public static final int USER_TYPE = 1;
    public static final String GROUP = "group";
    public static final int GROUP_TYPE = 2;
    public static final String ANYOTHER = "anyother";
    public static final int ANYOTHER_TYPE = 3;
    public static final String MASK = "mask";
    public static final int MASK_TYPE = 4;
	public static final String OWNER = "owner";
	public static final int OWNER_TYPE = 5;
	public static final int LDAP_USER_TYPE = 6;
	public static final String LDAP_USER = "ldap-user";
	public static final int LDAP_GROUP_TYPE = 7;
	public static final String LDAP_GROUP = "ldap-group";
	public static final int UNAUTHENTICATED_TYPE = 8;
	public static final String UNAUTENTICATED = "unauthenticated";

    private Integer aclTypeId = new Integer(-1);
    private String name;
    private Integer rank;
    private String description;
    private Integer defAclOnly = new Integer(0);
    private Integer idRequired = new Integer(0);

    public VKCAclType() {
    }

    public VKCAclType(Integer aclTypeId, String name, Integer rank,
                      String description) {
        this.aclTypeId = aclTypeId;
        this.name = name;
        this.rank = rank;
        this.description = description;
    }

    public void setAclTypeId(Integer aclTypeId) {
        this.aclTypeId = aclTypeId;
    }

    public Integer getAclTypeId() {
        return this.aclTypeId;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setRank(Integer rank) {
        this.rank = rank;
    }

    public Integer getRank() {
        return this.rank;
    }

	public void setIdRequired(Integer idRequired) {
			this.idRequired = idRequired;
	}

	public Integer getIdRequired() {
			return this.idRequired;
	}

    public boolean isIdRequired() {
    	if (this.idRequired.intValue() == 0)
    	    return false;
    	
    	return true;
    }

	public void setDefAclOnly(Integer defAclOnly) {
			this.defAclOnly = defAclOnly;
	}

	public Integer getDefAclOnly() {
			return this.defAclOnly;
	}

	public boolean defAclOnly() {
		if (this.defAclOnly.intValue() == 0)
			return false;
   	
		return true;
	}

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return this.description;
    }

    public boolean equals(Object o) {
        if (!(o instanceof VKCAclType)) {
            return false;
        }

        VKCAclType p = (VKCAclType) o;

        return p.getName().equals(this.getName());
    }

    public String toString() {
        return this.getName();
    }
    
    public boolean isGroupType() {
    	return aclTypeId.intValue() == GROUP_TYPE;
    }

	public boolean isUserType() {
		return aclTypeId.intValue() == USER_TYPE;
	}

}