You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/01/27 20:52:02 UTC
cvs commit: jakarta-cactus/src/framework/share/org/apache/cactus/client/authentication AbstractAuthentication.java BasicAuthentication.java
vmassol 02/01/27 11:52:02
Modified: src/framework/share/org/apache/cactus/client/authentication
AbstractAuthentication.java
BasicAuthentication.java
Log:
audit fix
Revision Changes Path
1.2 +19 -14 jakarta-cactus/src/framework/share/org/apache/cactus/client/authentication/AbstractAuthentication.java
Index: AbstractAuthentication.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/framework/share/org/apache/cactus/client/authentication/AbstractAuthentication.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractAuthentication.java 13 Jan 2002 21:21:17 -0000 1.1
+++ AbstractAuthentication.java 27 Jan 2002 19:52:02 -0000 1.2
@@ -69,47 +69,47 @@
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @author <a href="mailto:Jason.Robertson@acs-inc.com">Jason Robertson</a>
*
- * @version $Id: AbstractAuthentication.java,v 1.1 2002/01/13 21:21:17 vmassol Exp $
+ * @version $Id: AbstractAuthentication.java,v 1.2 2002/01/27 19:52:02 vmassol Exp $
*/
public abstract class AbstractAuthentication
{
/**
* User id part of the Credential
*/
- protected String userid;
+ private String userId;
/**
* Password part of the Credential
*/
- protected String password;
-
- public AbstractAuthentication(String theUserid, String thePassword)
+ private String password;
+
+ public AbstractAuthentication(String theUserId, String thePassword)
{
- setUserId(theUserid);
+ setUserId(theUserId);
setPassword(thePassword);
}
-
- public void setUserId(String theUserid)
+
+ public void setUserId(String theUserId)
{
- validateUserId(theUserid);
- this.userid = theUserid;
+ validateUserId(theUserId);
+ this.userId = theUserId;
}
public String getUserId()
{
- return this.userid;
+ return this.userId;
}
-
+
public void setPassword(String thePassword)
{
validatePassword(thePassword);
this.password = thePassword;
}
-
+
/**
* @exception IllegalArgumentException if invalid
*/
- protected abstract void validateUserId(String theUserid);
+ protected abstract void validateUserId(String theUserId);
/**
* @exception IllegalArgumentException if invalid
@@ -117,4 +117,9 @@
protected abstract void validatePassword(String thePassword);
public abstract void configure(HttpURLConnection theConnection);
+
+ protected String getPassword()
+ {
+ return this.password;
+ }
}
1.3 +33 -33 jakarta-cactus/src/framework/share/org/apache/cactus/client/authentication/BasicAuthentication.java
Index: BasicAuthentication.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/framework/share/org/apache/cactus/client/authentication/BasicAuthentication.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BasicAuthentication.java 27 Jan 2002 17:23:18 -0000 1.2
+++ BasicAuthentication.java 27 Jan 2002 19:52:02 -0000 1.3
@@ -63,7 +63,7 @@
{
super(userid, password);
}
-
+
protected void validateUserId(String userid)
{
// According to HTTP 1.0 Spec:
@@ -76,34 +76,34 @@
// "{" | "}" | SP | HT
// SP = <US-ASCII SP, space (32)>
// HT = <US-ASCII HT, horizontal-tab (9)>
-
+
// Validate the given userid
-
+
// The userid is optional, it can be blank.
if (userid == null)
{
return;
}
-
- // If it's non-blank, there is no maximum length
+
+ // If it's non-blank, there is no maximum length
// and it can't contain any illegal characters
String illegalChars = "()<>@,;:\\\"/[]?={} \t";
StringCharacterIterator iter = new StringCharacterIterator(userid);
-
+
for (char c = iter.first(); c != CharacterIterator.DONE;
c = iter.next()) {
- if ((illegalChars.indexOf(c) != -1) ||
- ((c >=0 ) && (c <= 31)) ||
+ if ((illegalChars.indexOf(c) != -1) ||
+ ((c >=0 ) && (c <= 31)) ||
(c == 127)) {
-
+
// Bad userid! Go to your room!
throw new IllegalArgumentException(
"Given userid contains illegal characters.");
}
}
}
-
+
protected void validatePassword(String password)
{
// According to HTTP 1.0 Spec:
@@ -117,35 +117,35 @@
// LF = <US-ASCII LF, linefeed (10)>
// SP = <US-ASCII SP, space (32)>
// HT = <US-ASCII HT, horizontal-tab (9)>
-
+
// Validate the given password
-
+
// The password can have zero characters, i.e. be blank.
if (password == null)
{
return;
}
-
- // If it's non-blank, there is no maximum length
+
+ // If it's non-blank, there is no maximum length
// and it can't contain any illegal characters
String exceptionChars = "\r\n \t"; // CR LF SP HT
StringCharacterIterator iter = new StringCharacterIterator(password);
-
+
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
if (((c >=0 ) && (c <= 31)) || (c == 127)) {
-
+
if (exceptionChars.indexOf(c) != -1 )
{
continue;
}
-
+
// Bad password! Go to your room!
throw new IllegalArgumentException(
"Given password contains illegal characters.");
}
}
}
-
+
public void configure(HttpURLConnection connection)
{
// According to HTTP 1.0 Spec:
@@ -156,10 +156,10 @@
//
// see setUserId and setPassword for details of token and TEXT
- String basicCookie = userid + ":" + password;
+ String basicCookie = getUserId() + ":" + getPassword();
String basicCredentials = "Basic " +
new String(base64Encode(basicCookie.getBytes()));
-
+
connection.setRequestProperty("Authorization", basicCredentials);
}
@@ -170,13 +170,13 @@
private static char[] alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".toCharArray();
-
+
/**
* Lookup table for converting base64 characters to value in range 0..63
*/
private static byte[] codes = new byte[256];
-
- static
+
+ static
{
for (int i=0; i<256; i++) {
codes[i] = -1;
@@ -204,7 +204,7 @@
private static char[] base64Encode(byte[] data)
{
char[] out = new char[((data.length + 2) / 3) * 4];
-
+
//
// 3 bytes encode to 4 chars. Output is always an even
// multiple of 4 characters.
@@ -213,33 +213,33 @@
{
boolean quad = false;
boolean trip = false;
-
+
int val = (0xFF & (int) data[i]);
val <<= 8;
-
+
if ((i+1) < data.length)
{
val |= (0xFF & (int) data[i+1]);
trip = true;
}
-
+
val <<= 8;
-
- if ((i+2) < data.length)
+
+ if ((i+2) < data.length)
{
val |= (0xFF & (int) data[i+2]);
quad = true;
}
-
+
out[index+3] = alphabet[(quad? (val & 0x3F): 64)];
val >>= 6;
-
+
out[index+2] = alphabet[(trip? (val & 0x3F): 64)];
val >>= 6;
-
+
out[index+1] = alphabet[val & 0x3F];
val >>= 6;
-
+
out[index+0] = alphabet[val & 0x3F];
}
return out;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>