001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/security/drm/model/Privilege.java $ 002 /*---------------------------------------------------------------------------- 003 This file is part of deegree, http://deegree.org/ 004 Copyright (C) 2001-2009 by: 005 Department of Geography, University of Bonn 006 and 007 lat/lon GmbH 008 009 This library is free software; you can redistribute it and/or modify it under 010 the terms of the GNU Lesser General Public License as published by the Free 011 Software Foundation; either version 2.1 of the License, or (at your option) 012 any later version. 013 This library is distributed in the hope that it will be useful, but WITHOUT 014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 016 details. 017 You should have received a copy of the GNU Lesser General Public License 018 along with this library; if not, write to the Free Software Foundation, Inc., 019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 021 Contact information: 022 023 lat/lon GmbH 024 Aennchenstr. 19, 53177 Bonn 025 Germany 026 http://lat-lon.de/ 027 028 Department of Geography, University of Bonn 029 Prof. Dr. Klaus Greve 030 Postfach 1147, 53001 Bonn 031 Germany 032 http://www.geographie.uni-bonn.de/deegree/ 033 034 e-mail: info@deegree.org 035 ----------------------------------------------------------------------------*/ 036 package org.deegree.security.drm.model; 037 038 /** 039 * Default implementation of privilege-objects. 040 * 041 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider</a> 042 * @version $Revision: 18195 $ 043 */ 044 045 public class Privilege { 046 047 // predefined privileges 048 public static final Privilege WRITE = new Privilege( 1, "write" ); 049 050 public static final Privilege ADDUSER = new Privilege( 2, "adduser" ); 051 052 public static final Privilege ADDGROUP = new Privilege( 3, "addgroup" ); 053 054 public static final Privilege ADDROLE = new Privilege( 4, "addrole" ); 055 056 public static final Privilege ADDOBJECT = new Privilege( 5, "addobject" ); 057 058 private int id; 059 060 private String name; 061 062 /** 063 * Creates a new <code>Privilege</code>-instance. 064 * 065 * @param id 066 * @param name 067 */ 068 public Privilege( int id, String name ) { 069 this.id = id; 070 this.name = name; 071 } 072 073 /** 074 * Returns the unique identifier of this privilege. 075 */ 076 public int getID() { 077 return id; 078 } 079 080 /** 081 * Returns the name of this privilege. 082 * 083 */ 084 public String getName() { 085 return name; 086 } 087 088 /** 089 * Indicates whether some other privilege is "equal to" this one. 090 * 091 * @param that 092 */ 093 public boolean equals( Object that ) { 094 if ( that instanceof Privilege ) { 095 return ( ( (Privilege) that ).getID() == getID() ); 096 } 097 return false; 098 } 099 100 /** 101 * Returns a hash code value for the object. This method is supported for the benefit of 102 * hashtables such as those provided by java.util.Hashtable. 103 */ 104 public int hashCode() { 105 return id; 106 } 107 }