[jboss-cvs] JBossAS SVN: r61758 - in trunk/ejb3/src: resources/test/tck5sec and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 27 16:14:53 EDT 2007


Author: bdecoste
Date: 2007-03-27 16:14:53 -0400 (Tue, 27 Mar 2007)
New Revision: 61758

Added:
   trunk/ejb3/src/resources/test/tck5sec/
   trunk/ejb3/src/resources/test/tck5sec/META-INF/
   trunk/ejb3/src/resources/test/tck5sec/META-INF/jboss.xml
   trunk/ejb3/src/resources/test/tck5sec/auth.conf
   trunk/ejb3/src/resources/test/tck5sec/roles.properties
   trunk/ejb3/src/resources/test/tck5sec/users.properties
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSession.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSessionTest.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulTestBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSession.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSessionBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/unit/Tck5SecTestCase.java
Log:
tests that mimic failed TCK EJB3 security tests for @RunAsPrincipal

Added: trunk/ejb3/src/resources/test/tck5sec/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/tck5sec/META-INF/jboss.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/tck5sec/META-INF/jboss.xml	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<jboss
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+        version="3.0">
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatefulTestBean</ejb-name>
+         <security-identity>
+        	<run-as-principal>javajoe</run-as-principal>
+         </security-identity>
+      </session>
+   </enterprise-beans>
+</jboss>

Added: trunk/ejb3/src/resources/test/tck5sec/auth.conf
===================================================================
--- trunk/ejb3/src/resources/test/tck5sec/auth.conf	                        (rev 0)
+++ trunk/ejb3/src/resources/test/tck5sec/auth.conf	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,37 @@
+j2eeri {
+    org.jboss.security.plugins.samples.IdentityLoginModule required;
+};
+
+simple {
+    org.jboss.security.ClientLoginModule  required
+	;
+};
+spec-test {
+    org.jboss.security.ClientLoginModule  required
+	;
+};
+LoginContext {
+    org.jboss.security.plugins.samples.IdentityLoginModule required
+        principal="scott"
+	;
+    org.jboss.security.plugins.samples.RolesLoginModule required
+        ;
+};
+
+other {
+    // Put your login modules that work without jBoss here
+    org.jboss.security.srp.jaas.SRPLoginModule required
+	password-stacking="useFirstPass"
+	principalClassName="org.jboss.security.SimplePrincipal"
+	srpServerJndiName="SRPServerInterface"
+	debug=true
+	;
+
+    // jBoss LoginModule
+    org.jboss.security.ClientLoginModule  required
+	password-stacking="useFirstPass"
+	;
+
+    // Put your login modules that need jBoss here
+};
+ 

Added: trunk/ejb3/src/resources/test/tck5sec/roles.properties
===================================================================
--- trunk/ejb3/src/resources/test/tck5sec/roles.properties	                        (rev 0)
+++ trunk/ejb3/src/resources/test/tck5sec/roles.properties	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,2 @@
+j2ee=Employee,Administrator
+javajoe=Employee,Manager
\ No newline at end of file

Added: trunk/ejb3/src/resources/test/tck5sec/users.properties
===================================================================
--- trunk/ejb3/src/resources/test/tck5sec/users.properties	                        (rev 0)
+++ trunk/ejb3/src/resources/test/tck5sec/users.properties	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,2 @@
+javajoe=javajoe
+j2ee=j2ee

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulBean.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.security.SecurityDomain;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulSession.class)
+ at SecurityDomain("other")
+public class StatefulBean implements StatefulSession
+{
+   private static final Logger log = Logger.getLogger(StatefulBean.class);
+
+   @Resource
+   SessionContext sessionContext;
+   
+   @RolesAllowed({"Manager"})
+   public boolean EjbSecRoleRef(String role)
+   {
+      log.info("isCallerInRole(" + role + ") = "
+            + sessionContext.isCallerInRole(role));
+       return sessionContext.isCallerInRole(role);
+   }
+
+   @RolesAllowed( { "Administrator", "Manager", "VP", "Employee" })
+   public boolean EjbOverloadedSecRoleRefs(String role1)
+   {
+      log.info("isCallerInRole(" + role1 + ") = "
+            + sessionContext.isCallerInRole(role1));
+      return sessionContext.isCallerInRole(role1);
+   }
+
+   @RolesAllowed( { "Administrator", "Manager", "VP", "Employee" })
+   public boolean EjbOverloadedSecRoleRefs(String role1, String role2)
+   {
+      log.info("isCallerInRole(" + role1 + ")= "
+            + sessionContext.isCallerInRole(role1) + "isCallerInRole(" + role2
+            + ")= " + sessionContext.isCallerInRole(role2));
+      return sessionContext.isCallerInRole(role1)
+            && sessionContext.isCallerInRole(role2);
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSession.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSession.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSession.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulSession
+{
+   boolean EjbOverloadedSecRoleRefs(String role1, String role2);
+   
+   boolean EjbOverloadedSecRoleRefs(String role1);
+   
+   boolean EjbSecRoleRef(String role);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSessionTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSessionTest.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulSessionTest.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulSessionTest
+{
+   boolean EjbOverloadedSecRoleRefs(String role1, String role2);
+   
+   boolean EjbSecRoleRef(String role);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulTestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulTestBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatefulTestBean.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.annotation.security.RunAs;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+
+import org.jboss.annotation.security.SecurityDomain;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulSessionTest.class)
+ at SecurityDomain("other")
+ at RunAs("Manager")
+//@org.jboss.annotation.security.RunAsPrincipal("javajoe")
+public class StatefulTestBean implements StatefulSessionTest
+{
+   private static final Logger log = Logger.getLogger(StatefulTestBean.class);
+
+   @EJB
+   private StatefulSession ejbRef;
+
+   @Resource
+   SessionContext sessionContext;
+   
+   @RolesAllowed({"Administrator", "Manager", "VP", "Employee"})
+   public boolean EjbSecRoleRef(String role)
+   {
+      log.info("Starting Security role reference positive test");
+      log.info("isCallerInRole(" + role + ")= "
+            + sessionContext.isCallerInRole(role));
+       try {
+           boolean result = ejbRef.EjbSecRoleRef(role);
+           if ( ! result )
+               return false;
+           return true;
+       } catch ( Exception e ) {
+             e.printStackTrace();
+          return false; 
+       }
+   }
+
+   @RolesAllowed( { "Administrator", "Manager", "VP", "Employee" })
+   public boolean EjbOverloadedSecRoleRefs(String role1, String role2)
+   {
+      log.info("Starting Overloaded security role references test");
+      
+      log.info("isCallerInRole(" + role1 + ")= "
+            + sessionContext.isCallerInRole(role1) + "isCallerInRole(" + role2
+            + ")= " + sessionContext.isCallerInRole(role2));
+      
+      try
+      {
+         boolean result = ejbRef.EjbOverloadedSecRoleRefs(role1);
+         if (!result)
+         {
+            log.info("EjbOverloadedSecRoleRefs(emp_secrole_ref) returned false");
+            return false;
+         }
+
+         result = ejbRef.EjbOverloadedSecRoleRefs(role1, role2);
+         if (result)
+         {
+
+            log.info("EjbOverloadedSecRoleRefs(emp_secrole_ref,mgr_secrole_ref) returned true");
+            return false;
+         }
+         return true;
+      } catch (Exception e)
+      {
+         log.info("EjbOverloadedSecRoleRefs(" + role1 + "," + role2
+               + ") failed with Exception: ", e);
+         return false;
+      }
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSession.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSession.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSession.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessSession
+{
+    
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSessionBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSessionBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/StatelessSessionBean.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.security.SecurityDomain;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessSession.class)
+ at SecurityDomain("other")
+public class StatelessSessionBean implements StatelessSession
+{
+   private static final Logger log = Logger.getLogger(StatelessSessionBean.class);
+   
+   @Resource SessionContext sessionContext;
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/unit/Tck5SecTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/unit/Tck5SecTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/tck5sec/unit/Tck5SecTestCase.java	2007-03-27 20:14:53 UTC (rev 61758)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.tck5sec.unit;
+
+import java.io.IOException;
+
+import javax.naming.InitialContext;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+
+import org.jboss.ejb3.test.tck5sec.StatefulSessionTest;
+import org.jboss.ejb3.test.tck5sec.StatelessSession;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.auth.login.XMLLoginConfigImpl;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class Tck5SecTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(Tck5SecTestCase.class);
+
+   public Tck5SecTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void test2() throws Exception
+   {
+      AppCallbackHandler handler = new AppCallbackHandler("j2ee", "j2ee".toCharArray());
+      LoginContext lc = new LoginContext("spec-test", handler);
+      lc.login();
+      
+      InitialContext jndiContext = new InitialContext();
+      StatefulSessionTest sfsb = (StatefulSessionTest)jndiContext.lookup("StatefulTestBean/remote");
+      boolean success = sfsb.EjbOverloadedSecRoleRefs("Employee", "Administrator");
+      assertTrue(success);
+   }
+   
+   public void atest3() throws Exception
+   {
+      AppCallbackHandler handler = new AppCallbackHandler("j2ee", "j2ee".toCharArray());
+      LoginContext lc = new LoginContext("spec-test", handler);
+      lc.login();
+      
+      InitialContext jndiContext = new InitialContext();
+      StatefulSessionTest sfsb = (StatefulSessionTest)jndiContext.lookup("StatefulTestBean/remote");
+      boolean success = sfsb.EjbSecRoleRef("Employee");
+      assertTrue(success);
+   }
+
+   public static Test suite() throws Exception
+   {
+      Configuration.setConfiguration(new XMLLoginConfigImpl());
+      return getDeploySetup(Tck5SecTestCase.class, "tck5sec-test.jar");
+
+   }
+   
+   class AppCallbackHandler implements CallbackHandler
+   {  
+      private String username;
+      private char[] password;
+      private byte[] data;
+      private String text;
+
+      public AppCallbackHandler(String username, char[] password)
+      {
+         this.username = username;
+         this.password = password;
+      }
+      public AppCallbackHandler(String username, char[] password, byte[] data)
+      {
+         this.username = username;
+         this.password = password;
+         this.data = data;
+      }
+      public AppCallbackHandler(String username, char[] password, byte[] data, String text)
+      {
+         this.username = username;
+         this.password = password;
+         this.data = data;
+         this.text = text;
+      }
+
+      public void handle(Callback[] callbacks) throws
+            IOException, UnsupportedCallbackException
+      {
+         for (int i = 0; i < callbacks.length; i++)
+         {
+            Callback c = callbacks[i];
+    
+            if( c instanceof NameCallback )
+            {
+               NameCallback nc = (NameCallback) c;
+               nc.setName(username);
+            }
+            else if( c instanceof PasswordCallback )
+            {
+               PasswordCallback pc = (PasswordCallback) c;
+               pc.setPassword(password);
+            }
+            else if( c instanceof TextInputCallback )
+            {
+               TextInputCallback tc = (TextInputCallback) c;
+               tc.setText(text);
+            }
+            else
+            {
+               throw new UnsupportedCallbackException(c, "Unrecognized Callback");
+            }
+         }
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list