[jboss-cvs] JBossAS SVN: r64160 - in projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml: core and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 20 08:47:49 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-07-20 08:47:49 -0400 (Fri, 20 Jul 2007)
New Revision: 64160
Added:
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/bridge/JBossPolicyFinder.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestAttributeFactory.java
Modified:
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossPDP.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossRequestContext.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossXACMLPolicy.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyFactory.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestResponseContextFactory.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/interfaces/RequestContext.java
projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/locators/JBossPolicyLocator.java
Log:
include JAXB2 and other changes
Added: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/bridge/JBossPolicyFinder.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/bridge/JBossPolicyFinder.java (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/bridge/JBossPolicyFinder.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., 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.xacml.bridge;
+
+import com.sun.xacml.finder.PolicyFinder;
+
+//$Id$
+
+/**
+ * Represents a consolidated PolicyFinder
+ * that can contain all the PolicyFinderModules
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 19, 2007
+ * @version $Revision$
+ */
+public class JBossPolicyFinder extends PolicyFinder
+{
+ public JBossPolicyFinder()
+ {
+ super();
+ }
+}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossPDP.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossPDP.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossPDP.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -36,6 +36,7 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
+import org.jboss.security.xacml.bridge.JBossPolicyFinder;
import org.jboss.security.xacml.factories.PolicyFactory;
import org.jboss.security.xacml.factories.RequestResponseContextFactory;
import org.jboss.security.xacml.interfaces.PolicyDecisionPoint;
@@ -57,8 +58,7 @@
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.finder.AttributeFinder;
-import com.sun.xacml.finder.AttributeFinderModule;
-import com.sun.xacml.finder.PolicyFinder;
+import com.sun.xacml.finder.AttributeFinderModule;
import com.sun.xacml.finder.PolicyFinderModule;
import com.sun.xacml.finder.impl.CurrentEnvModule;
import com.sun.xacml.finder.impl.SelectorModule;
@@ -77,7 +77,7 @@
private Set<PolicyLocator> locators = new HashSet<PolicyLocator>();
private Set<XACMLPolicy> policies = new HashSet<XACMLPolicy>();
- private PolicyFinder policyFinder = new PolicyFinder();
+ private JBossPolicyFinder policyFinder = new JBossPolicyFinder();
public JBossPDP()
{
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossRequestContext.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossRequestContext.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossRequestContext.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -21,13 +21,21 @@
*/
package org.jboss.security.xacml.core;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
+import javax.xml.bind.JAXB;
+import javax.xml.bind.JAXBElement;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.jboss.security.xacml.core.model.context.ObjectFactory;
+import org.jboss.security.xacml.core.model.context.RequestType;
+import org.jboss.security.xacml.factories.RequestResponseContextFactory;
import org.jboss.security.xacml.interfaces.RequestContext;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.w3c.dom.Document;
@@ -57,7 +65,17 @@
{
map.put(key, obj);
}
+
+ public void setRequest(RequestType requestType) throws IOException
+ {
+ JAXBElement<RequestType> requestJAXB = new ObjectFactory().createRequest(requestType);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JAXB.marshal(requestJAXB, baos);
+ ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
+ readRequest(bis);
+ }
+
public void readRequest(InputStream is) throws IOException
{
try
@@ -70,7 +88,14 @@
throw new RuntimeException(e);
}
}
-
+
+ public void marshall(OutputStream os) throws IOException
+ {
+ RequestCtx storedRequest = get(XACMLConstants.REQUEST_CTX);
+ if(storedRequest != null)
+ storedRequest.encode(os);
+ }
+
private Node getRequest(InputStream is) throws Exception
{
String contextSchema = "urn:oasis:names:tc:xacml:2.0:context:schema:os";
@@ -82,4 +107,5 @@
NodeList nodes = doc.getElementsByTagNameNS(contextSchema, "Request");
return nodes.item(0);
}
+
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossXACMLPolicy.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossXACMLPolicy.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/core/JBossXACMLPolicy.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -28,12 +28,12 @@
import java.util.List;
import java.util.Map;
+import org.jboss.security.xacml.bridge.JBossPolicyFinder;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XACMLPolicy;
import org.jboss.security.xacml.util.XACMLPolicyUtil;
-import com.sun.xacml.AbstractPolicy;
-import com.sun.xacml.finder.PolicyFinder;
+import com.sun.xacml.AbstractPolicy;
//$Id$
@@ -45,7 +45,7 @@
*/
public class JBossXACMLPolicy implements XACMLPolicy
{
- private PolicyFinder finder = new PolicyFinder();
+ private JBossPolicyFinder finder = new JBossPolicyFinder();
private List<XACMLPolicy> enclosingPolicies = new ArrayList<XACMLPolicy>();
@@ -79,7 +79,7 @@
map.put(XACMLConstants.UNDERLYING_POLICY, policy);
}
- public JBossXACMLPolicy(InputStream is, int type, PolicyFinder theFinder) throws Exception
+ public JBossXACMLPolicy(InputStream is, int type, JBossPolicyFinder theFinder) throws Exception
{
AbstractPolicy policy = null;
XACMLPolicyUtil xpu = new XACMLPolicyUtil();
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyFactory.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyFactory.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyFactory.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -24,12 +24,12 @@
import java.io.InputStream;
import java.lang.reflect.Constructor;
+import org.jboss.security.xacml.bridge.JBossPolicyFinder;
import org.jboss.security.xacml.core.JBossXACMLPolicy;
import org.jboss.security.xacml.core.SecurityActions;
-import org.jboss.security.xacml.interfaces.XACMLPolicy;
+import org.jboss.security.xacml.interfaces.XACMLPolicy;
+
-import com.sun.xacml.finder.PolicyFinder;
-
//$Id$
/**
@@ -72,7 +72,7 @@
}
public static XACMLPolicy createPolicySet(InputStream policySetFile,
- PolicyFinder theFinder)
+ JBossPolicyFinder theFinder)
throws Exception
{
return (XACMLPolicy) getCtrWithFinder().newInstance(new Object[]{policySetFile,
@@ -103,6 +103,6 @@
return constructingClass.getConstructor(new Class[] {
InputStream.class,
Integer.TYPE ,
- PolicyFinder.class});
+ JBossPolicyFinder.class});
}
}
Added: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestAttributeFactory.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestAttributeFactory.java (rev 0)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestAttributeFactory.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., 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.xacml.factories;
+
+import org.jboss.security.xacml.core.model.context.AttributeType;
+import org.jboss.security.xacml.core.model.context.AttributeValueType;
+
+//$Id$
+
+/**
+ * Construct Commonly Used Attributes in Request Subject/Resource/Action
+ * and Environment sections
+ * @author Anil.Saldhana at redhat.com
+ * @since Jul 20, 2007
+ * @version $Revision$
+ */
+public class RequestAttributeFactory
+{
+
+ public static AttributeType createIntegerAttributeType(String attrID, String issuer, int value)
+ {
+ AttributeType attributeType = new AttributeType();
+ attributeType.setAttributeId(attrID);
+ attributeType.setDataType("http://www.w3.org/2001/XMLSchema#integer");
+ if(issuer != null)
+ attributeType.setIssuer(issuer);
+ AttributeValueType avt = new AttributeValueType();
+ avt.getContent().add("" + value);
+ attributeType.getAttributeValue().add(avt);
+ return attributeType;
+ }
+
+ public static AttributeType createStringAttributeType(String attrID, String issuer, String value)
+ {
+ AttributeType attributeType = new AttributeType();
+ attributeType.setAttributeId(attrID);
+ attributeType.setDataType("http://www.w3.org/2001/XMLSchema#string");
+ if(issuer != null)
+ attributeType.setIssuer(issuer);
+ AttributeValueType avt = new AttributeValueType();
+ avt.getContent().add(value);
+ attributeType.getAttributeValue().add(avt);
+ return attributeType;
+ }
+
+}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestResponseContextFactory.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestResponseContextFactory.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/RequestResponseContextFactory.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -23,6 +23,8 @@
import org.jboss.security.xacml.core.JBossRequestContext;
import org.jboss.security.xacml.core.JBossResponseContext;
+import org.jboss.security.xacml.core.model.context.AttributeType;
+import org.jboss.security.xacml.core.model.context.AttributeValueType;
import org.jboss.security.xacml.interfaces.RequestContext;
import org.jboss.security.xacml.interfaces.ResponseContext;
@@ -44,5 +46,5 @@
public static ResponseContext createResponseContext()
{
return new JBossResponseContext();
- }
+ }
}
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/interfaces/RequestContext.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/interfaces/RequestContext.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/interfaces/RequestContext.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -23,7 +23,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import org.jboss.security.xacml.core.model.context.RequestType;
+
//$Id$
/**
@@ -34,5 +37,7 @@
*/
public interface RequestContext extends ContextMapOp
{
+ void setRequest(RequestType requestType) throws IOException;
void readRequest(InputStream is) throws IOException;
-}
+ void marshall(OutputStream os) throws IOException;
+}
\ No newline at end of file
Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/locators/JBossPolicyLocator.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/locators/JBossPolicyLocator.java 2007-07-20 12:46:58 UTC (rev 64159)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/locators/JBossPolicyLocator.java 2007-07-20 12:47:49 UTC (rev 64160)
@@ -52,15 +52,7 @@
public JBossPolicyLocator(Set<XACMLPolicy> policies)
{
setPolicies(policies);
- }
-/*
- public void setPolicy(XACMLPolicy xacmlPolicy)
- {
- if(xacmlPolicy.getType() != XACMLPolicy.POLICY)
- throw new IllegalArgumentException("xacmlPolicy arg is not of " +
- "type Policy:"+xacmlPolicy);
- this.policy = xacmlPolicy;
- }*/
+ }
@Override
public void setPolicies(Set<XACMLPolicy> policies)
More information about the jboss-cvs-commits
mailing list