001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/osid/authz/impl/AuthorizationImpl.java $
003: * $Id: AuthorizationImpl.java 9276 2006-05-10 23:04:20Z daisyf@stanford.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.tool.assessment.osid.authz.impl;
021:
022: import java.util.Date;
023:
024: import org.osid.authorization.Authorization;
025: import org.osid.authorization.Function;
026: import org.osid.authorization.Qualifier;
027: import org.osid.shared.Id;
028:
029: /**
030: * <p>Title: </p>
031: * <p>Description: </p>
032: * <p>Copyright: Copyright (c) 2004</p>
033: * <p>Company: </p>
034: * @author not attributable
035: * @version 1.0
036: */
037:
038: public class AuthorizationImpl implements Authorization {
039: private Id agentId;
040: private Function function;
041: private Qualifier qualifier;
042: private long effectiveDate;
043: private long expirationDate;
044: private Id modifiedBy;
045: private long modifiedDate;
046: private boolean isExplicit;
047: private boolean isActiveNow;
048:
049: public AuthorizationImpl() {
050: }
051:
052: public Id getAgentId() {
053: return null;
054: }
055:
056: public Function getFunction() {
057: return null;
058: }
059:
060: public Qualifier getQualifier() {
061: return null;
062: }
063:
064: public long getEffectiveDate() {
065: return 0L;
066: }
067:
068: public long getExpirationDate() {
069: return 0L;
070: }
071:
072: public Id getModifiedBy() {
073: return null;
074: }
075:
076: public long getModifiedDate() {
077: return 0L;
078: }
079:
080: public boolean isExplicit() {
081: return false;
082: }
083:
084: public void updateExpirationDate(long long0) {
085: }
086:
087: public void updateEffectiveDate(long long0) {
088: }
089:
090: public boolean isActiveNow() {
091: int effectiveVal = (getEffectiveDate() == 0) ? 0 : 1;
092: int expirationVal = (getExpirationDate() == 0) ? 0 : 2;
093:
094: // current time in ms
095: long nowMillis = (new Date()).getTime();
096: boolean returnVal = false;
097:
098: switch (effectiveVal + expirationVal) {
099: case 0: // both are 0
100: returnVal = true;
101: break;
102:
103: case 1: // effectiveDate is not 0
104: if (nowMillis > getEffectiveDate())
105: returnVal = true;
106: else
107: returnVal = false;
108:
109: break;
110: case 2: // expirationDate is not null
111: if (nowMillis < getExpirationDate())
112: returnVal = true;
113: else
114: returnVal = false;
115:
116: break;
117:
118: case 3: // both effectiveDate and expirationDate are not null
119: if ((nowMillis > getEffectiveDate())
120: && (nowMillis < getExpirationDate()))
121: returnVal = true;
122: else
123: returnVal = false;
124: }
125: return returnVal;
126: }
127: }
|