Re: HttpAdapter class JAASification
"SuperBonBon" <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.devel |
|---|---|
| Message-ID | <[email protected]> |
Here are the patchs : HttpAdaptorTest.diff,HttpAdaptor.diff,HttpAdaptorMBean.diff, HttpAdaptorMBeanDescription.diff : For the http adaptor JAAS auth functionality and the adapted unit test SSLAdaptorServerSocketFactory.diff : Adds a small patch so that when the specified keystore path is not found into the classpath, it looks at the filesystem to try to find it, this allow to load keystore from the filesystem instead from the classpath only. XSLTProcessor.diff : A bug has been added during latest refactoring and the console was not working anymore when cache was disabled ( the processor was unable to find the xsl stylesheets for transformation ). Everything is in order now. SMTP.diff : I have just removed an ex.printstackTrace that was already logged ( I don't like to see stacktraces in System.out :o) ) Do you have any idea if those mods could be included in the final 2.0 release ? I would really enjoy it. Regards SuperBonBon > Allright, the modification ( as well as the unit test mod ) is done > but unfortunatly I can't compile the whole stuff to test it with the > provided ant script with the latest HEAD version. > I've read that you have some compilation problems, > I'll wait until the latest CVS HEAD > version compiles to finish the job and give you the cvs diff. > > Regards > SuperBonBon > > ----- Original Message ----- > From: "Carlos Quiroz" <[email protected]> > To: <[email protected]> > Sent: Monday, February 02, 2004 9:17 AM > Subject: Re: [Mx4j-devel] HttpAdapter class JAASification > > >> Hi >> >> That would be great. The current method is very crude and I've been > eager >> to get a nicer (more elegant) authentication method, so by all > means do >> it. Just try to not break the current methods so it keeps being > backward >> compatible >> >> Regards >> Carlos Quiroz >> >> On Thu, 29 Jan 2004 19:52:36 +0100, "Superbonbon" > <[email protected]> >> said: >> > Hi, >> > >> > I had to modify the mx4j.adaptor.http.HttpAdapter class for my > project > so >> > that users can authenticate >> > against JAAS login modules instead of the regular > username/password >> > method provided ( addAuthorization( String userName, String > password ) >> > {...} ) >> > >> > I've done this for the 1.1.1 version, let me know if you would > like to >> > see >> > such functionality with the latest CVS HEAD version of the file. >> > I could do the CVS patch quite quickly. >> > >> > Regards >> > >> > SuperBonBon >> >> >> ------------------------------------------------------- >> The SF.Net email is sponsored by EclipseCon 2004 >> Premiere Conference on Open Tools Development and Integration >> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. >> http://www.eclipsecon.org/osdn >> _______________________________________________ >> Mx4j-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/mx4j-devel >> > > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > Mx4j-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mx4j-devel >
HttpAdaptor.diff
(text/plain, 7.4 KB)
Index: HttpAdaptor.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/adaptor/http/HttpAdaptor.java,v
retrieving revision 1.3
diff -r1.3 HttpAdaptor.java
18a19
> import java.util.HashSet;
41c42
< * @version $Revision: 1.3 $
---
> * @version $Revision: 1.4 $
79a81,84
>
> private HashSet JAASAuthorizedUsernames = new HashSet();
>
> private String JAASLoginModuleName = null;
534c539
< if (logger.isEnabledFor(Logger.INFO)) logger.info("HttpAdaptor version " + VERSION + " stopped on port " + port);
---
> if (logger.isEnabledFor(Logger.INFO)) logger.info("HttpAdaptor version " + VERSION + " stopped on port " + port);
600a606,617
>
> /**
> * Removes an authorization for a given username
> */
> public void removeAuthorization(String username)
> {
> if (username == null)
> {
> throw new IllegalArgumentException("username cannot be null");
> }
> authorizations.remove(username);
> }
601a619,691
> /**
> * Define the JAAS login modules set config that will be used to authenticate users.
> * Note that adding a JAAS login module will try to authenticate users against bith JAAS login modules set
> * and users defined by {@link mx4j.adaptor.http.HttpAdaptor#addAuthorization} addAuthorization( String, String ) method
> * @jmx:managed-operation description="Define the JAAS login modules set config that will be used to authenticate users."
> * @jmx:managed-operation-parameter name="JAASLoginModuleName" position="0" description="The JAAS login modules config entry name"
> * @jmx:managed-operation-parameter name="JAASConfigProviderClassName" position="1" description="The JAAS config class provider, null if using the default JAAS config parser"
> **/
> public void setJAASLoginModule(String JAASLoginModuleName, String JAASConfigProviderClassName)
> {
> if (JAASConfigProviderClassName != null)
> {
> java.security.Security.setProperty("login.configuration.provider", JAASConfigProviderClassName);
> }
> try
> {
> // we just test that the given name match effectivly a config entry.
> // an error will raise if no module match the given JAASLoginModuleName name
> new javax.security.auth.login.LoginContext(JAASLoginModuleName);
> }
> catch (javax.security.auth.login.LoginException ex)
> {
> IllegalArgumentException illegArgEx = new IllegalArgumentException("Unable to create JAAS login context for setting " + JAASLoginModuleName);
> illegArgEx.initCause(ex);
> throw illegArgEx;
> }
> this.JAASLoginModuleName = JAASLoginModuleName;
> }
>
> /**
> * Disable the defined JAAS login module functionality.
> * @jmx:managed-operation description="Disable the defined JAAS login module functionality."
> **/
> public void disableJAASLoginModule()
> {
> this.JAASLoginModuleName = null;
> }
>
> /**
> * Adds an allowed user name for the configured JAAS login modules set
> * If this method is never called all users defined by the JAAS login modules set
> * will be able to connect against this http adaptor
> * @jmx:managed-operation-parameter name="JAASUsername" position="0" description="The allowed user name"
> **/
> public void addJAASAuthorization(String JAASUsername)
> {
> if (JAASLoginModuleName == null)
> {
> throw new IllegalArgumentException("no JAAS realm defined");
> }
> if (JAASUsername == null)
> {
> throw new IllegalArgumentException("JAASUsername cannot be null");
> }
> JAASAuthorizedUsernames.add(JAASUsername.toLowerCase());
> }
>
> /**
> * Removes an user name for the configured JAAS login modules set from the authorized JAAS users list
> * @jmx:managed-operation-parameter name="JAASUsername" position="0" description="The user name to remove"
> **/
> public void removeJAASAuthorization(String JAASUsername)
> {
> if (JAASLoginModuleName == null)
> {
> throw new IllegalArgumentException("no JAAS realm defined");
> }
> if (JAASUsername == null)
> {
> throw new IllegalArgumentException("JAASUsername cannot be null");
> }
> JAASAuthorizedUsernames.remove(JAASUsername.toLowerCase());
> }
844a935,945
>
> /**
> * A very basic JAAS callback handler, does only support name and password
> * callbacks, all others will be simply ignored.
> * @author <a href="mailto:[email protected]">SuperBonBon</a>
> */
> private class BasicCallbackHandler implements javax.security.auth.callback.CallbackHandler
> {
>
> private String userName;
> private String password;
845a947,979
> private BasicCallbackHandler(String userName, String password)
> {
> this.userName = userName;
> this.password = password;
> }
>
> public void handle(javax.security.auth.callback.Callback[] callbacks)
> throws IOException, javax.security.auth.callback.UnsupportedCallbackException
> {
> for (int i=0; i<callbacks.length; i++)
> {
> javax.security.auth.callback.Callback cb = callbacks[i];
> if (cb instanceof javax.security.auth.callback.NameCallback)
> {
> // we just fill the username
> javax.security.auth.callback.NameCallback nc = (javax.security.auth.callback.NameCallback)cb;
> nc.setName(userName);
> }
> else if (cb instanceof javax.security.auth.callback.PasswordCallback)
> {
> // this time simply fill the provided password
> javax.security.auth.callback.PasswordCallback pc = (javax.security.auth.callback.PasswordCallback)cb;
> pc.setPassword(password.toCharArray());
> }
> else
> {
> // we simply log that that the callback handler is not handled.
> Logger log = getLogger();
> if (log.isEnabledFor(Logger.WARN)) log.warn("Ignoring login module callback " + cb.getClass().getName());
> }
> }
> }
> }
857c991
< public boolean isValid(String authorizationString) {
---
> private boolean isValid(String authorizationString) {
869c1003,1032
< return isUsernameValid(username, password);
---
> // ok first we look if the given user name and password match something defined
> // by the regular addAuthorization() method
> boolean auth = isUsernameValid(username, password);
> // ok let's take a look at the custom JAAS realm if
> // first auth failed and if a JAAS login modules set has been defined
> if (!auth && JAASLoginModuleName != null)
> {
> boolean makeJAASLookup = JAASAuthorizedUsernames.size() == 0 || JAASAuthorizedUsernames.contains(username.toLowerCase());
> if (makeJAASLookup)
> {
> BasicCallbackHandler handler = new BasicCallbackHandler(username, password);
> javax.security.auth.login.LoginContext context = new javax.security.auth.login.LoginContext(JAASLoginModuleName, handler);
> try
> {
> context.login();
> auth = true;
> }
> catch (javax.security.auth.login.LoginException ex)
> {
> // ok JAAS login modules throw LoginException when the user can't be authenticated
> // but if the cause of this error is different than LoginException class then we can assume
> // we have a problem with the login module itself
> if (ex.getCause() != null && !(ex.getCause() instanceof javax.security.auth.login.LoginException))
> {
> throw ex;
> }
> }
> }
> }
> return auth;
872a1036,1037
> Logger log = getLogger();
> if (log.isEnabledFor(Logger.ERROR)) log.error("Error during authentication", e);
879d1043
<
HttpAdaptorMBean.diff
(text/plain, 1.5 KB)
Index: HttpAdaptorMBean.java =================================================================== RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/adaptor/http/HttpAdaptorMBean.java,v retrieving revision 1.1 diff -r1.1 HttpAdaptorMBean.java 22c22 < * @version $Revision: 1.1 $ --- > * @version $Revision: 1.2 $ 169a170,199 > > /** > * Define the JAAS login modules set config that will be used to authenticate users. > * Note that adding a JAAS login module will try to authenticate users against bith JAAS login modules set > * and users defined by addAuthorization( String, String ) method > **/ > public void setJAASLoginModule(String JAASLoginModuleName, String JAASConfigProviderClassName); > > /** > * Removes an authorization for a given username > */ > public void removeAuthorization(String username); > > /** > * Adds an allowed user name for the configured JAAS login modules set > * If this method is never called all users defined by the JAAS login modules set > * will be able to connect against this http adaptor > **/ > public void addJAASAuthorization(String JAASUsername); > > /** > * Removes an user name for the configured JAAS login modules set from the authorized JAAS users list > **/ > public void removeJAASAuthorization(String JAASUsername); > > /** > * Disable the defined JAAS login module functionality. > **/ > public void disableJAASLoginModule(); >
HttpAdaptorMBeanDescription.diff
(text/plain, 2.7 KB)
Index: HttpAdaptorMBeanDescription.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/adaptor/http/HttpAdaptorMBeanDescription.java,v
retrieving revision 1.1
diff -r1.1 HttpAdaptorMBeanDescription.java
19c19
< * @version $Revision: 1.1 $
---
> * @version $Revision: 1.2 $
171c171
< if (name.equals("addCommandProcessor"))
---
> else if (name.equals("addCommandProcessor"))
175c175
< if (name.equals("removeCommandProcessor"))
---
> else if (name.equals("removeCommandProcessor"))
179c179
< if (name.equals("start"))
---
> else if (name.equals("start"))
183c183
< if (name.equals("stop"))
---
> else if (name.equals("stop"))
187c187
< if (name.equals("addAuthorization"))
---
> else if (name.equals("addAuthorization"))
190a191,210
> else if (name.equals("removeAuthorization"))
> {
> return "Removes an authorized user";
> }
> else if (name.equals("setJAASLoginModule"))
> {
> return "Define the JAAS login module to authenticate users";
> }
> else if (name.equals("addJAASAuthorization"))
> {
> return "Adds an JAAS login module user name, all users accepted when never called";
> }
> else if (name.equals("removeJAASAuthorization"))
> {
> return "Removes an authorized JAAS login module user name";
> }
> else if (name.equals("disableJAASLoginModule"))
> {
> return "Disable the defined JAAS login module functionality";
> }
207c227
< if (name.equals("addCommandProcessor"))
---
> else if (name.equals("addCommandProcessor"))
217c237
< if (name.equals("removeCommandProcessor"))
---
> else if (name.equals("removeCommandProcessor"))
225c245
< if (name.equals("addAuthorization"))
---
> else if (name.equals("addAuthorization"))
234a255,282
> else if (name.equals("removeAuthorization"))
> {
> return "username";
> }
> else if (name.equals("setJAASLoginModule"))
> {
> switch (index)
> {
> case 0:
> return "the JAAS configuration login module name";
> case 1:
> return "the JAAS configuration provider class name, null for default provider";
> }
> }
> else if (name.equals("addJAASAuthorization"))
> {
> switch (index)
> {
> case 0:
> return "username";
> case 1:
> return "password";
> }
> }
> else if (name.equals("removeJAASAuthorization"))
> {
> return "username";
> }
HttpAdaptorTest.diff
(text/plain, 12.2 KB)
Index: HttpAdaptorTest.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/test/test/mx4j/tools/adaptor/http/HttpAdaptorTest.java,v
retrieving revision 1.1
diff -r1.1 HttpAdaptorTest.java
5,6c5,6
< * This software is distributed under the terms of the MX4J License version 1.0.
< * See the terms of the MX4J License in the documentation provided with this software.
---
> * This software is distributed under the terms of the MX4J License version 1.0.
> * See the terms of the MX4J License in the documentation provided with this software.
9c9
< package test.mx4j.tools.adaptor.http;
---
> package test.mx4j.tools.adaptor.http;
15a16
> import java.util.Map;
22d22
< import mx4j.tools.adaptor.http.HttpAdaptor;
25d24
< import mx4j.tools.adaptor.http.HttpOutputStream;
26a26,32
> import javax.security.auth.Subject;
> 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.login.AppConfigurationEntry;
> import javax.security.auth.login.LoginException;
29c35
< * Class HttpAdaptorTest, tests the basics of the HttpAdaptor class
---
> * Class HttpAdaptorTest, tests the basics of the HttpAdaptor class
32c38
< * @version $Revision: 1.1 $
---
> * @version $Revision: 1.2 $
36,38c42,48
< protected MBeanServer server;
< protected ObjectName name;
< protected static final int DEFAULT_PORT = 9090;
---
> protected MBeanServer server;
> protected ObjectName name;
> protected static final int DEFAULT_PORT = 9090;
>
> protected final static String DEFAULT_TEST_USER_NAME = "mx4j";
> protected final static String DEFAULT_TEST_USER_PASS = "mx4j";
>
41c51
< * Constructor requested by the JUnit framework
---
> * Constructor requested by the JUnit framework
45c55
< super("HTTPAdapter Test");
---
> super("HTTPAdapter Test");
49c59
< * Constructor requested by the JUnit framework
---
> * Constructor requested by the JUnit framework
60,65c70,75
< server = MBeanServerFactory.createMBeanServer("Http");
< name = new ObjectName("Http:name=HttpAdaptor");
< server.createMBean("mx4j.tools.adaptor.http.HttpAdaptor", name, null);
< // use another port. There is less proabablity of collision
< server.setAttribute(name, new Attribute("Port", new Integer(DEFAULT_PORT)));
< server.invoke(name, "start", null, null);
---
> server = MBeanServerFactory.createMBeanServer("Http");
> name = new ObjectName("Http:name=HttpAdaptor");
> server.createMBean("mx4j.tools.adaptor.http.HttpAdaptor", name, null);
> // use another port. There is less proabablity of collision
> server.setAttribute(name, new Attribute("Port", new Integer(DEFAULT_PORT)));
> server.invoke(name, "start", null, null);
76c86,87
< try {
---
> try
> {
78c89,91
< } catch (Exception e) {
---
> }
> catch (Exception e)
> {
113,114c126,127
< new Object[] {null, null},
< new String[] {"java.lang.String", "java.lang.String"});
---
> new Object[] {null, null},
> new String[] {"java.lang.String", "java.lang.String"});
122,123c135,136
< new Object[] {"mx4j", "mx4j"},
< new String[] {"java.lang.String", "java.lang.String"});
---
> new Object[] {DEFAULT_TEST_USER_NAME, DEFAULT_TEST_USER_PASS},
> new String[] {"java.lang.String", "java.lang.String"});
156c169
< }
---
> }
158,159c171,172
< public void testAuthentication() throws Exception
< {
---
> public void testAuthentication() throws Exception
> {
162c175
< URL url = new URL("http://" + host +":" + port +"/");
---
> URL url = new URL("http://" + host + ":" + port + "/");
164,165c177
< InputStream in = connection.getInputStream();
< in.close();
---
> readInputStream(connection, true);
169,170c181,182
< new Object[] {"mx4j", "mx4j"},
< new String[] {"java.lang.String", "java.lang.String"});
---
> new Object[] {DEFAULT_TEST_USER_NAME, DEFAULT_TEST_USER_PASS},
> new String[] {"java.lang.String", "java.lang.String"});
172c184
< url = new URL("http://" + host +":" + port +"/");
---
> url = new URL("http://" + host + ":" + port + "/");
174,179c186
< try {
< in = connection.getInputStream();
< } catch (Exception e) {
< } finally {
< in.close();
< }
---
> readInputStream(connection, false);
181c188,214
< url = new URL("http://" + host +":" + port +"/");
---
> url = new URL("http://" + host + ":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic bXg0ajpteDRq");
> readInputStream( connection, false );
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 200);
> waitToStop();
>
> // we test the JAAS login module
> server.invoke(name, "removeAuthorization",
> new Object[] {DEFAULT_TEST_USER_NAME},
> new String[] {"java.lang.String"});
> server.invoke(name, "start", null, null);
>
> // we make sur that the default user is not anymore accepted by the
> // standard auth method
> url = new URL("http://" + host + ":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic bXg0ajpteDRq");
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 403);
>
> server.invoke(name, "setJAASLoginModule",
> new Object[] {"testConfigModule", "test.mx4j.tools.adaptor.http.HttpAdaptorTest$TestLoginConfig"},
> new String[] {"java.lang.String", "java.lang.String"});
>
> // does it work against JAAS ?
> url = new URL("http://" + host + ":" + port + "/");
184,185c217,258
< in = connection.getInputStream();
< in.close();
---
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 200);
>
> // does it rejects wrong credentials ?
> url = new URL("http://" + host + ":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic falseBase64Pwd");
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 403);
>
> // we add an JAAS authorized user name different than DEFAULT_TEST_USER_NAME
> // to make sur that the default username is rejected since not in
> // the JAAS accepted users list
> server.invoke(name, "addJAASAuthorization",
> new Object[] {"johndoe"},
> new String[] {"java.lang.String"});
> // and we authenticate with DEFAULT_TEST_USER_NAME
> url = new URL("http://" + host +":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic bXg0ajpteDRq");
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 403);
>
> // should work again when johndoe is removed from the accepted list
> server.invoke(name, "removeJAASAuthorization",
> new Object[] {"johndoe" },
> new String[] {"java.lang.String" });
> url = new URL("http://" + host +":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic bXg0ajpteDRq");
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 200);
>
> // removing the use of JAAS to authenticate users to test that default user is rejected
> // since JAAS is disabled and removed by removeAuthorization() before
> server.invoke(name, "disableJAASLoginModule", null, null);
> url = new URL("http://" + host + ":" + port + "/");
> connection = url.openConnection();
> connection.setRequestProperty("Authorization", "basic bXg0ajpteDRq");
> readInputStream(connection, false);
> assertEquals(((HttpURLConnection)connection).getResponseCode(), 403);
>
189a263,285
> private void readInputStream(URLConnection connection, boolean throwIOException) throws IOException
> {
> InputStream in = null;
> IOException ioEx = null;
> try
> {
> in = connection.getInputStream();
> while ( in.read() != -1 );
> } catch (IOException e)
> {
> ioEx = e;
> }
> finally
> {
> if ( in != null )
> {
> in.close();
> }
> }
> if ( throwIOException && ioEx != null ) {
> throw ioEx;
> }
> }
191c287
< public void testAddCommandProcessor() throws Exception
---
> public void testAddCommandProcessor() throws Exception
193c289
< String host = "localhost";
---
> String host = "localhost";
196,197c292,293
< URL url = new URL("http://" + host +":" + port +"/nonexistant");
< server.invoke(name, "addCommandProcessor", new Object[] {"nonexistant", new DummyCommandProcessor()}, new String[] {"java.lang.String", "mx4j.tools.adaptor.http.HttpCommandProcessor"});
---
> URL url = new URL("http://" + host + ":" + port + "/nonexistant");
> server.invoke(name, "addCommandProcessor", new Object[] {"nonexistant", new DummyCommandProcessor()}, new String[] {"java.lang.String", "mx4j.tools.adaptor.http.HttpCommandProcessor"});
201c297
< server.invoke(name, "removeCommandProcessor", new Object[] {"nonexistant"}, new String[] {"java.lang.String"});
---
> server.invoke(name, "removeCommandProcessor", new Object[] {"nonexistant"}, new String[] {"java.lang.String"});
205c301
< server.invoke(name, "addCommandProcessor", new Object[] {"nonexistant", "test.mx4j.tools.adaptor.http.HttpAdaptorTest$DummyCommandProcessor"}, new String[] {"java.lang.String", "java.lang.String"});
---
> server.invoke(name, "addCommandProcessor", new Object[] {"nonexistant", "test.mx4j.tools.adaptor.http.HttpAdaptorTest$DummyCommandProcessor"}, new String[] {"java.lang.String", "java.lang.String"});
212c308
< try {
---
> try {
233,234c329,332
< public static class DummyCommandProcessor extends HttpCommandProcessorAdaptor {
< public Document executeRequest(HttpInputStream in) throws IOException, JMException {
---
> public static class DummyCommandProcessor extends HttpCommandProcessorAdaptor
> {
> public Document executeRequest(HttpInputStream in) throws IOException, JMException
> {
237a336,361
>
> public static class TestLoginConfig extends javax.security.auth.login.Configuration
> {
>
> public AppConfigurationEntry[] getAppConfigurationEntry(String applicationName)
> {
> if ( applicationName.equals("testConfigModule"))
> {
> java.util.Map options = new java.util.HashMap();
> options.put( "testUserName", DEFAULT_TEST_USER_NAME );
> options.put( "testPassword", DEFAULT_TEST_USER_PASS );
> return new AppConfigurationEntry[]
> {
> new AppConfigurationEntry( "test.mx4j.tools.adaptor.http.HttpAdaptorTest$TestLoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUISITE, options )
> };
> }
> return null;
> }
>
> public void refresh()
> {
> }
> }
>
> public static class TestLoginModule implements javax.security.auth.spi.LoginModule
> {
238a363,410
> private String testUserName;
> private String testPassword;
> private CallbackHandler handler;
>
> public boolean abort() throws LoginException
> {
> return true;
> }
>
> public boolean commit() throws LoginException
> {
> return true;
> }
>
> public void initialize(Subject subject,
> CallbackHandler callbackHandler,
> Map sharedState,
> Map options)
> {
> testUserName = (String)options.get("testUserName");
> testPassword = (String)options.get("testPassword");
> handler = callbackHandler;
> }
>
> public boolean login() throws LoginException
> {
> NameCallback nameCB = new NameCallback("Please enter your name");
> PasswordCallback passCB = new PasswordCallback("Please enter your password", false);
> try
> {
> handler.handle(new Callback[]{ nameCB, passCB });
> }
> catch (Exception ex)
> {
> LoginException ex2 = new LoginException("Error during login module callback handling");
> ex2.initCause(ex);
> throw ex2;
> }
> String providedUsername = nameCB.getName();
> String providedPassword = new String( passCB.getPassword() );
> return testUserName.equals( providedUsername ) && providedPassword.equals( testPassword );
> }
>
> public boolean logout() throws LoginException
> {
> return true;
> }
> }
SMTP.diff
(text/plain, 306 B)
Index: SMTP.java =================================================================== RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/mail/SMTP.java,v retrieving revision 1.4 diff -r1.4 SMTP.java 52c52 < * @version $Revision: 1.4 $ --- > * @version $Revision: 1.5 $ 165d164 < e.printStackTrace();
SSLAdaptorServerSocketFactory.diff
(text/plain, 1 KB)
Index: SSLAdaptorServerSocketFactory.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/adaptor/ssl/SSLAdaptorServerSocketFactory.java,v
retrieving revision 1.2
diff -r1.2 SSLAdaptorServerSocketFactory.java
12a13
> import java.io.FileInputStream;
58c59
< * @version $Revision: 1.2 $
---
> * @version $Revision: 1.3 $
167c168,181
< if (keyStoreStream == null) {throw new IOException("Cannot find KeyStore " + m_keyStoreName);}
---
> if (keyStoreStream == null)
> {
> // let's look at the file system, maybe that the name provided
> // is in fact a file path...
> java.io.File fle = new java.io.File( m_keyStoreName );
> if ( fle.exists() )
> {
> keyStoreStream = new FileInputStream( fle );
> }
> }
> if (keyStoreStream == null)
> {
> throw new IOException("Cannot find KeyStore " + m_keyStoreName);
> }
169c183,189
<
---
> try
> {
> keyStoreStream.close();
> }
> catch ( Exception ex )
> {
> }
XSLTProcessor.diff
(text/plain, 2.1 KB)
Index: XSLTProcessor.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/adaptor/http/XSLTProcessor.java,v
retrieving revision 1.5
diff -r1.5 XSLTProcessor.java
49c49
< * @version $Revision: 1.5 $
---
> * @version $Revision: 1.6 $
165,189c165,186
< if (useCache)
< {
< synchronized (this)
< {
< if (templatesCache.containsKey(path))
< {
< return ((Templates)templatesCache.get(path)).newTransformer();
< }
< else
< {
< InputStream stream = getInputStream(path);
< if (stream != null)
< {
< if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Creating template for path " + path);
< Templates template = factory.newTemplates(new StreamSource(stream));
< if (useCache) templatesCache.put(path, template);
< return template.newTransformer();
< }
< else
< {
< if (logger.isEnabledFor(Logger.INFO)) logger.info("XSL template for path '" + path + "' not found");
< }
< }
< }
< }
---
> synchronized (this)
> {
> if (useCache && templatesCache.containsKey(path))
> {
> return ((Templates)templatesCache.get(path)).newTransformer();
> }
> else
> {
> InputStream stream = getInputStream(path);
> if (stream != null)
> {
> if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Creating template for path " + path);
> Templates template = factory.newTemplates(new StreamSource(stream));
> if (useCache) templatesCache.put(path, template);
> return template.newTransformer();
> }
> else
> {
> if (logger.isEnabledFor(Logger.INFO)) logger.info("XSL template for path '" + path + "' not found");
> }
> }
> }