JBoss Portal SVN: r12690 - branches/Enterprise_Portal_Platform_4_3/core-admin/src/resources/portal-admin-war/jsf/common.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2009-01-28 15:34:56 -0500 (Wed, 28 Jan 2009)
New Revision: 12690
Modified:
branches/Enterprise_Portal_Platform_4_3/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml
Log:
namespace fix in portlet layout
Modified: branches/Enterprise_Portal_Platform_4_3/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml 2009-01-28 20:31:38 UTC (rev 12689)
+++ branches/Enterprise_Portal_Platform_4_3/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml 2009-01-28 20:34:56 UTC (rev 12690)
@@ -56,7 +56,7 @@
initialMode="edit_content"
initialWindowState="normal"
renderParameters="#{pageManager.selectedRenderParameters}"
- onClick="url.setParameter('windowName', document.getElementById(document.getElementById('namespaceHolder').value + ':windowForm:windowName').value);"/>
+ onClick="url.setParameter('windowName', document.getElementById(document.getElementById('namespaceHolder').value).value);"/>
<input type="hidden" value="#{pageManager.namespace}" id="namespaceHolder"/>
</td>
</tr>
15 years, 4 months
JBoss Portal SVN: r12689 - branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/common.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2009-01-28 15:31:38 -0500 (Wed, 28 Jan 2009)
New Revision: 12689
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml
Log:
namespace fix in portlet layout
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml 2009-01-28 19:51:05 UTC (rev 12688)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/common/editPageLayout.xhtml 2009-01-28 20:31:38 UTC (rev 12689)
@@ -56,7 +56,7 @@
initialMode="edit_content"
initialWindowState="normal"
renderParameters="#{pageManager.selectedRenderParameters}"
- onClick="url.setParameter('windowName', document.getElementById(document.getElementById('namespaceHolder').value + ':windowForm:windowName').value);"/>
+ onClick="url.setParameter('windowName', document.getElementById(document.getElementById('namespaceHolder').value).value);"/>
<input type="hidden" value="#{pageManager.namespace}" id="namespaceHolder"/>
</td>
</tr>
15 years, 4 months
JBoss Portal SVN: r12688 - in branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal: wsrp/consumer and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2009-01-28 14:51:05 -0500 (Wed, 28 Jan 2009)
New Revision: 12688
Modified:
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- JBPORTAL-2284: ProducerInfo are now created with a RegistrationInfo that's marked as undetermined instead of null.
Modified: branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28 19:47:33 UTC (rev 12687)
+++ branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28 19:51:05 UTC (rev 12688)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -31,6 +31,7 @@
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import java.util.Collection;
@@ -77,7 +78,8 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
TransactionAssert.commitTransaction();
TransactionAssert.beginTransaction();
@@ -103,7 +105,7 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ assertTrue(info.getRegistrationInfo().isUndetermined());
assertNull(registry.getConsumer("inexistent"));
Collection consumers = registry.getConfiguredConsumers();
Modified: branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28 19:47:33 UTC (rev 12687)
+++ branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28 19:51:05 UTC (rev 12688)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -152,7 +152,8 @@
public void testRefreshAndRegistration() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
@@ -173,7 +174,8 @@
public void testGetRegistrationContext() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
Modified: branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28 19:47:33 UTC (rev 12687)
+++ branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28 19:51:05 UTC (rev 12688)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -123,6 +123,7 @@
public ProducerInfo()
{
persistentEndpointInfo = new EndpointConfigurationInfo(this);
+ persistentRegistrationInfo = RegistrationInfo.createUndeterminedRegistration(this);
}
public ConsumerRegistry getRegistry()
@@ -345,7 +346,8 @@
try
{
// if we don't yet have registration information, get an unregistered service description
- serviceDescription = getUnmanagedServiceDescription(persistentRegistrationInfo == null);
+ boolean unmanaged = persistentRegistrationInfo == null || persistentRegistrationInfo.isUndetermined();
+ serviceDescription = getUnmanagedServiceDescription(unmanaged);
result.setServiceDescription(serviceDescription);
}
catch (OperationFailedFault operationFailedFault)
@@ -409,7 +411,7 @@
}
private RefreshResult refreshInfo(boolean forceRefresh, ServiceDescription serviceDescription, RefreshResult result)
- throws PortletInvokerException
+ throws PortletInvokerException
{
// do we need to call initCookie or not?
requiresInitCookie = serviceDescription.getRequiresInitCookie();
@@ -542,8 +544,8 @@
if (info.isUsesMethodGet())
{
log.warn("Portlet '" + portletHandle
- + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
- "the list of offered portlets for producer " + persistentId);
+ + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
+ "the list of offered portlets for producer " + persistentId);
}
else
{
@@ -616,7 +618,7 @@
catch (Exception e)
{
log.debug("Couldn't get portlet via getPortletDescription for producer '" + persistentId
- + "'. Attempting to retrieve it from the service description as this producer might not support the PortletManagement interface.", e);
+ + "'. Attempting to retrieve it from the service description as this producer might not support the PortletManagement interface.", e);
justRefreshed = refresh(true);
portlet = getPortletFromCaches(portletHandle, justRefreshed);
@@ -686,7 +688,7 @@
private boolean isCacheExpired()
{
boolean result = !useCache() || System.currentTimeMillis() > expirationTimeMillis || popsMap == null
- || portletGroups == null;
+ || portletGroups == null;
if (result)
{
log.debug("Cache expired or not used");
@@ -765,7 +767,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for producer "
- + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred) throws PortletInvokerException
@@ -787,7 +789,7 @@
public RegistrationContext getRegistrationContext() throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
+ if (persistentRegistrationInfo == null || persistentRegistrationInfo.isUndetermined())
{
refresh(false);
}
@@ -835,7 +837,7 @@
throw new RuntimeException("Couldn't reset registration", e);
}
throw new IllegalArgumentException("Couldn't get property descriptions for portlet '" + portletHandle
- + "' because the provided registration is invalid!");
+ + "' because the provided registration is invalid!");
}
catch (Exception e)
{
@@ -887,7 +889,7 @@
{
log.debug("Attempting registration");
RegistrationContext registrationContext = persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
+ .register(persistentRegistrationInfo.getRegistrationData());
if (registrationContext == null)
{
@@ -897,7 +899,7 @@
persistentRegistrationInfo.setRegistrationContext(registrationContext);
String msg = "Consumer with id '" + persistentId + "' successfully registered with handle: '"
- + registrationContext.getRegistrationHandle() + "'";
+ + registrationContext.getRegistrationHandle() + "'";
log.debug(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
@@ -963,7 +965,7 @@
{
RegistrationContext registrationContext = getRegistrationContext();
ModifyRegistration modifyRegistration = WSRPTypeFactory.createModifyRegistration(registrationContext,
- persistentRegistrationInfo.getRegistrationData());
+ persistentRegistrationInfo.getRegistrationData());
RegistrationState state = persistentEndpointInfo.getRegistrationService().modifyRegistration(modifyRegistration);
// force refresh of internal RegistrationInfo state
@@ -993,7 +995,7 @@
else
{
throw new IllegalStateException("Cannot modify registration for producer '" + persistentId
- + "' as it's not registered");
+ + "' as it's not registered");
}
}
@@ -1013,7 +1015,7 @@
}
RefreshResult result =
- persistentRegistrationInfo.refresh(serviceDescription, persistentId, mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
+ persistentRegistrationInfo.refresh(serviceDescription, persistentId, mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
log.debug("Refreshed registration information for consumer with id '" + persistentId + "'");
@@ -1023,9 +1025,9 @@
public boolean isRefreshNeeded(boolean considerCache)
{
boolean result = (considerCache && isCacheExpired())
- || persistentRegistrationInfo == null
- || persistentRegistrationInfo.isRefreshNeeded()
- || persistentEndpointInfo.isRefreshNeeded();
+ || persistentRegistrationInfo == null
+ || persistentRegistrationInfo.isRefreshNeeded()
+ || persistentEndpointInfo.isRefreshNeeded();
if (result)
{
log.debug("Refresh needed for producer '" + persistentId + "'");
Modified: branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28 19:47:33 UTC (rev 12687)
+++ branches/Enterprise_Portal_Platform_4_3/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28 19:51:05 UTC (rev 12688)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -68,6 +68,12 @@
private transient boolean modifyRegistrationNeeded;
private transient ProducerInfo parent;
+ /**
+ * Marker string to identify a RegistrationInfo created for a producer that might not require registration as a work
+ * around https://jira.jboss.org/jira/browse/JBPORTAL-2284
+ */
+ private static final String UNDETERMINED_REGISTRATION = "__JBP__UNDETERMINED__REGISTRATION__";
+
public RegistrationInfo(ProducerInfo producerInfo)
{
this();
@@ -76,6 +82,18 @@
parent = producerInfo;
}
+ static RegistrationInfo createUndeterminedRegistration(ProducerInfo producerInfo)
+ {
+ RegistrationInfo info = new RegistrationInfo(producerInfo);
+ info.setConsumerName(UNDETERMINED_REGISTRATION);
+ return info;
+ }
+
+ public boolean isUndetermined()
+ {
+ return UNDETERMINED_REGISTRATION.equals(persistentConsumerName);
+ }
+
public RegistrationInfo(ProducerInfo producerInfo, boolean requiresRegistration)
{
this(producerInfo);
@@ -379,6 +397,12 @@
if (forceRefresh || isRefreshNeeded())
{
+ // if we were previously undetermined, become determined! :)
+ if (isUndetermined())
+ {
+ setConsumerName(WSRPConstants.DEFAULT_CONSUMER_NAME);
+ }
+
// get a service description if we don't already have one
if (serviceDescription == null && parent != null)
{
15 years, 4 months
JBoss Portal SVN: r12687 - branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2009-01-28 14:47:33 -0500 (Wed, 28 Jan 2009)
New Revision: 12687
Modified:
branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/DialectFactory.java
branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java
Log:
Use correct dialects
Modified: branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/DialectFactory.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/DialectFactory.java 2009-01-28 19:18:03 UTC (rev 12686)
+++ branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/DialectFactory.java 2009-01-28 19:47:33 UTC (rev 12687)
@@ -23,6 +23,9 @@
package org.jboss.portal.jems.hibernate;
import org.hibernate.HibernateException;
+import org.hibernate.dialect.Oracle10gDialect;
+import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.dialect.Oracle9iDialect;
import java.util.HashMap;
import java.util.Map;
@@ -91,29 +94,33 @@
private static final Map MAPPERS = new HashMap();
- static
- {
- // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
- MAPPERS.put("HSQL Database Engine", new VersionInsensitiveMapper("org.hibernate.dialect.HSQLDialect"));
- MAPPERS.put("DB2/NT", new VersionInsensitiveMapper("org.hibernate.dialect.DB2Dialect"));
- MAPPERS.put("MySQL", new VersionInsensitiveMapper("org.hibernate.dialect.MySQLDialect"));
- MAPPERS.put("PostgreSQL", new VersionInsensitiveMapper("org.hibernate.dialect.PostgreSQLDialect"));
- MAPPERS.put("Microsoft SQL Server Database", new VersionInsensitiveMapper("org.hibernate.dialect.SQLServerDialect"));
- MAPPERS.put("Microsoft SQL Server", new VersionInsensitiveMapper("org.hibernate.dialect.SQLServerDialect"));
- MAPPERS.put("Sybase SQL Server", new VersionInsensitiveMapper("org.hibernate.dialect.SybaseDialect"));
- MAPPERS.put("Informix Dynamic Server", new VersionInsensitiveMapper("org.hibernate.dialect.InformixDialect"));
+ static {
+ // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
+ MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
+ MAPPERS.put( "DB2/NT", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
+ MAPPERS.put( "PostgreSQL", new VersionInsensitiveMapper( "org.hibernate.dialect.PostgreSQLDialect" ) );
+ MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
+ MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
+ MAPPERS.put( "Sybase SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
+ MAPPERS.put( "Adaptive Server Enterprise", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
+ MAPPERS.put( "Informix Dynamic Server", new VersionInsensitiveMapper( "org.hibernate.dialect.InformixDialect" ) );
+ MAPPERS.put( "Apache Derby", new VersionInsensitiveMapper( "org.hibernate.dialect.DerbyDialect" ) );
- MAPPERS.put(
- "Oracle",
- new DatabaseDialectMapper()
- {
- public String getDialectClass(int majorVersion)
- {
- return majorVersion > 8
- ? "org.hibernate.dialect.Oracle9Dialect"
- : "org.hibernate.dialect.OracleDialect";
- }
- }
- );
- }
+ MAPPERS.put(
+ "Oracle",
+ new DatabaseDialectMapper() {
+ public String getDialectClass(int majorVersion) {
+ switch ( majorVersion ) {
+ case 8: return Oracle8iDialect.class.getName();
+ case 9: return Oracle9iDialect.class.getName();
+ case 10: return Oracle10gDialect.class.getName();
+ default: throw new HibernateException( "unknown Oracle major version [" + majorVersion + "]" );
+ }
+ }
+ }
+ );
+ }
+
}
Modified: branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java 2009-01-28 19:18:03 UTC (rev 12686)
+++ branches/Enterprise_Portal_Platform_4_3/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java 2009-01-28 19:47:33 UTC (rev 12687)
@@ -30,9 +30,6 @@
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.Oracle9Dialect;
-import org.hibernate.dialect.OracleDialect;
import org.hibernate.usertype.UserType;
/**
15 years, 4 months
JBoss Portal SVN: r12686 - in branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal: wsrp/consumer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-01-28 14:18:03 -0500 (Wed, 28 Jan 2009)
New Revision: 12686
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- JBPORTAL-2284: ProducerInfo are now created with a RegistrationInfo that's marked as undetermined instead of null.
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28 11:21:15 UTC (rev 12685)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28 19:18:03 UTC (rev 12686)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -31,6 +31,7 @@
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import java.util.Collection;
@@ -77,7 +78,8 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
TransactionAssert.commitTransaction();
TransactionAssert.beginTransaction();
@@ -103,7 +105,7 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ assertTrue(info.getRegistrationInfo().isUndetermined());
assertNull(registry.getConsumer("inexistent"));
Collection consumers = registry.getConfiguredConsumers();
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28 11:21:15 UTC (rev 12685)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28 19:18:03 UTC (rev 12686)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -152,7 +152,8 @@
public void testRefreshAndRegistration() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
@@ -173,7 +174,8 @@
public void testGetRegistrationContext() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28 11:21:15 UTC (rev 12685)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28 19:18:03 UTC (rev 12686)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -123,6 +123,7 @@
public ProducerInfo()
{
persistentEndpointInfo = new EndpointConfigurationInfo(this);
+ persistentRegistrationInfo = RegistrationInfo.createUndeterminedRegistration(this);
}
public ConsumerRegistry getRegistry()
@@ -345,7 +346,8 @@
try
{
// if we don't yet have registration information, get an unregistered service description
- serviceDescription = getUnmanagedServiceDescription(persistentRegistrationInfo == null);
+ boolean unmanaged = persistentRegistrationInfo == null || persistentRegistrationInfo.isUndetermined();
+ serviceDescription = getUnmanagedServiceDescription(unmanaged);
result.setServiceDescription(serviceDescription);
}
catch (OperationFailedFault operationFailedFault)
@@ -409,7 +411,7 @@
}
private RefreshResult refreshInfo(boolean forceRefresh, ServiceDescription serviceDescription, RefreshResult result)
- throws PortletInvokerException
+ throws PortletInvokerException
{
// do we need to call initCookie or not?
requiresInitCookie = serviceDescription.getRequiresInitCookie();
@@ -542,8 +544,8 @@
if (info.isUsesMethodGet())
{
log.warn("Portlet '" + portletHandle
- + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
- "the list of offered portlets for producer " + persistentId);
+ + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
+ "the list of offered portlets for producer " + persistentId);
}
else
{
@@ -616,7 +618,7 @@
catch (Exception e)
{
log.debug("Couldn't get portlet via getPortletDescription for producer '" + persistentId
- + "'. Attempting to retrieve it from the service description as this producer might not support the PortletManagement interface.", e);
+ + "'. Attempting to retrieve it from the service description as this producer might not support the PortletManagement interface.", e);
justRefreshed = refresh(true);
portlet = getPortletFromCaches(portletHandle, justRefreshed);
@@ -686,7 +688,7 @@
private boolean isCacheExpired()
{
boolean result = !useCache() || System.currentTimeMillis() > expirationTimeMillis || popsMap == null
- || portletGroups == null;
+ || portletGroups == null;
if (result)
{
log.debug("Cache expired or not used");
@@ -765,7 +767,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for producer "
- + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ", cause == null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred) throws PortletInvokerException
@@ -787,7 +789,7 @@
public RegistrationContext getRegistrationContext() throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
+ if (persistentRegistrationInfo == null || persistentRegistrationInfo.isUndetermined())
{
refresh(false);
}
@@ -835,7 +837,7 @@
throw new RuntimeException("Couldn't reset registration", e);
}
throw new IllegalArgumentException("Couldn't get property descriptions for portlet '" + portletHandle
- + "' because the provided registration is invalid!");
+ + "' because the provided registration is invalid!");
}
catch (Exception e)
{
@@ -887,7 +889,7 @@
{
log.debug("Attempting registration");
RegistrationContext registrationContext = persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
+ .register(persistentRegistrationInfo.getRegistrationData());
if (registrationContext == null)
{
@@ -897,7 +899,7 @@
persistentRegistrationInfo.setRegistrationContext(registrationContext);
String msg = "Consumer with id '" + persistentId + "' successfully registered with handle: '"
- + registrationContext.getRegistrationHandle() + "'";
+ + registrationContext.getRegistrationHandle() + "'";
log.debug(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
@@ -963,7 +965,7 @@
{
RegistrationContext registrationContext = getRegistrationContext();
ModifyRegistration modifyRegistration = WSRPTypeFactory.createModifyRegistration(registrationContext,
- persistentRegistrationInfo.getRegistrationData());
+ persistentRegistrationInfo.getRegistrationData());
RegistrationState state = persistentEndpointInfo.getRegistrationService().modifyRegistration(modifyRegistration);
// force refresh of internal RegistrationInfo state
@@ -993,7 +995,7 @@
else
{
throw new IllegalStateException("Cannot modify registration for producer '" + persistentId
- + "' as it's not registered");
+ + "' as it's not registered");
}
}
@@ -1013,7 +1015,7 @@
}
RefreshResult result =
- persistentRegistrationInfo.refresh(serviceDescription, persistentId, mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
+ persistentRegistrationInfo.refresh(serviceDescription, persistentId, mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
log.debug("Refreshed registration information for consumer with id '" + persistentId + "'");
@@ -1023,9 +1025,9 @@
public boolean isRefreshNeeded(boolean considerCache)
{
boolean result = (considerCache && isCacheExpired())
- || persistentRegistrationInfo == null
- || persistentRegistrationInfo.isRefreshNeeded()
- || persistentEndpointInfo.isRefreshNeeded();
+ || persistentRegistrationInfo == null
+ || persistentRegistrationInfo.isRefreshNeeded()
+ || persistentEndpointInfo.isRefreshNeeded();
if (result)
{
log.debug("Refresh needed for producer '" + persistentId + "'");
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28 11:21:15 UTC (rev 12685)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28 19:18:03 UTC (rev 12686)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -68,6 +68,12 @@
private transient boolean modifyRegistrationNeeded;
private transient ProducerInfo parent;
+ /**
+ * Marker string to identify a RegistrationInfo created for a producer that might not require registration as a work
+ * around https://jira.jboss.org/jira/browse/JBPORTAL-2284
+ */
+ private static final String UNDETERMINED_REGISTRATION = "__JBP__UNDETERMINED__REGISTRATION__";
+
public RegistrationInfo(ProducerInfo producerInfo)
{
this();
@@ -76,6 +82,18 @@
parent = producerInfo;
}
+ static RegistrationInfo createUndeterminedRegistration(ProducerInfo producerInfo)
+ {
+ RegistrationInfo info = new RegistrationInfo(producerInfo);
+ info.setConsumerName(UNDETERMINED_REGISTRATION);
+ return info;
+ }
+
+ public boolean isUndetermined()
+ {
+ return UNDETERMINED_REGISTRATION.equals(persistentConsumerName);
+ }
+
public RegistrationInfo(ProducerInfo producerInfo, boolean requiresRegistration)
{
this(producerInfo);
@@ -379,6 +397,12 @@
if (forceRefresh || isRefreshNeeded())
{
+ // if we were previously undetermined, become determined! :)
+ if (isUndetermined())
+ {
+ setConsumerName(WSRPConstants.DEFAULT_CONSUMER_NAME);
+ }
+
// get a service description if we don't already have one
if (serviceDescription == null && parent != null)
{
15 years, 4 months
JBoss Portal SVN: r12685 - branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-01-28 06:21:15 -0500 (Wed, 28 Jan 2009)
New Revision: 12685
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
Log:
html-source saving toggle fix
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-28 11:18:32 UTC (rev 12684)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-28 11:21:15 UTC (rev 12685)
@@ -31,7 +31,7 @@
}
String sh = System.getProperty("html-src");
- if ("true".equals(ss)) {
+ if ("true".equals(sh)) {
htmlSource = true;
}
}
15 years, 4 months
JBoss Portal SVN: r12684 - branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-01-28 06:18:32 -0500 (Wed, 28 Jan 2009)
New Revision: 12684
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
Log:
not saving debug html source
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-01-28 11:08:43 UTC (rev 12683)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-01-28 11:18:32 UTC (rev 12684)
@@ -317,7 +317,7 @@
selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select/option[4]");
selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/input");
selenium.waitForPageToLoad(PAGE_LOAD);
- savePage("3.html");
+
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /newFile"));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
15 years, 4 months
JBoss Portal SVN: r12683 - branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-01-28 06:08:43 -0500 (Wed, 28 Jan 2009)
New Revision: 12683
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
Log:
more timeout for archive upload
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-01-28 07:02:58 UTC (rev 12682)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-01-28 11:08:43 UTC (rev 12683)
@@ -38,7 +38,7 @@
logoutIfPossible();
login("admin", "admin");
// timeout hack
- selenium.setSpeed("10000");
+ selenium.setSpeed("15000");
}
@AfterMethod(groups = { "log" })
15 years, 4 months
JBoss Portal SVN: r12682 - in modules/authorization/trunk: PAP/src/test/java/org/jboss/security/authz/components and 24 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-28 02:02:58 -0500 (Wed, 28 Jan 2009)
New Revision: 12682
Added:
modules/authorization/trunk/core-components/
modules/authorization/trunk/core-components/pom.xml
modules/authorization/trunk/core-components/src/
modules/authorization/trunk/core-components/src/main/
modules/authorization/trunk/core-components/src/main/java/
modules/authorization/trunk/core-components/src/main/java/org/
modules/authorization/trunk/core-components/src/main/java/org/jboss/
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/
modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/subject/
modules/authorization/trunk/core-components/src/main/resources/
modules/authorization/trunk/core-components/src/test/
modules/authorization/trunk/core-components/src/test/java/
modules/authorization/trunk/core-components/src/test/java/org/
modules/authorization/trunk/core-components/src/test/java/org/jboss/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/NoPermitMeansDeniedAlg.java
modules/authorization/trunk/core-components/src/test/resources/
modules/authorization/trunk/core-components/src/test/resources/log4j.properties
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
Removed:
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/
modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpResource.java
Modified:
modules/authorization/trunk/.classpath
modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
modules/authorization/trunk/pom.xml
Log:
some refactoring of project structure
Modified: modules/authorization/trunk/.classpath
===================================================================
--- modules/authorization/trunk/.classpath 2009-01-28 06:09:13 UTC (rev 12681)
+++ modules/authorization/trunk/.classpath 2009-01-28 07:02:58 UTC (rev 12682)
@@ -4,6 +4,10 @@
<classpathentry kind="src" path="common/src/main/resources"/>
<classpathentry kind="src" path="common/src/test/java"/>
<classpathentry kind="src" path="common/src/test/resources"/>
+ <classpathentry kind="src" path="core-components/src/main/java"/>
+ <classpathentry kind="src" path="core-components/src/main/resources"/>
+ <classpathentry kind="src" path="core-components/src/test/java"/>
+ <classpathentry kind="src" path="core-components/src/test/resources"/>
<classpathentry kind="src" path="PEP/src/main/java"/>
<classpathentry kind="src" path="PEP/src/main/resources"/>
<classpathentry kind="src" path="PEP/src/test/java"/>
Added: modules/authorization/trunk/core-components/pom.xml
===================================================================
--- modules/authorization/trunk/core-components/pom.xml (rev 0)
+++ modules/authorization/trunk/core-components/pom.xml 2009-01-28 07:02:58 UTC (rev 12682)
@@ -0,0 +1,55 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-parent</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-authz-core-components</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Authorization Core Components</name>
+ <url>http://www.jboss.org</url>
+ <description>Contains Core Security Components</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.security.authz</groupId>
+ <artifactId>jboss-authz-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- jboss xacml -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-xacml</artifactId>
+ </dependency>
+
+ <!-- junit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <includes>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Copied: modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/subject (from rev 12681, modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject)
Property changes on: modules/authorization/trunk/core-components/src/main/java/org/jboss/security/authz/components/subject
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject (from rev 12681, modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject)
Property changes on: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-01-28 06:09:13 UTC (rev 12681)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-01-28 07:02:58 UTC (rev 12682)
@@ -31,7 +31,7 @@
import org.jboss.security.authz.model.Policy;
import org.jboss.security.authz.model.Rule;
import org.jboss.security.authz.model.ExpressionBuilder;
-import org.jboss.security.authz.pap.policy.HierarchialPolicy;
+import org.jboss.security.authz.test.MockPolicy;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -52,7 +52,7 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getAllowAuthMethodRule());
- Policy policy = new HierarchialPolicy("testGetAllowAuthMethodRule", target, rules);
+ Policy policy = new MockPolicy("testGetAllowAuthMethodRule", target, rules);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -70,7 +70,7 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getDenyAuthMethodRule());
- Policy policy = new HierarchialPolicy("testGetDenyAuthMethodRule", target, rules);
+ Policy policy = new MockPolicy("testGetDenyAuthMethodRule", target, rules);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -88,7 +88,7 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getAllowIdentityRule());
- Policy policy = new HierarchialPolicy("testGetAllowIdentityRule", target, rules);
+ Policy policy = new MockPolicy("testGetAllowIdentityRule", target, rules);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
@@ -106,7 +106,7 @@
Set<Rule> rules = new HashSet<Rule>();
rules.add(identity.getDenyIdentityRule());
- Policy policy = new HierarchialPolicy("testGetDenyIdentityRule", target, rules);
+ Policy policy = new MockPolicy("testGetDenyIdentityRule", target, rules);
log.info("----------------------------------------------------------------");
log.info(policy.generateXACMLPolicy());
Added: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java (rev 0)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/MockPolicy.java 2009-01-28 07:02:58 UTC (rev 12682)
@@ -0,0 +1,283 @@
+/******************************************************************************
+ * 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.test;
+
+import java.util.List;
+import java.util.Set;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBElement;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.model.Effect;
+import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.authz.model.DroolsRuleExpression;
+import org.jboss.security.authz.model.Expression;
+import org.jboss.security.authz.xacml.AttributeDesignatorUtil;
+import org.jboss.security.authz.xacml.PolicyUtil;
+
+import org.jboss.security.xacml.core.model.policy.ActionMatchType;
+import org.jboss.security.xacml.core.model.policy.SubjectMatchType;
+import org.jboss.security.xacml.core.model.policy.ApplyType;
+import org.jboss.security.xacml.core.model.policy.VariableReferenceType;
+import org.jboss.security.xacml.core.model.policy.EffectType;
+import org.jboss.security.xacml.core.model.policy.PolicyType;
+import org.jboss.security.xacml.core.model.policy.ResourceMatchType;
+import org.jboss.security.xacml.core.model.policy.ResourcesType;
+import org.jboss.security.xacml.core.model.policy.ResourceType;
+import org.jboss.security.xacml.core.model.policy.ActionsType;
+import org.jboss.security.xacml.core.model.policy.ActionType;
+import org.jboss.security.xacml.core.model.policy.SubjectsType;
+import org.jboss.security.xacml.core.model.policy.SubjectType;
+import org.jboss.security.xacml.core.model.policy.RuleType;
+import org.jboss.security.xacml.core.model.policy.TargetType;
+import org.jboss.security.xacml.core.model.policy.ConditionType;
+import org.jboss.security.xacml.core.model.policy.ObjectFactory;
+import org.jboss.security.xacml.core.model.policy.AttributeValueType;
+import org.jboss.security.xacml.core.model.policy.SubjectAttributeDesignatorType;
+import org.jboss.security.xacml.factories.PolicyAttributeFactory;
+
+/**
+ * Used for specifying policies for Resources represented by unique URIs, sometimes forming a tree like relationship with other Resources in the system
+ *
+ * An example of such resources would be tree of resources/nodes in a Content Management System
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPolicy extends Policy
+{
+ /**
+ *
+ * @param policyUri
+ */
+ public MockPolicy(String policyUri)
+ {
+ super(policyUri);
+ }
+
+ public MockPolicy(String policyUri, Target target, Set<Rule> rules) throws PolicyException
+ {
+ super(policyUri, target, rules);
+ }
+
+
+ @Override
+ public String generateXACMLPolicy() throws PolicyException
+ {
+ ByteArrayOutputStream bos = null;
+ try
+ {
+ String xacmlXml = null;
+
+ //SetUp the Policy Header
+ ObjectFactory objectFactory = new ObjectFactory();
+ PolicyType policyType = new PolicyType();
+ policyType.setPolicyId(this.policyUri);
+ policyType.setVersion("2.0");
+ policyType.setRuleCombiningAlgId(new NoPermitMeansDeniedAlg().getIdentifier().toString());
+
+ TargetType targetType = new TargetType();
+ policyType.setTarget(targetType);
+
+ //Process Resource Matches as Targets for the Policy
+ List<AttributeExpression> resourceMatches = this.target.getResourceMatches();
+ if(resourceMatches != null && !resourceMatches.isEmpty())
+ {
+ ResourcesType resourcesType = new ResourcesType();
+ targetType.setResources(resourcesType);
+ ResourceType resourceType = new ResourceType();
+
+ for(AttributeExpression resourceMatch: resourceMatches)
+ {
+ ResourceMatchType rmt = new ResourceMatchType();
+
+ rmt.setMatchId(resourceMatch.getFunctionId());
+ rmt.setResourceAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(resourceMatch.getAttribute()));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createStringAttributeType(resourceMatch.getAttribute().getValue()));
+
+ resourceType.getResourceMatch().add(rmt);
+ }
+
+ resourcesType.getResource().add(resourceType);
+ }
+
+ //Process the Policy Rules
+ if(this.rules != null && !this.rules.isEmpty())
+ {
+ for(Rule rule: this.rules)
+ {
+ RuleType ruleType = new RuleType();
+ ruleType.setRuleId(rule.getRuleId());
+ if(rule.getEffect() == Effect.PERMIT)
+ {
+ ruleType.setEffect(EffectType.PERMIT);
+ }
+ else
+ {
+ ruleType.setEffect(EffectType.DENY);
+ }
+
+ //Process the Rule Target
+ if(rule.getTarget() != null)
+ {
+ List<AttributeExpression> actionMatches = rule.getTarget().getActionMatches();
+ List<AttributeExpression> subjectMatches = rule.getTarget().getSubjectMatches();
+ TargetType ruleTarget = new TargetType();
+
+ if(actionMatches != null && !actionMatches.isEmpty())
+ {
+ ruleTarget.setActions(this.generateRuleActions(actionMatches));
+ }
+
+ if(subjectMatches != null && !subjectMatches.isEmpty())
+ {
+ ruleTarget.setSubjects(this.generateRuleSubjects(subjectMatches));
+ }
+
+ ruleType.setTarget(ruleTarget);
+ }
+
+ //Process the Rule Expression/Condition
+ ConditionType condition = this.generateCondition(objectFactory, rule.getExpression());
+ ruleType.setCondition(condition);
+
+ policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(ruleType);
+ }
+ }
+
+ bos = new ByteArrayOutputStream();
+ PolicyUtil.marshall(bos, policyType);
+ xacmlXml = new String(bos.toByteArray());
+
+ return xacmlXml;
+ }
+ catch(Exception e)
+ {
+ throw new PolicyException(e);
+ }
+ finally
+ {
+ if(bos != null)
+ {
+ try{bos.close();}catch(IOException ioe){}
+ }
+ }
+ }
+
+ private ActionsType generateRuleActions(List<AttributeExpression> actionMatches)
+ {
+ ActionsType actions = new ActionsType();
+
+ for(AttributeExpression action: actionMatches)
+ {
+ ActionType actionType = new ActionType();
+ ActionMatchType amct = new ActionMatchType();
+ amct.setMatchId(action.getFunctionId());
+ amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType(action.getAttribute().getValue()));
+ amct.setActionAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(action.getAttribute()));
+ actionType.getActionMatch().add(amct);
+ actions.getAction().add(actionType);
+ }
+
+ return actions;
+ }
+
+ private SubjectsType generateRuleSubjects(List<AttributeExpression> subjectMatches)
+ {
+ SubjectsType subjects = new SubjectsType();
+
+ for(AttributeExpression subject: subjectMatches)
+ {
+ SubjectType subjectType = new SubjectType();
+ SubjectMatchType match = new SubjectMatchType();
+ match.setMatchId(subject.getFunctionId());
+ match.setAttributeValue(PolicyAttributeFactory.createStringAttributeType(subject.getAttribute().getValue()));
+ match.setSubjectAttributeDesignator((SubjectAttributeDesignatorType)AttributeDesignatorUtil.getAttributeDesignator(subject.getAttribute()));
+ subjectType.getSubjectMatch().add(match);
+ subjects.getSubject().add(subjectType);
+ }
+
+ return subjects;
+ }
+
+ /**
+ *
+ * @param expression
+ * @return
+ */
+ private ConditionType generateCondition(ObjectFactory objectFactory, Expression expression)
+ {
+ ConditionType condition = new ConditionType();
+
+ if(expression instanceof AttributeExpression)
+ {
+ AttributeExpression attributeExpression = (AttributeExpression)expression;
+
+ //Function to be applied
+ ApplyType apply = new ApplyType();
+ apply.setFunctionId(attributeExpression.getFunctionId());
+
+ //Value to check against
+ AttributeValueType attrValue = PolicyAttributeFactory.createStringAttributeType(attributeExpression.getAttribute().getValue());
+ JAXBElement<AttributeValueType> jaxbAttrValue = objectFactory.createAttributeValue(attrValue);
+ apply.getExpression().add(jaxbAttrValue);
+
+ //Place within the Context where this Value should exist during an Authorization Request
+ apply.getExpression().add(AttributeDesignatorUtil.getAttributeDesignatorXml(attributeExpression.getAttribute()));
+
+
+ condition.setExpression(objectFactory.createApply(apply));
+ }
+ else if(expression instanceof DroolsRuleExpression)
+ {
+ DroolsRuleExpression ruleExpression = (DroolsRuleExpression)expression;
+
+ //Function to be applied
+ ApplyType apply = new ApplyType();
+ apply.setFunctionId(ruleExpression.getFunctionId());
+
+
+ VariableReferenceType ruleReference = new VariableReferenceType();
+ ruleReference.setVariableId(ruleExpression.getRuleReference());
+ JAXBElement<VariableReferenceType> jaxbRuleReference = objectFactory.createVariableReference(ruleReference);
+ apply.getExpression().add(jaxbRuleReference);
+
+
+ condition.setExpression(objectFactory.createApply(apply));
+ }
+
+ return condition;
+ }
+
+ private String generateUniqueId()
+ {
+ return UUID.randomUUID().toString();
+ }
+}
Added: modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/NoPermitMeansDeniedAlg.java
===================================================================
--- modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/NoPermitMeansDeniedAlg.java (rev 0)
+++ modules/authorization/trunk/core-components/src/test/java/org/jboss/security/authz/test/NoPermitMeansDeniedAlg.java 2009-01-28 07:02:58 UTC (rev 12682)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.test;
+
+import java.util.List;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.security.xacml.sunxacml.combine.RuleCombiningAlgorithm;
+import org.jboss.security.xacml.sunxacml.EvaluationCtx;
+import org.jboss.security.xacml.sunxacml.ctx.Result;
+import org.jboss.security.xacml.sunxacml.Rule;
+import org.jboss.security.xacml.sunxacml.combine.RuleCombinerElement;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class NoPermitMeansDeniedAlg extends RuleCombiningAlgorithm
+{
+ /**
+ *
+ * @throws URISyntaxException
+ */
+ public NoPermitMeansDeniedAlg() throws URISyntaxException
+ {
+ super(new URI("rule-combining-alg:nopermit-means-denied"));
+ }
+
+ /**
+ *
+ * @param context
+ * @param rules
+ * @return
+ */
+ public Result combine(EvaluationCtx context, List parameters, List ruleElements)
+ {
+ Result result = new Result(Result.DECISION_PERMIT);
+
+ Iterator rules = ruleElements.iterator();
+ boolean permitFound = false;
+ while(rules.hasNext())
+ {
+ RuleCombinerElement ruleCombinerElement = (RuleCombinerElement)rules.next();
+ Rule rule = ruleCombinerElement.getRule();
+ Result currentResult = rule.evaluate(context);
+
+ if(currentResult.getDecision() == Result.DECISION_PERMIT)
+ {
+ permitFound = true;
+ break;
+ }
+ }
+
+ if(!permitFound)
+ {
+ result = new Result(Result.DECISION_DENY);
+ }
+
+ return result;
+ }
+}
Added: modules/authorization/trunk/core-components/src/test/resources/log4j.properties
===================================================================
--- modules/authorization/trunk/core-components/src/test/resources/log4j.properties (rev 0)
+++ modules/authorization/trunk/core-components/src/test/resources/log4j.properties 2009-01-28 07:02:58 UTC (rev 12682)
@@ -0,0 +1,8 @@
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
Copied: modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java (from rev 12681, modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpResource.java)
===================================================================
--- modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java (rev 0)
+++ modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-01-28 07:02:58 UTC (rev 12682)
@@ -0,0 +1,114 @@
+/*
+* 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.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.http.components.HttpResource;
+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.pap.policy.HierarchialPolicy;
+
+
+/**
+ * @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.setUrl("/portal/admin-tool/modifyLayout");
+
+ Target target = httpResource.getURLTarget(false);
+
+ Policy policy = new HierarchialPolicy("testGetURLTargetNoParameters", target, new HashSet<Rule>());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testGetURLTargetWithParameters() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUrl("/portal/admin-tool/modifyLayout");
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+
+ Target target = httpResource.getURLTarget(true);
+
+ Policy policy = new HierarchialPolicy("testGetURLTargetWithParameters", target, new HashSet<Rule>());
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testRoleRules() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUrl("/portal/admin-tool/modifyLayout");
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+ httpResource.addAllowedRole("admin");
+ httpResource.addDeniedRole("anonymous");
+
+ Target target = httpResource.getURLTarget(true);
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(httpResource.getPermittedRolesRule());
+ rules.add(httpResource.getDeniedRolesRule());
+
+ Policy policy = new HierarchialPolicy("testRoleRules", target, rules);
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testIPRules() throws Exception
+ {
+ HttpResource httpResource = new HttpResource();
+ httpResource.setUrl("/portal/admin-tool/modifyLayout");
+ httpResource.addParameter("test1", "test1://value");
+ httpResource.addParameter("test2", "test2://value");
+ httpResource.addAllowedRole("admin");
+ httpResource.addDeniedRole("anonymous");
+ httpResource.addAllowedIp("192.168.x.x");
+
+ Target target = httpResource.getURLTarget(true);
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(httpResource.getPermittedRolesRule());
+ rules.add(httpResource.getDeniedRolesRule());
+ rules.add(httpResource.getAllowedIpsRule());
+
+ Policy policy = new HierarchialPolicy("testIPRules", target, rules);
+
+ log.info("------------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+}
Property changes on: modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpResource.java
===================================================================
--- modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpResource.java 2009-01-28 06:09:13 UTC (rev 12681)
+++ modules/authorization/trunk/http-authz/src/test/java/org/jboss/security/authz/http/pap/TestHttpResource.java 2009-01-28 07:02:58 UTC (rev 12682)
@@ -1,110 +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.http.pap;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-
-import org.jboss.security.authz.http.components.HttpResource;
-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.pap.policy.HierarchialPolicy;
-
-
-/**
- * @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("/portal/admin-tool/modifyLayout");
-
- Target target = httpResource.getURLTarget(false);
-
- Policy policy = new HierarchialPolicy("testGetURLTargetNoParameters", target, new HashSet<Rule>());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateXACMLPolicy());
- }
-
- public void testGetURLTargetWithParameters() throws Exception
- {
- HttpResource httpResource = new HttpResource("/portal/admin-tool/modifyLayout");
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
-
- Target target = httpResource.getURLTarget(true);
-
- Policy policy = new HierarchialPolicy("testGetURLTargetWithParameters", target, new HashSet<Rule>());
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateXACMLPolicy());
- }
-
- public void testRoleRules() throws Exception
- {
- HttpResource httpResource = new HttpResource("/portal/admin-tool/modifyLayout");
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowedRole("admin");
- httpResource.addDeniedRole("anonymous");
-
- Target target = httpResource.getURLTarget(true);
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(httpResource.getPermittedRolesRule());
- rules.add(httpResource.getDeniedRolesRule());
-
- Policy policy = new HierarchialPolicy("testRoleRules", target, rules);
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateXACMLPolicy());
- }
-
- public void testIPRules() throws Exception
- {
- HttpResource httpResource = new HttpResource("/portal/admin-tool/modifyLayout");
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowedRole("admin");
- httpResource.addDeniedRole("anonymous");
- httpResource.addAllowedIp("192.168.x.x");
-
- Target target = httpResource.getURLTarget(true);
- Set<Rule> rules = new HashSet<Rule>();
- rules.add(httpResource.getPermittedRolesRule());
- rules.add(httpResource.getDeniedRolesRule());
- rules.add(httpResource.getAllowedIpsRule());
-
- Policy policy = new HierarchialPolicy("testIPRules", target, rules);
-
- log.info("------------------------------------------------------------------");
- log.info(policy.generateXACMLPolicy());
- }
-}
Modified: modules/authorization/trunk/pom.xml
===================================================================
--- modules/authorization/trunk/pom.xml 2009-01-28 06:09:13 UTC (rev 12681)
+++ modules/authorization/trunk/pom.xml 2009-01-28 07:02:58 UTC (rev 12682)
@@ -10,10 +10,11 @@
<description>JBoss Authorization</description>
<modules>
- <module>common</module>
+ <module>common</module>
+ <module>core-components</module>
<module>PEP</module>
<module>PAP</module>
- <module>http-authz</module>
+ <module>http-authz</module>
<!--
<module>security-console</module>
-->
15 years, 4 months
JBoss Portal SVN: r12681 - in modules/authorization/trunk: PAP/src/test/java/org/jboss/security/authz and 5 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-28 01:09:13 -0500 (Wed, 28 Jan 2009)
New Revision: 12681
Added:
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/
modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
Modified:
modules/authorization/trunk/PAP/pom.xml
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/xacml/AttributeDesignatorUtil.java
modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/components/HttpResource.java
Log:
Adding more security components
Modified: modules/authorization/trunk/PAP/pom.xml
===================================================================
--- modules/authorization/trunk/PAP/pom.xml 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/PAP/pom.xml 2009-01-28 06:09:13 UTC (rev 12681)
@@ -74,10 +74,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.3.1</version>
<configuration>
- <includes>
- <!--
- <include>**/TestHierarchialPolicy.java</include>
- -->
+ <includes>
+ <include>**/TestIdentity.java</include>
</includes>
</configuration>
</plugin>
Added: modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java
===================================================================
--- modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java (rev 0)
+++ modules/authorization/trunk/PAP/src/test/java/org/jboss/security/authz/components/subject/TestIdentity.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -0,0 +1,114 @@
+/*
+* 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.Target;
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.ExpressionBuilder;
+import org.jboss.security.authz.pap.policy.HierarchialPolicy;
+
+/**
+ * @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 testGetAllowAuthMethodRule() throws Exception
+ {
+ Identity identity = new Identity();
+ identity.setName("admin");
+ identity.setAuthenticationMethod("CERT");
+
+ Target target = new Target();
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
+
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(identity.getAllowAuthMethodRule());
+
+ Policy policy = new HierarchialPolicy("testGetAllowAuthMethodRule", target, rules);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testGetDenyAuthMethodRule() throws Exception
+ {
+ Identity identity = new Identity();
+ identity.setName("admin");
+ identity.setAuthenticationMethod("CERT");
+
+ Target target = new Target();
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
+
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(identity.getDenyAuthMethodRule());
+
+ Policy policy = new HierarchialPolicy("testGetDenyAuthMethodRule", target, rules);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testGetAllowIdentityRule() throws Exception
+ {
+ Identity identity = new Identity();
+ identity.setName("admin");
+ identity.setAuthenticationMethod("CERT");
+
+ Target target = new Target();
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
+
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(identity.getAllowIdentityRule());
+
+ Policy policy = new HierarchialPolicy("testGetAllowIdentityRule", target, rules);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+
+ public void testGetDenyIdentityRule() throws Exception
+ {
+ Identity identity = new Identity();
+ identity.setName("admin");
+ identity.setAuthenticationMethod("CERT");
+
+ Target target = new Target();
+ target.addResourceMatch(ExpressionBuilder.getInstance().createResourceIdExpression("test://Resource"));
+
+ Set<Rule> rules = new HashSet<Rule>();
+ rules.add(identity.getDenyIdentityRule());
+
+ Policy policy = new HierarchialPolicy("testGetDenyIdentityRule", target, rules);
+
+ log.info("----------------------------------------------------------------");
+ log.info(policy.generateXACMLPolicy());
+ }
+}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -24,7 +24,11 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.authz.model.Effect;
import org.jboss.security.authz.model.ExpressionBuilder;
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.tools.GeneralTool;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -50,14 +54,11 @@
*/
private String authenticationMethod;
- public Identity(String name)
+ public Identity()
{
- if(name == null || name.trim().length() == 0)
- {
- throw new IllegalArgumentException("Identity Name Cannot Be Empty");
- }
+
}
-
+
public String getName()
{
return name;
@@ -80,35 +81,122 @@
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
- * Creates an expression for matching an the Identity of the Authenticated User
+ * Creates a Rule to Allow Access to this Identity
*
- * @return an expression that will be used within the Policy Definition
+ * @return rule that Allows Access to this Identity
*/
- public AttributeExpression createIdentityExpression()
- {
- return ExpressionBuilder.getInstance().createIdentityExpression(this.name);
+ public Rule getAllowIdentityRule()
+ {
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Identity Name Is Missing!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
+ target.addSubjectMatch(ExpressionBuilder.getInstance().createIdentityExpression(this.name));
+
+ return rule;
}
/**
- * Creates an expression for matching the Authentication Method of the User
+ * Creates a Rule to Deny Access to this Identity
*
- * @return an expression that will be used within the Policy Definition
+ * @return rule that Denies Access to this Identity
*/
- public AttributeExpression createAuthMethodExpression()
- {
- if(this.authenticationMethod == null || this.authenticationMethod.trim().length() == 0)
- {
- throw new IllegalStateException("Authentication Method is Empty");
- }
+ public Rule getDenyIdentityRule()
+ {
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Identity Name Is Missing!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
- AttributeExpression expression = new AttributeExpression();
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
- expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ target.addSubjectMatch(ExpressionBuilder.getInstance().createIdentityExpression(this.name));
- Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_AUTHENTICATION_METHOD,
- XMLSchemaConstants.DATATYPE_STRING, this.authenticationMethod);
- expression.setAttribute(attribute);
-
- return expression;
+ return rule;
}
+
+ /**
+ * Creates a Rule to Allow Access to this Identity if User is authenticated with the Authentication Method
+ *
+ * @return rule that Allows Access if User of this Identity is authenticated by this Authentication Method
+ */
+ public Rule getAllowAuthMethodRule()
+ {
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Identity Name Is Missing!!");
+ }
+
+ if(this.authenticationMethod == null || this.authenticationMethod.trim().length() == 0)
+ {
+ throw new IllegalStateException("Authentication Method Is Missing!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
+ target.addSubjectMatch(ExpressionBuilder.getInstance().createIdentityExpression(this.name));
+
+ AttributeExpression expression = new AttributeExpression();
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_AUTHENTICATION_METHOD,
+ XMLSchemaConstants.DATATYPE_STRING, this.authenticationMethod);
+ expression.setAttribute(attribute);
+ rule.setExpression(expression);
+
+ return rule;
+ }
+
+ /**
+ * Creates a Rule to Deny Access to this Identity if User is authenticated with the Authentication Method
+ *
+ * @return rule that Allows Access if User of this Identity is authenticated by this Authentication Method
+ */
+ public Rule getDenyAuthMethodRule()
+ {
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Identity Name Is Missing!!");
+ }
+
+ if(this.authenticationMethod == null || this.authenticationMethod.trim().length() == 0)
+ {
+ throw new IllegalStateException("Authentication Method Is Missing!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
+
+ target.addSubjectMatch(ExpressionBuilder.getInstance().createIdentityExpression(this.name));
+
+ AttributeExpression expression = new AttributeExpression();
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_AUTHENTICATION_METHOD,
+ XMLSchemaConstants.DATATYPE_STRING, this.authenticationMethod);
+ expression.setAttribute(attribute);
+ rule.setExpression(expression);
+
+ return rule;
+ }
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -26,6 +26,10 @@
import org.jboss.security.authz.model.Attribute;
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.tools.GeneralTool;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -50,6 +54,11 @@
*/
private String dnsName;
+ /**
+ * Regular Expression for matching the fact whether the IP Address of the remote Machine falls within the specified range of IP Addresses
+ */
+ private String ipRangeRegEx;
+
public Machine()
{
@@ -74,19 +83,37 @@
{
this.dnsName = dnsName;
}
+
+
+ public String getIpRangeRegEx()
+ {
+ return ipRangeRegEx;
+ }
+
+ public void setIpRangeRegEx(String ipRangeRegEx)
+ {
+ this.ipRangeRegEx = ipRangeRegEx;
+ }
//------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
- * Creates an expression for matching the IP Address of the remote Machine
+ * Creates a Rule specifying that the Remote Machine with this IP Address should be Allowed Access
*
- * @return an expression that will be used within the Policy Definition
+ * @return the rule
*/
- public AttributeExpression createRemoteIPExpression()
+ public Rule getAllowedRemoteIP()
{
if(this.ipAddress == null)
{
throw new IllegalStateException("The IP Address is Empty");
}
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
AttributeExpression expression = new AttributeExpression();
expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
@@ -95,45 +122,94 @@
XMLSchemaConstants.DATATYPE_STRING, this.ipAddress.getHostAddress());
expression.setAttribute(attribute);
- return expression;
+ rule.setExpression(expression);
+
+ return rule;
}
/**
- * Creates an expression for matching the fact whether the IP Address of the remote Machine falls within the specified range of IP Addresses
+ * Creates a Rule specifying that the Remote Machine with this IP Address should be Denied Access
*
- * @param ipRangeRegex A regular expression to represent the range of IP Addresses
- * @return the desired expression
+ * @return the rule
*/
- public AttributeExpression createIsMachineInRangeExpression(String ipRangeRegex)
+ public Rule getDeniedRemoteIP()
{
if(this.ipAddress == null)
{
throw new IllegalStateException("The IP Address is Empty");
}
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
+
AttributeExpression expression = new AttributeExpression();
- expression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_IPADDRESS_MATCH);
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
- XMLSchemaConstants.DATATYPE_IPADDRESS, ipRangeRegex);
+ XMLSchemaConstants.DATATYPE_STRING, this.ipAddress.getHostAddress());
expression.setAttribute(attribute);
- return expression;
+ rule.setExpression(expression);
+
+ return rule;
}
+
+ /**
+ * Creates a Rule that specifies that the Remote Machine with its DNS address is Allowed Access
+ *
+ * @return the rule
+ */
+ public Rule getAllowedRemoteDNS()
+ {
+ if(this.dnsName == null || this.dnsName.trim().length() == 0)
+ {
+ throw new IllegalStateException("The DNSName is Empty");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_DNS_NAME,
+ XMLSchemaConstants.DATATYPE_STRING, this.dnsName);
+ expression.setAttribute(attribute);
+
+ rule.setExpression(expression);
+
+ return rule;
+ }
/**
- * Creates an expression for matching the DNS Name of the remote Machine
+ * Creates a Rule that specifies that the Remote Machine with its DNS address is Denied Access
*
- * @return the desired expression
+ * @return the rule
*/
- public AttributeExpression createRemoteDNSExpression()
+ public Rule getDenyRemoteDNS()
{
if(this.dnsName == null || this.dnsName.trim().length() == 0)
{
throw new IllegalStateException("The DNSName is Empty");
}
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
+
AttributeExpression expression = new AttributeExpression();
expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
@@ -142,6 +218,68 @@
XMLSchemaConstants.DATATYPE_STRING, this.dnsName);
expression.setAttribute(attribute);
- return expression;
+ rule.setExpression(expression);
+
+ return rule;
}
+
+ /**
+ * Creates a Rule specifying that the Remote Machine should be Allowed Access if it falls within the specified IP Range
+ *
+ * @return the rule
+ */
+ public Rule getAllowedRemoteIPRange()
+ {
+ if(this.ipRangeRegEx == null || this.ipRangeRegEx.trim().length() == 0)
+ {
+ throw new IllegalStateException("The IP Range is not specified");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_IPADDRESS_MATCH);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
+ XMLSchemaConstants.DATATYPE_IPADDRESS, this.ipRangeRegEx);
+ expression.setAttribute(attribute);
+
+ return rule;
+ }
+
+ /**
+ * Creates a Rule specifying that the Remote Machine should be Denied Access if it falls within the specified IP Range
+ *
+ * @return the rule
+ */
+ public Rule getDeniedRemoteIPRange()
+ {
+ if(this.ipRangeRegEx == null || this.ipRangeRegEx.trim().length() == 0)
+ {
+ throw new IllegalStateException("The IP Range is not specified");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_IPADDRESS_MATCH);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
+ XMLSchemaConstants.DATATYPE_IPADDRESS, this.ipRangeRegEx);
+ expression.setAttribute(attribute);
+
+ return rule;
+ }
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -24,6 +24,10 @@
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.Target;
+import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.model.Effect;
import org.jboss.security.xacml.interfaces.XACMLConstants;
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
@@ -44,12 +48,9 @@
*/
private String name;
- public Role(String name)
+ public Role()
{
- if(name == null || name.trim().length() == 0)
- {
- throw new IllegalArgumentException("Role Name Cannot Be Empty");
- }
+
}
public String getName()
@@ -63,20 +64,62 @@
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
- * Creates an expression for matching the Role of the Authenticated User
+ * Creates a Rule that Allows Access if the Identity/User in question Belongs to the specified Role
*
- * @return an expression that will be used within the Policy Definition
+ * @return the rule
*/
- public AttributeExpression createIsUserInRoleExpression()
+ public Rule getAllowUserInRole()
{
- AttributeExpression expression = new AttributeExpression();
-
- expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
-
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Role is not specified!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.PERMIT);
+ rule.setTarget(target);
+
+
+ AttributeExpression expression = new AttributeExpression();
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
XMLSchemaConstants.DATATYPE_STRING, this.name);
expression.setAttribute(attribute);
+ rule.setExpression(expression);
- return expression;
- }
+ return rule;
+ }
+
+ /**
+ * Creates a Rule that Denies Access if the Identity/User in question Belongs to the specified Role
+ *
+ * @return the rule
+ */
+ public Rule getDenyUserInRole()
+ {
+ if(this.name == null || this.name.trim().length() == 0)
+ {
+ throw new IllegalStateException("Role is not specified!!");
+ }
+
+ Rule rule = new Rule();
+ Target target = new Target();
+
+ rule.setRuleId(GeneralTool.generateUniqueId());
+ rule.setEffect(Effect.DENY);
+ rule.setTarget(target);
+
+
+ AttributeExpression expression = new AttributeExpression();
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_ROLE,
+ XMLSchemaConstants.DATATYPE_STRING, this.name);
+ expression.setAttribute(attribute);
+ rule.setExpression(expression);
+
+ return rule;
+ }
}
Modified: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/xacml/AttributeDesignatorUtil.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/xacml/AttributeDesignatorUtil.java 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/xacml/AttributeDesignatorUtil.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -51,7 +51,9 @@
//TODO: add all the conditions to detect a Subject Attribute
if(uri.equals(XACMLConstants.ATTRIBUTEID_ROLE) ||
- uri.equals(XACMLConstants.ATTRIBUTEID_IP_ADDRESS)
+ uri.equals(XACMLConstants.ATTRIBUTEID_IP_ADDRESS) ||
+ uri.equals(XACMLConstants.ATTRIBUTEID_AUTHENTICATION_METHOD) ||
+ uri.equals(XACMLConstants.ATTRIBUTEID_SUBJECT_ID)
)
{
attributeDesignator = PolicyAttributeFactory.createSubjectAttributeDesignatorType(attribute.getUri(),
@@ -86,13 +88,13 @@
String uri = attributeDesignator.getAttributeId();
//TODO: finish this implementation to include all Attribute Types like Resource, Action, and Environment
- if(uri.equals(XACMLConstants.ATTRIBUTEID_ACTION_ID))
+ if(uri.equals(XACMLConstants.ATTRIBUTEID_ACTION_ID)
+ )
{
xmlRep = objectFactory.createActionAttributeDesignator(attributeDesignator);
}
}
-
-
+
return xmlRep;
}
}
Modified: modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/components/HttpResource.java
===================================================================
--- modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/components/HttpResource.java 2009-01-27 21:05:15 UTC (rev 12680)
+++ modules/authorization/trunk/http-authz/src/main/java/org/jboss/security/authz/http/components/HttpResource.java 2009-01-28 06:09:13 UTC (rev 12681)
@@ -83,20 +83,8 @@
this.allowedRoles = new HashSet<String>();
this.deniedRoles = new HashSet<String>();
this.allowedIps = new HashSet<String>();
- }
-
- public HttpResource(String url)
- {
- this();
-
- if(url == null)
- {
- throw new IllegalArgumentException("URL Cannot Be Empty");
- }
+ }
- this.url = url;
- }
-
public Map<String, String> getParameters()
{
return parameters;
15 years, 4 months