You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2016/10/10 11:30:36 UTC
svn commit: r1764060 - in
/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security:
./ c14n/helper/ encryption/ stax/config/ transforms/ utils/ utils/resolver/
Author: coheigea
Date: Mon Oct 10 11:30:35 2016
New Revision: 1764060
URL: http://svn.apache.org/viewvc?rev=1764060&view=rev
Log:
Some code tidy up
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipher.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java Mon Oct 10 11:30:35 2016
@@ -205,10 +205,10 @@ public class Init {
Element[] list =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod");
- for (int i = 0; i < list.length; i++) {
- String uri = list[i].getAttributeNS(null, "URI");
+ for (Element element : list) {
+ String uri = element.getAttributeNS(null, "URI");
String javaClass =
- list[i].getAttributeNS(null, "JAVACLASS");
+ element.getAttributeNS(null, "JAVACLASS");
try {
Canonicalizer.register(uri, javaClass);
if (log.isDebugEnabled()) {
@@ -225,10 +225,10 @@ public class Init {
Element[] tranElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm");
- for (int i = 0; i < tranElem.length; i++) {
- String uri = tranElem[i].getAttributeNS(null, "URI");
+ for (Element element : tranElem) {
+ String uri = element.getAttributeNS(null, "URI");
String javaClass =
- tranElem[i].getAttributeNS(null, "JAVACLASS");
+ element.getAttributeNS(null, "JAVACLASS");
try {
Transform.register(uri, javaClass);
if (log.isDebugEnabled()) {
@@ -249,8 +249,7 @@ public class Init {
if (algorithmsNode != null) {
Element[] algorithms =
XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm");
- for (int i = 0; i < algorithms.length; i++) {
- Element element = algorithms[i];
+ for (Element element : algorithms) {
String id = element.getAttributeNS(null, "URI");
JCEMapper.register(id, new JCEMapper.Algorithm(element));
}
@@ -261,10 +260,10 @@ public class Init {
Element[] sigElems =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm");
- for (int i = 0; i < sigElems.length; i++) {
- String uri = sigElems[i].getAttributeNS(null, "URI");
+ for (Element sigElem : sigElems) {
+ String uri = sigElem.getAttributeNS(null, "URI");
String javaClass =
- sigElems[i].getAttributeNS(null, "JAVACLASS");
+ sigElem.getAttributeNS(null, "JAVACLASS");
/** $todo$ handle registering */
@@ -283,14 +282,14 @@ public class Init {
}
if (tag.equals("ResourceResolvers")) {
- Element[]resolverElem =
+ Element[] resolverElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
- for (int i = 0; i < resolverElem.length; i++) {
+ for (Element element : resolverElem) {
String javaClass =
- resolverElem[i].getAttributeNS(null, "JAVACLASS");
+ element.getAttributeNS(null, "JAVACLASS");
String description =
- resolverElem[i].getAttributeNS(null, "DESCRIPTION");
+ element.getAttributeNS(null, "DESCRIPTION");
if (description != null && description.length() > 0) {
if (log.isDebugEnabled()) {
@@ -319,11 +318,11 @@ public class Init {
Element[] resolverElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
List<String> classNames = new ArrayList<String>(resolverElem.length);
- for (int i = 0; i < resolverElem.length; i++) {
+ for (Element element : resolverElem) {
String javaClass =
- resolverElem[i].getAttributeNS(null, "JAVACLASS");
+ element.getAttributeNS(null, "JAVACLASS");
String description =
- resolverElem[i].getAttributeNS(null, "DESCRIPTION");
+ element.getAttributeNS(null, "DESCRIPTION");
if (description != null && description.length() > 0) {
if (log.isDebugEnabled()) {
@@ -350,9 +349,9 @@ public class Init {
Element[] nl =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping");
- for (int i = 0; i < nl.length; i++) {
- String namespace = nl[i].getAttributeNS(null, "namespace");
- String prefix = nl[i].getAttributeNS(null, "prefix");
+ for (Element element : nl) {
+ String namespace = element.getAttributeNS(null, "namespace");
+ String prefix = element.getAttributeNS(null, "prefix");
if (log.isDebugEnabled()) {
log.debug("Now I try to bind " + prefix + " to " + namespace);
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java Mon Oct 10 11:30:35 2016
@@ -141,7 +141,8 @@ public final class C14nHelper {
if (ctxNode != null) {
NamedNodeMap attributes = ctxNode.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
C14nHelper.assertNotRelativeNS((Attr) attributes.item(i));
}
} else {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipher.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipher.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipher.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/encryption/XMLCipher.java Mon Oct 10 11:30:35 2016
@@ -2485,7 +2485,8 @@ public class XMLCipher {
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_ENCRYPTIONPROPERTY);
- for (int i = 0; i < encryptionPropertyList.getLength(); i++) {
+ int length = encryptionPropertyList.getLength();
+ for (int i = 0; i < length; i++) {
Node n = encryptionPropertyList.item(i);
if (null != n) {
result.addEncryptionProperty(newEncryptionProperty((Element) n));
@@ -2537,7 +2538,8 @@ public class XMLCipher {
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_DATAREFERENCE);
- for (int i = 0; i < list.getLength() ; i++) {
+ int drLength = list.getLength();
+ for (int i = 0; i < drLength; i++) {
String uri = ((Element) list.item(i)).getAttributeNS(null, "URI");
result.add(result.newDataReference(uri));
}
@@ -2547,7 +2549,8 @@ public class XMLCipher {
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_KEYREFERENCE);
- for (int i = 0; i < list.getLength() ; i++) {
+ int krLength = list.getLength();
+ for (int i = 0; i < krLength; i++) {
String uri = ((Element) list.item(i)).getAttributeNS(null, "URI");
result.add(result.newKeyReference(uri));
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java Mon Oct 10 11:30:35 2016
@@ -183,7 +183,8 @@ public class XIncludeHandler extends Def
transformer.transform(new DOMSource(document, document.getDocumentURI()), saxResult);
} else {
NodeList nodeList = evaluateXPointer(xpointer, document);
- for (int i = 0; i < nodeList.getLength(); i++) {
+ int length = nodeList.getLength();
+ for (int i = 0; i < length; i++) {
Node node = nodeList.item(i);
transformer.transform(new DOMSource(node, document.getDocumentURI()), saxResult);
}
@@ -299,7 +300,8 @@ public class XIncludeHandler extends Def
private int findBalancedEndIndex(String string, int startIndex, char opening, char ending) {
int endIndex = -1;
int openPar = 1;
- for (int i = startIndex; i < string.length(); i++) {
+ int length = string.length();
+ for (int i = startIndex; i < length; i++) {
char curChar = string.charAt(i);
if (curChar == opening) {
openPar++;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java Mon Oct 10 11:30:35 2016
@@ -364,7 +364,8 @@ public final class Transform extends Sig
// give it to the current document
if (contextNodes != null) {
- for (int i = 0; i < contextNodes.getLength(); i++) {
+ int length = contextNodes.getLength();
+ for (int i = 0; i < length; i++) {
appendSelf(contextNodes.item(i).cloneNode(true));
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XMLUtils.java Mon Oct 10 11:30:35 2016
@@ -170,7 +170,8 @@ public final class XMLUtils {
Element el = (Element)rootNode;
if (el.hasAttributes()) {
NamedNodeMap nl = el.getAttributes();
- for (int i = 0;i < nl.getLength(); i++) {
+ int length = nl.getLength();
+ for (int i = 0; i < length; i++) {
result.add(nl.item(i));
}
}
@@ -963,7 +964,8 @@ public final class XMLUtils {
NamedNodeMap attributes = se.getAttributes();
if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
Attr attr = (Attr)attributes.item(i);
if (attr.isId() && id.equals(attr.getValue())) {
if (foundElement == null) {
@@ -1026,7 +1028,8 @@ public final class XMLUtils {
NamedNodeMap attributes = se.getAttributes();
if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
Attr attr = (Attr)attributes.item(i);
if (attr.isId() && id.equals(attr.getValue()) && se != knownElement) {
log.debug("Multiple elements with the same 'Id' attribute value!");
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java?rev=1764060&r1=1764059&r2=1764060&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverSpi.java Mon Oct 10 11:30:35 2016
@@ -124,8 +124,8 @@ public abstract class ResourceResolverSp
String[] understood = this.engineGetPropertyKeys();
if (understood != null) {
- for (int i = 0; i < understood.length; i++) {
- if (understood[i].equals(propertyToTest)) {
+ for (String str : understood) {
+ if (str.equals(propertyToTest)) {
return true;
}
}