Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java
new file mode 100644
index 000000000..286e328cc
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.internal.permadmin;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
+
+public class SecurityTableUpdate implements ConditionalPermissionUpdate {
+
+ private final SecurityAdmin securityAdmin;
+ private final List<ConditionalPermissionInfo> rows;
+ private final long timeStamp;
+
+ public SecurityTableUpdate(SecurityAdmin securityAdmin, SecurityRow[] rows, long timeStamp) {
+ this.securityAdmin = securityAdmin;
+ this.timeStamp = timeStamp;
+ // must make a snap shot of the security rows.
+ this.rows = new ArrayList<ConditionalPermissionInfo>(rows.length);
+ for (int i = 0; i < rows.length; i++)
+ // Use SecurityRowSnapShot to prevent modification before commit
+ // and to throw exceptions from delete
+ this.rows.add(new SecurityRowSnapShot(rows[i].getName(), rows[i].internalGetConditionInfos(), rows[i].internalGetPermissionInfos(), rows[i].getAccessDecision()));
+ }
+
+ public boolean commit() {
+ return securityAdmin.commit(rows, timeStamp);
+ }
+
+ public List<ConditionalPermissionInfo> getConditionalPermissionInfos() {
+ // it is fine to return the internal list; it is a snap shot and we allow clients to modify it.
+ return rows;
+ }
+
+}

Back to the top