Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
278,000
PasswordAuthentication (final String host, final String prompt) { if (AUTHENTICATION_CANCELLED) { return null; } final String password = getPlainProxyPassword(); if (PROXY_AUTHENTICATION) { final String login = getSecure("proxy.login"); if (!StringUtil.isEmptyOrSpaces(login) && !StringUtil.isEmptyOrSpaces(password)) { return new PasswordAuthentication(login, password.toCharArray()); } } // do not try to show any dialogs if application is exiting if (ApplicationManager.getApplication() == null || ApplicationManager.getApplication().isDisposed()) { return null; } if (ApplicationManager.getApplication().isUnitTestMode()) { return null; } final PasswordAuthentication[] value = new PasswordAuthentication[1]; runAboveAll(() -> { if (AUTHENTICATION_CANCELLED) { return; } // password might have changed, and the check below is for that final String password1 = getPlainProxyPassword(); if (PROXY_AUTHENTICATION) { final String login = getSecure("proxy.login"); if (!StringUtil.isEmptyOrSpaces(login) && !StringUtil.isEmptyOrSpaces(password1)) { value[0] = new PasswordAuthentication(login, password1.toCharArray()); return; } } AuthenticationDialog dialog = new AuthenticationDialog( PopupUtil.getActiveComponent(), IdeBundle.message("dialog.title.proxy.authentication", host), IdeBundle.message("dialog.message.please.enter.credentials.for", prompt), getSecure("proxy.login"), "", KEEP_PROXY_PASSWORD ); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { PROXY_AUTHENTICATION = true; AuthenticationPanel panel = dialog.getPanel(); final boolean keepPass = panel.isRememberPassword(); KEEP_PROXY_PASSWORD = keepPass; storeSecure("proxy.login", StringUtil.nullize(panel.getLogin())); if (keepPass) { setPlainProxyPassword(String.valueOf(panel.getPassword())); } else { removeSecure("proxy.password"); } value[0] = new PasswordAuthentication(panel.getLogin(), panel.getPassword()); } else { AUTHENTICATION_CANCELLED = true; } }); return value[0]; }
getPromptedAuthentication
278,001
void (final @NotNull Runnable runnable) { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null && progressIndicator.isModal()) { WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(runnable); } else { Application app = ApplicationManager.getApplication(); app.invokeAndWait(runnable, ModalityState.any()); } }
runAboveAll
278,002
boolean (@Nullable String url) { if (!USE_HTTP_PROXY) return false; URI uri = url != null ? VfsUtil.toUri(url) : null; return uri == null || !isProxyException(uri.getHost()); }
isHttpProxyEnabledForUrl
278,003
boolean (URI uri) { String uriHost = uri.getHost(); return isProxyException(uriHost); }
isProxyException
278,004
boolean (@Nullable String uriHost) { if (StringUtil.isEmptyOrSpaces(uriHost) || StringUtil.isEmptyOrSpaces(PROXY_EXCEPTIONS)) { return false; } List<String> hosts = StringUtil.split(PROXY_EXCEPTIONS, ","); for (String hostPattern : hosts) { String regexpPattern = StringUtil.escapeToRegexp(hostPattern.trim()).replace("\\*", ".*"); if (Pattern.compile(regexpPattern).matcher(uriHost).matches()) { return true; } } return false; }
isProxyException
278,005
boolean (@NotNull Proxy proxy) { return !Proxy.NO_PROXY.equals(proxy) && !Proxy.Type.DIRECT.equals(proxy.type()); }
isRealProxy
278,006
void () { synchronized (myLock) { myGenericPasswords.clear(); myGenericCancelled.clear(); } }
clearGenericPasswords
278,007
void (@NotNull CommonProxy.HostInfo info) { synchronized (myLock) { myGenericPasswords.remove(info); } }
removeGeneric
278,008
boolean () { return myStore; }
isStore
278,009
void (boolean store) { myStore = store; }
setStore
278,010
String () { return myUsername; }
getUsername
278,011
void (String username) { myUsername = username; }
setUsername
278,012
String () { return myPasswordCrypt; }
getPasswordCrypt
278,013
void (String passwordCrypt) { myPasswordCrypt = passwordCrypt; }
setPasswordCrypt
278,014
String (String key) { try { synchronized (myProxyCredentials) { final Properties props = myProxyCredentials.getValue(); return props.getProperty(key, null); } } catch (Exception e) { LOG.info(e); } return null; }
getSecure
278,015
void (String key, @Nullable String value) { if (value == null) { removeSecure(key); return; } try { synchronized (myProxyCredentials) { final Properties props = myProxyCredentials.getValue(); props.setProperty(key, value); myEncryptionSupport.store(props, "Proxy Credentials", PROXY_CREDENTIALS_FILE); } } catch (Exception e) { LOG.info(e); } }
storeSecure
278,016
void (String key) { try { synchronized (myProxyCredentials) { final Properties props = myProxyCredentials.getValue(); props.remove(key); myEncryptionSupport.store(props, "Proxy Credentials", PROXY_CREDENTIALS_FILE); } } catch (Exception e) { LOG.info(e); } }
removeSecure
278,017
HttpConfigurable () { return settings; }
getSettings
278,018
HttpProxySettingsUi () { return new HttpProxySettingsUi(settings); }
createUi
278,019
boolean (@NotNull HttpConfigurable settings) { return !Comparing.strEqual(myProxyExceptions.getText().trim(), settings.PROXY_EXCEPTIONS) || settings.USE_PROXY_PAC != myAutoDetectProxyRb.isSelected() || settings.USE_PAC_URL != myPacUrlCheckBox.isSelected() || !Comparing.strEqual(settings.PAC_URL, myPacUrlTextField.getText()) || settings.USE_HTTP_PROXY != myUseHTTPProxyRb.isSelected() || settings.PROXY_AUTHENTICATION != myProxyAuthCheckBox.isSelected() || settings.KEEP_PROXY_PASSWORD != myRememberProxyPasswordCheckBox.isSelected() || settings.PROXY_TYPE_IS_SOCKS != mySocks.isSelected() || !Comparing.strEqual(settings.getProxyLogin(), myProxyLoginTextField.getText()) || !Comparing.strEqual(settings.getPlainProxyPassword(), new String(myProxyPasswordTextField.getPassword())) || settings.PROXY_PORT != myProxyPortTextField.getNumber() || !Comparing.strEqual(settings.PROXY_HOST, myProxyHostTextField.getText()); }
isModified
278,020
void () { if (HttpConfigurable.getInstance() == null) { myCheckButton.setVisible(false); return; } myCheckButton.addActionListener(event -> { String error = isValid(); if (error != null) { Messages.showErrorDialog(myMainPanel, error); return; } final HttpConfigurable settings = HttpConfigurable.getInstance(); final String title = IdeBundle.message("dialog.title.check.proxy.settings"); final String url = Messages.showInputDialog(myMainPanel, IdeBundle.message("message.text.enter.url.to.check.connection"), title, Messages.getQuestionIcon(), settings.CHECK_CONNECTION_URL, null); if (StringUtil.isEmptyOrSpaces(url)) { return; } settings.CHECK_CONNECTION_URL = url; try { apply(settings); } catch (ConfigurationException e) { return; } final AtomicReference<IOException> exceptionReference = new AtomicReference<>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { try { HttpRequests.request(url).readTimeout(3 * 1000).tryConnect(); } catch (IOException e) { exceptionReference.set(e); } }, IdeBundle.message("progress.title.check.connection"), true, null); reset(settings); // since password might have been set final IOException exception = exceptionReference.get(); if (exception == null) { Messages.showMessageDialog(myMainPanel, IdeBundle.message("message.connection.successful"), title, Messages.getInformationIcon()); } else { final String message = exception.getMessage(); if (settings.USE_HTTP_PROXY) { settings.LAST_ERROR = message; } Messages.showErrorDialog(myMainPanel, errorText(message)); } }); }
configureCheckButton
278,021
void (@NotNull HttpConfigurable settings) { myNoProxyRb.setSelected(true); // default myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC); myPacUrlCheckBox.setSelected(settings.USE_PAC_URL); myPacUrlTextField.setText(settings.PAC_URL); myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY); myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION); enableProxy(settings.USE_HTTP_PROXY); myProxyLoginTextField.setText(settings.getProxyLogin()); myProxyPasswordTextField.setText(settings.getPlainProxyPassword()); myProxyPortTextField.setNumber(settings.PROXY_PORT); myProxyHostTextField.setText(settings.PROXY_HOST); myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS)); myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD); mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS); myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS); boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR); myErrorLabel.setVisible(showError); myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null); final String oldStyleText = CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties()); myOtherWarning.setVisible(oldStyleText != null); if (oldStyleText != null) { myOtherWarning.setText(oldStyleText); myOtherWarning.setIcon(Messages.getWarningIcon()); } }
reset
278,022
void () { myProxyExceptions = new RawCommandLineEditor(text -> { List<String> result = new ArrayList<>(); for (String token : text.split(",")) { String trimmedToken = token.trim(); if (!trimmedToken.isEmpty()) { result.add(trimmedToken); } } return result; }, strings -> StringUtil.join(strings, ", ")); }
createUIComponents
278,023
void (boolean enabled) { myHostNameLabel.setEnabled(enabled); myPortNumberLabel.setEnabled(enabled); myProxyHostTextField.setEnabled(enabled); myProxyPortTextField.setEnabled(enabled); mySocks.setEnabled(enabled); myHTTP.setEnabled(enabled); myProxyExceptions.setEnabled(enabled); myProxyExceptionsLabel.setEnabled(enabled); myNoProxyForLabel.setEnabled(enabled); myProxyAuthCheckBox.setEnabled(enabled); enableProxyAuthentication(enabled && myProxyAuthCheckBox.isSelected()); final boolean autoDetectProxy = myAutoDetectProxyRb.isSelected(); myPacUrlCheckBox.setEnabled(autoDetectProxy); myClearPasswordsButton.setEnabled(autoDetectProxy); myPacUrlTextField.setEnabled(autoDetectProxy && myPacUrlCheckBox.isSelected()); }
enableProxy
278,024
void (boolean enabled) { myProxyLoginLabel.setEnabled(enabled); myProxyLoginTextField.setEnabled(enabled); myProxyPasswordLabel.setEnabled(enabled); myProxyPasswordTextField.setEnabled(enabled); myRememberProxyPasswordCheckBox.setEnabled(enabled); }
enableProxyAuthentication
278,025
JComponent () { return myMainPanel; }
getComponent
278,026
AuthenticationPanel () { return panel; }
getPanel
278,027
List<Proxy> (@NotNull URI uri) { LOG.debug("IDEA-wide proxy selector asked for " + uri.toString()); String scheme = uri.getScheme(); if (!("http".equals(scheme) || "https".equals(scheme))) { LOG.debug("No proxy: not http/https scheme: " + scheme); return CommonProxy.NO_PROXY_LIST; } if (myHttpConfigurable.USE_HTTP_PROXY) { if (myHttpConfigurable.isProxyException(uri)) { LOG.debug("No proxy: URI '", uri, "' matches proxy exceptions [", myHttpConfigurable.PROXY_EXCEPTIONS, "]"); return CommonProxy.NO_PROXY_LIST; } if (myHttpConfigurable.PROXY_PORT < 0 || myHttpConfigurable.PROXY_PORT > 65535) { LOG.debug("No proxy: invalid port: " + myHttpConfigurable.PROXY_PORT); return CommonProxy.NO_PROXY_LIST; } Proxy.Type type = myHttpConfigurable.PROXY_TYPE_IS_SOCKS ? Proxy.Type.SOCKS : Proxy.Type.HTTP; Proxy proxy = new Proxy(type, new InetSocketAddress(myHttpConfigurable.PROXY_HOST, myHttpConfigurable.PROXY_PORT)); LOG.debug("Defined proxy: ", proxy); myHttpConfigurable.LAST_ERROR = null; return Collections.singletonList(proxy); } if (myHttpConfigurable.USE_PROXY_PAC) { // https://youtrack.jetbrains.com/issue/IDEA-262173 String oldDocumentBuilderFactory = System.setProperty(DOCUMENT_BUILDER_FACTORY_KEY, "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); try { return selectUsingPac(uri); } catch (Throwable e) { LOG.error("Cannot select using PAC", e); } finally { SystemProperties.setProperty(DOCUMENT_BUILDER_FACTORY_KEY, oldDocumentBuilderFactory); } } return CommonProxy.NO_PROXY_LIST; }
select
278,028
List<Proxy> (@NotNull URI uri) { // It is important to avoid resetting Pac based ProxySelector unless option was changed // New instance will download configuration file and interpret it before making the connection String pacUrlForUse = myHttpConfigurable.USE_PAC_URL && !StringUtil.isEmpty(myHttpConfigurable.PAC_URL) ? myHttpConfigurable.PAC_URL : null; Pair<ProxySelector, String> pair = myPacProxySelector.get(); if (pair != null && !Objects.equals(pair.second, pacUrlForUse)) { pair = null; } if (pair == null) { ProxySelector newProxySelector = NetUtils.getProxySelector(pacUrlForUse); pair = Pair.create(newProxySelector, pacUrlForUse); myPacProxySelector.lazySet(pair); } ProxySelector pacProxySelector = pair.first; if (pacProxySelector == null) { LOG.debug("No proxies detected"); } else { try { List<Proxy> select = pacProxySelector.select(uri); LOG.debug("Autodetected proxies: ", select); return select; } catch (StackOverflowError ignore) { LOG.warn("Too large PAC script (JRE-247)"); } } return CommonProxy.NO_PROXY_LIST; }
selectUsingPac
278,029
void (URI uri, SocketAddress sa, IOException ioe) { if (myHttpConfigurable.USE_PROXY_PAC) { myHttpConfigurable.removeGeneric(new CommonProxy.HostInfo(uri.getScheme(), uri.getHost(), uri.getPort())); LOG.debug("generic proxy credentials (if were saved) removed"); return; } final InetSocketAddress isa = sa instanceof InetSocketAddress ? (InetSocketAddress) sa : null; if (myHttpConfigurable.USE_HTTP_PROXY && isa != null && Objects.equals(myHttpConfigurable.PROXY_HOST, isa.getHostString())) { LOG.debug("connection failed message passed to http configurable"); myHttpConfigurable.LAST_ERROR = ioe.getMessage(); } }
connectFailed
278,030
String () { return StringUtil.notNullize(myLoginTextField.getText()); }
getLogin
278,031
boolean () { return rememberPasswordCheckBox.isSelected(); }
isRememberPassword
278,032
JComponent () { return getLogin().isEmpty() ? myLoginTextField : myPasswordTextField; }
getPreferredFocusedComponent
278,033
PasswordAuthentication () { final String host = CommonProxy.getHostNameReliably(getRequestingHost(), getRequestingSite(), getRequestingURL()); // java.base/java/net/SocksSocketImpl.java:176 : there is SOCKS proxy auth, but without RequestorType passing final boolean isProxy = Authenticator.RequestorType.PROXY.equals(getRequestorType()) || "SOCKS authentication".equals(getRequestingPrompt()); final String prefix = isProxy ? IdeBundle.message("prompt.proxy.authentication") : IdeBundle.message("prompt.server.authentication"); Application application = ApplicationManager.getApplication(); if (isProxy) { // according to idea-wide settings if (myHttpConfigurable.USE_HTTP_PROXY) { LOG.debug("CommonAuthenticator.getPasswordAuthentication will return common defined proxy"); return myHttpConfigurable.getPromptedAuthentication(host + ":" + getRequestingPort(), getRequestingPrompt()); } else if (myHttpConfigurable.USE_PROXY_PAC) { LOG.debug("CommonAuthenticator.getPasswordAuthentication will return autodetected proxy"); if (myHttpConfigurable.isGenericPasswordCanceled(host, getRequestingPort())) return null; // same but without remembering the results.. final PasswordAuthentication password = myHttpConfigurable.getGenericPassword(host, getRequestingPort()); if (password != null) { return password; } // do not try to show any dialogs if application is exiting if (application == null || application.isDisposed()) { return null; } return myHttpConfigurable.getGenericPromptedAuthentication(prefix, host, getRequestingPrompt(), getRequestingPort(), true); } } // do not try to show any dialogs if application is exiting if (application == null || application.isDisposed()) { return null; } LOG.debug("CommonAuthenticator.getPasswordAuthentication generic authentication will be asked"); //return myHttpConfigurable.getGenericPromptedAuthentication(prefix, host, getRequestingPrompt(), getRequestingPort(), false); return null; }
getPasswordAuthentication
278,034
void (@NotNull ActionEvent e) { HttpConfigurable.editConfigurable(ObjectUtils.tryCast(e.getSource(), JComponent.class)); }
actionPerformed
278,035
boolean (@NlsContexts.DialogTitle String title, @NlsContexts.DetailedDescription String text) { if (ApplicationManager.getApplication().isUnitTestMode()) { throw new RuntimeException(title + ": " + text); } Ref<Boolean> ok = new Ref<>(false); try { ApplicationManager.getApplication().invokeAndWait(() -> { IOExceptionDialog dialog = new IOExceptionDialog(title, text); dialog.show(); ok.set(dialog.isOK()); }); } catch (RuntimeException e) { LOG.info(e); } return ok.get(); }
showErrorDialog
278,036
String (@NotNull CommonField name) { String field = myIssuerFields.get(name.getShortName()); return field == null ? NOT_AVAILABLE : field; }
getIssuerField
278,037
String () { try { return DigestUtil.sha256Hex(myCertificate.getEncoded()); } catch (CertificateEncodingException e) { return NOT_AVAILABLE; } }
getSha256Fingerprint
278,038
String () { try { return DigestUtil.sha1Hex(myCertificate.getEncoded()); } catch (Exception e) { return NOT_AVAILABLE; } }
getSha1Fingerprint
278,039
boolean () { try { myCertificate.checkValidity(); return true; } catch (Exception e) { return false; } }
isValid
278,040
boolean () { return new Date().getTime() > myCertificate.getNotAfter().getTime(); }
isExpired
278,041
boolean () { return new Date().getTime() < myCertificate.getNotBefore().getTime(); }
isNotYetValid
278,042
boolean () { return myCertificate.getIssuerX500Principal().equals(myCertificate.getSubjectX500Principal()); }
isSelfSigned
278,043
int () { return myCertificate.getVersion(); }
getVersion
278,044
String () { return myCertificate.getSerialNumber().toString(); }
getSerialNumber
278,045
X509Certificate () { return myCertificate; }
getCertificate
278,046
X500Principal () { return myCertificate.getIssuerX500Principal(); }
getIssuerX500Principal
278,047
X500Principal () { return myCertificate.getSubjectX500Principal(); }
getSubjectX500Principal
278,048
Date () { return myCertificate.getNotBefore(); }
getNotBefore
278,049
Date () { return myCertificate.getNotAfter(); }
getNotAfter
278,050
boolean (Object other) { return other instanceof CertificateWrapper && myCertificate.equals(((CertificateWrapper)other).getCertificate()); }
equals
278,051
int () { return myCertificate.hashCode(); }
hashCode
278,052
OsCertificatesService () { return ApplicationManager.getApplication().getService(OsCertificatesService.class); }
getInstance
278,053
ConfirmingTrustManager (@NotNull String path, @NotNull String password) { return new ConfirmingTrustManager(getSystemTrustManagers(), new MutableTrustManager(path, password)); }
createForStorage
278,054
List<X509TrustManager> () { List<X509TrustManager> result = new ArrayList<>(); X509TrustManager osManager = getOperatingSystemTrustManager(); if (osManager != null) { result.add(osManager); } X509TrustManager javaRuntimeManager = getJavaRuntimeDefaultTrustManager(); if (javaRuntimeManager != null) { result.add(javaRuntimeManager); } return result; }
getSystemTrustManagers
278,055
boolean (final X509Certificate[] chain, @NotNull CertificateConfirmationParameters parameters) { Application app = ApplicationManager.getApplication(); final X509Certificate endPoint = chain[0]; // IDEA-123467 and IDEA-123335 workaround String threadClassName = Strings.notNullize(Thread.currentThread().getClass().getCanonicalName()); if (threadClassName.equals("sun.awt.image.ImageFetcher")) { LOG.debug("Image Fetcher thread is detected. Certificate check will be skipped."); return true; } if (app.isHeadlessEnvironment() || CertificateManager.getInstance().getState().ACCEPT_AUTOMATICALLY) { LOG.debug("Certificate will be accepted automatically"); if (parameters.myAddToKeyStore) { myCustomManager.addCertificate(endPoint); } return true; } if (app.isUnitTestMode()) { return false; } boolean accepted = false; if (parameters.myAskUser) { String acceptLogMessage = "Going to ask user about certificate for: " + endPoint.getSubjectX500Principal().toString() + ", issuer: " + endPoint.getIssuerX500Principal().toString(); if (parameters.myAskOrRejectReason != null) { acceptLogMessage += ". Reason: " + parameters.myAskOrRejectReason; } LOG.info(acceptLogMessage); accepted = CertificateManager.Companion.showAcceptDialog(() -> { // TODO may be another kind of warning, if default trust store is missing return CertificateWarningDialog.createUntrustedCertificateWarning(endPoint, parameters.myCertificateDetails); }); } else { String rejectLogMessage = "Didn't show certificate dialog for: " + endPoint.getSubjectX500Principal().toString() + ", issuer: " + endPoint.getIssuerX500Principal().toString(); if (parameters.myAskOrRejectReason != null) { rejectLogMessage += ". Reason: " + parameters.myAskOrRejectReason; } LOG.warn(rejectLogMessage); } if (accepted) { LOG.info("Certificate was accepted by user"); if (parameters.myAddToKeyStore) { myCustomManager.addCertificate(endPoint); } if (parameters.myOnUserAcceptCallback != null) { parameters.myOnUserAcceptCallback.run(); } } return accepted; }
confirmAndUpdate
278,056
X509Certificate[] () { Set<X509Certificate> certificates = new HashSet<>(); for (X509TrustManager manager : mySystemManagers) { try { certificates.addAll(Arrays.asList(manager.getAcceptedIssuers())); } catch (Throwable exception) { LOG.error("Could not get list of accepted issuers (trusted root identities) from " + manager.toString() + " (" + manager.getClass().getName() + ")", exception); } } certificates.addAll(Arrays.asList(myCustomManager.getAcceptedIssuers())); return certificates.toArray(X509Certificate[]::new); }
getAcceptedIssuers
278,057
MutableTrustManager () { return myCustomManager; }
getCustomManager
278,058
TrustManagerFactory () { try { return TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); } catch (NoSuchAlgorithmException e) { LOG.error("Cannot create trust manager factory", e); return null; } }
createFactory
278,059
KeyStore (@NotNull String path, @NotNull String password) { KeyStore keyStore; try { keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); Path cacertsFile = Path.of(path); if (Files.exists(cacertsFile)) { try (InputStream stream = Files.newInputStream(cacertsFile)) { keyStore.load(stream, password.toCharArray()); } } else { try { Files.createDirectories(cacertsFile.getParent()); } catch (IOException e) { LOG.error("Cannot create directories: " + cacertsFile.getParent(), e); return null; } keyStore.load(null, password.toCharArray()); } } catch (Exception e) { LOG.error("Cannot create key store", e); return null; } return keyStore; }
createKeyStore
278,060
boolean (@NotNull X509Certificate certificate) { myWriteLock.lock(); try { if (isBroken()) { return false; } myKeyStore.setCertificateEntry(createAlias(certificate), certificate); flushKeyStore(); LOG.info("Added certificate for '" + certificate.getSubjectX500Principal().toString() + "' to " + myPath); // trust manager should be updated each time its key store was modified myTrustManager = initFactoryAndGetManager(); myDispatcher.getMulticaster().certificateAdded(certificate); return true; } catch (Exception e) { LOG.error("Cannot add certificate", e); return false; } finally { myWriteLock.unlock(); } }
addCertificate
278,061
boolean (@NotNull String path) { X509Certificate certificate = CertificateUtil.loadX509Certificate(path); return certificate != null && addCertificate(certificate); }
addCertificate
278,062
String (@NotNull X509Certificate certificate) { return CertificateUtil.getCommonName(certificate); }
createAlias
278,063
boolean (@NotNull X509Certificate certificate) { return removeCertificate(createAlias(certificate)); }
removeCertificate
278,064
boolean (@NotNull String alias) { myWriteLock.lock(); try { if (isBroken()) { return false; } // for listeners X509Certificate certificate = getCertificate(alias); if (certificate == null) { LOG.error("No certificate found for alias: " + alias); return false; } myKeyStore.deleteEntry(alias); flushKeyStore(); // trust manager should be updated each time its key store was modified myTrustManager = initFactoryAndGetManager(); myDispatcher.getMulticaster().certificateRemoved(certificate); return true; } catch (Exception e) { LOG.error("Cannot remove certificate for alias: " + alias, e); return false; } finally { myWriteLock.unlock(); } }
removeCertificate
278,065
List<X509Certificate> () { myReadLock.lock(); try { List<X509Certificate> certificates = new ArrayList<>(); for (String alias : Collections.list(myKeyStore.aliases())) { certificates.add(getCertificate(alias)); } return List.copyOf(certificates); } catch (Exception e) { LOG.error(e); return Collections.emptyList(); } finally { myReadLock.unlock(); } }
getCertificates
278,066
boolean (@NotNull String alias) { myReadLock.lock(); try { return myKeyStore.containsAlias(alias); } catch (KeyStoreException e) { LOG.error(e); return false; } finally { myReadLock.unlock(); } }
containsCertificate
278,067
X509Certificate[] () { myReadLock.lock(); try { // trust no one if broken if (keyStoreIsEmpty() || isBroken()) { return NO_CERTIFICATES; } return myTrustManager.getAcceptedIssuers(); } finally { myReadLock.unlock(); } }
getAcceptedIssuers
278,068
void (@NotNull CertificateListener listener) { myDispatcher.addListener(listener); }
addListener
278,069
void (@NotNull CertificateListener listener) { myDispatcher.removeListener(listener); }
removeListener
278,070
boolean () { try { return myKeyStore.size() == 0; } catch (KeyStoreException e) { LOG.error(e); return true; } }
keyStoreIsEmpty
278,071
X509TrustManager () { try { if (myFactory != null && myKeyStore != null) { myFactory.init(myKeyStore); final TrustManager[] trustManagers = myFactory.getTrustManagers(); final X509TrustManager result = findX509TrustManager(trustManagers); if (result == null) { LOG.error("Cannot find X509 trust manager among " + Arrays.toString(trustManagers)); } return result; } } catch (KeyStoreException e) { LOG.error("Cannot initialize trust store", e); } return null; }
initFactoryAndGetManager
278,072
boolean () { return myKeyStore == null || myFactory == null || myTrustManager == null; }
isBroken
278,073
CertificateConfirmationParameters (boolean addToKeyStore, @Nullable @NlsContexts.DialogMessage String certificateDetails, @Nullable Runnable onUserAcceptCallback) { return new CertificateConfirmationParameters(true, addToKeyStore, certificateDetails, onUserAcceptCallback, null); }
askConfirmation
278,074
CertificateConfirmationParameters () { return new CertificateConfirmationParameters(false, false, null, null, null); }
doNotAskConfirmation
278,075
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CertificateConfirmationParameters that = (CertificateConfirmationParameters)o; return myAskUser == that.myAskUser && myAddToKeyStore == that.myAddToKeyStore && Objects.equals(myCertificateDetails, that.myCertificateDetails) && Objects.equals(myOnUserAcceptCallback, that.myOnUserAcceptCallback); }
equals
278,076
int () { return Objects.hash(myAskUser, myAddToKeyStore, myCertificateDetails, myOnUserAcceptCallback); }
hashCode
278,077
X509Certificate () { return myCertificateWrapper.getCertificate(); }
getCertificate
278,078
void (FormBuilder builder, Map<String, @NlsSafe String> fields) { builder = builder.setFormLeftIndent(IdeBorderFactory.TITLED_BORDER_INDENT); for (CommonField field : CommonField.values()) { String value = fields.get(field.getShortName()); if (value == null) { continue; } String label = new HtmlBuilder() .append(field.getShortName()) .append(" (") .append(HtmlChunk.text(field.getLongName()).bold()) .append(")") .wrapWith("html") .toString(); builder = builder.addLabeledComponent(label, new JBLabel(value)); } builder.setFormLeftIndent(0); }
updateBuilderWithPrincipalData
278,079
void (FormBuilder builder, @Nls String title) { builder.addComponent(new TitledSeparator(title), IdeBorderFactory.TITLED_BORDER_TOP_INSET); }
updateBuilderWithTitle
278,080
JComponent (@Nls String text) { JTextPane pane = new JTextPane(); pane.setOpaque(false); pane.setEditable(false); pane.setContentType("text/plain"); pane.setText(text); //Messages.installHyperlinkSupport(pane); return pane; }
getTextPane
278,081
JComponent (@NlsContexts.Label String mainText, @Nls String errorText, boolean hasError) { SimpleColoredComponent component = new SimpleColoredComponent(); if (hasError) { component.append(mainText + " (" + errorText + ")", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.RED)); } else { component.append(mainText); } return component; }
createColoredComponent
278,082
CertificateFactory () { try { return CertificateFactory.getInstance(X509); } catch (CertificateException e) { throw new RuntimeException("Can't initialize X.509 certificate factory", e); } }
createFactory
278,083
String (@NotNull X509Certificate certificate) { return new CertificateWrapper(certificate).getSubjectField(CertificateWrapper.CommonField.COMMON_NAME); }
getCommonName
278,084
CertificateWarningDialog (@NotNull X509Certificate certificate, @Nullable @NlsContexts.DialogMessage String details) { return new CertificateWarningDialog(certificate, IdeBundle.message("dialog.title.untrusted.server.s.certificate"), details == null ? IdeBundle.message("text.server.s.certificate.trusted") : IdeBundle.message("text.server.s.certificate.trusted.details", details)); }
createUntrustedCertificateWarning
278,085
CertificateWarningDialog (@NotNull X509Certificate certificate) { return createUntrustedCertificateWarning(certificate, null); }
createUntrustedCertificateWarning
278,086
CertificateWarningDialog (@NotNull X509Certificate certificate) { throw new UnsupportedOperationException("Not supported"); }
createExpiredCertificateWarning
278,087
void () { super.revalidateAndRepaint(); updateBounds(); }
revalidateAndRepaint
278,088
void () { super.updateUI(); setOpaque(false); if (myFont == null) { setFont(StartupUiUtil.getLabelFont()); } updateBounds(); }
updateUI
278,089
boolean (@NotNull MouseEvent e, int clickCount) { if (e.getButton() == MouseEvent.BUTTON1 && clickCount == 1) { ActionListener actionListener = findActionListenerAt(e.getPoint()); if (actionListener != null) { actionListener.actionPerformed(new ActionEvent(e, 0, "")); return true; } } return false; }
onClick
278,090
void (final MouseEvent e) { if (isStatusVisibleInner()) { if (findActionListenerAt(e.getPoint()) != null) { if (myOriginalCursor == null) { myOriginalCursor = myMouseTarget.getCursor(); myMouseTarget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } else if (myOriginalCursor != null) { myMouseTarget.setCursor(myOriginalCursor); myOriginalCursor = null; } } }
mouseMoved
278,091
boolean () { return myFont != null; }
isFontSet
278,092
void (@NotNull Font font) { setFontImpl(font); }
setFont
278,093
void () { setFontImpl(null); }
resetFont
278,094
void (Font font) { myPrimaryColumn.fragments.forEach(fragment -> fragment.myComponent.setFont(font)); mySecondaryColumn.fragments.forEach(fragment -> fragment.myComponent.setFont(font)); myFont = font; }
setFontImpl
278,095
boolean () { return myCenterAlignText; }
isCenterAlignText
278,096
void (boolean centerAlignText) { myCenterAlignText = centerAlignText; }
setCenterAlignText
278,097
void (@Nullable Component owner) { attachTo(owner, owner); }
attachTo
278,098
void (@Nullable Component owner, @Nullable Component mouseTarget) { if (myOwner != null) { myOwner.removeHierarchyListener(myHierarchyListener); } if (myMouseTarget != null) { myClickListener.uninstall(myMouseTarget); myMouseTarget.removeMouseMotionListener(myMouseMotionListener); } myOwner = owner; myMouseTarget = mouseTarget; if (myMouseTarget != null) { myClickListener.installOn(myMouseTarget); myMouseTarget.addMouseMotionListener(myMouseMotionListener); } if (myOwner != null) { myOwner.addHierarchyListener(myHierarchyListener); } }
attachTo
278,099
boolean () { if (!isStatusVisible()) return false; if (!myInLoadingPanel) return true; JBLoadingPanel loadingPanel = UIUtil.getParentOfType(JBLoadingPanel.class, myOwner); return loadingPanel == null || !loadingPanel.isLoading(); }
isStatusVisibleInner