You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/09/28 05:02:46 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient NTLM.java
jsdever 2002/09/27 20:02:46
Modified: httpclient/src/java/org/apache/commons/httpclient NTLM.java
Log:
Fix for the GUMP compliation failure.
Allow for runtime determination of which security provider to use for NTLM authentication. The provider is chosen through the httpclient.security.provider system property.
Thanks for comments by Dennis Cook and Steve Downey.
Revision Changes Path
1.2 +35 -7 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NTLM.java
Index: NTLM.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NTLM.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NTLM.java 26 Sep 2002 11:40:16 -0000 1.1
+++ NTLM.java 28 Sep 2002 03:02:46 -0000 1.2
@@ -62,6 +62,9 @@
package org.apache.commons.httpclient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.security.*;
import java.util.*;
import java.io.*;
@@ -78,8 +81,9 @@
* efforts of a wide range of people.</p>
*
* @author <a href="mailto:adrian@ephox.com">Adrian Sutton</a>
- * @version $Revision$ $Date$
+ * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
*
+ * @version $Revision$ $Date$
* @since 2.0
*/
public final class NTLM {
@@ -87,9 +91,33 @@
private static byte[] currResponse;
private static int pos = 0;
- static {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
- }
+ /** Log object for this class. */
+ private static final Log log = LogFactory.getLog(NTLM.class);
+
+ //Initialize the security provider
+ static {
+ //TODO: do not use System properties
+ String secProviderName = System.getProperty(
+ "httpclient.security.provider",
+ "com.sun.crypto.provider.SunJCE");
+ try {
+ java.security.Provider secProvider = (java.security.Provider)
+ Class.forName(secProviderName).newInstance();
+ Security.addProvider(secProvider);
+ } catch (ClassNotFoundException e) {
+ log.error("Specified security provider " + secProviderName +
+ " could not be found by the class loader", e);
+ } catch (ClassCastException e) {
+ log.error("Specified security provider " + secProviderName +
+ " is not of type java.security.Provider", e);
+ } catch (InstantiationException e) {
+ log.error("Specified security provider " + secProviderName +
+ " could not be instantiated", e);
+ } catch (IllegalAccessException e) {
+ log.error("Specified security provider " + secProviderName +
+ " does not allow access to the constructor", e);
+ }
+ }
/**
* <p>Returns the response for the given message.</p>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>