001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/security/impl/sakai/RoleWrapper.java $
003: * $Id: RoleWrapper.java 14225 2006-09-05 17:39:44Z 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.impl.sakai;
021:
022: import java.util.ArrayList;
023: import java.util.List;
024:
025: import org.apache.commons.logging.Log;
026: import org.apache.commons.logging.LogFactory;
027: import org.sakaiproject.authz.api.AuthzGroup;
028: import org.sakaiproject.authz.api.Role;
029: import org.sakaiproject.metaobj.shared.model.Artifact;
030: import org.sakaiproject.metaobj.shared.model.Id;
031: import org.sakaiproject.metaobj.shared.model.OspRole;
032:
033: public class RoleWrapper implements OspRole {
034: protected final transient Log logger = LogFactory
035: .getLog(getClass());
036:
037: private Id id = null;
038: private Id eid = null;
039: private Role sakaiRole = null;
040: private AuthzGroup sakaiRealm = null;
041:
042: public RoleWrapper(Id id, Id eid, Role sakaiRole,
043: AuthzGroup sakaiRealm) {
044: this .id = id;
045: this .eid = eid;
046: this .sakaiRealm = sakaiRealm;
047: this .sakaiRole = sakaiRole;
048: }
049:
050: public Id getId() {
051: return id;
052: }
053:
054: public Id getEid() {
055: return eid;
056: }
057:
058: public Artifact getProfile() {
059: return null;
060: }
061:
062: public void setProfile(Artifact profile) {
063:
064: }
065:
066: public Object getProperty(String key) {
067: return null;
068: }
069:
070: public String getDisplayName() {
071: return getSakaiRole().getId();
072: }
073:
074: public boolean isInRole(String role) {
075: return role.equals(id.getValue());
076: }
077:
078: public boolean isInitialized() {
079: return true;
080: }
081:
082: public String getRole() {
083: return id.getValue();
084: }
085:
086: public List getWorksiteRoles(String worksiteId) {
087: return new ArrayList();
088: }
089:
090: public List getWorksiteRoles() {
091: return new ArrayList();
092: }
093:
094: public boolean isRole() {
095: return true;
096: }
097:
098: public AuthzGroup getSakaiRealm() {
099: return sakaiRealm;
100: }
101:
102: public Role getSakaiRole() {
103: return sakaiRole;
104: }
105:
106: public boolean equals(Object o) {
107: if (this == o) {
108: return true;
109: }
110: if (!(o instanceof RoleWrapper)) {
111: return false;
112: }
113:
114: final RoleWrapper roleWrapper = (RoleWrapper) o;
115:
116: if (id != null ? !id.equals(roleWrapper.id)
117: : roleWrapper.id != null) {
118: return false;
119: }
120:
121: return true;
122: }
123:
124: public int hashCode() {
125: return (id != null ? id.hashCode() : 0);
126: }
127:
128: /**
129: * Returns the name of this principal.
130: *
131: * @return the name of this principal.
132: */
133: public String getName() {
134: return getDisplayName();
135: }
136:
137: /**
138: * gets the name of the role idependant of the site it belongs to
139: *
140: * @return
141: */
142: public String getRoleName() {
143: return getSakaiRole().getId();
144: }
145: }
|