summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/HttpUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-12-03 17:03:31 -0500
committerJames Moger <james.moger@gitblit.com>2012-12-03 17:03:31 -0500
commitd3c18925529690716ce1b9038169d7a07e53b287 (patch)
tree3093efba039b384841bfb1d32e0ec78d6b9ae82c /src/com/gitblit/utils/HttpUtils.java
parent37fa664c58df034607edf2485a1414b3417b2755 (diff)
downloadgitblit-d3c18925529690716ce1b9038169d7a07e53b287.tar.gz
gitblit-d3c18925529690716ce1b9038169d7a07e53b287.zip
Set subjectAlternativeName on SSL cert if CN=IPAddress (issue-170)
Diffstat (limited to 'src/com/gitblit/utils/HttpUtils.java')
-rw-r--r--src/com/gitblit/utils/HttpUtils.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/gitblit/utils/HttpUtils.java b/src/com/gitblit/utils/HttpUtils.java
index b40088c8..56c8bd20 100644
--- a/src/com/gitblit/utils/HttpUtils.java
+++ b/src/com/gitblit/utils/HttpUtils.java
@@ -178,4 +178,26 @@ public class HttpUtils {
}
return null;
}
+
+ public static boolean isIpAddress(String address) {
+ if (StringUtils.isEmpty(address)) {
+ return false;
+ }
+ String [] fields = address.split("\\.");
+ if (fields.length == 4) {
+ // IPV4
+ for (String field : fields) {
+ try {
+ int value = Integer.parseInt(field);
+ if (value < 0 || value > 255) {
+ return false;
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ }
+ }
+ // TODO IPV6?
+ return false;
+ }
}