mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Github: select 'Host' part of url for list of trusted hosts
Before this commit we save 'https://mycompany.com/github' from settings and compare it with 'mycompany.com' from URI
This commit is contained in:
@@ -111,7 +111,13 @@ public class GithubSslSupport {
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
public boolean askIfShouldProceed(final String host) {
|
||||
public boolean askIfShouldProceed(final String url) {
|
||||
String host = GithubUrlUtil.getHostFromUrl(url);
|
||||
if (host == null) {
|
||||
GithubUtil.LOG.warn("Bad SSL host: " + url);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String BACK_TO_SAFETY = "No, I don't trust";
|
||||
final String TRUST = "Proceed anyway";
|
||||
//int choice = Messages.showDialog("The security certificate of " + host + " is not trusted. Do you want to proceed anyway?",
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.jetbrains.plugins.github.util;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.apache.commons.httpclient.URI;
|
||||
import org.apache.commons.httpclient.URIException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.github.api.GithubApiUtil;
|
||||
@@ -71,6 +73,19 @@ public class GithubUrlUtil {
|
||||
return "https://" + getGitHostWithoutProtocol();
|
||||
}
|
||||
|
||||
/**
|
||||
* E.g.: https://github.com/suffix/ -> github.com
|
||||
*/
|
||||
@Nullable
|
||||
public static String getHostFromUrl(@NotNull String url) {
|
||||
try {
|
||||
return new URI(url, false).getHost();
|
||||
}
|
||||
catch (URIException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* E.g.: github.com
|
||||
* my.company.url
|
||||
|
||||
Reference in New Issue
Block a user