Author: sohil.shah(a)jboss.com
Date: 2008-12-13 01:41:52 -0500 (Sat, 13 Dec 2008)
New Revision: 12380
Added:
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/
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/tools/
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/tools/GeneralTool.java
Log:
code backup
Added:
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
(rev 0)
+++
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Identity.java 2008-12-13
06:41:52 UTC (rev 12380)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * 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 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Identity
+{
+ private String name;
+ private String authenticationMethod;
+
+ public Identity(String name)
+ {
+ if(name == null || name.trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Identity Name Cannot Be Empty");
+ }
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+
+ public String getAuthenticationMethod()
+ {
+ return authenticationMethod;
+ }
+
+ public void setAuthenticationMethod(String authenticationMethod)
+ {
+ this.authenticationMethod = authenticationMethod;
+ }
+
//------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching an the Identity of the Authenticated User
+ *
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createIdentityExpression()
+ {
+ AttributeExpression expression = new AttributeExpression();
+
+ expression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ Attribute attribute = new Attribute(XACMLConstants.ATTRIBUTEID_SUBJECT_ID,
+ XMLSchemaConstants.DATATYPE_STRING, this.name);
+ expression.setAttribute(attribute);
+
+ return expression;
+ }
+
+ /**
+ * Creates an expression for matching the Authentication Method of the User
+ *
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createAuthMethodExpression()
+ {
+ if(this.authenticationMethod == null || this.authenticationMethod.trim().length()
== 0)
+ {
+ throw new IllegalStateException("Authentication Method is Empty");
+ }
+
+ 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;
+ }
+}
Added:
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
(rev 0)
+++
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Machine.java 2008-12-13
06:41:52 UTC (rev 12380)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Machine
+{
+
+}
Added:
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
(rev 0)
+++
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/components/subject/Role.java 2008-12-13
06:41:52 UTC (rev 12380)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Role
+{
+ private String name;
+
+ public Role(String name)
+ {
+ if(name == null || name.trim().length() == 0)
+ {
+ throw new IllegalArgumentException("Role Name Cannot Be Empty");
+ }
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
//------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Creates an expression for matching the Role of the Authenticated User
+ *
+ * @return an expression that will be used within the Policy Definition
+ */
+ public AttributeExpression createIsUserInRole()
+ {
+ 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);
+
+ return expression;
+ }
+}
Added:
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/tools/GeneralTool.java
===================================================================
---
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/tools/GeneralTool.java
(rev 0)
+++
modules/authorization/trunk/common/src/main/java/org/jboss/security/authz/tools/GeneralTool.java 2008-12-13
06:41:52 UTC (rev 12380)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.tools;
+
+import java.util.UUID;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class GeneralTool
+{
+ public static String generateUniqueId()
+ {
+ return UUID.randomUUID().toString();
+ }
+}