From 640ae10c602667265f529053e7642573f4a434c3 Mon Sep 17 00:00:00 2001
From: gnaegi <none@none>
Date: Fri, 22 Feb 2013 14:48:56 +0100
Subject: [PATCH] OO-552 implement sec callback to test if access control
 module is enabled

---
 .../group/_spring/businessGroupContext.xml    |  1 +
 ...sControlModuleEnabledSecurityCallback.java | 46 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 src/main/java/org/olat/resource/accesscontrol/AccessControlModuleEnabledSecurityCallback.java

diff --git a/src/main/java/org/olat/group/_spring/businessGroupContext.xml b/src/main/java/org/olat/group/_spring/businessGroupContext.xml
index 3cd2545334b..04f80970af9 100644
--- a/src/main/java/org/olat/group/_spring/businessGroupContext.xml
+++ b/src/main/java/org/olat/group/_spring/businessGroupContext.xml
@@ -124,6 +124,7 @@
 	<bean class="org.olat.core.extensions.action.GenericActionExtension" name="groups.open" init-method="initExtensionPoints">
 		<property name="order" value="8201" />
 		<property name="navigationKey" value="OpenGroups" />
+		<property name="securityCallbackClassName" value="org.olat.resource.accesscontrol.AccessControlModuleEnabledSecurityCallback" />
 		<property name="actionController">	
 			<bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype">
 				<property name="className" value="org.olat.group.ui.main.OpenBusinessGroupsController"/>
diff --git a/src/main/java/org/olat/resource/accesscontrol/AccessControlModuleEnabledSecurityCallback.java b/src/main/java/org/olat/resource/accesscontrol/AccessControlModuleEnabledSecurityCallback.java
new file mode 100644
index 00000000000..0ce311b840d
--- /dev/null
+++ b/src/main/java/org/olat/resource/accesscontrol/AccessControlModuleEnabledSecurityCallback.java
@@ -0,0 +1,46 @@
+/**
+ * <a href=“http://www.openolat.org“>
+ * OpenOLAT - Online Learning and Training</a><br>
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); <br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at the
+ * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
+ * <p>
+ * Unless required by applicable law or agreed to in writing,<br>
+ * software distributed under the License is distributed on an "AS IS" BASIS, <br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
+ * See the License for the specific language governing permissions and <br>
+ * limitations under the License.
+ * <p>
+ * Initial code contributed and copyrighted by<br>
+ * 22.02.2013 by frentix GmbH, http://www.frentix.com
+ * <p>
+ **/
+package org.olat.resource.accesscontrol;
+
+import org.olat.core.CoreSpringFactory;
+import org.olat.core.extensions.action.ActionExtensionSecurityCallback;
+import org.olat.core.gui.UserRequest;
+
+/**
+ * @author Florian Gnaegi, frentix GmbH
+ * 
+ * This callback returns true when the access control module is enabled, false otherwise
+ * 
+ */
+public class AccessControlModuleEnabledSecurityCallback implements
+		ActionExtensionSecurityCallback {
+
+	private final AccessControlModule acModule = CoreSpringFactory.getImpl(AccessControlModule.class);
+
+	/**
+	 * @see org.olat.core.extensions.action.ActionExtensionSecurityCallback#
+	 * isAllowedToLaunchActionController(org.olat.core.gui.UserRequest)
+	 */
+	@Override
+	public boolean isAllowedToLaunchActionController(UserRequest ureq) {
+		return acModule.isEnabled();
+	}
+
+}
-- 
GitLab