@Override public String toString() { return clientName + "@" + serverName.getDisplayName(); } }
@Override public String toString() { if (clientName != null) { return serverConfig.getServerName().getDisplayName() + "@" + clientName; } return serverConfig.getServerName().getDisplayName(); }
@NotNull public String getServerDisplayId() { return getServerName().getDisplayName(); }
private void renderP4ServerName(P4ServerName value) { append(P4Bundle.getString("connection.tree.server-name-key"), CONNECTION_PROPERTY_KEY_STYLE); append(value.getDisplayName(), CONNECTION_PROPERTY_VALUE_STYLE); }
@SuppressWarnings("SameParameterValue") @NotNull private static String portName(@NotNull String serverName) { return Objects.requireNonNull(P4ServerName.forPort(serverName)).getDisplayName(); } }
@Override public void unknownServer(@NotNull ServerErrorEvent.ServerNameErrorEvent<Exception> event) { simpleError( // #138 - show the display name P4Bundle.message("user-error.unknown-server.message", event.getName().getDisplayName()), P4Bundle.message("user-error.unknown-server.title")); LOG.warn(event.getError()); }
@NotNull public static Map<String, String> toProperties(@NotNull ServerConfig config, @Nullable String valueIfUnset, @Nullable String valueIfPasswordStored, @Nullable String valueIfPasswordNotStored) { Map<String, String> ret = new HashMap<>(); ret.put(PerforceEnvironment.P4PORT, config.getServerName().getDisplayName()); ret.put(PerforceEnvironment.P4TRUST, ! config.hasTrustTicket() || config.getTrustTicket() == null ? valueIfUnset : config.getTrustTicket().toString()); ret.put(PerforceEnvironment.P4USER, config.getUsername()); ret.put(PerforceEnvironment.P4TICKETS, ! config.hasAuthTicket() || config.getAuthTicket() == null ? valueIfUnset : config.getAuthTicket().toString()); ret.put(PerforceEnvironment.P4SERVER_FINGERPRINT, ! config.hasServerFingerprint() || config.getServerFingerprint() == null ? valueIfUnset : config.getServerFingerprint()); ret.put(PerforceEnvironment.P4PASSWD, config.usesStoredPassword() ? valueIfPasswordStored : valueIfPasswordNotStored); ret.put(PerforceEnvironment.P4LOGINSSO, ! config.hasLoginSso() || config.getLoginSso() == null ? valueIfUnset : config.getLoginSso()); return ret; }
private Promise<OneTimeString> promptForPassword(@Nullable Project project, @NotNull ServerConfig config) { final AsyncPromise<OneTimeString> ret = new AsyncPromise<>(); // Because this can happen while a dialog is shown, we instead want to force it to run. // So don't use the ApplicationManager to run later. EventQueue.invokeLater(() -> { CredentialPromptDialog.askPassword( project, P4Bundle.getString("login.password.title"), P4Bundle.message("login.password.message", config.getServerName().getDisplayName(), config.getUsername()), getCredentialAttributes(config, false), true, null); }); return ret; } }
@Test void forPort_justPort() { P4ServerName name = P4ServerName.forPort("1667"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("localhost:1667")); assertThat("display", name.getDisplayName(), is("localhost:1667")); assertThat("url", name.getUrl(), is("p4jrpcnts://localhost:1667")); assertThat("full port", name.getFullPort(), is("localhost:1667")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_simpleProtocolPort() { P4ServerName name = P4ServerName.forPort("tcp:host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_ssl() { P4ServerName name = P4ServerName.forPort("ssl://host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(true)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTSSSL)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("ssl:host:1234")); assertThat("url", name.getUrl(), is("p4jrpcntsssl://host:1234")); assertThat("full port", name.getFullPort(), is("ssl://host:1234")); assertThat("protocol name", name.getProtocolName(), is("ssl")); }
@Test void forPort_hostPort() { P4ServerName name = P4ServerName.forPort("host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
! configPart.hasServerNameSet() || configPart.getServerName() == null ? valueIfUnset : configPart.getServerName().getDisplayName()); ret.put(PerforceEnvironment.P4TRUST, ! configPart.hasTrustTicketFileSet() || configPart.getTrustTicketFile() == null
@Override public void passwordUnnecessary(@NotNull ServerErrorEvent.ServerConfigErrorEvent<AuthenticationFailedException> e) { // Inform the user about the unnecessary password. if (shouldHandleProblem(e.getConfig(), FailureType.PASSWORD_UNNECESSARY)) { UserMessage.showNotification(null, UserMessage.WARNING, P4Bundle.message("connection.password.unnecessary.details", e.getName().getDisplayName()), P4Bundle.message("connection.password.unnecessary.title"), NotificationType.INFORMATION); // Update the password to remove the stored password. ApplicationPasswordRegistry.getInstance().remove(e.getConfig()); } else { LOG.info("Not handling password uncessary issue for " + e.getConfig()); } } });
P4Bundle.message("login.password-not-stored.error", e.getName().getDisplayName()), P4Bundle.getString("login.password-not-stored.error.title"), NotificationType.ERROR); P4Bundle.message("login.password.error", e.getName().getDisplayName()), P4Bundle.getString("login.password.error.title"), NotificationType.ERROR,