Skip to content

Commit 4b28446

Browse files
authored
Using correct class to access static members (#188)
- Members were accessed using classes extending the real member owner - Eclipse cleanup Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
1 parent 792a2c6 commit 4b28446

8 files changed

Lines changed: 37 additions & 36 deletions

File tree

src/main/java/org/apache/xml/security/stax/config/XIncludeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void startElement(String uri, String localName, String qName, Attributes
156156
DOMResult domResult = new DOMResult();
157157
try {
158158
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
159-
SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
159+
SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
160160
saxTransformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
161161
try {
162162
saxTransformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");

src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import javax.crypto.KeyGenerator;
3030
import javax.xml.stream.XMLStreamWriter;
3131

32+
import org.apache.xml.security.algorithms.JCEMapper;
3233
import org.apache.xml.security.exceptions.XMLSecurityException;
33-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
3434
import org.apache.xml.security.stax.impl.DocumentContextImpl;
3535
import org.apache.xml.security.stax.impl.OutboundSecurityContextImpl;
3636
import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
@@ -245,7 +245,7 @@ private void configureEncryptionKeys(final OutboundSecurityContextImpl outboundS
245245
}
246246
// If none is configured then generate one
247247
String keyAlgorithm =
248-
JCEAlgorithmMapper.getJCEKeyAlgorithmFromURI(securityProperties.getEncryptionSymAlgorithm());
248+
JCEMapper.getJCEKeyAlgorithmFromURI(securityProperties.getEncryptionSymAlgorithm());
249249
KeyGenerator keyGen;
250250
try {
251251
keyGen = KeyGenerator.getInstance(keyAlgorithm);
@@ -256,7 +256,7 @@ private void configureEncryptionKeys(final OutboundSecurityContextImpl outboundS
256256
//whereas bouncy castle expects the block size of 128 or 192 bits
257257
if (keyAlgorithm.contains("AES")) {
258258
int keyLength =
259-
JCEAlgorithmMapper.getKeyLengthFromURI(securityProperties.getEncryptionSymAlgorithm());
259+
JCEMapper.getKeyLengthFromURI(securityProperties.getEncryptionSymAlgorithm());
260260
keyGen.init(keyLength);
261261
}
262262

src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import javax.crypto.spec.SecretKeySpec;
4242
import javax.xml.XMLConstants;
4343
import javax.xml.namespace.QName;
44+
import javax.xml.stream.XMLStreamConstants;
4445
import javax.xml.stream.XMLStreamException;
4546
import javax.xml.transform.Source;
4647
import javax.xml.transform.stream.StreamSource;
@@ -104,25 +105,25 @@ public static String getXMLEventAsString(XMLSecEvent xmlSecEvent) {
104105
int eventType = xmlSecEvent.getEventType();
105106

106107
switch (eventType) {
107-
case XMLSecEvent.START_ELEMENT:
108+
case XMLStreamConstants.START_ELEMENT:
108109
return "START_ELEMENT";
109-
case XMLSecEvent.END_ELEMENT:
110+
case XMLStreamConstants.END_ELEMENT:
110111
return "END_ELEMENT";
111-
case XMLSecEvent.PROCESSING_INSTRUCTION:
112+
case XMLStreamConstants.PROCESSING_INSTRUCTION:
112113
return "PROCESSING_INSTRUCTION";
113-
case XMLSecEvent.CHARACTERS:
114+
case XMLStreamConstants.CHARACTERS:
114115
return "CHARACTERS";
115-
case XMLSecEvent.COMMENT:
116+
case XMLStreamConstants.COMMENT:
116117
return "COMMENT";
117-
case XMLSecEvent.START_DOCUMENT:
118+
case XMLStreamConstants.START_DOCUMENT:
118119
return "START_DOCUMENT";
119-
case XMLSecEvent.END_DOCUMENT:
120+
case XMLStreamConstants.END_DOCUMENT:
120121
return "END_DOCUMENT";
121-
case XMLSecEvent.ATTRIBUTE:
122+
case XMLStreamConstants.ATTRIBUTE:
122123
return "ATTRIBUTE";
123-
case XMLSecEvent.DTD:
124+
case XMLStreamConstants.DTD:
124125
return "DTD";
125-
case XMLSecEvent.NAMESPACE:
126+
case XMLStreamConstants.NAMESPACE:
126127
return "NAMESPACE";
127128
default:
128129
throw new IllegalArgumentException("Illegal XMLSecEvent received: " + eventType);

src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.security.NoSuchAlgorithmException;
2222
import java.security.NoSuchProviderException;
2323

24+
import org.apache.xml.security.algorithms.JCEMapper;
2425
import org.apache.xml.security.exceptions.XMLSecurityException;
25-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
2626

2727
/**
2828
*/
@@ -41,13 +41,13 @@ public static synchronized SignatureAlgorithmFactory getInstance() {
4141
}
4242

4343
public SignatureAlgorithm getSignatureAlgorithm(String algoURI) throws XMLSecurityException, NoSuchProviderException, NoSuchAlgorithmException {
44-
String algorithmClass = JCEAlgorithmMapper.getAlgorithmClassFromURI(algoURI);
44+
String algorithmClass = JCEMapper.getAlgorithmClassFromURI(algoURI);
4545
if (algorithmClass == null) {
4646
throw new XMLSecurityException("algorithms.NoSuchMap",
4747
new Object[] {algoURI});
4848
}
49-
String jceName = JCEAlgorithmMapper.translateURItoJCEID(algoURI);
50-
String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(algoURI);
49+
String jceName = JCEMapper.translateURItoJCEID(algoURI);
50+
String jceProvider = JCEMapper.getJCEProviderFromURI(algoURI);
5151
if ("MAC".equalsIgnoreCase(algorithmClass)) {
5252
return new HMACSignatureAlgorithm(jceName, jceProvider);
5353
} else if ("Signature".equalsIgnoreCase(algorithmClass)) {

src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import javax.xml.stream.events.Attribute;
5656

5757
import org.apache.commons.codec.binary.Base64OutputStream;
58+
import org.apache.xml.security.algorithms.JCEMapper;
5859
import org.apache.xml.security.binding.xmldsig.KeyInfoType;
5960
import org.apache.xml.security.binding.xmlenc.EncryptedDataType;
6061
import org.apache.xml.security.binding.xmlenc.EncryptedKeyType;
@@ -63,7 +64,6 @@
6364
import org.apache.xml.security.binding.xop.Include;
6465
import org.apache.xml.security.exceptions.XMLSecurityException;
6566
import org.apache.xml.security.stax.config.ConfigurationProperties;
66-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
6767
import org.apache.xml.security.stax.ext.AbstractInputProcessor;
6868
import org.apache.xml.security.stax.ext.InboundSecurityContext;
6969
import org.apache.xml.security.stax.ext.InputProcessorChain;
@@ -234,7 +234,7 @@ private XMLSecEvent processEvent(InputProcessorChain inputProcessorChain, boolea
234234
handleSecurityToken(inboundSecurityToken, inputProcessorChain.getSecurityContext(), encryptedDataType);
235235

236236
final String algorithmURI = encryptedDataType.getEncryptionMethod().getAlgorithm();
237-
final int ivLength = JCEAlgorithmMapper.getIVLengthFromURI(algorithmURI) / 8;
237+
final int ivLength = JCEMapper.getIVLengthFromURI(algorithmURI) / 8;
238238
Cipher symCipher = getCipher(algorithmURI);
239239

240240
if (encryptedDataType.getCipherData().getCipherReference() != null) {
@@ -437,8 +437,8 @@ private void forwardToWrapperElement(XMLStreamReader xmlStreamReader) throws XML
437437
private Cipher getCipher(String algorithmURI) throws XMLSecurityException {
438438
Cipher symCipher;
439439
try {
440-
String jceName = JCEAlgorithmMapper.translateURItoJCEID(algorithmURI);
441-
String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(algorithmURI);
440+
String jceName = JCEMapper.translateURItoJCEID(algorithmURI);
441+
String jceProvider = JCEMapper.getJCEProviderFromURI(algorithmURI);
442442
if (jceName == null) {
443443
throw new XMLSecurityException("algorithms.NoSuchMap",
444444
new Object[] {algorithmURI});

src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
import javax.xml.stream.XMLStreamConstants;
3838
import javax.xml.stream.XMLStreamException;
3939

40+
import org.apache.xml.security.algorithms.JCEMapper;
4041
import org.apache.xml.security.binding.excc14n.InclusiveNamespaces;
4142
import org.apache.xml.security.binding.xmldsig.ReferenceType;
4243
import org.apache.xml.security.binding.xmldsig.SignatureType;
4344
import org.apache.xml.security.binding.xmldsig.TransformType;
4445
import org.apache.xml.security.exceptions.XMLSecurityException;
4546
import org.apache.xml.security.stax.config.ConfigurationProperties;
46-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
4747
import org.apache.xml.security.stax.config.ResourceResolverMapper;
4848
import org.apache.xml.security.stax.ext.AbstractInputProcessor;
4949
import org.apache.xml.security.stax.ext.InboundSecurityContext;
@@ -294,8 +294,8 @@ protected DigestOutputStream createMessageDigestOutputStream(ReferenceType refer
294294
throws XMLSecurityException {
295295

296296
String digestMethodAlgorithm = referenceType.getDigestMethod().getAlgorithm();
297-
String jceName = JCEAlgorithmMapper.translateURItoJCEID(digestMethodAlgorithm);
298-
String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(digestMethodAlgorithm);
297+
String jceName = JCEMapper.translateURItoJCEID(digestMethodAlgorithm);
298+
String jceProvider = JCEMapper.getJCEProviderFromURI(digestMethodAlgorithm);
299299
if (jceName == null) {
300300
throw new XMLSecurityException("algorithms.NoSuchMap",
301301
new Object[] {digestMethodAlgorithm});

src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
import javax.crypto.spec.PSource;
3737
import javax.crypto.spec.SecretKeySpec;
3838

39+
import org.apache.xml.security.algorithms.JCEMapper;
3940
import org.apache.xml.security.binding.xmldsig.DigestMethodType;
4041
import org.apache.xml.security.binding.xmldsig.KeyInfoType;
4142
import org.apache.xml.security.binding.xmlenc.CipherValueType;
4243
import org.apache.xml.security.binding.xmlenc.EncryptedKeyType;
4344
import org.apache.xml.security.binding.xmlenc11.MGFType;
4445
import org.apache.xml.security.binding.xop.Include;
4546
import org.apache.xml.security.exceptions.XMLSecurityException;
46-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
4747
import org.apache.xml.security.stax.ext.AbstractInputSecurityHeaderHandler;
4848
import org.apache.xml.security.stax.ext.InboundSecurityContext;
4949
import org.apache.xml.security.stax.ext.InputProcessorChain;
@@ -124,7 +124,7 @@ public Key getKey(String algorithmURI, XMLSecurityConstants.AlgorithmUsage algor
124124
return key;
125125
}
126126

127-
String algoFamily = JCEAlgorithmMapper.getJCEKeyAlgorithmFromURI(algorithmURI);
127+
String algoFamily = JCEMapper.getJCEKeyAlgorithmFromURI(algorithmURI);
128128
key = new SecretKeySpec(getSecret(this, correlationID, algorithmURI), algoFamily);
129129
setSecretKey(algorithmURI, key);
130130
return key;
@@ -170,8 +170,8 @@ private byte[] getSecret(InboundSecurityToken wrappedSecurityToken, String corre
170170
if (algorithmURI == null) {
171171
throw new XMLSecurityException("stax.encryption.noEncAlgo");
172172
}
173-
String jceName = JCEAlgorithmMapper.translateURItoJCEID(algorithmURI);
174-
String jceProvider = JCEAlgorithmMapper.getJCEProviderFromURI(algorithmURI);
173+
String jceName = JCEMapper.translateURItoJCEID(algorithmURI);
174+
String jceProvider = JCEMapper.getJCEProviderFromURI(algorithmURI);
175175
if (jceName == null) {
176176
throw new XMLSecurityException("algorithms.NoSuchMap",
177177
new Object[] {algorithmURI});
@@ -206,7 +206,7 @@ private byte[] getSecret(InboundSecurityToken wrappedSecurityToken, String corre
206206
algorithmSuiteSecurityEvent.setCorrelationID(correlationID);
207207
inboundSecurityContext.registerSecurityEvent(algorithmSuiteSecurityEvent);
208208

209-
jceDigestAlgorithm = JCEAlgorithmMapper.translateURItoJCEID(digestMethodType.getAlgorithm());
209+
jceDigestAlgorithm = JCEMapper.translateURItoJCEID(digestMethodType.getAlgorithm());
210210
}
211211

212212
PSource.PSpecified pSource = PSource.PSpecified.DEFAULT;
@@ -220,7 +220,7 @@ private byte[] getSecret(InboundSecurityToken wrappedSecurityToken, String corre
220220
final MGFType mgfType =
221221
XMLSecurityUtils.getQNameType(encryptedKeyType.getEncryptionMethod().getContent(), XMLSecurityConstants.TAG_xenc11_MGF);
222222
if (mgfType != null) {
223-
String jceMGFAlgorithm = JCEAlgorithmMapper.translateURItoJCEID(mgfType.getAlgorithm());
223+
String jceMGFAlgorithm = JCEMapper.translateURItoJCEID(mgfType.getAlgorithm());
224224
mgfParameterSpec = new MGF1ParameterSpec(jceMGFAlgorithm);
225225
}
226226
OAEPParameterSpec oaepParameterSpec = new OAEPParameterSpec(jceDigestAlgorithm, "MGF1", mgfParameterSpec, pSource);
@@ -255,7 +255,7 @@ private byte[] getSecret(InboundSecurityToken wrappedSecurityToken, String corre
255255
LOG.warn("Unwrapping of the encrypted key failed with error: " + e.getMessage() + ". " +
256256
"Generating a faked one to mitigate timing attacks.");
257257

258-
int keyLength = JCEAlgorithmMapper.getKeyLengthFromURI(symmetricAlgorithmURI);
258+
int keyLength = JCEMapper.getKeyLengthFromURI(symmetricAlgorithmURI);
259259
this.decryptedKey = XMLSecurityConstants.generateBytes(keyLength / 8);
260260
return this.decryptedKey;
261261
}

src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import javax.xml.stream.XMLStreamConstants;
3838
import javax.xml.stream.XMLStreamException;
3939

40+
import org.apache.xml.security.algorithms.JCEMapper;
4041
import org.apache.xml.security.exceptions.XMLSecurityException;
41-
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
4242
import org.apache.xml.security.stax.ext.OutputProcessorChain;
4343
import org.apache.xml.security.stax.ext.SecurePart;
4444
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
@@ -189,7 +189,7 @@ protected void createKeyInfoStructure(OutputProcessorChain outputProcessorChain)
189189
createStartElementAndOutputAsEvent(outputProcessorChain, XMLSecurityConstants.TAG_xenc_CipherValue, false, null);
190190

191191
//encrypt the symmetric session key with the public key from the receiver:
192-
String jceid = JCEAlgorithmMapper.translateURItoJCEID(encryptionKeyTransportAlgorithm);
192+
String jceid = JCEMapper.translateURItoJCEID(encryptionKeyTransportAlgorithm);
193193
if (jceid == null) {
194194
throw new XMLSecurityException("algorithms.NoSuchMap",
195195
new Object[] {encryptionKeyTransportAlgorithm});
@@ -204,7 +204,7 @@ protected void createKeyInfoStructure(OutputProcessorChain outputProcessorChain)
204204

205205
String jceDigestAlgorithm = "SHA-1";
206206
if (encryptionKeyTransportDigestAlgorithm != null) {
207-
jceDigestAlgorithm = JCEAlgorithmMapper.translateURItoJCEID(encryptionKeyTransportDigestAlgorithm);
207+
jceDigestAlgorithm = JCEMapper.translateURItoJCEID(encryptionKeyTransportDigestAlgorithm);
208208
}
209209

210210
PSource.PSpecified pSource = PSource.PSpecified.DEFAULT;
@@ -215,7 +215,7 @@ protected void createKeyInfoStructure(OutputProcessorChain outputProcessorChain)
215215

216216
MGF1ParameterSpec mgfParameterSpec = new MGF1ParameterSpec("SHA-1");
217217
if (encryptionKeyTransportMGFAlgorithm != null) {
218-
String jceMGFAlgorithm = JCEAlgorithmMapper.translateURItoJCEID(encryptionKeyTransportMGFAlgorithm);
218+
String jceMGFAlgorithm = JCEMapper.translateURItoJCEID(encryptionKeyTransportMGFAlgorithm);
219219
mgfParameterSpec = new MGF1ParameterSpec(jceMGFAlgorithm);
220220
}
221221
algorithmParameterSpec = new OAEPParameterSpec(jceDigestAlgorithm, "MGF1", mgfParameterSpec, pSource);

0 commit comments

Comments
 (0)