001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/security/model/Permission.java $
003: * $Id: Permission.java 14230 2006-09-05 18:02:51Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.metaobj.security.model;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024: import org.sakaiproject.metaobj.shared.model.Agent;
025:
026: public class Permission {
027: protected final transient Log logger = LogFactory
028: .getLog(getClass());
029:
030: private Agent agent;
031: private String function;
032: private boolean readOnly = false;
033:
034: public Permission() {
035: }
036:
037: public Permission(Agent agent, String function) {
038: this .agent = agent;
039: this .function = function;
040: }
041:
042: public Permission(Agent agent, String function, boolean readOnly) {
043: this .agent = agent;
044: this .function = function;
045: this .readOnly = readOnly;
046: }
047:
048: public String getFunction() {
049: return function;
050: }
051:
052: public void setFunction(String function) {
053: this .function = function;
054: }
055:
056: public Agent getAgent() {
057: return agent;
058: }
059:
060: public void setAgent(Agent agent) {
061: this .agent = agent;
062: }
063:
064: public boolean isReadOnly() {
065: return readOnly;
066: }
067:
068: public void setReadOnly(boolean readOnly) {
069: this .readOnly = readOnly;
070: }
071:
072: public String toString() {
073: return getAgent().getDisplayName() + "~" + getFunction();
074: }
075:
076: public boolean equals(Object o) {
077: if (this == o) {
078: return true;
079: }
080: if (!(o instanceof Permission)) {
081: return false;
082: }
083:
084: final Permission permission = (Permission) o;
085:
086: if (agent != null ? !agent.equals(permission.agent)
087: : permission.agent != null) {
088: return false;
089: }
090: if (function != null ? !function.equals(permission.function)
091: : permission.function != null) {
092: return false;
093: }
094:
095: return true;
096: }
097:
098: public int hashCode() {
099: int result;
100: result = (agent != null ? agent.hashCode() : 0);
101: result = 29 * result
102: + (function != null ? function.hashCode() : 0);
103: return result;
104: }
105: }
|