Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 7ba9e17

Browse files
committed
More refactor of utils.resolver / keys
git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk@1877678 13f79535-47bb-0310-9956-ffa450edef68
1 parent f62e311 commit 7ba9e17

5 files changed

Lines changed: 4 additions & 267 deletions

File tree

src/main/java/org/apache/xml/security/keys/content/DEREncodedKeyValue.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ public PublicKey getPublicKey() throws XMLSecurityException {
116116
if (publicKey != null) {
117117
return publicKey;
118118
}
119-
} catch (NoSuchAlgorithmException e) { //NOPMD
120-
// Do nothing, try the next type
121-
} catch (InvalidKeySpecException e) { //NOPMD
119+
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) { //NOPMD
122120
// Do nothing, try the next type
123121
}
124122
}
@@ -136,10 +134,7 @@ protected byte[] getEncodedDER(PublicKey publicKey) throws XMLSecurityException
136134
KeyFactory keyFactory = KeyFactory.getInstance(publicKey.getAlgorithm());
137135
X509EncodedKeySpec keySpec = keyFactory.getKeySpec(publicKey, X509EncodedKeySpec.class);
138136
return keySpec.getEncoded();
139-
} catch (NoSuchAlgorithmException e) {
140-
Object[] exArgs = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
141-
throw new XMLSecurityException(e, "DEREncodedKeyValue.UnsupportedPublicKey", exArgs);
142-
} catch (InvalidKeySpecException e) {
137+
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
143138
Object[] exArgs = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
144139
throw new XMLSecurityException(e, "DEREncodedKeyValue.UnsupportedPublicKey", exArgs);
145140
}

src/main/java/org/apache/xml/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java

Lines changed: 0 additions & 180 deletions
This file was deleted.

src/main/java/org/apache/xml/security/stax/impl/util/LimitingInputStream.java

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.io.InputStream;
2424
import java.net.InetSocketAddress;
25-
import java.net.MalformedURLException;
2625
import java.net.Proxy;
2726
import java.net.URISyntaxException;
2827
import java.net.URI;
@@ -157,14 +156,8 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
157156
return result;
158157
}
159158

160-
} catch (URISyntaxException ex) {
159+
} catch (URISyntaxException | IOException | IllegalArgumentException ex) {
161160
throw new ResourceResolverException(ex, context.uriToResolve, context.baseUri, "generic.EmptyMessage");
162-
} catch (MalformedURLException ex) {
163-
throw new ResourceResolverException(ex, context.uriToResolve, context.baseUri, "generic.EmptyMessage");
164-
} catch (IOException ex) {
165-
throw new ResourceResolverException(ex, context.uriToResolve, context.baseUri, "generic.EmptyMessage");
166-
} catch (IllegalArgumentException e) {
167-
throw new ResourceResolverException(e, context.uriToResolve, context.baseUri, "generic.EmptyMessage");
168161
}
169162
}
170163

src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
101101
* {@inheritDoc}
102102
*/
103103
public boolean engineCanResolveURI(ResourceResolverContext context) {
104-
if (context.uriToResolve == null) {
105-
return false;
106-
}
107104
return isXPointerSlash(context.uriToResolve) || isXPointerId(context.uriToResolve);
108105
}
109106

@@ -124,7 +121,7 @@ private static boolean isXPointerSlash(String uri) {
124121
* @return whether it has an xpointer id
125122
*/
126123
private static boolean isXPointerId(String uri) {
127-
if (uri.startsWith(XP) && uri.endsWith("))")) {
124+
if (uri != null && uri.startsWith(XP) && uri.endsWith("))")) {
128125
String idPlusDelim = uri.substring(XP_LENGTH, uri.length() - 2);
129126

130127
int idLen = idPlusDelim.length() -1;

0 commit comments

Comments
 (0)