You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/09/12 04:15:32 UTC
svn commit: r694581 - in
/portals/jetspeed-2/portal/branches/security-refactoring:
components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/
jetspeed-api/src/main/java/org/apache/jetspeed/security/
Author: ate
Date: Thu Sep 11 19:15:32 2008
New Revision: 694581
URL: http://svn.apache.org/viewvc?rev=694581&view=rev
Log:
New JetspeedPermission factory solution hiding the concrete implementation
Added:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java (with props)
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java (with props)
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java (with props)
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java
portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPermissionsFactory.java
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java Thu Sep 11 19:15:32 2008
@@ -72,29 +72,40 @@
* <p>Mask used for determining what actions are allowed or requested.</p>
*/
protected final int mask;
+
+ private final PersistentJetspeedPermission permission;
- /**
- * <p>Constructor for PortletPermission.</p>
- *
- * @param name The portlet name.
- * @param actions The actions on the portlet.
- */
- public BaseJetspeedPermission(String name, String actions)
+ public BaseJetspeedPermission(String type, String name, int mask)
{
super(name);
- mask = parseActions(actions);
+ this.permission = new PersistentJetspeedPermission(type, name);
+ this.mask = mask;
}
-
- /**
- * <p>Constructor for PortletPermission.</p>
- *
- * @param name The portlet name.
- * @param mask The mask representing actions on the portlet.
- */
- public BaseJetspeedPermission(String name, int mask)
+
+ public BaseJetspeedPermission(String type, String name, String actions)
{
super(name);
- this.mask = mask;
+ this.permission = new PersistentJetspeedPermission(type, name);
+ this.mask = parseActions(actions);
+ }
+
+ public BaseJetspeedPermission(PersistentJetspeedPermission permission)
+ {
+ super(permission.getName());
+ this.permission = permission;
+ this.mask = parseActions(permission.getActions());
+ }
+
+ public PersistentJetspeedPermission getPermission()
+ {
+ // ensure actions field is filled
+ getActions();
+ return permission;
+ }
+
+ public String getType()
+ {
+ return permission.getType();
}
/**
@@ -102,8 +113,7 @@
*/
public int hashCode()
{
- StringBuffer value = new StringBuffer(getName());
- return value.toString().hashCode() ^ mask;
+ return getName().hashCode() ^ mask;
}
/**
@@ -111,7 +121,11 @@
*/
public String getActions()
{
- return JetspeedActions.getContainerActions(mask);
+ if (permission.getActions() == null)
+ {
+ permission.setActions(JetspeedActions.getContainerActions(mask));
+ }
+ return permission.getActions();
}
/* (non-Javadoc)
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java Thu Sep 11 19:15:32 2008
@@ -18,6 +18,8 @@
import java.security.Permission;
+import org.apache.jetspeed.security.JetspeedPermissionsFactory;
+
/**
* <p>Folder permission.</p>
* <p>This code was partially inspired from:</p>
@@ -50,6 +52,33 @@
public static final String WILD_CHAR_STR = new String(new char[]{WILD_CHAR});
public static final char FOLDER_SEPARATOR = '/';
public static final String FOLDER_SEPARATOR_STR = new String(new char[]{FOLDER_SEPARATOR});
+
+ public static class Factory extends JetspeedPermissionFactory
+ {
+ public Factory()
+ {
+ super(JetspeedPermissionsFactory.FOLDER_PERMISSION);
+ }
+
+ public FolderPermission newPermission(String name, String actions)
+ {
+ return new FolderPermission(getType(), name, actions);
+ }
+
+ public FolderPermission newPermission(String name, int mask)
+ {
+ return new FolderPermission(getType(), name, mask);
+ }
+
+ public FolderPermission newPermission(PersistentJetspeedPermission permission)
+ {
+ if (permission.getType().equals(getType()))
+ {
+ return new FolderPermission(permission);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
+ }
+ }
// does path indicate a folder? (wildcard or recursive)
private boolean folder;
@@ -59,27 +88,21 @@
private String cpath;
- /**
- * <p>Constructor for FolderPermission.</p>
- *
- * @param name The portlet name.
- * @param actions The actions on the portlet.
- */
- public FolderPermission(String name, String actions)
+ protected FolderPermission(PersistentJetspeedPermission permission)
{
- super(name, actions);
+ super(permission);
parsePath();
}
- /**
- * <p>Constructor for FolderPermission.</p>
- *
- * @param name The portlet name.
- * @param mask The mask of actions on the portlet.
- */
- public FolderPermission(String name, int mask)
+ protected FolderPermission(String type, String name, int mask)
+ {
+ super(type, name, mask);
+ parsePath();
+ }
+
+ protected FolderPermission(String type, String name, String actions)
{
- super(name, mask);
+ super(type, name, actions);
parsePath();
}
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java Thu Sep 11 19:15:32 2008
@@ -18,6 +18,8 @@
import java.security.Permission;
+import org.apache.jetspeed.security.JetspeedPermissionsFactory;
+
/**
* <p>Fragment permission.</p>
* <p>This code was partially inspired from articles from:</p>
@@ -45,26 +47,46 @@
{
private static final long serialVersionUID = -7577936466248811111L;
- /**
- * <p>Constructor for FragmentPermission.</p>
- *
- * @param name The fragment name.
- * @param actions The actions on the fragment.
- */
- public FragmentPermission(String name, String actions)
+ public static class Factory extends JetspeedPermissionFactory
{
- super(name, actions);
+ public Factory()
+ {
+ super(JetspeedPermissionsFactory.FRAGMENT_PERMISSION);
+ }
+
+ public FragmentPermission newPermission(String name, String actions)
+ {
+ return new FragmentPermission(getType(), name, actions);
+ }
+
+ public FragmentPermission newPermission(String name, int mask)
+ {
+ return new FragmentPermission(getType(), name, mask);
+ }
+
+ public FragmentPermission newPermission(PersistentJetspeedPermission permission)
+ {
+ if (permission.getType().equals(getType()))
+ {
+ return new FragmentPermission(permission);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
+ }
+ }
+
+ protected FragmentPermission(PersistentJetspeedPermission permission)
+ {
+ super(permission);
}
- /**
- * <p>Constructor for FragmentPermission.</p>
- *
- * @param name The fragment name.
- * @param mask The mask of actions on the fragment.
- */
- public FragmentPermission(String name, int mask)
+ protected FragmentPermission(String type, String name, int mask)
+ {
+ super(type, name, mask);
+ }
+
+ protected FragmentPermission(String type, String name, String actions)
{
- super(name, mask);
+ super(type, name, actions);
}
public boolean implies(Permission permission)
Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java?rev=694581&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java Thu Sep 11 19:15:32 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.jetspeed.security.spi.impl;
+
+/**
+ * @version $Id$
+ *
+ */
+public abstract class JetspeedPermissionFactory
+{
+ private String type;
+
+ public JetspeedPermissionFactory(String type)
+ {
+ this.type = type;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public abstract BaseJetspeedPermission newPermission(String name, String actions);
+
+ public abstract BaseJetspeedPermission newPermission(String name, int mask);
+
+ public abstract BaseJetspeedPermission newPermission(PersistentJetspeedPermission permission);
+}
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java?rev=694581&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java Thu Sep 11 19:15:32 2008
@@ -0,0 +1,59 @@
+/*
+ * 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.jetspeed.security.spi.impl;
+
+import java.io.Serializable;
+
+import org.apache.jetspeed.security.JetspeedPermission;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+
+/**
+ * @version $Id$
+ *
+ */
+public class JetspeedPrincipalPermission implements Serializable
+{
+ private static final long serialVersionUID = 1842368505096279355L;
+
+ @SuppressWarnings("unused")
+ private JetspeedPrincipal principal;
+ @SuppressWarnings("unused")
+ private JetspeedPermission permission;
+
+ public JetspeedPrincipalPermission()
+ {
+ // needed for OJB/JPA although in practice it should *never* be needed to be loaded
+ // as the only operations to be used are insert/delete, never update
+ }
+
+ public JetspeedPrincipalPermission(JetspeedPrincipal principal, JetspeedPermission permission)
+ {
+ this.principal = principal;
+ this.permission = permission;
+ }
+
+ public JetspeedPrincipal getPrincipal()
+ {
+ return principal;
+ }
+
+ public JetspeedPermission getPermission()
+ {
+ return permission;
+ }
+}
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalPermission.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java Thu Sep 11 19:15:32 2008
@@ -18,6 +18,8 @@
import java.security.Permission;
+import org.apache.jetspeed.security.JetspeedPermissionsFactory;
+
/**
* <p>Folder permission.</p>
* <p>This code was partially inspired from articles from:</p>
@@ -32,26 +34,46 @@
{
private static final long serialVersionUID = -3374203894346164388L;
- /**
- * <p>Constructor for PagePermission.</p>
- *
- * @param name The portlet name.
- * @param actions The actions on the portlet.
- */
- public PagePermission(String name, String actions)
+ public static class Factory extends JetspeedPermissionFactory
{
- super(name, actions);
+ public Factory()
+ {
+ super(JetspeedPermissionsFactory.PAGE_PERMISSION);
+ }
+
+ public PagePermission newPermission(String name, String actions)
+ {
+ return new PagePermission(getType(), name, actions);
+ }
+
+ public PagePermission newPermission(String name, int mask)
+ {
+ return new PagePermission(getType(), name, mask);
+ }
+
+ public PagePermission newPermission(PersistentJetspeedPermission permission)
+ {
+ if (permission.getType().equals(getType()))
+ {
+ return new PagePermission(permission);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
+ }
+ }
+
+ protected PagePermission(PersistentJetspeedPermission permission)
+ {
+ super(permission);
}
- /**
- * <p>Constructor for PagePermission.</p>
- *
- * @param name The portlet name.
- * @param mask The mask for actions on the portlet.
- */
- public PagePermission(String name, int mask)
+ protected PagePermission(String type, String name, int mask)
+ {
+ super(type, name, mask);
+ }
+
+ protected PagePermission(String type, String name, String actions)
{
- super(name, mask);
+ super(type, name, actions);
}
public boolean implies(Permission permission)
Added: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java?rev=694581&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java (added)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java Thu Sep 11 19:15:32 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.jetspeed.security.spi.impl;
+
+import org.apache.jetspeed.security.JetspeedPermission;
+
+/**
+ * @version $Id$
+ *
+ */
+public class PersistentJetspeedPermission implements JetspeedPermission
+{
+ private static final long serialVersionUID = 9200223005769593282L;
+ private Long id;
+ private String type;
+ private String name;
+ private String actions;
+
+ public PersistentJetspeedPermission(String type, String name)
+ {
+ this.type = type;
+ this.name = name;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getActions()
+ {
+ return actions;
+ }
+
+ public void setActions(String actions)
+ {
+ this.actions = actions;
+ }
+}
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PersistentJetspeedPermission.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java Thu Sep 11 19:15:32 2008
@@ -18,6 +18,8 @@
import java.security.Permission;
+import org.apache.jetspeed.security.JetspeedPermissionsFactory;
+
/**
* <p>Portlet permission.</p>
* <p>This code was partially inspired from articles from:</p>
@@ -32,26 +34,46 @@
{
private static final long serialVersionUID = 3246898917185555596L;
- /**
- * <p>Constructor for PortletPermission.</p>
- *
- * @param name The portlet name.
- * @param actions The actions on the portlet.
- */
- public PortletPermission(String name, String actions)
+ public static class Factory extends JetspeedPermissionFactory
{
- super(name, actions);
+ public Factory()
+ {
+ super(JetspeedPermissionsFactory.PORTLET_PERMISSION);
+ }
+
+ public PortletPermission newPermission(String name, String actions)
+ {
+ return new PortletPermission(getType(), name, actions);
+ }
+
+ public PortletPermission newPermission(String name, int mask)
+ {
+ return new PortletPermission(getType(), name, mask);
+ }
+
+ public PortletPermission newPermission(PersistentJetspeedPermission permission)
+ {
+ if (permission.getType().equals(getType()))
+ {
+ return new PortletPermission(permission);
+ }
+ throw new IllegalArgumentException("Permission is not of type "+getType());
+ }
+ }
+
+ protected PortletPermission(PersistentJetspeedPermission permission)
+ {
+ super(permission);
}
- /**
- * <p>Constructor for PortletPermission.</p>
- *
- * @param name The portlet name.
- * @param mask The mask of actions on the portlet.
- */
- public PortletPermission(String name, int mask)
+ protected PortletPermission(String type, String name, int mask)
+ {
+ super(type, name, mask);
+ }
+
+ protected PortletPermission(String type, String name, String actions)
{
- super(name, mask);
+ super(type, name, actions);
}
public boolean implies(Permission permission)
Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPermissionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPermissionsFactory.java?rev=694581&r1=694580&r2=694581&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPermissionsFactory.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPermissionsFactory.java Thu Sep 11 19:15:32 2008
@@ -30,5 +30,7 @@
JetspeedPermission newPermission(String type, String name, String actions);
- JetspeedPermission newPermission(String type, String name, int mask);
+ JetspeedPermission newPermission(String type, String name, int mask);
+
+ int parseActions(String actions);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org