[jboss-cvs] JBossAS SVN: r79415 - in projects/security/security-spi/trunk/spi/src: tests/org/jboss/test/security and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 13 14:32:34 EDT 2008
Author: anil.saldhana at jboss.com
Date: 2008-10-13 14:32:34 -0400 (Mon, 13 Oct 2008)
New Revision: 79415
Added:
projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/
projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/MappingUnitTestCase.java
projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/TestMappingProvider.java
Modified:
projects/security/security-spi/trunk/spi/src/main/org/jboss/security/mapping/MappingProvider.java
Log:
SECURITY-287: mapping provider supports method
Modified: projects/security/security-spi/trunk/spi/src/main/org/jboss/security/mapping/MappingProvider.java
===================================================================
--- projects/security/security-spi/trunk/spi/src/main/org/jboss/security/mapping/MappingProvider.java 2008-10-13 17:02:47 UTC (rev 79414)
+++ projects/security/security-spi/trunk/spi/src/main/org/jboss/security/mapping/MappingProvider.java 2008-10-13 18:32:34 UTC (rev 79415)
@@ -37,4 +37,12 @@
* @param result
*/
void setMappingResult(MappingResult<T> result);
-}
\ No newline at end of file
+
+ /**
+ * Whether this mapping provider supports
+ * mapping T
+ * @param t
+ * @return
+ */
+ boolean supports(Class<?> p);
+}
\ No newline at end of file
Added: projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/MappingUnitTestCase.java
===================================================================
--- projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/MappingUnitTestCase.java (rev 0)
+++ projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/MappingUnitTestCase.java 2008-10-13 18:32:34 UTC (rev 79415)
@@ -0,0 +1,49 @@
+/*
+ * 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.mapping;
+
+import java.security.acl.Group;
+
+import javax.naming.InitialContext;
+import javax.security.auth.x500.X500Principal;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the mapping framework
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 13, 2008
+ */
+public class MappingUnitTestCase extends TestCase
+{
+ public void testMappingProviderSupportsMethod()
+ {
+ TestMappingProvider tmp = new TestMappingProvider();
+ //Support Principal
+ assertTrue(tmp.supports(X500Principal.class));
+ //Do not support group principal
+ assertFalse(tmp.supports(Group.class));
+ //Do not support arbitrary JDK class
+ assertFalse(tmp.supports(InitialContext.class));
+ assertFalse(tmp.supports(MappingUnitTestCase.class));
+ }
+}
\ No newline at end of file
Added: projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/TestMappingProvider.java
===================================================================
--- projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/TestMappingProvider.java (rev 0)
+++ projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/mapping/TestMappingProvider.java 2008-10-13 18:32:34 UTC (rev 79415)
@@ -0,0 +1,61 @@
+/*
+ * 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.mapping;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Map;
+
+import org.jboss.security.mapping.MappingProvider;
+import org.jboss.security.mapping.MappingResult;
+
+/**
+ * A Test Mapping Provider for Principal
+ * @author anil.saldhana at redhat.com
+ */
+public class TestMappingProvider implements MappingProvider<Principal>
+{
+ public void init(Map<String, Object> options)
+ {
+ }
+
+ public void performMapping(Map<String, Object> map, Principal mappedObject)
+ {
+ }
+
+ public void setMappingResult(MappingResult<Principal> result)
+ {
+ }
+
+ public boolean supports(Class<?> p)
+ {
+ //Do not support group principal
+ if(Group.class.isAssignableFrom(p))
+ return false;
+
+ //Support Principal
+ if(Principal.class.isAssignableFrom(p))
+ return true;
+
+ return false;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list