JBoss Portal SVN: r12450 - in modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components: resource and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-07 23:19:57 -0500 (Wed, 07 Jan 2009)
New Revision: 12450
Added:
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/resource/
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
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/Machine.java
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java
Log:
code backup
Added: modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java
===================================================================
--- modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java (rev 0)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/resource/HttpResource.java 2009-01-08 04:19:57 UTC (rev 12450)
@@ -0,0 +1,138 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.components.resource;
+
+import java.net.URL;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
+/**
+ * The HttpResource Policy Component represents a System Resource available via the HTTP Protocol
+ *
+ * This Component provides an easy to use Developer API for generating commonly used Expressions/Logic related to Http information that must be
+ * represented within an Authorization Policy
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class HttpResource
+{
+ /**
+ * The URL that identifies this resource
+ */
+ private URL url;
+
+ /**
+ * The HTTP Parameters that are used to access this resource
+ */
+ private Map<String, String> parameters;
+
+ public HttpResource(URL url)
+ {
+ if(url == null)
+ {
+ throw new IllegalArgumentException("URL Cannot Be Empty");
+ }
+
+ this.url = url;
+ this.parameters = new HashMap<String, String>();
+ }
+
+ public Map<String, String> getParameters()
+ {
+ return parameters;
+ }
+
+
+ public void setParameters(Map<String, String> parameters)
+ {
+ this.parameters = parameters;
+ }
+
+
+ public URL getUrl()
+ {
+ return url;
+ }
+
+
+ public void setUrl(URL url)
+ {
+ this.url = url;
+ }
+
+ public void addParameter(String name, String value)
+ {
+ if(this.parameters == null)
+ {
+ this.parameters = new HashMap<String, String>();
+ }
+ this.parameters.put(name, value);
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching the URL of the HttpResource
+ *
+ * @return desired expression
+ */
+ public AttributeExpression createURLExpression()
+ {
+ if(this.url == null)
+ {
+ throw new IllegalStateException("Http URL cannot be Empty");
+ }
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_RESOURCE_ID,
+ XMLSchemaConstants.DATATYPE_STRING, this.url.toString());
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching the URL along with its Parameters
+ *
+ * @return the desired expression
+ */
+ public AttributeExpression createURLWithParametersExpression()
+ {
+ 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);
+
+ return expression;
+ }
+}
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-07 23:21:18 UTC (rev 12449)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2009-01-08 04:19:57 UTC (rev 12450)
@@ -28,12 +28,24 @@
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
/**
+ * The Identity Policy Component represents the "Identity/User" that is Authenticated by the System
+ *
+ * This Component provides an easy to use Developer API for generating commonly used Expressions/Logic related to Identity information that must be
+ * represented within an Authorization Policy
+ *
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
public class Identity
{
+ /**
+ * Unique id/name of the Identity
+ */
private String name;
+
+ /**
+ * Authentication Method used to Authenticate this Identity
+ */
private String authenticationMethod;
public Identity(String name)
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-07 23:21:18 UTC (rev 12449)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java 2009-01-08 04:19:57 UTC (rev 12450)
@@ -22,11 +22,126 @@
******************************************************************************/
package org.jboss.security.authz.components.subject;
+import java.net.InetAddress;
+
+import org.jboss.security.authz.model.Attribute;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.xacml.interfaces.XACMLConstants;
+import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
+
/**
+ * The Machine Policy Component represents the "Machine" that is accessing the System
+ *
+ * This Component provides an easy to use Developer API for generating commonly used Expressions/Logic related to Machine related information that must be
+ * represented within an Authorization Policy
+ *
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
public class Machine
{
+ /**
+ * IP Address of the machine
+ */
+ private InetAddress ipAddress;
+
+ /**
+ * DNS Name of the machine
+ */
+ private String dnsName;
+
+ public Machine()
+ {
+
+ }
+ public InetAddress getIpAddress()
+ {
+ return ipAddress;
+ }
+
+ public void setIpAddress(InetAddress ipAddress)
+ {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getDnsName()
+ {
+ return dnsName;
+ }
+
+ public void setDnsName(String dnsName)
+ {
+ this.dnsName = dnsName;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching the IP Address of the remote Machine
+ *
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createRemoteIPExpression()
+ {
+ if(this.ipAddress == null)
+ {
+ throw new IllegalStateException("The IP Address is Empty");
+ }
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
+ XMLSchemaConstants.DATATYPE_STRING, this.ipAddress.getHostAddress());
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching the fact whether the IP Address of the remote Machine falls within the specified range of IP Addresses
+ *
+ * @param ipRangeRegex A regular expression to represent the range of IP Addresses
+ * @return the desired expression
+ */
+ public AttributeExpression createIsMachineInRangeExpression(String ipRangeRegex)
+ {
+ if(this.ipAddress == null)
+ {
+ throw new IllegalStateException("The IP Address is Empty");
+ }
+
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_IPADDRESS_MATCH);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_IP_ADDRESS,
+ XMLSchemaConstants.DATATYPE_IPADDRESS, ipRangeRegex);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching the DNS Name of the remote Machine
+ *
+ * @return the desired expression
+ */
+ public AttributeExpression createRemoteDNSExpression()
+ {
+ if(this.dnsName == null || this.dnsName.trim().length() == 0)
+ {
+ throw new IllegalStateException("The DNSName is Empty");
+ }
+
+ 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);
+
+ return expression;
+ }
}
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-07 23:21:18 UTC (rev 12449)
+++ modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java 2009-01-08 04:19:57 UTC (rev 12450)
@@ -28,11 +28,20 @@
import org.jboss.security.xacml.interfaces.XMLSchemaConstants;
/**
+ * The Role Policy Component represents the "Roles" that are assigned to users of a System
+ *
+ * This Component provides an easy to use Developer API for generating commonly used Expressions/Logic related to Role information that must be
+ * represented within an Authorization Policy
+ *
+ *
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
public class Role
{
+ /**
+ * Role Name
+ */
private String name;
public Role(String name)
@@ -58,7 +67,7 @@
*
* @return an expression that will be used within the Policy Definition
*/
- public AttributeExpression createIsUserInRole()
+ public AttributeExpression createIsUserInRoleExpression()
{
AttributeExpression expression = new AttributeExpression();
17 years, 3 months
JBoss Portal SVN: r12449 - in modules/portlet/trunk/samples/src/main: artifacts/remotecontroller-portlet-war/WEB-INF and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-01-07 18:21:18 -0500 (Wed, 07 Jan 2009)
New Revision: 12449
Modified:
modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java
Log:
- JBPORTAL-2238: Trying to get remote window to refresh when main page is refreshed... Not working yet.
- doHeaders doesn't seem to be working either...
- Google portlet now publishes zip as an event as well in case portlets are interested in it
Modified: modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2009-01-07 19:34:24 UTC (rev 12448)
+++ modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2009-01-07 23:21:18 UTC (rev 12449)
@@ -63,6 +63,9 @@
<read-only>false</read-only>
</preference>
</portlet-preferences>
+ <supported-publishing-event>
+ <qname xmlns:jbp='urn:jboss:portal:samples:event'>jbp:ZipEvent</qname>
+ </supported-publishing-event>
<supported-public-render-parameter>zipcode</supported-public-render-parameter>
</portlet>
@@ -107,6 +110,11 @@
<supported-public-render-parameter>zipcode</supported-public-render-parameter>
</portlet>
+ <event-definition>
+ <qname xmlns:jbp='urn:jboss:portal:samples:event'>jbp:ZipEvent</qname>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+
<public-render-parameter>
<identifier>zipcode</identifier>
<qname xmlns:g='urn:jboss:portal:simple:google'>g:zipcode</qname>
Modified: modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml 2009-01-07 19:34:24 UTC (rev 12448)
+++ modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml 2009-01-07 23:21:18 UTC (rev 12449)
@@ -52,5 +52,10 @@
<identifier>zipcode</identifier>
<qname xmlns:g='urn:jboss:portal:simple:google'>g:zipcode</qname>
</public-render-parameter>
+
+ <container-runtime-option>
+ <name>javax.portlet.renderHeaders</name>
+ <value>true</value>
+ </container-runtime-option>
</portlet-app>
Modified: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java
===================================================================
--- modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java 2009-01-07 19:34:24 UTC (rev 12448)
+++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java 2009-01-07 23:21:18 UTC (rev 12449)
@@ -31,6 +31,7 @@
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.xml.namespace.QName;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -55,6 +56,8 @@
private static final String BEGINNING_STRING = "beginningString";
private static final String QUERY = "query";
+ public static final QName QNAME = new QName("urn:jboss:portal:samples:event", "ZipEvent");
+
/**
* gl=US forces use of US google site, hl=en forces results to be in English so that regardless of location the query
* should result in the expected result.
@@ -159,6 +162,9 @@
// request view
actionResponse.setPortletMode(PortletMode.VIEW);
+
+ // send out zip event
+ actionResponse.setEvent(QNAME, zip);
}
protected String postProcessHTML(String html)
Modified: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java
===================================================================
--- modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java 2009-01-07 19:34:24 UTC (rev 12448)
+++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java 2009-01-07 23:21:18 UTC (rev 12449)
@@ -30,16 +30,35 @@
renderResponse.setContentType("text/html");
PrintWriter printWriter = renderResponse.getWriter();
String namespace = renderResponse.getNamespace();
- printWriter.print("<script type='text/javascript'>function " + namespace
- + "_openRemote(url){window.name='" + namespace + "_parent';window.open(url, '" + namespace
- + "_remote', 'width=400,height=200,scrollable=yes')}</script>");
- printWriter.print("<p><a href='#' onclick=\"" + namespace + "_openRemote('");
+ printWriter.print("<p><a href='#' onclick=\"" + namespace + "_remote=" + namespace + "_openRemote('");
ResourceURL resource = renderResponse.createResourceURL();
printWriter.print(resource);
printWriter.print("')\">Open remote control!</a></p>");
-}
+ }
@Override
+ protected void doHeaders(RenderRequest renderRequest, RenderResponse renderResponse)
+ {
+ PrintWriter printWriter = null;
+ try
+ {
+ printWriter = renderResponse.getWriter();
+ String namespace = renderResponse.getNamespace();
+ String remoteWindowName = namespace + "_remote";
+ printWriter.print("<script type='text/javascript'>var " + remoteWindowName + "; function " + namespace
+ + "_openRemote(url){window.name='" + namespace + "_parent';window.open(url, '" + remoteWindowName
+ + "', 'width=400,height=200,scrollable=yes')}" +
+ "onload = function() {" +
+ "if (typeof " + remoteWindowName + " != 'undefined') {" + remoteWindowName + ".location.reload(true);}" +
+ "}</script>");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+ @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException
{
resourceResponse.setContentType("text/html");
17 years, 3 months