summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/utils
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-06-28 17:28:50 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-06-28 17:28:50 +0200
commit6eebf3f29b9658a4e74ab1d1f90146c8e029c736 (patch)
tree06acac1ffecee6ff0cdeaed77397312b0db0e8eb /src/main/java/org/uic/barcode/utils
parent- initial implementation of FCB version 3.0.0 - !!Tests still missing!! (diff)
downloadUIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar.gz
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar.bz2
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar.lz
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar.xz
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.tar.zst
UIC-barcode-6eebf3f29b9658a4e74ab1d1f90146c8e029c736.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/utils')
-rw-r--r--src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
index e3918b0..1671ba9 100644
--- a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
+++ b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
@@ -39,24 +39,40 @@ public class AlgorithmNameResolver {
Provider[] provs = Security.getProviders();
for (Provider prov : provs) {
+
+ String name = getName(type, oid, prov);
+ if (name != null) return name;
- SortedSet<String> typeAndOID = getTypeAndOIDStrings(prov);
-
- for (String entry : typeAndOID) {
- String[] typeAndOIDArray = entry.split("-");
- String ptype = typeAndOIDArray[0];
- if (ptype.equalsIgnoreCase(type)) {
- String poid = typeAndOIDArray[1];
- Service pservice = prov.getService(ptype, poid);
- String palgo = pservice.getAlgorithm();
-
- if (poid != null && ptype.equalsIgnoreCase(type) && poid.equals(oid)) {
- return palgo;
- }
- }
- }
}
+ if (oid.startsWith("1.2.840.10045")) {
+ return "ECDSA";
+ } else if (oid.startsWith("1.2.840.10040")) {
+ return "DSA";
+ }
+
+ return null;
+
+ }
+
+ public static String getName(String type, String oid, Provider prov) throws Exception {
+
+ SortedSet<String> typeAndOID = getTypeAndOIDStrings(prov);
+
+ for (String entry : typeAndOID) {
+ String[] typeAndOIDArray = entry.split("-");
+ String ptype = typeAndOIDArray[0];
+ if (ptype.equalsIgnoreCase(type)) {
+ String poid = typeAndOIDArray[1];
+ Service pservice = prov.getService(ptype, poid);
+ String palgo = pservice.getAlgorithm();
+
+ if (poid != null && ptype.equalsIgnoreCase(type) && poid.equals(oid)) {
+ return palgo;
+ }
+ }
+ }
+
if (oid.startsWith("1.2.840.10045")) {
return "ECDSA";
@@ -104,6 +120,8 @@ public class AlgorithmNameResolver {
return null;
}
+
+
private static SortedSet<String> getTypeAndOIDStrings(Provider prov) {