8046949: Generify the javax.xml.crypto API

Reviewed-by: xuelei
This commit is contained in:
Sean Mullan 2014-11-21 15:23:36 -05:00
parent 2c4ba7c947
commit ca85e583e9
46 changed files with 258 additions and 410 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,9 +37,10 @@ import java.util.Iterator;
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @param <T> the type of nodes maintained by this set
* @since 1.6
*/
public interface NodeSetData extends Data {
public interface NodeSetData<T> extends Data, Iterable<T> {
/**
* Returns a read-only iterator over the nodes contained in this
@ -52,6 +53,5 @@ public interface NodeSetData extends Data {
* @return an <code>Iterator</code> over the nodes in this
* <code>NodeSetData</code> in document order
*/
@SuppressWarnings("rawtypes")
Iterator iterator();
Iterator<T> iterator();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,7 @@ import javax.xml.crypto.XMLCryptoContext;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.w3c.dom.Element;
/**
@ -219,8 +220,7 @@ public class DOMCryptoContext implements XMLCryptoContext {
*
* @return a read-only iterator over the set of mappings
*/
@SuppressWarnings("rawtypes")
public Iterator iterator() {
public Iterator<Map.Entry<String, Element>> iterator() {
return Collections.unmodifiableMap(idMap).entrySet().iterator();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -51,8 +51,8 @@ import java.util.List;
*
* <pre>
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
* List references = Collections.singletonList(factory.newReference
* ("#reference-1", DigestMethod.SHA1));
* Reference ref = factory.newReference("#reference-1", DigestMethod.SHA1);
* List<Reference> references = Collections.singletonList(ref);
* Manifest manifest = factory.newManifest(references, "manifest-1");
* </pre>
*
@ -86,6 +86,5 @@ public interface Manifest extends XMLStructure {
*
* @return an unmodifiable list of one or more <code>Reference</code>s
*/
@SuppressWarnings("rawtypes")
List getReferences();
List<Reference> getReferences();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -85,8 +85,7 @@ public interface Reference extends URIReference, XMLStructure {
* @return an unmodifiable list of <code>Transform</code>s
* (may be empty but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getTransforms();
List<Transform> getTransforms();
/**
* Returns the digest method of this <code>Reference</code>.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,6 +87,5 @@ public interface SignatureProperties extends XMLStructure {
* @return an unmodifiable list of one or more
* <code>SignatureProperty</code>s
*/
@SuppressWarnings("rawtypes")
List getProperties();
List<SignatureProperty> getProperties();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -91,6 +91,5 @@ public interface SignatureProperty extends XMLStructure {
*
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
*/
@SuppressWarnings("rawtypes")
List getContent();
List<XMLStructure> getContent();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -80,8 +80,7 @@ public interface SignedInfo extends XMLStructure {
*
* @return an unmodifiable list of one or more {@link Reference}s
*/
@SuppressWarnings("rawtypes")
List getReferences();
List<Reference> getReferences();
/**
* Returns the optional <code>Id</code> attribute of this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -64,7 +64,8 @@ import javax.xml.crypto.XMLStructure;
*
* <pre>
* XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
* List content = Collections.singletonList(fac.newManifest(references)));
* Manifest manifest = fac.newManifest(references);
* List<XMLStructure> content = Collections.singletonList(manifest);
* XMLObject object = factory.newXMLObject(content, "object-1", null, null);
* </pre>
*
@ -100,8 +101,7 @@ public interface XMLObject extends XMLStructure {
* @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
* but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getContent();
List<XMLStructure> getContent();
/**
* Returns the Id of this <code>XMLObject</code>.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -136,8 +136,7 @@ public interface XMLSignature extends XMLStructure {
* @return an unmodifiable list of <code>XMLObject</code>s (may be empty
* but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getObjects();
List<XMLObject> getObjects();
/**
* Returns the optional Id of this <code>XMLSignature</code>.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -365,9 +365,8 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if any of the <code>objects</code> are not of
* type <code>XMLObject</code>
*/
@SuppressWarnings("rawtypes")
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
List objects, String id, String signatureValueId);
List<? extends XMLObject> objects, String id, String signatureValueId);
/**
* Creates a <code>Reference</code> with the specified URI and digest
@ -399,9 +398,8 @@ public abstract class XMLSignatureFactory {
* compliant
* @throws NullPointerException if <code>dm</code> is <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id);
List<? extends Transform> transforms, String type, String id);
/**
* Creates a <code>Reference</code> with the specified parameters and
@ -430,9 +428,9 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if <code>dm</code> or
* <code>digestValue</code> is <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List transforms, String type, String id, byte[] digestValue);
List<? extends Transform> transforms, String type, String id,
byte[] digestValue);
/**
* Creates a <code>Reference</code> with the specified parameters.
@ -473,10 +471,9 @@ public abstract class XMLSignatureFactory {
* <code>appliedTransforms</code> or <code>result</code> is
* <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract Reference newReference(String uri, DigestMethod dm,
List appliedTransforms, Data result, List transforms, String type,
String id);
List<? extends Transform> appliedTransforms, Data result,
List<? extends Transform> transforms, String type, String id);
/**
* Creates a <code>SignedInfo</code> with the specified canonicalization
@ -493,9 +490,8 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if any of the parameters
* are <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references);
SignatureMethod sm, List<? extends Reference> references);
/**
* Creates a <code>SignedInfo</code> with the specified parameters.
@ -512,9 +508,8 @@ public abstract class XMLSignatureFactory {
* @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
* <code>references</code> are <code>null</code>
*/
@SuppressWarnings("rawtypes")
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references, String id);
SignatureMethod sm, List<? extends Reference> references, String id);
// Object factory methods
/**
@ -530,9 +525,8 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract XMLObject newXMLObject(List content, String id,
String mimeType, String encoding);
public abstract XMLObject newXMLObject(List<? extends XMLStructure> content,
String id, String mimeType, String encoding);
/**
* Creates a <code>Manifest</code> containing the specified
@ -547,8 +541,7 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
@SuppressWarnings("rawtypes")
public abstract Manifest newManifest(List references);
public abstract Manifest newManifest(List<? extends Reference> references);
/**
* Creates a <code>Manifest</code> containing the specified
@ -564,8 +557,8 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>references</code> contains any
* entries that are not of type {@link Reference}
*/
@SuppressWarnings("rawtypes")
public abstract Manifest newManifest(List references, String id);
public abstract Manifest newManifest(List<? extends Reference> references,
String id);
/**
* Creates a <code>SignatureProperty</code> containing the specified
@ -583,9 +576,8 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>content</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract SignatureProperty newSignatureProperty
(List content, String target, String id);
(List<? extends XMLStructure> content, String target, String id);
/**
* Creates a <code>SignatureProperties</code> containing the specified
@ -602,9 +594,8 @@ public abstract class XMLSignatureFactory {
* @throws ClassCastException if <code>properties</code> contains any
* entries that are not of type {@link SignatureProperty}
*/
@SuppressWarnings("rawtypes")
public abstract SignatureProperties newSignatureProperties
(List properties, String id);
(List<? extends SignatureProperty> properties, String id);
// Algorithm factory methods
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -94,8 +94,7 @@ public interface KeyInfo extends XMLStructure {
* in this <code>KeyInfo</code>. Never returns <code>null</code> or an
* empty list.
*/
@SuppressWarnings("rawtypes")
List getContent();
List<XMLStructure> getContent();
/**
* Return the optional Id attribute of this <code>KeyInfo</code>, which

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -305,8 +305,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract KeyInfo newKeyInfo(List content);
public abstract KeyInfo newKeyInfo(List<? extends XMLStructure> content);
/**
* Creates a <code>KeyInfo</code> containing the specified list of key
@ -325,8 +324,8 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract KeyInfo newKeyInfo(List content, String id);
public abstract KeyInfo newKeyInfo(List<? extends XMLStructure> content,
String id);
/**
* Creates a <code>KeyName</code> from the specified name.
@ -387,9 +386,8 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket,
List other);
List<? extends XMLStructure> other);
/**
* Creates a <code>PGPData</code> from the specified PGP key material
@ -411,8 +409,8 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>other</code> contains any
* entries that are not of type {@link XMLStructure}
*/
@SuppressWarnings("rawtypes")
public abstract PGPData newPGPData(byte[] keyPacket, List other);
public abstract PGPData newPGPData(byte[] keyPacket,
List<? extends XMLStructure> other);
/**
* Creates a <code>RetrievalMethod</code> from the specified URI.
@ -443,9 +441,8 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>transforms</code> contains any
* entries that are not of type {@link Transform}
*/
@SuppressWarnings("rawtypes")
public abstract RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms);
List<? extends Transform> transforms);
/**
* Creates a <code>X509Data</code> containing the specified list of
@ -469,8 +466,7 @@ public abstract class KeyInfoFactory {
* @throws ClassCastException if <code>content</code> contains any entries
* that are not of one of the valid types mentioned above
*/
@SuppressWarnings("rawtypes")
public abstract X509Data newX509Data(List content);
public abstract X509Data newX509Data(List<?> content);
/**
* Creates an <code>X509IssuerSerial</code> from the specified X.500 issuer

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -112,6 +112,5 @@ public interface PGPData extends XMLStructure {
* @return an unmodifiable list of <code>XMLStructure</code>s (may be
* empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
List getExternalElements();
List<XMLStructure> getExternalElements();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -80,8 +80,7 @@ public interface RetrievalMethod extends URIReference, XMLStructure {
* @return an unmodifiable list of <code>Transform</code> objects (may be
* empty but never <code>null</code>).
*/
@SuppressWarnings("rawtypes")
List getTransforms();
List<Transform> getTransforms();
/**
* Returns the URI of the referenced <code>KeyInfo</code> information.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -109,6 +109,5 @@ public interface X509Data extends XMLStructure {
* @return an unmodifiable list of the content in this <code>X509Data</code>
* (never <code>null</code> or empty)
*/
@SuppressWarnings("rawtypes")
List getContent();
List<?> getContent();
}

View File

@ -59,7 +59,7 @@ import java.util.List;
*/
public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
private List<String> preList;
private final List<String> prefixList;
/**
* Indicates the default namespace ("#default").
@ -71,7 +71,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* list.
*/
public ExcC14NParameterSpec() {
preList = Collections.emptyList();
prefixList = Collections.emptyList();
}
/**
@ -86,22 +86,14 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* @throws ClassCastException if any of the entries in the list are not
* of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public ExcC14NParameterSpec(List prefixList) {
public ExcC14NParameterSpec(List<String> prefixList) {
if (prefixList == null) {
throw new NullPointerException("prefixList cannot be null");
}
List<?> copy = new ArrayList<>((List<?>)prefixList);
for (int i = 0, size = copy.size(); i < size; i++) {
if (!(copy.get(i) instanceof String)) {
throw new ClassCastException("not a String");
}
}
@SuppressWarnings("unchecked")
List<String> temp = (List<String>)copy;
preList = Collections.unmodifiableList(temp);
List<String> tempList = Collections.checkedList(new ArrayList<>(),
String.class);
tempList.addAll(prefixList);
this.prefixList = Collections.unmodifiableList(tempList);
}
/**
@ -114,8 +106,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
* @return the inclusive namespace prefix list (may be empty but never
* <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public List getPrefixList() {
return preList;
public List<String> getPrefixList() {
return prefixList;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -59,27 +59,18 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
* @throws NullPointerException if <code>xPathList</code> is
* <code>null</code>
*/
@SuppressWarnings("rawtypes")
public XPathFilter2ParameterSpec(List xPathList) {
public XPathFilter2ParameterSpec(List<XPathType> xPathList) {
if (xPathList == null) {
throw new NullPointerException("xPathList cannot be null");
}
List<?> xPathListCopy = new ArrayList<>((List<?>)xPathList);
if (xPathListCopy.isEmpty()) {
List<XPathType> tempList =
Collections.checkedList(new ArrayList<XPathType>(),
XPathType.class);
tempList.addAll(xPathList);
if (tempList.isEmpty()) {
throw new IllegalArgumentException("xPathList cannot be empty");
}
int size = xPathListCopy.size();
for (int i = 0; i < size; i++) {
if (!(xPathListCopy.get(i) instanceof XPathType)) {
throw new ClassCastException
("xPathList["+i+"] is not a valid type");
}
}
@SuppressWarnings("unchecked")
List<XPathType> temp = (List<XPathType>)xPathListCopy;
this.xPathList = Collections.unmodifiableList(temp);
this.xPathList = Collections.unmodifiableList(tempList);
}
/**
@ -91,8 +82,7 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
* @return a <code>List</code> of <code>XPathType</code> objects
* (never <code>null</code> or empty)
*/
@SuppressWarnings("rawtypes")
public List getXPathList() {
public List<XPathType> getXPathList() {
return xPathList;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
/**
* Parameters for the <a href="http://www.w3.org/TR/xmldsig-core/#sec-XPath">
@ -51,8 +50,8 @@ import java.util.Map.Entry;
*/
public final class XPathFilterParameterSpec implements TransformParameterSpec {
private String xPath;
private Map<String,String> nsMap;
private final String xPath;
private final Map<String,String> nsMap;
/**
* Creates an <code>XPathFilterParameterSpec</code> with the specified
@ -83,26 +82,16 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec {
* @throws ClassCastException if any of the map's keys or entries are not
* of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public XPathFilterParameterSpec(String xPath, Map namespaceMap) {
public XPathFilterParameterSpec(String xPath, Map<String,String> namespaceMap) {
if (xPath == null || namespaceMap == null) {
throw new NullPointerException();
}
this.xPath = xPath;
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<?,?> me = entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
@SuppressWarnings("unchecked")
Map<String,String> temp = (Map<String,String>)copy;
nsMap = Collections.unmodifiableMap(temp);
Map<String,String> tempMap = Collections.checkedMap(new HashMap<>(),
String.class,
String.class);
tempMap.putAll(namespaceMap);
this.nsMap = Collections.unmodifiableMap(tempMap);
}
/**
@ -125,8 +114,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec {
* @return a <code>Map</code> of namespace prefixes to namespace URIs (may
* be empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public Map getNamespaceMap() {
public Map<String,String> getNamespaceMap() {
return nsMap;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,6 @@
package javax.xml.crypto.dsig.spec;
import java.util.Collections;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
@ -106,7 +105,7 @@ public class XPathType {
private final String expression;
private final Filter filter;
private Map<String,String> nsMap;
private final Map<String,String> nsMap;
/**
* Creates an <code>XPathType</code> instance with the specified XPath
@ -147,26 +146,24 @@ public class XPathType {
* @throws ClassCastException if any of the map's keys or entries are
* not of type <code>String</code>
*/
@SuppressWarnings("rawtypes")
public XPathType(String expression, Filter filter, Map namespaceMap) {
this(expression, filter);
public XPathType(String expression, Filter filter,
Map<String,String> namespaceMap) {
if (expression == null) {
throw new NullPointerException("expression cannot be null");
}
if (filter == null) {
throw new NullPointerException("filter cannot be null");
}
if (namespaceMap == null) {
throw new NullPointerException("namespaceMap cannot be null");
}
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<?,?> me = entries.next();
if (!(me.getKey() instanceof String) ||
!(me.getValue() instanceof String)) {
throw new ClassCastException("not a String");
}
}
@SuppressWarnings("unchecked")
Map<String,String> temp = (Map<String,String>)copy;
nsMap = Collections.unmodifiableMap(temp);
this.expression = expression;
this.filter = filter;
Map<String,String> tempMap = Collections.checkedMap(new HashMap<>(),
String.class,
String.class);
tempMap.putAll(namespaceMap);
this.nsMap = Collections.unmodifiableMap(tempMap);
}
/**
@ -198,8 +195,7 @@ public class XPathType {
* @return a <code>Map</code> of namespace prefixes to namespace URIs
* (may be empty, but never <code>null</code>)
*/
@SuppressWarnings("rawtypes")
public Map getNamespaceMap() {
public Map<String,String> getNamespaceMap() {
return nsMap;
}
}

View File

@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
*/
/*
* $Id: ApacheCanonicalizer.java 1333869 2012-05-04 10:42:44Z coheigea $
@ -166,11 +166,9 @@ public abstract class ApacheCanonicalizer extends TransformService {
(subTree.getRoot())));
}
} else if (data instanceof NodeSetData) {
NodeSetData nsd = (NodeSetData)data;
// convert Iterator to Set
@SuppressWarnings("unchecked")
Set<Node> ns = Utils.toNodeSet(nsd.iterator());
nodeSet = ns;
NodeSetData<?> nsd = (NodeSetData<?>)data;
// convert Iterator to Set<Node>
nodeSet = Utils.toNodeSet(nsd.iterator());
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Canonicalizing " + nodeSet.size() + " nodes");
}
@ -236,7 +234,6 @@ public abstract class ApacheCanonicalizer extends TransformService {
in = new XMLSignatureInput(subTree.getRoot());
in.setExcludeComments(subTree.excludeComments());
} else {
@SuppressWarnings("unchecked")
Set<Node> nodeSet =
Utils.toNodeSet(((NodeSetData)data).iterator());
in = new XMLSignatureInput(nodeSet);

View File

@ -39,7 +39,7 @@ import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
public class ApacheNodeSetData implements ApacheData, NodeSetData {
public class ApacheNodeSetData implements ApacheData, NodeSetData<Node> {
private XMLSignatureInput xi;

View File

@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
*/
/*
* $Id: ApacheTransform.java 1333869 2012-05-04 10:42:44Z coheigea $
@ -175,7 +175,6 @@ public abstract class ApacheTransform extends TransformService {
in = new XMLSignatureInput(subTree.getRoot());
in.setExcludeComments(subTree.excludeComments());
} else {
@SuppressWarnings("unchecked")
Set<Node> nodeSet =
Utils.toNodeSet(((NodeSetData)data).iterator());
in = new XMLSignatureInput(nodeSet);

View File

@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
*/
/*
* $Id: DOMExcC14NMethod.java 1197150 2011-11-03 14:34:57Z coheigea $
@ -119,7 +119,6 @@ public final class DOMExcC14NMethod extends ApacheCanonicalizer {
ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec;
StringBuilder prefixListAttr = new StringBuilder("");
@SuppressWarnings("unchecked")
List<String> prefixList = params.getPrefixList();
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append(prefixList.get(i));

View File

@ -68,17 +68,14 @@ public final class DOMKeyInfo extends DOMStructure implements KeyInfo {
if (content == null) {
throw new NullPointerException("content cannot be null");
}
this.keyInfoTypes =
Collections.unmodifiableList(new ArrayList<XMLStructure>(content));
List<XMLStructure> tempList =
Collections.checkedList(new ArrayList<XMLStructure>(),
XMLStructure.class);
tempList.addAll(content);
this.keyInfoTypes = Collections.unmodifiableList(tempList);
if (this.keyInfoTypes.isEmpty()) {
throw new IllegalArgumentException("content cannot be empty");
}
for (int i = 0, size = this.keyInfoTypes.size(); i < size; i++) {
if (!(this.keyInfoTypes.get(i) instanceof XMLStructure)) {
throw new ClassCastException
("content["+i+"] is not a valid KeyInfo type");
}
}
this.id = id;
}

View File

@ -34,6 +34,7 @@ import java.security.PublicKey;
import java.util.List;
import javax.xml.crypto.*;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.keyinfo.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -48,13 +49,11 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory {
public DOMKeyInfoFactory() { }
@SuppressWarnings("rawtypes")
public KeyInfo newKeyInfo(List content) {
public KeyInfo newKeyInfo(List<? extends XMLStructure> content) {
return newKeyInfo(content, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public KeyInfo newKeyInfo(List content, String id) {
public KeyInfo newKeyInfo(List<? extends XMLStructure> content, String id) {
return new DOMKeyInfo(content, id);
}
@ -79,13 +78,13 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory {
return newPGPData(keyId, null, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
public PGPData newPGPData(byte[] keyId, byte[] keyPacket,
List<? extends XMLStructure> other) {
return new DOMPGPData(keyId, keyPacket, other);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public PGPData newPGPData(byte[] keyPacket, List other) {
public PGPData newPGPData(byte[] keyPacket,
List<? extends XMLStructure> other) {
return new DOMPGPData(keyPacket, other);
}
@ -93,17 +92,15 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory {
return newRetrievalMethod(uri, null, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms) {
List<? extends Transform> transforms) {
if (uri == null) {
throw new NullPointerException("uri must not be null");
}
return new DOMRetrievalMethod(uri, type, transforms);
}
@SuppressWarnings("rawtypes")
public X509Data newX509Data(List content) {
public X509Data newX509Data(List<?> content) {
return new DOMX509Data(content);
}

View File

@ -33,7 +33,6 @@ import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.keyinfo.KeyValue;
// import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;

View File

@ -67,18 +67,15 @@ public final class DOMManifest extends DOMStructure implements Manifest {
if (references == null) {
throw new NullPointerException("references cannot be null");
}
this.references =
Collections.unmodifiableList(new ArrayList<Reference>(references));
List<Reference> tempList =
Collections.checkedList(new ArrayList<Reference>(),
Reference.class);
tempList.addAll(references);
this.references = Collections.unmodifiableList(tempList);
if (this.references.isEmpty()) {
throw new IllegalArgumentException("list of references must " +
"contain at least one entry");
}
for (int i = 0, size = this.references.size(); i < size; i++) {
if (!(this.references.get(i) instanceof Reference)) {
throw new ClassCastException
("references["+i+"] is not a valid type");
}
}
this.id = id;
}
@ -127,7 +124,6 @@ public final class DOMManifest extends DOMStructure implements Manifest {
return id;
}
@SuppressWarnings("unchecked")
static List<Reference> getManifestReferences(Manifest mf) {
return mf.getReferences();
}

View File

@ -73,18 +73,13 @@ public final class DOMPGPData extends DOMStructure implements PGPData {
if (keyPacket == null) {
throw new NullPointerException("keyPacket cannot be null");
}
if (other == null || other.isEmpty()) {
this.externalElements = Collections.emptyList();
} else {
this.externalElements =
Collections.unmodifiableList(new ArrayList<XMLStructure>(other));
for (int i = 0, size = this.externalElements.size(); i < size; i++) {
if (!(this.externalElements.get(i) instanceof XMLStructure)) {
throw new ClassCastException
("other["+i+"] is not a valid PGPData type");
}
}
List<XMLStructure> tempList =
Collections.checkedList(new ArrayList<XMLStructure>(),
XMLStructure.class);
if (other != null) {
tempList.addAll(other);
}
this.externalElements = Collections.unmodifiableList(tempList);
this.keyPacket = keyPacket.clone();
checkKeyPacket(keyPacket);
this.keyId = null;
@ -120,18 +115,13 @@ public final class DOMPGPData extends DOMStructure implements PGPData {
if (keyId.length != 8) {
throw new IllegalArgumentException("keyId must be 8 bytes long");
}
if (other == null || other.isEmpty()) {
this.externalElements = Collections.emptyList();
} else {
this.externalElements =
Collections.unmodifiableList(new ArrayList<XMLStructure>(other));
for (int i = 0, size = this.externalElements.size(); i < size; i++) {
if (!(this.externalElements.get(i) instanceof XMLStructure)) {
throw new ClassCastException
("other["+i+"] is not a valid PGPData type");
}
}
List<XMLStructure> tempList =
Collections.checkedList(new ArrayList<XMLStructure>(),
XMLStructure.class);
if (other != null) {
tempList.addAll(other);
}
this.externalElements = Collections.unmodifiableList(tempList);
this.keyId = keyId.clone();
this.keyPacket = keyPacket == null ? null
: keyPacket.clone();

View File

@ -147,29 +147,21 @@ public final class DOMReference extends DOMStructure
if (dm == null) {
throw new NullPointerException("DigestMethod must be non-null");
}
if (appliedTransforms == null) {
this.allTransforms = new ArrayList<Transform>();
} else {
this.allTransforms = new ArrayList<Transform>(appliedTransforms);
for (int i = 0, size = this.allTransforms.size(); i < size; i++) {
if (!(this.allTransforms.get(i) instanceof Transform)) {
throw new ClassCastException
("appliedTransforms["+i+"] is not a valid type");
}
}
List<Transform> tempList =
Collections.checkedList(new ArrayList<Transform>(),
Transform.class);
if (appliedTransforms != null) {
tempList.addAll(appliedTransforms);
}
if (transforms == null) {
this.transforms = Collections.emptyList();
} else {
this.transforms = new ArrayList<Transform>(transforms);
for (int i = 0, size = this.transforms.size(); i < size; i++) {
if (!(this.transforms.get(i) instanceof Transform)) {
throw new ClassCastException
("transforms["+i+"] is not a valid type");
}
}
this.allTransforms.addAll(this.transforms);
List<Transform> tempList2 =
Collections.checkedList(new ArrayList<Transform>(),
Transform.class);
if (transforms != null) {
tempList.addAll(transforms);
tempList2.addAll(transforms);
}
this.allTransforms = Collections.unmodifiableList(tempList);
this.transforms = tempList2;
this.digestMethod = dm;
this.uri = uri;
if ((uri != null) && (!uri.equals(""))) {
@ -642,7 +634,7 @@ public final class DOMReference extends DOMStructure
if (xsi.isNodeSet()) {
try {
final Set<Node> s = xsi.getNodeSet();
return new NodeSetData() {
return new NodeSetData<Node>() {
public Iterator<Node> iterator() { return s.iterator(); }
};
} catch (Exception e) {

View File

@ -90,18 +90,13 @@ public final class DOMRetrievalMethod extends DOMStructure
if (uri == null) {
throw new NullPointerException("uri cannot be null");
}
if (transforms == null || transforms.isEmpty()) {
this.transforms = Collections.emptyList();
} else {
this.transforms = Collections.unmodifiableList(
new ArrayList<Transform>(transforms));
for (int i = 0, size = this.transforms.size(); i < size; i++) {
if (!(this.transforms.get(i) instanceof Transform)) {
throw new ClassCastException
("transforms["+i+"] is not a valid type");
}
}
List<Transform> tempList =
Collections.checkedList(new ArrayList<Transform>(),
Transform.class);
if (transforms != null) {
tempList.addAll(transforms);
}
this.transforms = Collections.unmodifiableList(tempList);
this.uri = uri;
if (!uri.equals("")) {
try {
@ -244,7 +239,7 @@ public final class DOMRetrievalMethod extends DOMStructure
// guard against RetrievalMethod loops
if ((data instanceof NodeSetData) && Utils.secureValidation(context)) {
NodeSetData nsd = (NodeSetData)data;
NodeSetData<?> nsd = (NodeSetData<?>)data;
Iterator<?> i = nsd.iterator();
if (i.hasNext()) {
Node root = (Node)i.next();

View File

@ -69,18 +69,15 @@ public final class DOMSignatureProperties extends DOMStructure
{
if (properties == null) {
throw new NullPointerException("properties cannot be null");
} else if (properties.isEmpty()) {
throw new IllegalArgumentException("properties cannot be empty");
} else {
this.properties = Collections.unmodifiableList(
new ArrayList<SignatureProperty>(properties));
for (int i = 0, size = this.properties.size(); i < size; i++) {
if (!(this.properties.get(i) instanceof SignatureProperty)) {
throw new ClassCastException
("properties["+i+"] is not a valid type");
}
}
}
List<SignatureProperty> tempList =
Collections.checkedList(new ArrayList<SignatureProperty>(),
SignatureProperty.class);
tempList.addAll(properties);
if (tempList.isEmpty()) {
throw new IllegalArgumentException("properties cannot be empty");
}
this.properties = Collections.unmodifiableList(tempList);
this.id = id;
}

View File

@ -71,20 +71,18 @@ public final class DOMSignatureProperty extends DOMStructure
{
if (target == null) {
throw new NullPointerException("target cannot be null");
} else if (content == null) {
throw new NullPointerException("content cannot be null");
} else if (content.isEmpty()) {
throw new IllegalArgumentException("content cannot be empty");
} else {
this.content = Collections.unmodifiableList(
new ArrayList<XMLStructure>(content));
for (int i = 0, size = this.content.size(); i < size; i++) {
if (!(this.content.get(i) instanceof XMLStructure)) {
throw new ClassCastException
("content["+i+"] is not a valid type");
}
}
}
if (content == null) {
throw new NullPointerException("content cannot be null");
}
List<XMLStructure> tempList =
Collections.checkedList(new ArrayList<XMLStructure>(),
XMLStructure.class);
tempList.addAll(content);
if (tempList.isEmpty()) {
throw new IllegalArgumentException("content cannot be empty");
}
this.content = Collections.unmodifiableList(tempList);
this.target = target;
this.id = id;
}
@ -169,7 +167,6 @@ public final class DOMSignatureProperty extends DOMStructure
boolean idsEqual = (id == null ? osp.getId() == null
: id.equals(osp.getId()));
@SuppressWarnings("unchecked")
List<XMLStructure> ospContent = osp.getContent();
return (equalsContent(ospContent) &&
target.equals(osp.getTarget()) && idsEqual);

View File

@ -100,19 +100,14 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
}
this.canonicalizationMethod = cm;
this.signatureMethod = sm;
this.references = Collections.unmodifiableList(
new ArrayList<Reference>(references));
if (this.references.isEmpty()) {
throw new IllegalArgumentException("list of references must " +
"contain at least one entry");
}
for (int i = 0, size = this.references.size(); i < size; i++) {
Object obj = this.references.get(i);
if (!(obj instanceof Reference)) {
throw new ClassCastException("list of references contains " +
"an illegal type");
}
List<Reference> tempList =
Collections.checkedList(new ArrayList<Reference>(),
Reference.class);
tempList.addAll(references);
if (tempList.isEmpty()) {
throw new IllegalArgumentException("references cannot be empty");
}
this.references = Collections.unmodifiableList(tempList);
}
/**

View File

@ -44,7 +44,7 @@ import org.w3c.dom.Node;
* directly on the subdocument and there is no need to convert it
* first to an XPath node-set.
*/
public class DOMSubTreeData implements NodeSetData {
public class DOMSubTreeData implements NodeSetData<Node> {
private boolean excludeComments;
private Node root;

View File

@ -367,9 +367,7 @@ public class DOMUtils {
private static boolean paramsEqual(XPathFilter2ParameterSpec spec1,
XPathFilter2ParameterSpec spec2)
{
@SuppressWarnings("unchecked")
List<XPathType> types = spec1.getXPathList();
@SuppressWarnings("unchecked")
List<XPathType> otypes = spec2.getXPathList();
int size = types.size();
if (size != otypes.size()) {

View File

@ -135,7 +135,7 @@ public final class DOMX509Data extends DOMStructure implements X509Data {
this.content = Collections.unmodifiableList(content);
}
public List<Object> getContent() {
public List<?> getContent() {
return content;
}
@ -265,7 +265,7 @@ public final class DOMX509Data extends DOMStructure implements X509Data {
}
X509Data oxd = (X509Data)o;
@SuppressWarnings("unchecked") List<Object> ocontent = oxd.getContent();
List<?> ocontent = oxd.getContent();
int size = content.size();
if (size != ocontent.size()) {
return false;

View File

@ -70,18 +70,13 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject {
public DOMXMLObject(List<? extends XMLStructure> content, String id,
String mimeType, String encoding)
{
if (content == null || content.isEmpty()) {
this.content = Collections.emptyList();
} else {
this.content = Collections.unmodifiableList(
new ArrayList<XMLStructure>(content));
for (int i = 0, size = this.content.size(); i < size; i++) {
if (!(this.content.get(i) instanceof XMLStructure)) {
throw new ClassCastException
("content["+i+"] is not a valid type");
}
}
List<XMLStructure> tempList =
Collections.checkedList(new ArrayList<XMLStructure>(),
XMLStructure.class);
if (content != null) {
tempList.addAll(content);
}
this.content = Collections.unmodifiableList(tempList);
this.id = id;
this.mimeType = mimeType;
this.encoding = encoding;
@ -204,7 +199,6 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject {
(mimeType == null ? oxo.getMimeType() == null
: mimeType.equals(oxo.getMimeType()));
@SuppressWarnings("unchecked")
List<XMLStructure> oxoContent = oxo.getContent();
return (idsEqual && encodingsEqual && mimeTypesEqual &&
equalsContent(oxoContent));

View File

@ -109,18 +109,13 @@ public final class DOMXMLSignature extends DOMStructure
this.si = si;
this.id = id;
this.sv = new DOMSignatureValue(signatureValueId);
if (objs == null) {
this.objects = Collections.emptyList();
} else {
this.objects =
Collections.unmodifiableList(new ArrayList<XMLObject>(objs));
for (int i = 0, size = this.objects.size(); i < size; i++) {
if (!(this.objects.get(i) instanceof XMLObject)) {
throw new ClassCastException
("objs["+i+"] is not an XMLObject");
}
}
List<XMLObject> tempList =
Collections.checkedList(new ArrayList<XMLObject>(),
XMLObject.class);
if (objs != null) {
tempList.addAll(objs);
}
this.objects = Collections.unmodifiableList(tempList);
this.ki = ki;
}
@ -270,7 +265,6 @@ public final class DOMXMLSignature extends DOMStructure
}
// validate all References
@SuppressWarnings("unchecked")
List<Reference> refs = this.si.getReferences();
boolean validateRefs = true;
for (int i = 0, size = refs.size(); validateRefs && i < size; i++) {
@ -297,7 +291,6 @@ public final class DOMXMLSignature extends DOMStructure
{
for (int i=0, size=objects.size(); validateMans && i < size; i++) {
XMLObject xo = objects.get(i);
@SuppressWarnings("unchecked")
List<XMLStructure> content = xo.getContent();
int csize = content.size();
for (int j = 0; validateMans && j < csize; j++) {
@ -307,7 +300,6 @@ public final class DOMXMLSignature extends DOMStructure
log.log(java.util.logging.Level.FINE, "validating manifest");
}
Manifest man = (Manifest)xs;
@SuppressWarnings("unchecked")
List<Reference> manRefs = man.getReferences();
int rsize = manRefs.size();
for (int k = 0; validateMans && k < rsize; k++) {
@ -348,20 +340,17 @@ public final class DOMXMLSignature extends DOMStructure
signatureIdMap = new HashMap<String, XMLStructure>();
signatureIdMap.put(id, this);
signatureIdMap.put(si.getId(), si);
@SuppressWarnings("unchecked")
List<Reference> refs = si.getReferences();
for (Reference ref : refs) {
signatureIdMap.put(ref.getId(), ref);
}
for (XMLObject obj : objects) {
signatureIdMap.put(obj.getId(), obj);
@SuppressWarnings("unchecked")
List<XMLStructure> content = obj.getContent();
for (XMLStructure xs : content) {
if (xs instanceof Manifest) {
Manifest man = (Manifest)xs;
signatureIdMap.put(man.getId(), man);
@SuppressWarnings("unchecked")
List<Reference> manRefs = man.getReferences();
for (Reference ref : manRefs) {
allReferences.add(ref);
@ -483,7 +472,6 @@ public final class DOMXMLSignature extends DOMStructure
// reference dependencies in the XPath Transform - so be on
// the safe side, and skip and do at end in the final sweep
if (uri.length() == 0) {
@SuppressWarnings("unchecked")
List<Transform> transforms = ref.getTransforms();
for (Transform transform : transforms) {
String transformAlg = transform.getAlgorithm();

View File

@ -58,9 +58,8 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
return new DOMXMLSignature(si, ki, null, null, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
List objects, String id, String signatureValueId) {
List<? extends XMLObject> objects, String id, String signatureValueId) {
return new DOMXMLSignature(si, ki, objects, id, signatureValueId);
}
@ -68,16 +67,14 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
return newReference(uri, dm, null, null, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public Reference newReference(String uri, DigestMethod dm, List transforms,
String type, String id) {
public Reference newReference(String uri, DigestMethod dm,
List<? extends Transform> transforms, String type, String id) {
return new DOMReference(uri, type, dm, transforms, id, getProvider());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public Reference newReference(String uri, DigestMethod dm,
List appliedTransforms, Data result, List transforms, String type,
String id) {
List<? extends Transform> appliedTransforms, Data result,
List<? extends Transform> transforms, String type, String id) {
if (appliedTransforms == null) {
throw new NullPointerException("appliedTransforms cannot be null");
}
@ -91,9 +88,9 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
(uri, type, dm, appliedTransforms, result, transforms, id, getProvider());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public Reference newReference(String uri, DigestMethod dm, List transforms,
String type, String id, byte[] digestValue) {
public Reference newReference(String uri, DigestMethod dm,
List<? extends Transform> transforms, String type, String id,
byte[] digestValue) {
if (digestValue == null) {
throw new NullPointerException("digestValue cannot be null");
}
@ -101,43 +98,38 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
(uri, type, dm, null, null, transforms, id, digestValue, getProvider());
}
@SuppressWarnings("rawtypes")
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references) {
SignatureMethod sm, List<? extends Reference> references) {
return newSignedInfo(cm, sm, references, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignedInfo newSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm, List references, String id) {
SignatureMethod sm, List<? extends Reference> references, String id) {
return new DOMSignedInfo(cm, sm, references, id);
}
// Object factory methods
@SuppressWarnings({ "unchecked", "rawtypes" })
public XMLObject newXMLObject(List content, String id, String mimeType,
String encoding) {
public XMLObject newXMLObject(List<? extends XMLStructure> content,
String id, String mimeType, String encoding) {
return new DOMXMLObject(content, id, mimeType, encoding);
}
@SuppressWarnings("rawtypes")
public Manifest newManifest(List references) {
public Manifest newManifest(List<? extends Reference> references) {
return newManifest(references, null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public Manifest newManifest(List references, String id) {
public Manifest newManifest(List<? extends Reference> references,
String id) {
return new DOMManifest(references, id);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignatureProperties newSignatureProperties(List props, String id) {
public SignatureProperties newSignatureProperties(
List<? extends SignatureProperty> props, String id) {
return new DOMSignatureProperties(props, id);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public SignatureProperty newSignatureProperty
(List info, String target, String id) {
(List<? extends XMLStructure> info, String target, String id) {
return new DOMSignatureProperty(info, target, id);
}

View File

@ -133,7 +133,6 @@ public final class DOMXPathFilter2Transform extends ApacheTransform {
String prefix = DOMUtils.getNSPrefix(context, Transform.XPATH2);
String qname = (prefix == null || prefix.length() == 0)
? "xmlns" : "xmlns:" + prefix;
@SuppressWarnings("unchecked")
List<XPathType> xpathList = xp.getXPathList();
for (XPathType xpathType : xpathList) {
Element elem = DOMUtils.createElement(ownerDoc, "XPath",
@ -146,7 +145,6 @@ public final class DOMXPathFilter2Transform extends ApacheTransform {
Transform.XPATH2);
// add namespace attributes, if necessary
@SuppressWarnings("unchecked")
Set<Map.Entry<String, String>> entries =
xpathType.getNamespaceMap().entrySet();
for (Map.Entry<String, String> entry : entries) {

View File

@ -99,7 +99,6 @@ public final class DOMXPathTransform extends ApacheTransform {
xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));
// add namespace attributes, if necessary
@SuppressWarnings("unchecked")
Set<Map.Entry<String, String>> entries =
xp.getNamespaceMap().entrySet();
for (Map.Entry<String, String> entry : entries) {

View File

@ -70,10 +70,10 @@ public final class Utils {
* @param i the Iterator
* @return the Set of Nodes
*/
static Set<Node> toNodeSet(Iterator<Node> i) {
static Set<Node> toNodeSet(Iterator<?> i) {
Set<Node> nodeSet = new HashSet<Node>();
while (i.hasNext()) {
Node n = i.next();
Node n = (Node)i.next();
nodeSet.add(n);
// insert attributes nodes to comply with XPath
if (n.getNodeType() == Node.ELEMENT_NODE) {

View File

@ -23,7 +23,7 @@
/**
* @test
* @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349
* @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949
* @summary Basic unit tests for generating XML Signatures with JSR 105
* @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
* X509KeySelector.java GenerationTests.java
@ -377,7 +377,7 @@ public class GenerationTests {
static void test_create_signature_x509_crt_crl() throws Exception {
System.out.println("* Generating signature-x509-crt-crl.xml");
List<Object> xds = new ArrayList<Object>();
List<Object> xds = new ArrayList<>();
CertificateFactory cf = CertificateFactory.getInstance("X.509");
xds.add(signingCert);
FileInputStream fis = new FileInputStream(CRL);
@ -444,7 +444,7 @@ public class GenerationTests {
SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha1, refs);
// create objects
List<XMLStructure> objs = new ArrayList<XMLStructure>();
List<XMLObject> objs = new ArrayList<>();
// Object 1
List<Reference> manRefs = Collections.singletonList
@ -559,7 +559,7 @@ public class GenerationTests {
System.out.println("* Generating signature.xml");
// create references
List<Reference> refs = new ArrayList<Reference>();
List<Reference> refs = new ArrayList<>();
// Reference 1
refs.add(fac.newReference(STYLESHEET, sha1));
@ -610,7 +610,7 @@ public class GenerationTests {
SignatureProperties.TYPE, null));
// Reference 8
List<Transform> transforms = new ArrayList<Transform>();
List<Transform> transforms = new ArrayList<>();
transforms.add(fac.newTransform
(Transform.ENVELOPED, (TransformParameterSpec) null));
refs.add(fac.newReference("", sha1, transforms, null, null));
@ -685,7 +685,7 @@ public class GenerationTests {
Document doc = db.newDocument();
// create objects
List<XMLStructure> objs = new ArrayList<XMLStructure>();
List<XMLObject> objs = new ArrayList<>();
// Object 1
objs.add(fac.newXMLObject(Collections.singletonList
@ -705,7 +705,7 @@ public class GenerationTests {
(new DOMStructure(nc)), "object-3", null, null));
// Manifest
List<Reference> manRefs = new ArrayList<Reference>();
List<Reference> manRefs = new ArrayList<>();
// Manifest Reference 1
manRefs.add(fac.newReference(STYLESHEET,
@ -715,7 +715,7 @@ public class GenerationTests {
manRefs.add(fac.newReference("#reference-1", sha1));
// Manifest Reference 3
List<Transform> manTrans = new ArrayList<Transform>();
List<Transform> manTrans = new ArrayList<>();
String xslt = ""
+ "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'\n"
+ " xmlns='http://www.w3.org/TR/xhtml1/strict' \n"
@ -770,7 +770,7 @@ public class GenerationTests {
null, null));
// Object 4
List<Object> xds = new ArrayList<Object>();
List<Object> xds = new ArrayList<>();
xds.add("CN=User");
xds.add(kifac.newX509IssuerSerial
("CN=User", new BigInteger("45ef2729", 16)));
@ -930,7 +930,7 @@ public class GenerationTests {
static void test_create_exc_signature() throws Exception {
System.out.println("* Generating exc_signature.xml");
List<Reference> refs = new ArrayList<Reference>(4);
List<Reference> refs = new ArrayList<>(4);
// create reference 1
refs.add(fac.newReference
@ -942,7 +942,7 @@ public class GenerationTests {
null, null));
// create reference 2
List<String> prefixList = new ArrayList<String>(2);
List<String> prefixList = new ArrayList<>(2);
prefixList.add("bar");
prefixList.add("#default");
ExcC14NParameterSpec params = new ExcC14NParameterSpec(prefixList);
@ -963,7 +963,7 @@ public class GenerationTests {
null, null));
// create reference 4
prefixList = new ArrayList<String>(2);
prefixList = new ArrayList<>(2);
prefixList.add("bar");
prefixList.add("#default");
params = new ExcC14NParameterSpec(prefixList);
@ -982,7 +982,7 @@ public class GenerationTests {
fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null), refs);
// create KeyInfo
List<XMLStructure> kits = new ArrayList<XMLStructure>(2);
List<XMLStructure> kits = new ArrayList<>(2);
kits.add(kifac.newKeyValue(validatingKey));
KeyInfo ki = kifac.newKeyInfo(kits);
@ -1027,10 +1027,10 @@ public class GenerationTests {
static void test_create_sign_spec() throws Exception {
System.out.println("* Generating sign-spec.xml");
List<Reference> refs = new ArrayList<Reference>(2);
List<Reference> refs = new ArrayList<>(2);
// create reference 1
List<XPathType> types = new ArrayList<XPathType>(3);
List<XPathType> types = new ArrayList<>(3);
types.add(new XPathType(" //ToBeSigned ", XPathType.Filter.INTERSECT));
types.add(new XPathType(" //NotToBeSigned ",
XPathType.Filter.SUBTRACT));
@ -1043,7 +1043,7 @@ public class GenerationTests {
null, null));
// create reference 2
List<Transform> trans2 = new ArrayList<Transform>(2);
List<Transform> trans2 = new ArrayList<>(2);
trans2.add(fac.newTransform(Transform.ENVELOPED,
(TransformParameterSpec) null));
XPathFilter2ParameterSpec xp2 = new XPathFilter2ParameterSpec
@ -1061,9 +1061,9 @@ public class GenerationTests {
fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null), refs);
// create KeyInfo
List<XMLStructure> kits = new ArrayList<XMLStructure>(2);
List<XMLStructure> kits = new ArrayList<>(2);
kits.add(kifac.newKeyValue(validatingKey));
List<Object> xds = new ArrayList<Object>(2);
List<Object> xds = new ArrayList<>(2);
xds.add("CN=User");
xds.add(signingCert);
kits.add(kifac.newX509Data(xds));

View File

@ -101,9 +101,7 @@ class KeySelectors {
throw new KeySelectorException("Null KeyInfo object!");
}
// search for X509Data in keyinfo
Iterator iter = keyInfo.getContent().iterator();
while (iter.hasNext()) {
XMLStructure kiType = (XMLStructure) iter.next();
for (XMLStructure kiType : keyInfo.getContent()) {
if (kiType instanceof X509Data) {
X509Data xd = (X509Data) kiType;
Object[] entries = xd.getContent().toArray();
@ -114,10 +112,8 @@ class KeySelectors {
crl = (X509CRL) entries[i];
}
}
Iterator xi = xd.getContent().iterator();
boolean hasCRL = false;
while (xi.hasNext()) {
Object o = xi.next();
for (Object o : xd.getContent()) {
// skip non-X509Certificate entries
if (o instanceof X509Certificate) {
if ((purpose != KeySelector.Purpose.VERIFY) &&
@ -152,10 +148,8 @@ class KeySelectors {
throw new KeySelectorException("Null KeyInfo object!");
}
SignatureMethod sm = (SignatureMethod) method;
List list = keyInfo.getContent();
for (int i = 0; i < list.size(); i++) {
XMLStructure xmlStructure = (XMLStructure) list.get(i);
for (XMLStructure xmlStructure : keyInfo.getContent()) {
if (xmlStructure instanceof KeyValue) {
PublicKey pk = null;
try {
@ -282,9 +276,7 @@ class KeySelectors {
if (keyInfo == null) {
throw new KeySelectorException("Null KeyInfo object!");
}
Iterator iter = keyInfo.getContent().iterator();
while (iter.hasNext()) {
XMLStructure xmlStructure = (XMLStructure) iter.next();
for (XMLStructure xmlStructure : keyInfo.getContent()) {
try {
if (xmlStructure instanceof KeyName) {
String name = ((KeyName)xmlStructure).getName();
@ -330,14 +322,12 @@ class KeySelectors {
}
} else if (xmlStructure instanceof X509Data) {
List content = ((X509Data)xmlStructure).getContent();
int size = content.size();
Vector<X509Certificate> result = null;
// Lookup the public key using the information
// specified in X509Data element, i.e. searching
// over the collection of certificate files under
// "certs" subdirectory and return those match.
for (int k = 0; k<size; k++) {
Object obj = content.get(k);
for (Object obj : content) {
if (obj instanceof String) {
result = match(MATCH_SUBJECT, obj, certs);
} else if (obj instanceof byte[]) {

View File

@ -78,9 +78,10 @@ class SignatureValidator {
// Check reference cache
if (cache) {
Iterator i = signature.getSignedInfo().getReferences().iterator();
for (int j=0; i.hasNext(); j++) {
Reference ref = (Reference) i.next();
Iterator<Reference> i =
signature.getSignedInfo().getReferences().iterator();
for (int j = 0; i.hasNext(); j++) {
Reference ref = i.next();
if (!digestInputEqual(ref)) {
throw new Exception
("cached data for Reference[" + j + "] is not correct");
@ -88,10 +89,10 @@ class SignatureValidator {
// check that dereferenced data does not contain comment nodes
if (ref.getURI() == "") {
System.out.println("checking deref data");
NodeSetData data = (NodeSetData) ref.getDereferencedData();
Iterator ni = data.iterator();
while (ni.hasNext()) {
Node n = (Node) ni.next();
@SuppressWarnings("unchecked")
NodeSetData<Node> data =
(NodeSetData<Node>)ref.getDereferencedData();
for (Node n : data) {
if (n.getNodeType() == Node.COMMENT_NODE) {
throw new Exception("dereferenced data for " +
" Reference[" + j + " contains comment node");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -139,9 +139,7 @@ class X509KeySelector extends KeySelector {
}
// Iterate through KeyInfo types
Iterator i = keyInfo.getContent().iterator();
while (i.hasNext()) {
XMLStructure kiType = (XMLStructure) i.next();
for (XMLStructure kiType : keyInfo.getContent()) {
// check X509Data
if (kiType instanceof X509Data) {
X509Data xd = (X509Data) kiType;
@ -303,9 +301,7 @@ class X509KeySelector extends KeySelector {
}
Collection<X509Certificate> certs = new ArrayList<>();
Iterator xi = xd.getContent().iterator();
while (xi.hasNext()) {
Object o = xi.next();
for (Object o : xd.getContent()) {
// check X509IssuerSerial
if (o instanceof X509IssuerSerial) {
X509IssuerSerial xis = (X509IssuerSerial) o;