001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 */
016package org.kuali.rice.kew.doctype;
017
018import java.io.Serializable;
019import java.util.HashMap;
020import java.util.Map;
021
022import org.kuali.rice.kew.api.extension.ExtensionDefinition;
023import org.kuali.rice.kew.framework.document.security.DocumentSecurityAttribute;
024
025/**
026 * Caches information about various security constraints for a single user which have already been
027 * analyzed and don't need to be analyzed again.  For example, once it's been determined that
028 * a user is a member of a workgroup or a role, it is not necessary to requery the
029 * workgroup or role for information on whether that user is a member.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class SecuritySession implements Serializable {
034
035        private static final long serialVersionUID = 2542191040889845305L;
036
037        private final String principalId;
038        private Map<String, Boolean> authenticatedWorkgroups = new HashMap<String, Boolean>();
039        private Map<String, Boolean> passesRoleSecurity = new HashMap<String, Boolean>();
040    private Map<String, DocumentSecurityAttribute> securityAttributeClassNameMap = new HashMap<String, DocumentSecurityAttribute>();
041    private Map<String, ExtensionDefinition> extensionDefinitionMap = new HashMap<String, ExtensionDefinition>();
042
043        private Map<String, DocumentTypeSecurity> documentTypeSecurity = new HashMap<String, DocumentTypeSecurity>();
044
045        public SecuritySession(String principalId) {
046                this.principalId = principalId;
047        }
048
049        public String getPrincipalId() {
050                return principalId;
051        }
052
053        public Map<String, Boolean> getPassesRoleSecurity() {
054                return passesRoleSecurity;
055        }
056
057        public void setPassesRoleSecurity(Map<String, Boolean> passesRoleSecurity) {
058                this.passesRoleSecurity = passesRoleSecurity;
059        }
060
061        public Map<String, Boolean> getAuthenticatedWorkgroups() {
062                return authenticatedWorkgroups;
063        }
064
065        public void setAuthenticatedWorkgroups(Map<String, Boolean> authenticatedWorkgroups) {
066                this.authenticatedWorkgroups = authenticatedWorkgroups;
067        }
068
069        public Map<String, DocumentTypeSecurity> getDocumentTypeSecurity() {
070                return documentTypeSecurity;
071        }
072
073        public void setDocumentTypeSecurity(Map<String, DocumentTypeSecurity> documentTypeSecurity) {
074                this.documentTypeSecurity = documentTypeSecurity;
075        }
076
077    public DocumentSecurityAttribute getSecurityAttributeForClass(String className) {
078        return this.securityAttributeClassNameMap.get(className);
079    }
080
081    public void setSecurityAttributeForClass(String className, DocumentSecurityAttribute securityAttribute) {
082        this.securityAttributeClassNameMap.put(className, securityAttribute);
083    }
084
085    public ExtensionDefinition getExtensionByName(String extensionName) {
086        return extensionDefinitionMap.get(extensionName);
087    }
088
089    public void setExtensionForName(String extensionName, ExtensionDefinition extension) {
090        this.extensionDefinitionMap.put(extensionName, extension);
091    }
092}