summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-01-12 23:25:43 -0600
committerEndi Sukma Dewata <edewata@redhat.com>2012-01-18 12:56:06 -0600
commit84e512223229b2d54e1a04b7899f888732c8fdba (patch)
tree33c022adbd60ce1103d0f0c97fcfc1e229a86643 /pki/base/util/src
parent2a535f04f7b7bf670b19b95801e25178af5c91f9 (diff)
downloadpki-84e512223229b2d54e1a04b7899f888732c8fdba.tar.gz
pki-84e512223229b2d54e1a04b7899f888732c8fdba.tar.xz
pki-84e512223229b2d54e1a04b7899f888732c8fdba.zip
Added generics (part 2).
This patch brings down the warnings from 4648 to 3992. Ticket #2
Diffstat (limited to 'pki/base/util/src')
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/http/HttpMessage.java16
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java6
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/xml/XMLObject.java4
-rw-r--r--pki/base/util/src/netscape/security/acl/GroupImpl.java12
-rw-r--r--pki/base/util/src/netscape/security/pkcs/PKCS10Attributes.java32
-rw-r--r--pki/base/util/src/netscape/security/x509/Attribute.java34
6 files changed, 48 insertions, 56 deletions
diff --git a/pki/base/util/src/com/netscape/cmsutil/http/HttpMessage.java b/pki/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
index 100cbb5af..badec5930 100644
--- a/pki/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
+++ b/pki/base/util/src/com/netscape/cmsutil/http/HttpMessage.java
@@ -30,14 +30,14 @@ import java.util.Hashtable;
*/
public class HttpMessage {
protected String mLine = null; // request or response line.
- protected Hashtable mHeaders = null;
+ protected Hashtable<String, String> mHeaders = null;
protected String mContent = null; // arbitrary content chars assumed.
/**
* Instantiate a HttpResponse for write to http client.
*/
public HttpMessage() {
- mHeaders = new Hashtable();
+ mHeaders = new Hashtable<String, String>();
}
/**
@@ -48,7 +48,7 @@ public class HttpMessage {
*/
public void setHeader(String name, String value) {
if (mHeaders == null)
- mHeaders = new Hashtable();
+ mHeaders = new Hashtable<String, String>();
mHeaders.put(name.toLowerCase(), value);
}
@@ -66,12 +66,12 @@ public class HttpMessage {
public void writeHeaders(OutputStreamWriter writer)
throws IOException {
if (mHeaders != null) {
- Enumeration keys = mHeaders.keys();
+ Enumeration<String> keys = mHeaders.keys();
String header, value;
while (keys.hasMoreElements()) {
- header = (String) keys.nextElement();
- value = (String) mHeaders.get(header);
+ header = keys.nextElement();
+ value = mHeaders.get(header);
writer.write(header + ":" + value + Http.CRLF);
}
}
@@ -84,7 +84,7 @@ public class HttpMessage {
*/
public void readHeaders(BufferedReader reader)
throws IOException {
- mHeaders = new Hashtable();
+ mHeaders = new Hashtable<String, String>();
int colon;
String line, key, value;
@@ -129,7 +129,7 @@ public class HttpMessage {
readHeaders(reader);
// won't work if content length is not set.
- String lenstr = (String) mHeaders.get("content-length");
+ String lenstr = mHeaders.get("content-length");
if (lenstr != null) {
int len = Integer.parseInt(lenstr);
diff --git a/pki/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java b/pki/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java
index 46860de19..d6974d371 100644
--- a/pki/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java
+++ b/pki/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java
@@ -21,7 +21,7 @@ import java.util.Enumeration;
import java.util.Vector;
public class AttributeSet {
- private Vector _attrs = new Vector();
+ private Vector<Attribute> _attrs = new Vector<Attribute>();
public AttributeSet() {
}
@@ -34,7 +34,7 @@ public class AttributeSet {
return _attrs.size();
}
- public Enumeration getAttributes() {
+ public Enumeration<Attribute> getAttributes() {
return _attrs.elements();
}
@@ -51,6 +51,6 @@ public class AttributeSet {
}
public Attribute getAttributeAt(int pos) {
- return (Attribute) _attrs.elementAt(pos);
+ return _attrs.elementAt(pos);
}
}
diff --git a/pki/base/util/src/com/netscape/cmsutil/xml/XMLObject.java b/pki/base/util/src/com/netscape/cmsutil/xml/XMLObject.java
index 8890d79fe..8317ad785 100644
--- a/pki/base/util/src/com/netscape/cmsutil/xml/XMLObject.java
+++ b/pki/base/util/src/com/netscape/cmsutil/xml/XMLObject.java
@@ -137,8 +137,8 @@ public class XMLObject {
return v;
}
- public Vector getValuesFromContainer(Node container, String tagname) {
- Vector v = new Vector();
+ public Vector<String> getValuesFromContainer(Node container, String tagname) {
+ Vector<String> v = new Vector<String>();
NodeList c = container.getChildNodes();
int len = c.getLength();
for (int i = 0; i < len; i++) {
diff --git a/pki/base/util/src/netscape/security/acl/GroupImpl.java b/pki/base/util/src/netscape/security/acl/GroupImpl.java
index fc50714f8..ed087a544 100644
--- a/pki/base/util/src/netscape/security/acl/GroupImpl.java
+++ b/pki/base/util/src/netscape/security/acl/GroupImpl.java
@@ -28,7 +28,7 @@ import java.util.Vector;
* @author Satish Dharmaraj
*/
public class GroupImpl implements Group {
- private Vector groupMembers = new Vector(50, 100);
+ private Vector<Principal> groupMembers = new Vector<Principal>(50, 100);
private String group;
/**
@@ -73,7 +73,7 @@ public class GroupImpl implements Group {
/**
* returns the enumeration of the members in the group.
*/
- public Enumeration members() {
+ public Enumeration<Principal> members() {
return groupMembers.elements();
}
@@ -118,7 +118,7 @@ public class GroupImpl implements Group {
if (groupMembers.contains(member)) {
return true;
} else {
- Vector alreadySeen = new Vector(10);
+ Vector<Group> alreadySeen = new Vector<Group>(10);
return isMemberRecurse(member, alreadySeen);
}
}
@@ -136,11 +136,11 @@ public class GroupImpl implements Group {
// a vector of already seen groups. Only new groups are considered,
// thereby avoiding loops.
//
- boolean isMemberRecurse(Principal member, Vector alreadySeen) {
- Enumeration e = members();
+ boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
+ Enumeration<Principal> e = members();
while (e.hasMoreElements()) {
boolean mem = false;
- Principal p = (Principal) e.nextElement();
+ Principal p = e.nextElement();
// if the member is in this collection, return true
if (p.equals(member)) {
diff --git a/pki/base/util/src/netscape/security/pkcs/PKCS10Attributes.java b/pki/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
index 46b309cc7..8beb1e64c 100644
--- a/pki/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
+++ b/pki/base/util/src/netscape/security/pkcs/PKCS10Attributes.java
@@ -35,19 +35,19 @@ import netscape.security.util.DerValue;
* @author Hemma Prafullchandra
* @version 1.10
*/
-public class PKCS10Attributes extends Vector implements DerEncoder {
+public class PKCS10Attributes extends Vector<PKCS10Attribute> implements DerEncoder {
/**
*
*/
private static final long serialVersionUID = 1362260612357629542L;
- private Hashtable map;
+ private Hashtable<String, PKCS10Attribute> map;
/**
* Default constructor for the certificate attribute.
*/
public PKCS10Attributes() {
- map = new Hashtable();
+ map = new Hashtable<String, PKCS10Attribute>();
}
/**
@@ -59,7 +59,7 @@ public class PKCS10Attributes extends Vector implements DerEncoder {
public PKCS10Attributes(DerInputStream in)
throws IOException {
- map = new Hashtable();
+ map = new Hashtable<String, PKCS10Attribute>();
DerValue[] attrs = in.getSet(5, true);
if (attrs != null) {
@@ -107,41 +107,41 @@ public class PKCS10Attributes extends Vector implements DerEncoder {
/**
* Set the attribute value.
*/
- public void setAttribute(String name, Object obj) throws IOException {
- map.put(name, obj);
- addElement(obj);
+ public void setAttribute(String name, PKCS10Attribute attr) throws IOException {
+ map.put(name, attr);
+ addElement(attr);
}
/**
* Get the attribute value.
*/
- public Object getAttribute(String name) throws IOException {
- Object obj = map.get(name);
+ public PKCS10Attribute getAttribute(String name) throws IOException {
+ PKCS10Attribute attr = map.get(name);
/*
- if (obj == null) {
+ if (attr == null) {
throw new IOException("No attribute found with name " + name);
}
*/
- return (obj);
+ return (attr);
}
/**
* Delete the attribute value.
*/
public void deleteAttribute(String name) throws IOException {
- Object obj = map.get(name);
- if (obj == null) {
+ PKCS10Attribute attr = map.get(name);
+ if (attr == null) {
throw new IOException("No attribute found with name " + name);
}
map.remove(name);
- removeElement(obj);
+ removeElement(attr);
}
/**
* Return an enumeration of names of attributes existing within this
* attribute.
*/
- public Enumeration getElements() {
- return (map.elements());
+ public Enumeration<PKCS10Attribute> getElements() {
+ return map.elements();
}
}
diff --git a/pki/base/util/src/netscape/security/x509/Attribute.java b/pki/base/util/src/netscape/security/x509/Attribute.java
index b026e30c3..11e22db10 100644
--- a/pki/base/util/src/netscape/security/x509/Attribute.java
+++ b/pki/base/util/src/netscape/security/x509/Attribute.java
@@ -64,7 +64,7 @@ public final class Attribute implements Serializable, DerEncoder {
private static final long serialVersionUID = -931486084625476764L;
//private variables
ObjectIdentifier oid;
- Vector valueSet = new Vector();
+ Vector<String> valueSet = new Vector<String>();
transient protected X500NameAttrMap attrMap;
//========== CONSTRUCTOR ==================================
@@ -93,7 +93,7 @@ public final class Attribute implements Serializable, DerEncoder {
* @param oid the object identifier of the attribute type
* @param values String value vector
*/
- public Attribute(ObjectIdentifier oid, Vector values)
+ public Attribute(ObjectIdentifier oid, Vector<String> values)
throws IOException {
//pre-condition verification
@@ -104,13 +104,9 @@ public final class Attribute implements Serializable, DerEncoder {
this.oid = oid;
//copy the value into the valueSet list
- Enumeration vals = values.elements();
+ Enumeration<String> vals = values.elements();
while (vals.hasMoreElements()) {
- Object obj = vals.nextElement();
- if (obj instanceof String)
- valueSet.addElement(obj);
- else
- throw new IOException("values vectore must consist of String object");
+ valueSet.addElement(vals.nextElement());
}
}
@@ -120,7 +116,7 @@ public final class Attribute implements Serializable, DerEncoder {
* @param oid attribute type string CN,OU,O,C,L,TITLE,ST,STREET,UID,MAIL,E,DC
* @param values String value vector
*/
- public Attribute(String attr, Vector values)
+ public Attribute(String attr, Vector<String> values)
throws IOException {
//pre-condition verification
@@ -143,13 +139,9 @@ public final class Attribute implements Serializable, DerEncoder {
this.oid = id;
//copy the value into the valueSet list
- Enumeration vals = values.elements();
+ Enumeration<String> vals = values.elements();
while (vals.hasMoreElements()) {
- Object obj = vals.nextElement();
- if (obj instanceof String)
- valueSet.addElement(obj);
- else
- throw new IOException("Values vectore must consist of String object");
+ valueSet.addElement(vals.nextElement());
}
}
@@ -188,7 +180,7 @@ public final class Attribute implements Serializable, DerEncoder {
*
* @return Enumeration of values of this Attribute.
*/
- public Enumeration getValues() {
+ public Enumeration<String> getValues() {
if (valueSet == null)
return null;
return valueSet.elements();
@@ -223,11 +215,11 @@ public final class Attribute implements Serializable, DerEncoder {
public String toString() {
String theoid = "Attribute: " + oid + "\n";
String values = "Values: ";
- Enumeration n = valueSet.elements();
+ Enumeration<String> n = valueSet.elements();
if (n.hasMoreElements()) {
- values += (String) n.nextElement();
+ values += n.nextElement();
while (n.hasMoreElements())
- values += "," + (String) n.nextElement();
+ values += "," + n.nextElement();
}
return theoid + values + "\n";
}
@@ -260,9 +252,9 @@ public final class Attribute implements Serializable, DerEncoder {
}
//loop through all the values and encode
- Enumeration vals = valueSet.elements();
+ Enumeration<String> vals = valueSet.elements();
while (vals.hasMoreElements()) {
- String val = (String) vals.nextElement();
+ String val = vals.nextElement();
DerValue derobj = converter.getValue(val);
derobj.encode(tmp);
}