[jboss-cvs] JBossAS SVN: r79686 - in projects/security/security-spi/trunk: authorization/src and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 17 23:33:30 EDT 2008


Author: anil.saldhana at jboss.com
Date: 2008-10-17 23:33:30 -0400 (Fri, 17 Oct 2008)
New Revision: 79686

Added:
   projects/security/security-spi/trunk/authorization/src/test/
   projects/security/security-spi/trunk/authorization/src/test/java/
   projects/security/security-spi/trunk/authorization/src/test/java/org/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/authorization/
   projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/authorization/ControlFlagUnitTestCase.java
   projects/security/security-spi/trunk/authorization/src/test/resources/
Modified:
   projects/security/security-spi/trunk/.classpath
   projects/security/security-spi/trunk/authorization/src/main/org/jboss/security/config/ControlFlag.java
Log:
ControlFlag method

Modified: projects/security/security-spi/trunk/.classpath
===================================================================
--- projects/security/security-spi/trunk/.classpath	2008-10-18 03:32:08 UTC (rev 79685)
+++ projects/security/security-spi/trunk/.classpath	2008-10-18 03:33:30 UTC (rev 79686)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="spi/src/tests"/>
+	<classpathentry kind="src" path="authorization/src/test/java"/>
 	<classpathentry kind="src" path="acl/src/main"/>
 	<classpathentry kind="src" path="identity/src/tests"/>
 	<classpathentry kind="src" path="identity/src/main"/>

Modified: projects/security/security-spi/trunk/authorization/src/main/org/jboss/security/config/ControlFlag.java
===================================================================
--- projects/security/security-spi/trunk/authorization/src/main/org/jboss/security/config/ControlFlag.java	2008-10-18 03:32:08 UTC (rev 79685)
+++ projects/security/security-spi/trunk/authorization/src/main/org/jboss/security/config/ControlFlag.java	2008-10-18 03:33:30 UTC (rev 79686)
@@ -21,8 +21,6 @@
   */
 package org.jboss.security.config; 
 
-//$Id$
-
 /**
  *  Control Flag for module entries
  *  @author Anil.Saldhana at redhat.com
@@ -38,7 +36,7 @@
    public static final ControlFlag OPTIONAL = new ControlFlag("OPTIONAL");
    
    public ControlFlag(String flag)
-   {
+   { 
       this.flag = flag;
    }  
    
@@ -50,4 +48,43 @@
    {
       return flag;
    }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if(obj instanceof ControlFlag == false)
+         return false;
+      ControlFlag objControlFlag = (ControlFlag) obj;
+      return flag.equals(objControlFlag.flag);
+   }
+
+   @Override
+   public int hashCode()
+   { 
+      return flag.hashCode();
+   } 
+   
+   /**
+    * Method that returns the correct
+    * Control flag that is associated with the
+    * argument flag, which can be (REQUIRED,
+    * REQUISITE, SUFFICIENT and OPTIONAL)
+    * @param flag
+    * @return
+    * @throws IllegalArgumentException when flag is 
+    * different from the four above
+    */
+   public static ControlFlag valueOf(String flag)
+   {
+      if("REQUIRED".equalsIgnoreCase(flag))
+         return REQUIRED;
+      if("REQUISITE".equalsIgnoreCase(flag))
+         return REQUISITE;
+      if("SUFFICIENT".equalsIgnoreCase(flag))
+         return SUFFICIENT;
+      if("OPTIONAL".equalsIgnoreCase(flag))
+         return OPTIONAL;
+      throw new IllegalArgumentException(flag + " is not recognized");
+            
+   }
 }
\ No newline at end of file

Added: projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/authorization/ControlFlagUnitTestCase.java
===================================================================
--- projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/authorization/ControlFlagUnitTestCase.java	                        (rev 0)
+++ projects/security/security-spi/trunk/authorization/src/test/java/org/jboss/test/security/spi/authorization/ControlFlagUnitTestCase.java	2008-10-18 03:33:30 UTC (rev 79686)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.security.spi.authorization;
+
+import org.jboss.security.config.ControlFlag;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Test the Control Flag
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 17, 2008
+ */
+public class ControlFlagUnitTestCase extends TestCase
+{
+   public void testFlag()
+   {
+      assertEquals(ControlFlag.REQUIRED, ControlFlag.valueOf("REQUIRED"));
+      assertEquals(ControlFlag.REQUIRED, ControlFlag.valueOf("required"));
+      assertEquals(ControlFlag.SUFFICIENT, ControlFlag.valueOf("SUFFICIENT"));
+      assertEquals(ControlFlag.SUFFICIENT, ControlFlag.valueOf("sufficient")); 
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list