public boolean hasLoginSso() { return getLoginSso() != null; }
LoginSsoCallbackHandler(@NotNull ServerConfig serverConfig, int lockWaitTimeoutMillis) { this.serverConfig = serverConfig; this.loginSsoCmd = serverConfig.getLoginSso(); if (loginSsoCmd == null) { throw new IllegalStateException("Should have login SSO at this point"); } this.lockWaitTimeoutMillis = lockWaitTimeoutMillis; }
@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; }
@Override public void singleSignOnExecutionFailed(@NotNull LoginFailureMessage.SingleSignOnExecutionFailureEvent e) { // No explicit action to take UserMessage.showNotification(null, UserMessage.ERROR, P4Bundle.message("error.loginsso.exec-failed.long", e.getConfig().getLoginSso(), e.getExitCode(), e.getStdout(), e.getStderr()), P4Bundle.message("error.loginsso.exec-failed.title"), NotificationType.ERROR); // TODO once the Single Sign On can take an argument, let this prompt for the argument. }
@Override public void singleSignOnFailed(@NotNull ServerErrorEvent.ServerConfigErrorEvent<AuthenticationFailedException> e) { LOG.info("Processing single sign on failure: " + e.getError().getMessage()); if (shouldHandleProblem(e.getConfig(), FailureType.SSO)) { // No explicit action to take UserMessage.showNotification(null, UserMessage.ERROR, P4Bundle.message("error.loginsso.exec-failed", e.getConfig().getLoginSso(), e.getError().getLocalizedMessage()), P4Bundle.message("error.loginsso.exec-failed.title"), NotificationType.ERROR); // TODO once the Single Sign On can take an argument, let this prompt for the argument. } else { LOG.info("Not handling SSO problem for " + e.getConfig()); } }
@Test void createFrom_empty() { ServerConfig sc = ServerConfig.createFrom( new MockConfigPart() .withUsername("username") .withServerName("servername") ); assertEquals(P4ServerName.forPort("servername"), sc.getServerName()); assertEquals("username", sc.getUsername()); assertNull(sc.getServerFingerprint()); assertNull(sc.getAuthTicket()); assertNull(sc.getTrustTicket()); assertNull(sc.getLoginSso()); assertThat(sc.getConfigVersion(), greaterThan(0)); assertFalse(sc.hasServerFingerprint()); assertFalse(sc.hasAuthTicket()); assertFalse(sc.hasTrustTicket()); assertFalse(sc.hasLoginSso()); assertFalse(sc.usesStoredPassword()); assertEquals("localhost:servername" + SEP + "username" + SEP + "null" + SEP + "null" + SEP + "null", sc.getServerId()); }