Webfinger · GJWT/javaOIDCMsg@ec1a552 · GitHub
Skip to content

Commit ec1a552

Browse files
committed
Webfinger
1 parent b58d4ba commit ec1a552

4 files changed

Lines changed: 173 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package oicclient.tuples;
2+
3+
public class Tuple {
4+
5+
private Object a;
6+
private Object b;
7+
8+
public Tuple(Object a, Object b) {
9+
this.a = a;
10+
this.b = b;
11+
}
12+
13+
public Object getA() {
14+
return a;
15+
}
16+
17+
public Object getB() {
18+
return b;
19+
}
20+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package oicclient.webfinger;
2+
3+
public class URINormalizer {
4+
5+
private static boolean hasScheme(String path) {
6+
if (path.contains("://")) {
7+
return true;
8+
} else {
9+
String authority = path.replace("/", "#")
10+
.replace("?", "#").split("#")[0];
11+
12+
String hostOrPort;
13+
if (authority.contains(":")) {
14+
hostOrPort = authority.split(":", 1)[1];
15+
if (hostOrPort.matches("^\\d+$")) {
16+
return false;
17+
}
18+
} else {
19+
return false;
20+
}
21+
}
22+
23+
return true;
24+
}
25+
26+
private static boolean isAccountSchemeAssumed(String path) {
27+
String[] arr;
28+
if (path.contains("@")) {
29+
arr = path.split("@");
30+
String host = arr[arr.length - 1];
31+
return !(host.contains(":") || host.contains("/") || host.contains("?"));
32+
} else {
33+
return false;
34+
}
35+
}
36+
37+
String normalize(String path) {
38+
if (!hasScheme(path)) {
39+
if (isAccountSchemeAssumed(path)) {
40+
path = "acct:" + path;
41+
} else {
42+
path = "https://" + path;
43+
}
44+
}
45+
46+
return path.split("#")[0];
47+
}
48+
}
Lines changed: 97 additions & 0 deletions

0 commit comments

Comments
 (0)