001: /*
002: * Copyright 2006 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.authorization;
017:
018: import org.kuali.rice.KNSServiceLocator;
019:
020: /**
021: * A list of standard authorization types used by the application as a whole.
022: *
023: */
024: public interface AuthorizationType {
025: public Class getTargetObjectClass();
026:
027: public String getName();
028:
029: abstract class AuthorizationTypeBase implements AuthorizationType {
030: private Class targetObjectClass;
031:
032: public AuthorizationTypeBase() {
033: };
034:
035: public AuthorizationTypeBase(Class businessObjectClass) {
036: this ();
037: this .targetObjectClass = businessObjectClass;
038: }
039:
040: public Class getTargetObjectClass() {
041: return targetObjectClass;
042: }
043:
044: public String getName() {
045: return this .getClass().getSimpleName().toLowerCase();
046: }
047: }
048:
049: class Default extends AuthorizationTypeBase { // ability to do something that can't be categorized into one of below auth tyes, because action has not implemented checkAuthorization
050: public Default(Class actionClass) {
051: super (actionClass);
052: }
053: }
054:
055: class Inquiry extends AuthorizationTypeBase { // ability to inquire (get detail) on a specific object
056: public Inquiry(Class businessObjectClass) {
057: super (businessObjectClass);
058: }
059:
060: public String getName() {
061: return KNSServiceLocator
062: .getBusinessObjectDictionaryService()
063: .getInquiryTitle(getTargetObjectClass());
064: }
065: }
066:
067: class Lookup extends AuthorizationTypeBase { // ability to perform a search on an object
068: public Lookup(Class businessObjectClass) {
069: super (businessObjectClass);
070: }
071:
072: public String getName() {
073: return KNSServiceLocator
074: .getBusinessObjectDictionaryService()
075: .getLookupTitle(getTargetObjectClass());
076: }
077: }
078:
079: class Document extends AuthorizationTypeBase { // ability to interact in any way with a document (view/initiate/approve)
080: private org.kuali.core.document.Document document;
081:
082: public Document(Class documentOrbusinessObjectClass,
083: org.kuali.core.document.Document document) {
084: super (documentOrbusinessObjectClass);
085: this .document = document;
086: }
087:
088: public String getName() {
089: return KNSServiceLocator.getDataDictionaryService()
090: .getDocumentLabelByClass(getTargetObjectClass());
091: }
092:
093: public org.kuali.core.document.Document getDocument() {
094: return document;
095: }
096: }
097:
098: class AdHocRequest extends AuthorizationTypeBase { // eligibility to be sent an ad hoc action request
099: private String actionRequested;
100:
101: public AdHocRequest(Class documentOrBusinessObjectClass,
102: String actionRequested) {
103: super (documentOrBusinessObjectClass);
104: this .actionRequested = actionRequested;
105: }
106:
107: public String getActionRequested() {
108: return actionRequested;
109: }
110: }
111: }
|