Author: sohil.shah(a)jboss.com
Date: 2009-06-22 22:03:19 -0400 (Mon, 22 Jun 2009)
New Revision: 13480
Added:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Delete.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Get.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Head.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Options.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Post.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Put.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Trace.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
Removed:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Delete.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Get.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Head.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Options.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Post.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Put.java
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Trace.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/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java
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/Operation.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/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/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestHierarchialPropagation.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliedActions.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliesHierarchialPropagation.java
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java
modules/authorization/trunk/pom.xml
Log:
refactoring
* http profile is broken and needs migration to the new developer framework api
* just backing stuff up
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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Manage.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -21,16 +21,11 @@
*/
package org.jboss.security.authz.components.action;
-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.component.ImpliedActions;
-import org.jboss.security.authz.model.Target;
-
/**
* Read represents a "manage" action that can be performed on a Resource
*
@@ -49,17 +44,5 @@
public Manage()
{
this.name = "manage";
- }
-
- @Override
- public List<Target> getTargets()
- {
- List<Target> manageTargets = new ArrayList<Target>();
- Write write = new Write();
-
- manageTargets.addAll(super.getTargets());
- manageTargets.addAll(write.getTargets());
-
- return manageTargets;
- }
+ }
}
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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Operation.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -21,20 +21,9 @@
*/
package org.jboss.security.authz.components.action;
-import java.util.List;
-import java.util.ArrayList;
-
-import org.jboss.security.authz.model.Attribute;
-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;
-
/**
* Represents any Operation that can be performed on a Resource
*
@@ -53,45 +42,5 @@
public String getName()
{
return this.name;
- }
- //-------Policy Generation
Services---------------------------------------------------------------------------------------------------------------------
- /**
- * A Target used for Matching this Action within a Policy Definition
- *
- * @return target
- */
- public List<Target> getTargets()
- {
- List<Target> targets = new ArrayList<Target>();
-
- Target target = new Target();
- AttributeExpression expression = new AttributeExpression();
- expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
- XMLSchemaConstants.DATATYPE_STRING, this.name);
- expression.setAttribute(attribute);
-
- target.addActionMatch(expression);
- targets.add(target);
-
- return targets;
- }
- //-------Request Context Generation
Services-------------------------------------------------------------------------------------------------------------
- /**
- * Creates this Action for the RequestContext
- *
- * @return action
- */
- public Action getAction()
- {
- Action action = new Action();
-
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
- XMLSchemaConstants.DATATYPE_STRING,
- this.name
- );
- action.addAttribute(attribute);
-
- return action;
- }
+ }
}
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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/Write.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -21,16 +21,11 @@
*/
package org.jboss.security.authz.components.action;
-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.component.ImpliedActions;
-import org.jboss.security.authz.model.Target;
-
/**
* Read represents a "write" action that can be performed on a Resource
*
@@ -49,17 +44,5 @@
public Write()
{
this.name = "write";
- }
-
- @Override
- public List<Target> getTargets()
- {
- List<Target> writeTargets = new ArrayList<Target>();
- Read read = new Read();
-
- writeTargets.addAll(super.getTargets());
- writeTargets.addAll(read.getTargets());
-
- return writeTargets;
- }
+ }
}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Delete.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Delete.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Delete.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Delete extends Operation
-{
- public Delete()
- {
- this.name = "delete";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Get.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Get.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Get.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Get extends Operation
-{
- public Get()
- {
- this.name = "get";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Head.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Head.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Head.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Head extends Operation
-{
- public Head()
- {
- this.name = "head";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Options.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Options.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Options.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Options extends Operation
-{
- public Options()
- {
- this.name = "options";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Post.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Post.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Post.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Post represents a "POST" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Post extends Operation
-{
- public Post()
- {
- this.name = "post";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Put.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Put.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Put.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Put extends Operation
-{
- public Put()
- {
- this.name = "put";
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Trace.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Trace.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Trace.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,37 +0,0 @@
-/*
-* 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.action.http;
-
-import org.jboss.security.authz.components.action.Operation;
-
-/**
- * Get represents a "GET" action that can be performed on a Http Servlet
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class Trace extends Operation
-{
- public Trace()
- {
- this.name = "trace";
- }
-}
Deleted:
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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,172 +0,0 @@
-/******************************************************************************
- * 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.resource;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.List;
-
-import org.jboss.security.authz.model.AttributeExpression;
-import org.jboss.security.authz.model.Attribute;
-import org.jboss.security.authz.model.Resource;
-import org.jboss.security.authz.model.PolicyMetaData;
-import org.jboss.security.authz.model.Target;
-import org.jboss.security.authz.xacml.ExpressionBuilder;
-
-import org.jboss.security.authz.components.action.Operation;
-
-import org.jboss.security.xacml.interfaces.XACMLConstants;
-import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
-
-/**
- * The HttpResource Policy Component represents a System Resource available via the HTTP
Protocol
- *
- * This Component provides an easy to use Developer API for generating commonly used
Expressions/Logic related to Http information that must be
- * represented within an Authorization Policy
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class HttpResource extends URIResource implements Cloneable
-{
- /**
- * The HTTP Parameters that are used to access this resource
- */
- private Map<String, String> parameters;
-
- /**
- * Used to apply the Policy based on Http Method being invoked
- */
- private Operation httpMethod;
-
- /**
- *
- */
- public HttpResource()
- {
- this.parameters = new HashMap<String, String>();
- }
-
- public Map<String, String> getParameters()
- {
- if(this.parameters == null)
- {
- this.parameters = new HashMap<String, String>();
- }
- return parameters;
- }
-
-
- public void setParameters(Map<String, String> parameters)
- {
- this.parameters = parameters;
- }
-
- public void addParameter(String name, String value)
- {
- this.getParameters().put(name, value);
- }
-
- public Operation getHttpMethod()
- {
- return this.httpMethod;
- }
-
- public void setHttpMethod(Operation httpMethod)
- {
- this.httpMethod = httpMethod;
- }
- //-------Services for Policy
Creation---------------------------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- * Produces PolicyMeta used to generate a Policy object to be registered with the
Policy Server
- *
- * @return the policy meta data
- */
- public PolicyMetaData getPolicyMetaData()
- {
- PolicyMetaData metadata = super.getPolicyMetaData();
-
- if(!this.getParameters().isEmpty())
- {
- Set<String> names = this.parameters.keySet();
- for(String name: names)
- {
- String value = this.parameters.get(name);
-
- AttributeExpression paramExpression =
ExpressionBuilder.getInstance().createCustomResourceExpression(name, value);
- paramExpression.setDesignatorMustBePresent(false);
- metadata.getTarget().addResourceMatch(paramExpression);
- }
- }
-
- if(this.httpMethod != null)
- {
- AttributeExpression actionExpression = new AttributeExpression();
-
- actionExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ACTION_ID,
- XMLSchemaConstants.DATATYPE_STRING, this.httpMethod.getName());
- actionExpression.setAttribute(attribute);
-
- List<Target> actionTarget = this.httpMethod.getTargets();
-
metadata.getTarget().addActionMatch(actionTarget.iterator().next().getActionMatches().iterator().next());
- }
-
- return metadata;
- }
- //---------Services for RequestContext
Generation------------------------------------------------------------------------------------------------------------------------------
- /**
- * Represents the Resource that is currently being accessed
- *
- * @return the Resource
- */
- public Resource getResource()
- {
- Resource urlResource = super.getResource();
-
- if(!this.getParameters().isEmpty())
- {
- Set<String> names = this.parameters.keySet();
- for(String name: names)
- {
- String value = this.parameters.get(name);
-
- Attribute customAttribute = new Attribute();
- customAttribute.setUri(name);
- customAttribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
- customAttribute.setValue(value);
- urlResource.addAttribute(customAttribute);
- }
- }
-
- return urlResource;
- }
-
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- public Object clone() throws CloneNotSupportedException
- {
- 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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/URIResource.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -22,30 +22,15 @@
package org.jboss.security.authz.components.resource;
import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-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;
-import org.jboss.security.authz.model.AttributeExpression;
-import org.jboss.security.authz.model.Resource;
-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;
-
/**
* Represents any System Resource uniquely identified by a URI
*
@@ -66,22 +51,7 @@
@TargetUri
protected URI uri;
- /**
- * Roles that are allowed access to this resource
- */
- protected Roles allowed;
-
- /**
- * Roles that are denied access to this resource
- */
- protected Roles denied;
-
- /**
- * Operation allowed on this resource
- */
- protected Operation operation;
-
-
+
public URIResource()
{
@@ -95,224 +65,5 @@
public void setUri(URI uri)
{
this.uri = uri;
- }
-
- public Roles getAllowed()
- {
- if(this.allowed == null)
- {
- this.allowed = new Roles();
- }
- return allowed;
- }
-
- public void setAllowed(Roles allowed)
- {
- this.allowed = allowed;
- }
-
- public void addAllowed(String name)
- {
- this.getAllowed().addName(name);
- }
-
- public Roles getDenied()
- {
- if(this.denied == null)
- {
- this.denied = new Roles();
- }
- return denied;
- }
-
- public void setDenied(Roles denied)
- {
- this.denied = denied;
- }
-
- public void addDenied(String name)
- {
- this.getDenied().addName(name);
- }
-
- public Operation getOperation()
- {
- return operation;
- }
-
- public void setOperation(Operation operation)
- {
- this.operation = operation;
- }
- //-------Policy
Services--------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- * Creates a Policy Target suggesting that the Policy should apply to this
HttpResource
- *
- * @param matchAllParameters 'true' = include matching of all the parameters,
'false' = only url matching, parameters are excluded
- */
- private Target getTarget()
- {
- if(this.uri == null)
- {
- throw new IllegalStateException("URI Cannot Be Empty");
- }
-
- Target target = new Target();
-
-
- AttributeExpression urlExpression = new AttributeExpression();
-
- String uriStr = this.uri.toString();
-
- if(uriStr.charAt(0) == '/' && uriStr.endsWith("/*"))
- {
- //If URL starts with '/' and ends with "/*", use a regular
expression to match it (In consistency with the servlet spec)
- urlExpression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_STRING_MATCH);
-
- String uriexp = uriStr.substring(1, uriStr.length()-2);
- StringBuilder buffer = new StringBuilder();
- buffer.append("^/"+uriexp+"$|");
- buffer.append("^"+uriexp+"$|");
- buffer.append("^/"+uriexp+"/.*|");
- buffer.append("^"+uriexp+"/.*");
-
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
- XMLSchemaConstants.DATATYPE_STRING, buffer.toString());
- urlExpression.setAttribute(attribute);
- }
- else
- {
- //use an exact match
- urlExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
-
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
- XMLSchemaConstants.DATATYPE_STRING, uriStr);
- urlExpression.setAttribute(attribute);
- }
-
- target.addResourceMatch(urlExpression);
-
- return target;
- }
-
- /**
- * Creates a Policy Rule suggesting the allowed roles are permitted access to the
'Resource' designated in the Policy
- *
- * @return the rule
- */
- private List<Rule> allowIfUserHasRole()
- {
- List<Rule> rules = new ArrayList<Rule>();
-
- if(this.operation != null)
- {
- List<Target> targets = this.operation.getTargets();
- if(targets != null)
- {
- for(Target target: targets)
- {
- Rule rule = this.getAllowed().allowIfUserHasRole();
- rule.setTarget(target);
- rules.add(rule);
- }
- }
- }
- else
- {
- rules.add(this.getAllowed().allowIfUserHasRole());
- }
-
- return rules;
- }
-
- /**
- * Creates a Policy Rule suggesting the denied roles are denied access to the
'Resource' designated in the Policy
- *
- * @return the role
- */
- private List<Rule> denyIfUserHasRole()
- {
- List<Rule> rules = new ArrayList<Rule>();
-
- if(this.operation != null)
- {
- List<Target> targets = this.operation.getTargets();
- if(targets != null)
- {
- for(Target target: targets)
- {
- Rule rule = this.getDenied().denyIfUserHasRole();
- rule.setTarget(target);
- rules.add(rule);
- }
- }
- }
- else
- {
- rules.add(this.getDenied().denyIfUserHasRole());
- }
-
- return rules;
- }
-
- /**
- * Produces PolicyMeta used to generate a Policy object to be registered with the
Policy Server
- *
- * @return the policy meta data
- */
- public PolicyMetaData getPolicyMetaData()
- {
- PolicyMetaData metadata = new PolicyMetaData();
-
- Target target = this.getTarget();
-
- Set<Rule> rules = new HashSet<Rule>();
-
- //Permitted Roles
- if(this.allowed != null)
- {
- rules.addAll(this.allowIfUserHasRole());
- }
-
- //Denied Roles
- if(this.denied != null)
- {
- rules.addAll(this.denyIfUserHasRole());
- }
-
- metadata.setTarget(target);
- metadata.setRules(rules);
-
- return metadata;
- }
- //-------Request Context
Services---------------------------------------------------------------------------------------------------------------------------
- /**
- * Represents the Resource that is currently being accessed
- *
- * @return the Resource
- */
- public Resource getResource()
- {
- Resource uriResource = new Resource();
-
- Attribute attribute = new Attribute();
- attribute.setUri(XACMLConstants.ATTRIBUTEID_RESOURCE_ID);
- attribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
- attribute.setValue(this.uri.toString());
- 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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -22,14 +22,6 @@
******************************************************************************/
package org.jboss.security.authz.components.subject;
-import org.jboss.security.authz.model.AttributeExpression;
-import org.jboss.security.authz.model.Effect;
-import org.jboss.security.authz.model.Rule;
-import org.jboss.security.authz.model.Target;
-import org.jboss.security.authz.model.Subject;
-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;
@@ -37,9 +29,6 @@
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;
-
/**
* The Identity Policy Component represents the "Identity/User" that is
Authenticated by the System
*
@@ -77,85 +66,5 @@
public void setName(String name)
{
this.name = name;
- }
- //--------Services for Policy
Generation----------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- * Creates a Rule to Allow Access to this Identity
- *
- * @return rule that Allows Access to this Identity
- */
- public Rule allow()
- {
- if(this.name == null || this.name.trim().length() == 0)
- {
- throw new IllegalStateException("Identity Name Is Missing!!");
- }
-
- Rule rule = new Rule();
-
- rule.setRuleId(GeneralTool.generateUniqueId());
- rule.setEffect(Effect.PERMIT);
- rule.setTarget(this.getIdentityTarget());
-
- return rule;
- }
-
- /**
- * Creates a Rule to Deny Access to this Identity
- *
- * @return rule that Denies Access to this Identity
- */
- public Rule deny()
- {
- if(this.name == null || this.name.trim().length() == 0)
- {
- throw new IllegalStateException("Identity Name Is Missing!!");
- }
-
- Rule rule = new Rule();
-
- rule.setRuleId(GeneralTool.generateUniqueId());
- rule.setEffect(Effect.DENY);
- rule.setTarget(this.getIdentityTarget());
-
- return rule;
- }
-
- /**
- * Creates a Target that produces a Policy Match if the Input Subject has an Identity
by the same 'Name' as this Identity
- *
- * @return target
- */
- private Target getIdentityTarget()
- {
- Target target = new Target();
-
- AttributeExpression expression = new AttributeExpression();
- expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
- XMLSchemaConstants.DATATYPE_STRING, this.name);
- expression.setAttribute(attribute);
-
- target.addSubjectMatch(expression);
- return target;
- }
- //------------Services for RequestContext
Generation--------------------------------------------------------------------------------------------------------------------
- /**
- * Creates a Subject for the RequestContext with this Identity
- *
- * @return subject
- */
- public Subject getSubject()
- {
- Subject subject = new Subject();
-
- subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
- XMLSchemaConstants.DATATYPE_STRING,
- this.name
- );
- 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-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/subject/Roles.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -26,12 +26,7 @@
import java.util.Set;
import java.util.HashSet;
-import org.jboss.security.authz.model.Attribute;
-import org.jboss.security.authz.model.DroolsRuleExpression;
-import org.jboss.security.authz.model.Rule;
-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;
@@ -40,9 +35,6 @@
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;
-
/**
* The Role Policy Component represents the "Roles" that are assigned to users
of a System
*
@@ -122,104 +114,7 @@
throw new IllegalArgumentException("Role Name should not be empty!!");
}
this.getNames().add(name);
- }
- //-------Services for Policy
Generation-----------------------------------------------------------------------------------------------------------------------------------------------------
- /**
- * Creates a Policy Rule suggesting the roles indicated by this object are permitted
access to the 'Resource' designated in the Policy
- * The User must belong to atleast one of the specified roles to gain access
- *
- * @return the rule
- */
- public Rule allowIfUserHasRole()
- {
- if(this.getNames().isEmpty())
- {
- throw new IllegalStateException("The List of Allowed Roles must not be
empty!!");
- }
-
- Rule rule = new Rule();
-
- String ruleReference = "roles://allowRule/"+GeneralTool.generateUniqueId();
- rule.setRuleId(ruleReference);
- rule.setEffect(Effect.PERMIT);
-
- //Generate a Drools Rule Expression
- StringBuffer buffer = new StringBuffer();
- for(String role: this.getNames())
- {
- buffer.append("$roles.contains(\""+role.toLowerCase()+"\")
|| ");
- }
- String condition = buffer.toString().trim();
- String ruleLogic = MessageFormat.format(Roles.allowRule,
- ruleReference, condition.substring(0, condition.length()-2).trim());
-
- DroolsRuleExpression expression = new DroolsRuleExpression();
- expression.setRuleReference(ruleReference);
- expression.setRule(ruleLogic);
- rule.setExpression(expression);
-
- return rule;
- }
-
- /**
- * Creates a Policy Rule suggesting the roles indicated by this object are denied
access to the 'Resource' designated in the Policy
- * If the user belongs to atleast one of these roles, he will be denied access
- *
- * @return the rule
- */
- public Rule denyIfUserHasRole()
- {
- if(this.getNames().isEmpty())
- {
- throw new IllegalStateException("The List of Denied Roles must not be
empty!!");
- }
-
- Rule rule = new Rule();
-
- String ruleReference = "roles://denyRule/"+GeneralTool.generateUniqueId();
- rule.setRuleId(ruleReference);
- rule.setEffect(Effect.DENY);
-
- //Generate a Drools Rule Expression
- StringBuffer buffer = new StringBuffer();
- for(String role: this.getNames())
- {
- buffer.append("$roles.contains(\""+role.toLowerCase()+"\")
|| ");
- }
- String condition = buffer.toString().trim();
- String ruleLogic = MessageFormat.format(Roles.denyRule,
- ruleReference, condition.substring(0, condition.length()-2).trim());
-
- DroolsRuleExpression expression = new DroolsRuleExpression();
- expression.setRuleReference(ruleReference);
- expression.setRule(ruleLogic);
- rule.setExpression(expression);
-
- return rule;
- }
- //--------Services for RequestContext
Generation-----------------------------------------------------------------------------------------------------------
- /**
- * Creates a Subject for the RequestContext with these Roles
- *
- * @return subject
- */
- public Subject getSubject()
- {
- Subject subject = new Subject();
-
- subject.setCategory(XACMLConstants.ATTRIBUTEID_ACCESS_SUBJECT);
-
- for(String name: this.getNames())
- {
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
- XMLSchemaConstants.DATATYPE_STRING,
- name
- );
- subject.addAttribute(attribute);
- }
-
- return subject;
- }
+ }
//------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
* Creates a Policy Rule suggesting the roles indicated by this object are permitted
access to the 'Resource' designated in the Policy
Deleted:
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,111 +0,0 @@
-/*
-* 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.http;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-
-import org.jboss.security.authz.components.resource.HttpResource;
-import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.test.MockPolicy;
-
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class TestHttpResource extends TestCase
-{
- private static Logger log = Logger.getLogger(TestHttpResource.class);
-
- public void testGetURLTargetNoParameters() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
-
- Policy policy = new MockPolicy("testGetURLTargetNoParameters",
httpResource.getPolicyMetaData());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testGetURLTargetWithParameters() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
-
-
- Policy policy = new MockPolicy("testGetURLTargetWithParameters",
httpResource.getPolicyMetaData());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testRoleRules() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
-
- Policy policy = new MockPolicy("testRoleRules",
httpResource.getPolicyMetaData());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testIPRules() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
-
- Policy policy = new MockPolicy("testIPRules",
httpResource.getPolicyMetaData());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testURLPattern() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/*"));
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
-
- Policy policy = new MockPolicy("testURLPattern",
httpResource.getPolicyMetaData());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-}
Deleted:
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
===================================================================
---
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,92 +0,0 @@
-/*
-* 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.subject;
-
-import java.util.Set;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-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.Policy;
-import org.jboss.security.authz.model.Rule;
-import org.jboss.security.authz.test.MockPolicy;
-import org.jboss.security.authz.xacml.*;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class TestIdentity extends TestCase
-{
- private static Logger log = Logger.getLogger(TestIdentity.class);
-
- public void testAllow() throws Exception
- {
- Identity identity = new Identity();
- identity.setName("admin");
-
- Target target = new Target();
- target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
-
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(identity.allow());
-
- PolicyMetaData metadata = new PolicyMetaData();
- metadata.setTarget(target);
- metadata.setRules(rules);
- Policy policy = new MockPolicy("testGetAllowIdentityRule", metadata);
-
- log.info("----------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testDeny() throws Exception
- {
- Identity identity = new Identity();
- identity.setName("admin");
-
- Target target = new Target();
- target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
-
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(identity.deny());
-
- PolicyMetaData metadata = new PolicyMetaData();
- metadata.setTarget(target);
- metadata.setRules(rules);
- Policy policy = new MockPolicy("testGetDenyIdentityRule", metadata);
-
- log.info("----------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
- public void testGetSubject() throws Exception
- {
- Identity identity = new Identity();
- identity.setName("admin");
-
- log.info("----------------------------------------------------------------");
- JAXBEncoder.marshall(System.out, identity.getSubject());
- }
-}
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Delete.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Delete.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Delete.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Delete.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-delete",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Delete extends Operation
+{
+ public Delete()
+ {
+ this.name = "delete";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Delete.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Get.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Get.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Get.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Get.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-get",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Get extends Operation
+{
+ public Get()
+ {
+ this.name = "get";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Get.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Head.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Head.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Head.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Head.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-head",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Head extends Operation
+{
+ public Head()
+ {
+ this.name = "head";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Head.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Options.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Options.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Options.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Options.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-options",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Options extends Operation
+{
+ public Options()
+ {
+ this.name = "options";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Options.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Post.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Post.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Post.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Post.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Post represents a "POST" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-post",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Post extends Operation
+{
+ public Post()
+ {
+ this.name = "post";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Post.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Put.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Put.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Put.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Put.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-put",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Put extends Operation
+{
+ public Put()
+ {
+ this.name = "put";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Put.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Trace.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/action/http/Trace.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Trace.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Trace.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,45 @@
+/*
+* 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.http.component.action;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.components.action.Operation;
+
+/**
+ * Get represents a "GET" action that can be performed on a Http Servlet
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+@Component(
+ name="http-trace",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.ACTION
+)
+public class Trace extends Operation
+{
+ public Trace()
+ {
+ this.name = "trace";
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/action/Trace.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,125 @@
+/******************************************************************************
+ * 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.http.component.resource;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.security.authz.component.Component;
+import org.jboss.security.authz.component.ComponentCategory;
+import org.jboss.security.authz.component.ComponentType;
+import org.jboss.security.authz.component.TargetUri;
+import org.jboss.security.authz.components.resource.URIResource;
+
+/**
+ * The HttpResource Policy Component represents a System Resource available via the HTTP
Protocol
+ *
+ * This Component provides an easy to use Developer API for generating commonly used
Expressions/Logic related to Http information that must be
+ * represented within an Authorization Policy
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+@Component(
+ name="http-uri",
+ type=ComponentType.TARGET,
+ category=ComponentCategory.RESOURCE
+)
+public class HttpResource extends URIResource implements Cloneable
+{
+ /**
+ * The HTTP Parameters that are used to access this resource
+ */
+ @TargetUri
+ private Map<String, String> parameters;
+
+ /**
+ *
+ */
+ public HttpResource()
+ {
+ this.parameters = new HashMap<String, String>();
+ }
+
+ public Map<String, String> getParameters()
+ {
+ if(this.parameters == null)
+ {
+ this.parameters = new HashMap<String, String>();
+ }
+ return parameters;
+ }
+
+
+ public void setParameters(Map<String, String> parameters)
+ {
+ this.parameters = parameters;
+ }
+
+ public void addParameter(String name, String value)
+ {
+ this.getParameters().put(name, value);
+ }
+
+ /*public PolicyMetaData getPolicyMetaData()
+ {
+ PolicyMetaData metadata = super.getPolicyMetaData();
+
+ if(!this.getParameters().isEmpty())
+ {
+ Set<String> names = this.parameters.keySet();
+ for(String name: names)
+ {
+ String value = this.parameters.get(name);
+
+ AttributeExpression paramExpression =
ExpressionBuilder.getInstance().createCustomResourceExpression(name, value);
+ paramExpression.setDesignatorMustBePresent(false);
+ metadata.getTarget().addResourceMatch(paramExpression);
+ }
+ }
+
+ return metadata;
+ }*/
+
+ /*public Resource getResource()
+ {
+ Resource urlResource = super.getResource();
+
+ if(!this.getParameters().isEmpty())
+ {
+ Set<String> names = this.parameters.keySet();
+ for(String name: names)
+ {
+ String value = this.parameters.get(name);
+
+ Attribute customAttribute = new Attribute();
+ customAttribute.setUri(name);
+ customAttribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
+ customAttribute.setValue(value);
+ urlResource.addAttribute(customAttribute);
+ }
+ }
+
+ return urlResource;
+ }*/
+}
Modified:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/configuration/HttpPolicyConfig.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -38,19 +38,19 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.authz.policy.server.plugin.XACMLPolicy;
import org.jboss.security.authz.policy.server.spi.PolicyConfig;
-import org.jboss.security.authz.components.action.http.Get;
-import org.jboss.security.authz.components.action.http.Post;
-import org.jboss.security.authz.components.action.http.Delete;
-import org.jboss.security.authz.components.action.http.Head;
-import org.jboss.security.authz.components.action.http.Options;
-import org.jboss.security.authz.components.action.http.Put;
-import org.jboss.security.authz.components.action.http.Trace;
+import org.jboss.security.authz.http.component.action.Delete;
+import org.jboss.security.authz.http.component.action.Get;
+import org.jboss.security.authz.http.component.action.Head;
+import org.jboss.security.authz.http.component.action.Options;
+import org.jboss.security.authz.http.component.action.Post;
+import org.jboss.security.authz.http.component.action.Put;
+import org.jboss.security.authz.http.component.action.Trace;
+import org.jboss.security.authz.http.component.resource.HttpResource;
/**
Modified:
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java
===================================================================
---
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/enforcement/SecurityFilter.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -44,6 +44,14 @@
import org.w3c.dom.Element;
import org.w3c.dom.Document;
+import org.jboss.security.authz.http.component.action.Delete;
+import org.jboss.security.authz.http.component.action.Get;
+import org.jboss.security.authz.http.component.action.Head;
+import org.jboss.security.authz.http.component.action.Options;
+import org.jboss.security.authz.http.component.action.Post;
+import org.jboss.security.authz.http.component.action.Put;
+import org.jboss.security.authz.http.component.action.Trace;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.http.configuration.HttpPolicyConfig;
import org.jboss.security.authz.tools.GeneralTool;
@@ -57,15 +65,7 @@
import org.jboss.security.authz.policy.client.enforcement.PolicyEnforcementPoint;
import org.jboss.security.authz.policy.client.provisioning.PolicyProvisioner;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.components.subject.Roles;
-import org.jboss.security.authz.components.action.http.Get;
-import org.jboss.security.authz.components.action.http.Post;
-import org.jboss.security.authz.components.action.http.Delete;
-import org.jboss.security.authz.components.action.http.Head;
-import org.jboss.security.authz.components.action.http.Options;
-import org.jboss.security.authz.components.action.http.Put;
-import org.jboss.security.authz.components.action.http.Trace;
/**
Copied:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
(from rev 13462,
modules/authorization/trunk/core-components-api/src/test/java/org/jboss/security/authz/components/http/TestHttpResource.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,111 @@
+/*
+* 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.http.components;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.http.component.resource.HttpResource;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.test.MockPolicy;
+
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestHttpResource extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestHttpResource.class);
+
+ public void testGetURLTargetNoParameters() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+
+ Policy policy = new MockPolicy("testGetURLTargetNoParameters",
httpResource.getPolicyMetaData());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+
+ public void testGetURLTargetWithParameters() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+
+
+ Policy policy = new MockPolicy("testGetURLTargetWithParameters",
httpResource.getPolicyMetaData());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+
+ public void testRoleRules() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+ httpResource.addAllowed("admin");
+ httpResource.addDenied("anonymous");
+
+ Policy policy = new MockPolicy("testRoleRules",
httpResource.getPolicyMetaData());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+
+ public void testIPRules() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+ httpResource.addAllowed("admin");
+ httpResource.addDenied("anonymous");
+
+ Policy policy = new MockPolicy("testIPRules",
httpResource.getPolicyMetaData());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+
+ public void testURLPattern() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/portal/*"));
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+ httpResource.addAllowed("admin");
+ httpResource.addDenied("anonymous");
+
+ Policy policy = new MockPolicy("testURLPattern",
httpResource.getPolicyMetaData());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateSystemPolicy());
+ }
+}
Modified:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestParameterMatching.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -25,8 +25,8 @@
import org.apache.log4j.Logger;
import org.jboss.security.authz.components.action.Read;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.policy.client.enforcement.Request;
Modified:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestRoles.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -25,8 +25,8 @@
import org.apache.log4j.Logger;
import org.jboss.security.authz.components.action.Read;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.policy.client.enforcement.PolicyEnforcementPoint;
Modified:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestURLPattern.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -26,8 +26,8 @@
import org.apache.log4j.Logger;
import org.jboss.security.authz.components.action.Read;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.PolicyMetaData;
Copied:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
(from rev 13462,
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java)
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
(rev 0)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -0,0 +1,130 @@
+/*
+* 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.http.integration;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.http.component.resource.HttpResource;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
+import org.jboss.security.authz.model.Resource;
+
+import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.components.action.Read;
+
+import org.jboss.security.authz.policy.client.enforcement.PolicyEnforcementPoint;
+import org.jboss.security.authz.policy.client.enforcement.Request;
+import org.jboss.security.authz.policy.client.enforcement.Response;
+import org.jboss.security.authz.policy.client.provisioning.PolicyProvisioner;
+import org.jboss.security.authz.policy.server.Server;
+
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestEnterprisePolicyFinderModule extends TestCase
+{
+ private static Logger log = Logger.getLogger(TestEnterprisePolicyFinderModule.class);
+
+ private PolicyEnforcementPoint enforcer;
+ private PolicyProvisioner provisioner;
+
+ public void setUp() throws Exception
+ {
+ Server.bootstrap();
+ this.enforcer =
(PolicyEnforcementPoint)Server.lookup("/enforcement/localEnforcementPoint");
+ this.provisioner =
(PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
+ }
+
+ public void tearDown() throws Exception
+ {
+ }
+
+ public void testNewPolicyEnforcement() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUri(new URI("/blah/index.html"));
+ httpResource.addParameter("param1", "param1Value");
+ httpResource.addParameter("param2", "param2Value");
+ httpResource.addAllowed("Admin");
+ httpResource.setOperation(new Read());
+
+ PolicyMetaData policyMetaData = httpResource.getPolicyMetaData();
+ this.provisioner.newPolicy(policyMetaData);
+
+
+ //Assert Policy State of the Server
+ Policy[] policies = this.provisioner.readAllPolicies();
+
+ assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
+ log.info("------------------------------------------------------------------------------");
+ log.info(policies[0].generateSystemPolicy());
+
+ //Send an Enforcement request that should be allowed
+ this.enforce(this.createRequest(httpResource, true), true);
+
+ //Send an Enforcement request that should be denied
+ this.enforce(this.createRequest(httpResource, false), false);
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void enforce(Request request, boolean mustBePermitted) throws Exception
+ {
+
+ Response response = this.enforcer.checkAccess(request);
+
+ assertNotNull(response);
+ if(mustBePermitted)
+ {
+ assertTrue("Access must be granted!!!", response.isAccessGranted());
+ }
+ else
+ {
+ assertFalse("Access must be denied!!!", response.isAccessGranted());
+ }
+
+ log.info("-----------------------------------");
+ log.info("Decision="+response.getMessage());
+ }
+
+ private Request createRequest(HttpResource httpResource, boolean mustBePermitted) throws
Exception
+ {
+ //Create a RequestType
+ Request request = new Request();
+
+ //Create Subjects
+ Roles roles = new Roles();
+ roles.addName(mustBePermitted?"Admin":"Anonymous");
+ request.addSubject(roles.getSubject());
+
+ //Create Resource
+ Resource urlResource = httpResource.getResource();
+ request.addResource(urlResource);
+
+ //Create Action
+ request.setAction(new Read().getAction());
+
+ return request;
+ }
+}
Property changes on:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/integration/TestEnterprisePolicyFinderModule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java
===================================================================
---
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/provisioning/TestHttpPolicyConfig.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -29,10 +29,10 @@
import org.apache.log4j.Logger;
-import org.jboss.security.authz.components.action.http.Get;
-import org.jboss.security.authz.components.action.http.Post;
-import org.jboss.security.authz.components.resource.HttpResource;
import org.jboss.security.authz.components.subject.Roles;
+import org.jboss.security.authz.http.component.action.Get;
+import org.jboss.security.authz.http.component.action.Post;
+import org.jboss.security.authz.http.component.resource.HttpResource;
import org.jboss.security.authz.http.configuration.HttpPolicyConfig;
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.tools.GeneralTool;
Modified:
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestHierarchialPropagation.java
===================================================================
---
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestHierarchialPropagation.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestHierarchialPropagation.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -60,7 +60,8 @@
{
}
- public void testExplicitPermit() throws Exception
+ //TODO: Rewrite these tests with the new Developer Framework
+ /*public void testExplicitPermit() throws Exception
{
//SetUp Resource
URIResource resource = new URIResource();
@@ -247,5 +248,5 @@
assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
log.info("------------------------------------------------------------------------------");
log.info(policies[0].generateSystemPolicy());
- }
+ }*/
}
Modified:
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliedActions.java
===================================================================
---
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliedActions.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliedActions.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -63,7 +63,8 @@
{
}
- public void testReadImpliedWithWrite() throws Exception
+ //TODO: Rewrite these tests with the new Developer Framework
+ /*public void testReadImpliedWithWrite() throws Exception
{
//SetUp Resource
URIResource resource = new URIResource();
@@ -164,5 +165,5 @@
assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
log.info("------------------------------------------------------------------------------");
log.info(policies[0].generateSystemPolicy());
- }
+ }*/
}
Modified:
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliesHierarchialPropagation.java
===================================================================
---
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliesHierarchialPropagation.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestImpliesHierarchialPropagation.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -62,7 +62,8 @@
{
}
- public void testExplicitPermitReadImpliedWithWrite() throws Exception
+ //TODO: Rewrite these tests with the new Developer Framework
+ /*public void testExplicitPermitReadImpliedWithWrite() throws Exception
{
//SetUp Resource
URIResource resource = new URIResource();
@@ -228,5 +229,5 @@
assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
log.info("------------------------------------------------------------------------------");
log.info(policies[0].generateSystemPolicy());
- }
+ }*/
}
Modified:
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java
===================================================================
---
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/TestPolicyServer.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -27,7 +27,6 @@
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.policy.client.provisioning.PolicyProvisioner;
-import org.jboss.security.authz.components.resource.HttpResource;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -49,7 +48,8 @@
{
}
- public void testNewPolicy() throws Exception
+ //TODO: Rewrite these tests with the new Developer Framework
+ /*public void testNewPolicy() throws Exception
{
HttpResource httpResource = new HttpResource();
httpResource.setUri(new URI("/blah/index.html"));
@@ -63,5 +63,5 @@
assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
log.info("------------------------------------------------------------------------------");
log.info(policies[0].generateSystemPolicy());
- }
+ }*/
}
Deleted:
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java
===================================================================
---
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java 2009-06-22
22:49:02 UTC (rev 13479)
+++
modules/authorization/trunk/policy-server/src/test/java/org/jboss/security/authz/policy/server/plugin/TestEnterprisePolicyFinderModule.java 2009-06-23
02:03:19 UTC (rev 13480)
@@ -1,130 +0,0 @@
-/*
-* 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.policy.server.plugin;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-import org.apache.log4j.Logger;
-
-import org.jboss.security.authz.model.Policy;
-import org.jboss.security.authz.model.PolicyMetaData;
-import org.jboss.security.authz.model.Resource;
-
-import org.jboss.security.authz.components.resource.HttpResource;
-import org.jboss.security.authz.components.subject.Roles;
-import org.jboss.security.authz.components.action.Read;
-
-import org.jboss.security.authz.policy.client.enforcement.PolicyEnforcementPoint;
-import org.jboss.security.authz.policy.client.enforcement.Request;
-import org.jboss.security.authz.policy.client.enforcement.Response;
-import org.jboss.security.authz.policy.client.provisioning.PolicyProvisioner;
-import org.jboss.security.authz.policy.server.Server;
-
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-public class TestEnterprisePolicyFinderModule extends TestCase
-{
- private static Logger log = Logger.getLogger(TestEnterprisePolicyFinderModule.class);
-
- private PolicyEnforcementPoint enforcer;
- private PolicyProvisioner provisioner;
-
- public void setUp() throws Exception
- {
- Server.bootstrap();
- this.enforcer =
(PolicyEnforcementPoint)Server.lookup("/enforcement/localEnforcementPoint");
- this.provisioner =
(PolicyProvisioner)Server.lookup("/provisioning/localProvisioner");
- }
-
- public void tearDown() throws Exception
- {
- }
-
- public void testNewPolicyEnforcement() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/blah/index.html"));
- httpResource.addParameter("param1", "param1Value");
- httpResource.addParameter("param2", "param2Value");
- httpResource.addAllowed("Admin");
- httpResource.setOperation(new Read());
-
- PolicyMetaData policyMetaData = httpResource.getPolicyMetaData();
- this.provisioner.newPolicy(policyMetaData);
-
-
- //Assert Policy State of the Server
- Policy[] policies = this.provisioner.readAllPolicies();
-
- assertTrue("Policy Store must not be empty!!", (policies != null &&
policies.length == 1));
- log.info("------------------------------------------------------------------------------");
- log.info(policies[0].generateSystemPolicy());
-
- //Send an Enforcement request that should be allowed
- this.enforce(this.createRequest(httpResource, true), true);
-
- //Send an Enforcement request that should be denied
- this.enforce(this.createRequest(httpResource, false), false);
- }
- //----------------------------------------------------------------------------------------------------------------------------------------------------------
- private void enforce(Request request, boolean mustBePermitted) throws Exception
- {
-
- Response response = this.enforcer.checkAccess(request);
-
- assertNotNull(response);
- if(mustBePermitted)
- {
- assertTrue("Access must be granted!!!", response.isAccessGranted());
- }
- else
- {
- assertFalse("Access must be denied!!!", response.isAccessGranted());
- }
-
- log.info("-----------------------------------");
- log.info("Decision="+response.getMessage());
- }
-
- private Request createRequest(HttpResource httpResource, boolean mustBePermitted) throws
Exception
- {
- //Create a RequestType
- Request request = new Request();
-
- //Create Subjects
- Roles roles = new Roles();
- roles.addName(mustBePermitted?"Admin":"Anonymous");
- request.addSubject(roles.getSubject());
-
- //Create Resource
- Resource urlResource = httpResource.getResource();
- request.addResource(urlResource);
-
- //Create Action
- request.setAction(new Read().getAction());
-
- return request;
- }
-}
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-06-22 22:49:02 UTC (rev 13479)
+++ modules/authorization/trunk/pom.xml 2009-06-23 02:03:19 UTC (rev 13480)
@@ -14,8 +14,10 @@
<module>core-components-api</module>
<module>agent</module>
<module>policy-server</module>
+ <!--
<module>http-profile</module>
- <module>portal-profile</module>
+ <module>portal-profile</module>
+ -->
</modules>
<properties>