package org.jenkinsci.plugins.p4_client.client; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.IServerInfo; public class ConnectionConfig { private final String p4port; private final boolean ssl; private final String serverUri; private final boolean unicode; public ConnectionConfig(String port, boolean ssl) { this.p4port = port; this.ssl = ssl; if (ssl) { this.serverUri = "p4javassl://" + port; } else { this.serverUri = "p4java://" + port; } this.unicode = checkUnicode(); } public String getPort() { return p4port; } public boolean isSsl() { return ssl; } public String getServerUri() { return serverUri; } public String toString() { return serverUri; } @Override public boolean equals(Object obj) { if (obj instanceof ConnectionConfig) { ConnectionConfig comp = (ConnectionConfig) obj; return this.toString().equals(comp.toString()); } else { return false; } } @Override public int hashCode() { int hash = 7; hash = (int) (1777 * hash + this.toString().hashCode()); return hash; } /** * Check the connection to the Perforce Server. * * @return true if OK. */ public boolean checkConnection() { try { ConnectionFactory.getConnection(this); return true; } catch (Exception e) { return false; } } /** * Query if the Perforce Server is set to run in Unicode enabled mode. * * @return true if unicode enabled, false if disabled of server is offline. * @throws Exception */ private boolean checkUnicode() { IOptionsServer connection; try { connection = ConnectionFactory.getConnection(this); IServerInfo info = connection.getServerInfo(); return info.isUnicodeEnabled(); } catch (Exception e) { return false; } } public boolean isUnicode() { return unicode; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#4 | 8940 | Paul Allen |
Major refactor for the ConnectionHelper class to simplify serialisation. Fixed remote Jenkins JNLP slave connection issue. ClientHelper now extends ConnectionHelper and takes on all methods that require a client workspace. P4StandardCredentials is sent to the remote node instead of Credentials ID due to an issue accessing the Credentials store over a remote connection. For simplicity Client ID (workspace name) is serialised instead of the Workspace object. |
||
#3 | 8660 | Paul Allen | Added P4TRUST for SSL connections in the Credentials plugin and ConnectionFactory. | ||
#2 | 8639 | Paul Allen |
Added hint URL to Credentials page when no Credentials are defined. Minor refactor and UX changes. |
||
#1 | 8629 | Paul Allen |
Added p4java with connection/authorisation helper classes. Included SSL support and detection of Unicode servers. |