Author: sohil.shah(a)jboss.com
Date: 2009-06-13 19:09:48 -0400 (Sat, 13 Jun 2009)
New Revision: 13453
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java
modules/authorization/trunk/portal-profile/
modules/authorization/trunk/portal-profile/pom.xml
modules/authorization/trunk/portal-profile/src/
modules/authorization/trunk/portal-profile/src/main/
modules/authorization/trunk/portal-profile/src/main/java/
modules/authorization/trunk/portal-profile/src/main/java/org/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java
modules/authorization/trunk/portal-profile/src/main/resources/
modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml
modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml
modules/authorization/trunk/portal-profile/src/test/
modules/authorization/trunk/portal-profile/src/test/java/
modules/authorization/trunk/portal-profile/src/test/resources/
Modified:
modules/authorization/trunk/.classpath
modules/authorization/trunk/common-api/pom.xml
modules/authorization/trunk/core-components-api/pom.xml
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties
modules/authorization/trunk/pom.xml
Log:
backing up some code before storms decide to knock out power again!!!
Modified: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/.classpath 2009-06-13 23:09:48 UTC (rev 13453)
@@ -16,6 +16,10 @@
<classpathentry kind="src"
path="http-profile/src/main/resources"/>
<classpathentry kind="src"
path="http-profile/src/test/java"/>
<classpathentry kind="src"
path="http-profile/src/test/resources"/>
+ <classpathentry kind="src"
path="portal-profile/src/main/java"/>
+ <classpathentry kind="src"
path="portal-profile/src/main/resources"/>
+ <classpathentry kind="src"
path="portal-profile/src/test/java"/>
+ <classpathentry kind="src"
path="portal-profile/src/test/resources"/>
<classpathentry kind="src"
path="documentation/reference-guide/en/modules"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var"
path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
Modified: modules/authorization/trunk/common-api/pom.xml
===================================================================
--- modules/authorization/trunk/common-api/pom.xml 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/common-api/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -18,6 +18,12 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jboss-xacml</artifactId>
- </dependency>
- </dependencies>
+ </dependency>
+
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+ </dependencies>
</project>
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/Agent.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.agent;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public final class Agent
+{
+ private static Logger log = Logger.getLogger(Agent.class);
+
+ private static Kernel kernel;
+
+ public Agent()
+ {
+
+ }
+
+ public static void bootstrap()
+ {
+ try
+ {
+ EmbeddedBootstrap bootstrap = new EmbeddedBootstrap();
+ bootstrap.run();
+
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("META-INF/jboss-beans.xml");
+
+ bootstrap.deploy(url);
+
+ kernel = bootstrap.getKernel();
+ }
+ catch(Exception e)
+ {
+ log.error("org.jboss.security.authz.policy.server.Server", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Object lookup(String serviceId)
+ {
+ Object service = null;
+
+ KernelController kernelController = kernel.getController();
+ ControllerContext controllerContext =
kernelController.getInstalledContext(serviceId);
+ if(controllerContext != null)
+ {
+ service = controllerContext.getTarget();
+ }
+
+ return service;
+ }
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/agent/EmbeddedBootstrap.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.agent;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+final class EmbeddedBootstrap extends BasicBootstrap
+{
+ private static Logger log = Logger.getLogger(EmbeddedBootstrap.class);
+
+ protected BasicXMLDeployer deployer;
+
+ public EmbeddedBootstrap() throws Exception
+ {
+ super();
+ }
+
+ public void bootstrap() throws Throwable
+ {
+ super.bootstrap();
+ deployer = new BasicXMLDeployer(getKernel());
+ Runtime.getRuntime().addShutdownHook(new Shutdown());
+ }
+
+ public void deploy(URL url)
+ {
+ try
+ {
+ // Workaround the fact that the BasicXMLDeployer does not handle
+ // redeployment correctly
+ if (deployer.getDeploymentNames().contains(url.toString()))
+ {
+ log.debug("Service is already deployed.");
+ return;
+ }
+ deployer.deploy(url);
+ }
+ catch (Throwable t)
+ {
+ log.error(this, t);
+ }
+ }
+
+ public void undeploy(URL url)
+ {
+ if (!deployer.getDeploymentNames().contains(url.toString()))
+ {
+ log.debug("Service is already undeployed.");
+ return;
+ }
+ try
+ {
+ deployer.undeploy(url);
+ }
+ catch (Throwable t)
+ {
+ log.error(this, t);
+ }
+ }
+
+ protected class Shutdown extends Thread
+ {
+ public void run()
+ {
+ log.info("Shutting down");
+ deployer.shutdown();
+ }
+ }
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/Component.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,56 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Component
+{
+ /**
+ * Unique name of the component
+ *
+ * @return
+ */
+ String name();
+
+ /**
+ * The type of component
+ *
+ * @return
+ */
+ ComponentType type();
+
+ /**
+ * The Enforcement Data Category that this component signifies
+ *
+ * @return
+ */
+ ComponentCategory category();
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentCategory.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public enum ComponentCategory
+{
+ RESOURCE, SUBJECT, ACTION, ENVIRONMENT
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentMarker.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,35 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+/**
+ * Just a marker interface used for Microcontainer callbacks for registration of security
components with the Agent Component Repository
+ *
+ * TODO: need to check with Microcontainer team if callbacks can be received based on
Type level Annotations. If so, this marker interface can be completely avoided and
+ * kept more elegant. This is more of an elegance issue and not a performance or too much
developer pain the ass issue.
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public interface ComponentMarker
+{
+
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentRepository.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,62 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class ComponentRepository
+{
+ private Map<String, Component> registeredComponents;
+
+ public ComponentRepository()
+ {
+
+ }
+
+ public void start()
+ {
+
+ }
+
+ public void stop()
+ {
+
+ }
+ //-----------Repository Access related
services----------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void register(String name, Component component)
+ {
+ this.registeredComponents.put(name, component);
+ }
+
+ public Component getComponent(String name)
+ {
+ return this.registeredComponents.get(name);
+ }
+
+ public void unregister(String name)
+ {
+ this.registeredComponents.remove(name);
+ }
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/ComponentType.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public enum ComponentType
+{
+ TARGET, LOGIC
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicData.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface LogicData
+{
+
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/LogicExpression.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.METHOD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface LogicExpression
+{
+
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/PolicyComposer.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PolicyComposer
+{
+
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/RuleDeclarationRepository.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,64 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class RuleDeclarationRepository
+{
+ private static Logger log = Logger.getLogger(RuleDeclarationRepository.class);
+
+ private Set<ComponentMarker> components;
+
+ public RuleDeclarationRepository()
+ {
+ }
+
+ public void start()
+ {
+ this.components = new HashSet<ComponentMarker>();
+ log.info("-------------------------------------------------------------------");
+ log.info("RuleDeclarationRepository successfully
started.....................");
+ log.info("-------------------------------------------------------------------");
+ }
+
+ public void stop()
+ {
+
+ }
+
+ public void register(ComponentMarker component)
+ {
+ this.components.add(component);
+
+ log.debug("--------------------------------------------------------------");
+ log.debug(component.getClass()+" was successfully registered.............");
+ log.debug("--------------------------------------------------------------");
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Added:
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
===================================================================
---
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java
(rev 0)
+++
modules/authorization/trunk/common-api/src/main/java/org/jboss/security/authz/component/TargetUri.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.component;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+(a)Target(ElementType.FIELD)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface TargetUri
+{
+
+}
Modified: modules/authorization/trunk/core-components-api/pom.xml
===================================================================
--- modules/authorization/trunk/core-components-api/pom.xml 2009-06-12 21:09:47 UTC (rev
13452)
+++ modules/authorization/trunk/core-components-api/pom.xml 2009-06-13 23:09:48 UTC (rev
13453)
@@ -34,6 +34,14 @@
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
- </dependency>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -24,6 +24,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
import org.jboss.security.authz.model.Target;
/**
@@ -33,6 +37,11 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="manage",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Manage extends Operation
{
public Manage()
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -28,6 +28,10 @@
import org.jboss.security.authz.model.AttributeExpression;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Action;
+
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.TargetUri;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -36,8 +40,9 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
-public abstract class Operation
+public abstract class Operation implements ComponentMarker
{
+ @TargetUri
protected String name;
public Operation()
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Read.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -21,11 +21,20 @@
*/
package org.jboss.security.authz.components.action;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
/**
* Read represents a "read" action that can be performed on a Resource
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="read",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Read extends Operation
{
public Read()
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -24,6 +24,10 @@
import java.util.List;
import java.util.ArrayList;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+
import org.jboss.security.authz.model.Target;
/**
@@ -33,6 +37,11 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
+@Component(
+ name="write",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
public class Write extends Operation
{
public Write()
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -167,4 +167,6 @@
{
return super.clone();
}
+
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
}
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.ArrayList;
+import org.apache.log4j.Logger;
+
import org.jboss.security.authz.model.PolicyMetaData;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Rule;
@@ -35,6 +37,11 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.components.subject.Roles;
import org.jboss.security.authz.components.action.Operation;
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.TargetUri;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -44,11 +51,19 @@
*
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
-public class URIResource
+@Component(
+ name="uri",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.RESOURCE
+)
+public class URIResource implements ComponentMarker
{
+ private static Logger log = Logger.getLogger(URIResource.class);
+
/**
* The unique URI that identifies this resource
*/
+ @TargetUri
protected URI uri;
/**
@@ -287,5 +302,17 @@
uriResource.addAttribute(attribute);
return uriResource;
+ }
+
+ public void start()
+ {
+ log.debug("-------------------------------------------------------");
+ log.debug("URIResource component successfully started.............");
+ log.debug("-------------------------------------------------------");
}
+
+ public void stop()
+ {
+
+ }
}
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -30,6 +30,13 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.component.LogicData;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -42,11 +49,18 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Identity
+@Component(
+ name="identity",
+ type=ComponentType.LOGIC,
+ category=ComponentCategory.SUBJECT
+)
+public class Identity implements ComponentMarker
{
/**
* Unique id/name of the Identity
*/
+ @TargetUri
+ @LogicData
private String name;
@@ -143,5 +157,5 @@
subject.addAttribute(attribute);
return subject;
- }
+ }
}
Modified:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -32,6 +32,14 @@
import org.jboss.security.authz.model.Subject;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.authz.model.Effect;
+
+import org.jboss.security.authz.component.ComponentMarker;
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.LogicData;
+import org.jboss.security.authz.component.LogicExpression;
+
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -45,7 +53,12 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Roles
+@Component(
+ name="roles",
+ type=ComponentType.LOGIC,
+ category=ComponentCategory.SUBJECT
+)
+public class Roles implements ComponentMarker
{
//make it package-level access so that unit tests can test these rules
static final String allowRule =
@@ -80,6 +93,7 @@
/**
* Role Names
*/
+ @LogicData
private Set<String> names;
public Roles()
@@ -116,6 +130,7 @@
*
* @return the rule
*/
+ @LogicExpression
public Rule allowIfUserHasRole()
{
if(this.getNames().isEmpty())
@@ -153,6 +168,7 @@
*
* @return the rule
*/
+ @LogicExpression
public Rule denyIfUserHasRole()
{
if(this.getNames().isEmpty())
Added:
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml
(rev 0)
+++
modules/authorization/trunk/core-components-api/src/main/resources/META-INF/jboss-beans.xml 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer:2.0
bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="/agent/RuleDeclarationRepository"
class="org.jboss.security.authz.component.RuleDeclarationRepository">
+ <incallback method="register"/>
+ </bean>
+
+ <bean name="/component/URIResource"
class="org.jboss.security.authz.components.resource.URIResource">
+ </bean>
+
+ <bean name="/component/Identity"
class="org.jboss.security.authz.components.subject.Identity">
+ </bean>
+
+ <bean name="/component/Roles"
class="org.jboss.security.authz.components.subject.Roles">
+ </bean>
+
+ <bean name="/component/Read"
class="org.jboss.security.authz.components.action.Read">
+ </bean>
+
+ <bean name="/component/Write"
class="org.jboss.security.authz.components.action.Write">
+ </bean>
+
+ <bean name="/component/Manage"
class="org.jboss.security.authz.components.action.Manage">
+ </bean>
+</deployment>
\ No newline at end of file
Added:
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml
(rev 0)
+++
modules/authorization/trunk/core-components-api/src/main/resources/authz-components.xml 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components>
+ <!--
+ TODO: Just for prototyping the Component Contract. Eventually the method of
configuration will be POJO components with Annotations
+ -->
+ <target-component name="uri" category="resource"
class="org.jboss.security.authz.components.resource.URIResource">
+ <target-uri>uniqueUri</target-uri>
+ </target-component>
+
+ <target-component name="operation" category="action"
class="org.jboss.security.authz.components.action.Operation">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="read" category="action"
class="org.jboss.security.authz.components.action.Read">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="write" category="action"
class="org.jboss.security.authz.components.action.Write">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <target-component name="manage" category="action"
class="org.jboss.security.authz.components.action.Manage">
+ <target-uri>name</target-uri>
+ </target-component>
+
+ <logic-component name="identity" category="subject"
class="org.jboss.security.authz.components.subject.Identity">
+ <target-uri>uri</target-uri>
+ <logic-data>
+ <data>name</data>
+ </logic-data>
+ </logic-component>
+
+ <logic-component name="roles" category="subject"
class="org.jboss.security.authz.components.subject.Roles">
+ <target-uri></target-uri>
+ <logic-data>
+ <data>names</data>
+ </logic-data>
+ <logic-expressions>
+ <expression>permitOperationIfUserHasRole</expression>
+ <expression>denyOperationIfUserHasRole</expression>
+ </logic-expressions>
+ </logic-component>
+
+
+ <!--
+ Core Rule Compositions shipped with the framework. These can be re-used and more
compositions can be added
+ depending upon Application/Profile Requirements
+ -->
+ <rule-composition name="permitOperationIfUserHasRole"
outcome="permit">
+ <target-component>operation</target-component>
+ <logic-component>roles</logic-component>
+ </rule-composition>
+
+ <rule-composition name="denyOperationIfUserHasRole"
outcome="deny">
+ <target-component>operation</target-component>
+ <logic-component>roles</logic-component>
+ </rule-composition>
+
+ <rule-composition name="permitIdentity" outcome="permit">
+ <target-component>identity</target-component>
+ </rule-composition>
+
+ <rule-composition name="denyIdentity" outcome="deny">
+ <target-component>identity</target-component>
+ </rule-composition>
+</components>
\ No newline at end of file
Added:
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java
(rev 0)
+++
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/repository/TestConfiguration.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,76 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.components.repository;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.component.ComponentRepository;
+import org.jboss.security.authz.agent.Agent;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestConfiguration extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestConfiguration.class);
+
+ protected void setUp() throws Exception
+ {
+ Agent.bootstrap();
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void test() throws Exception
+ {
+ InputStream is = null;
+ try
+ {
+ is =
Thread.currentThread().getContextClassLoader().getResourceAsStream("authz-components.xml");
+ String xmlConfig = GeneralTool.readStream(is);
+
+ ComponentRepository repository = new ComponentRepository();
+ this.parse(xmlConfig);
+
+ //Assert
+ }
+ finally
+ {
+ if(is != null)
+ {
+ is.close();
+ }
+ }
+ }
+ //------------Configuration related
services---------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void parse(String xmlConfig)
+ {
+ log.info("------------------------------------------------------");
+ log.info("Parsing-----------------------------------------------");
+ log.info(xmlConfig);
+ log.info("------------------------------------------------------");
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Modified:
modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties
===================================================================
---
modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties 2009-06-12
21:09:47 UTC (rev 13452)
+++
modules/authorization/trunk/core-components-api/src/test/resources/log4j.properties 2009-06-13
23:09:48 UTC (rev 13453)
@@ -1,8 +1,8 @@
# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=INFO, CONSOLE
+log4j.rootCategory=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-06-12 21:09:47 UTC (rev 13452)
+++ modules/authorization/trunk/pom.xml 2009-06-13 23:09:48 UTC (rev 13453)
@@ -13,7 +13,8 @@
<module>common-api</module>
<module>core-components-api</module>
<module>policy-server</module>
- <module>http-profile</module>
+ <module>http-profile</module>
+ <module>portal-profile</module>
</modules>
<properties>
Added: modules/authorization/trunk/portal-profile/pom.xml
===================================================================
--- modules/authorization/trunk/portal-profile/pom.xml (rev 0)
+++ modules/authorization/trunk/portal-profile/pom.xml 2009-06-13 23:09:48 UTC (rev
13453)
@@ -0,0 +1,71 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>portal-profile</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Authorization for a Portal</name>
+ <url>http://www.jboss.org</url>
+ <description>Contains Authorization Infrastructure for a
Portal</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>core-components-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>policy-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <!-- test dependencies -->
+ <!-- jboss xacml -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-xacml</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- jboss microcontainer -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- Drools -->
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added:
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java
===================================================================
---
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java
(rev 0)
+++
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/PortletResource.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,75 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.portal.api.components;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PortletResource
+{
+ private String name;
+ private Set<String> modes;
+ private Map<String, String> parameters;
+
+ public PortletResource()
+ {
+
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Set<String> getModes()
+ {
+ return modes;
+ }
+
+ public void setModes(Set<String> modes)
+ {
+ this.modes = modes;
+ }
+
+ public Map<String, String> getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, String> parameters)
+ {
+ this.parameters = parameters;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public String getUri()
+ {
+ return null;
+ }
+}
Added:
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java
===================================================================
---
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java
(rev 0)
+++
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/api/components/Preferences.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.portal.api.components;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class Preferences
+{
+ private Map<String, String> preferences;
+
+ public Preferences()
+ {
+
+ }
+
+ public Map<String, String> getPreferences()
+ {
+ return preferences;
+ }
+
+ public void setPreferences(Map<String, String> preferences)
+ {
+ this.preferences = preferences;
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+}
Added:
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java
===================================================================
---
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java
(rev 0)
+++
modules/authorization/trunk/portal-profile/src/main/java/org/jboss/security/authz/portal/configuration/PortalObjectPolicyConfig.java 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,44 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.security.authz.portal.configuration;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.policy.server.spi.PolicyConfig;
+
+/**
+ * Used to configure Security Policies for a Portal Object Tree using Easy Domain
specific XML
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class PortalObjectPolicyConfig implements PolicyConfig
+{
+ public PortalObjectPolicyConfig()
+ {
+
+ }
+ //-----PolicyConfig
Implementation--------------------------------------------------------------------------------------------------------------------------
+ public Policy[] configure(String easyDomainXml)
+ {
+ return null;
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------
+}
Added: modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml
(rev 0)
+++
modules/authorization/trunk/portal-profile/src/main/resources/authz-components.xml 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components>
+ <component name="portlet" configType="target"
contextType="resource"
class="org.jboss.security.authz.portal.api.components.PortletResource">
+ <unique-uri>uri</unique-uri>
+ </component>
+
+
+ <component name="preferences" configType="rule"
contextType="environment"
class="org.jboss.security.authz.portal.api.components.Preferences">
+ <attribute>preferences</attribute>
+ </component>
+</components>
\ No newline at end of file
Added: modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml
===================================================================
--- modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml
(rev 0)
+++
modules/authorization/trunk/portal-profile/src/main/resources/portal-policy.xml 2009-06-13
23:09:48 UTC (rev 13453)
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portal-security>
+ <!--
+ Demonstrates Application Level Authorization
+
+ Security Rule:
+ The specified topics "1234 and 5678" are available only when:
+ * User is an Employee
+ * User's IP fits into the specified range
+ * Time of Access falls between the specified range
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">1234</parameter>
+ </request-parameters>
+ </portlet-resource>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">5678</parameter>
+ </request-parameters>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>employees</role-name>
+ <role-name>partners</role-name>
+ </roles>
+ </auth-constraint>
+ <auth-constraint>
+ <ip-address allow="true">
+ <ip-range>
+ <address-from></address-from>
+ <address-to></address-to>
+ </ip-range>
+ </ip-address>
+ </auth-constraint>
+ <auth-constraint>
+ <time allow="true">
+ <from></from>
+ <to></to>
+ </time>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Application Level Authorization
+
+ Security Rule:
+ The specified topics "1111 and 2222" are available only when:
+ * User is 18 years or older
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">1111</parameter>
+ </request-parameters>
+ </portlet-resource>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <request-parameters>
+ <parameter name="topicId">2222</parameter>
+ </request-parameters>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <preferences allow="true">
+ <preference name="age">>=18</preference>
+ </preferences>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Portlet Level Authorization by protecting Portlet Modes
+
+ Security Rule: The Forums Portlet is available in VIEW, HELP, and EDIT mode when:
+ * User is a member of the Community
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <modes>
+ <mode>VIEW</mode>
+ <mode>HELP</mode>
+ <mode>EDIT</mode>
+ </modes>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>community</role-name>
+ </roles>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Demonstrates Portlet Level Authorization by protecting Portlet Modes
+
+ Security Rule: The Forums Portlet is available in ADMIN mode when:
+ * User is an Admin
+ -->
+ <portlet-security-constraint>
+ <portlet-resource-collection>
+ <portlet-resource>
+ <portlet-name>forums</portlet-name>
+ <modes>
+ <mode>ADMIN</mode>
+ </modes>
+ </portlet-resource>
+ </portlet-resource-collection>
+ <auth-constraints>
+ <auth-constraint>
+ <roles allow="true">
+ <role-name>admin</role-name>
+ </roles>
+ </auth-constraint>
+ </auth-constraints>
+ </portlet-security-constraint>
+
+ <!--
+ Configuration for the Portal Enforcement Engine
+ -->
+ <enforcement-config>
+ <!--
+ default value, (false)
+ If resource match is set to "policy-match-mandatory=true", it means
that if there is an http request to the web application,
+ that does not have any specified/matching "security policy" for it,
then this access should be "Denied".
+
+ The default value is set to "false" since this makes Policy
Provisioning less intensive for most web applications. This means that if
+ a "Policy" is not specified for a http request, it means that resource
does not need to be "protected", and access should be "Granted".
+
+ The protection can be increased depending on the application by changing this to
"true". In which case only Http Requests that have a matching "Security
Policy" will
+ be considered for "Access Control". All others will be
"Denied" access.
+ -->
+ <policy-match-mandatory>false</policy-match-mandatory>
+ </enforcement-config>
+</portal-security>
\ No newline at end of file