Author: reto
Date: Mon Dec 27 14:14:02 2010
New Revision: 1053073
URL: http://svn.apache.org/viewvc?rev=1053073&view=rev
Log:
/CLEREZZA-374: checking for ShellPermssion and createing Shell as Priviledged
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellPermission.scala
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala?rev=1053073&r1=1053072&r2=1053073&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellFactory.scala
Mon Dec 27 14:14:02 2010
@@ -25,6 +25,8 @@ import org.osgi.service.component.Compon
import java.io.InputStream
import java.io.OutputStream
+import java.security.AccessController
+import java.security.PrivilegedAction
import org.apache.clerezza.scala.scripting.InterpreterFactory
@@ -45,13 +47,18 @@ class ShellFactory() {
}
def createShell(in: InputStream, out: OutputStream) = {
- val shell = new Shell(interpreterFactory, in, out, commands)
- //shell.bind("bundleContext", classOf[BundleContext].getName,
componentContext.getBundleContext)
- //shell.bind("componentContext",
classOf[ComponentContext].getName, componentContext)
- shell.bind("osgiDsl", classOf[OsgiDsl].getName, new
OsgiDsl(componentContext, out))
- shell.addImport("org.apache.clerezza.{scala => zzscala, _ }")
- shell.addImport("osgiDsl._")
- shell
+ AccessController.checkPermission(new ShellPermission())
+ AccessController.doPrivileged(new PrivilegedAction[Shell] {
+ override def run() = {
+ val shell = new
Shell(interpreterFactory, in, out, commands)
+ //shell.bind("bundleContext",
classOf[BundleContext].getName, componentContext.getBundleContext)
+ //shell.bind("componentContext",
classOf[ComponentContext].getName, componentContext)
+ shell.bind("osgiDsl",
classOf[OsgiDsl].getName, new OsgiDsl(componentContext, out))
+
shell.addImport("org.apache.clerezza.{scala => zzscala, _ }")
+ shell.addImport("osgiDsl._")
+ shell
+ }
+ })
}
def bindInterpreterFactory(f: InterpreterFactory) = {
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellPermission.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellPermission.scala?rev=1053073&view=auto
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellPermission.scala
(added)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.shell/src/main/scala/org/apache/clerezza/shell/ShellPermission.scala
Mon Dec 27 14:14:02 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.clerezza.shell
+
+import java.security.Permission
+
+class ShellPermission(t: String, a: String) extends Permission(t) {
+ def this() = this(null,null)
+
+ def getActions = ""
+
+ def implies(p: Permission) = {
+ p match {
+ case sp: ShellPermission => true
+ case _ => false
+ }
+ }
+
+ override def hashCode = 67823
+
+ override def equals(other: Any) = other.isInstanceOf[ShellPermission]
+}