package org.jenkinsci.plugins.p4.credentials; import com.cloudbees.plugins.credentials.CredentialsScope; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.util.FormValidation; import hudson.util.Secret; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.client.ConnectionConfig; import org.jenkinsci.plugins.p4.client.ConnectionFactory; import org.jenkinsci.plugins.p4.client.ConnectionHelper; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; import javax.servlet.ServletException; import java.io.IOException; public class P4PasswordImpl extends P4BaseCredentials implements P4Password { /** * Ensure consistent serialisation. */ private static final long serialVersionUID = 1L; @NonNull private final Secret password; private boolean allhosts; @DataBoundConstructor public P4PasswordImpl(CredentialsScope scope, String id, String description, @NonNull String p4port, TrustImpl ssl, @NonNull String username, @CheckForNull String retry, @CheckForNull String timeout, @CheckForNull String p4host, @NonNull String password) { super(scope, id, description, p4port, ssl, username, retry, timeout, p4host); this.password = Secret.fromString(password); } @DataBoundSetter public void setAllhosts(boolean allhosts) { this.allhosts = allhosts; } public Secret getPassword() { return password; } public boolean isAllhosts() { return allhosts; } @Extension @Symbol("password") public static class DescriptorImpl extends BaseStandardCredentialsDescriptor { @Override public String getDisplayName() { return "Perforce Password Credential"; } public FormValidation doCheckP4port(@QueryParameter String value) { if (value != null && value.startsWith("ssl:")) { return FormValidation.error("Do not prefix P4PORT with 'ssl:', use the SSL checkbox."); } return FormValidation.ok(); } public FormValidation doTestConnection(@QueryParameter("p4port") String p4port, @QueryParameter("ssl") String ssl, @QueryParameter("trust") String trust, @QueryParameter("p4host") String p4host, @QueryParameter("username") String username, @QueryParameter("password") String password, @QueryParameter("allhosts") boolean allhosts) throws IOException, ServletException { try { // Test connection path to Server TrustImpl sslTrust = ("true".equals(ssl)) ? new TrustImpl(trust) : null; P4PasswordImpl test = new P4PasswordImpl(null, null, null, p4port, sslTrust, username, null, null, p4host, password); test.setAllhosts(allhosts); ConnectionConfig config = new ConnectionConfig(test); FormValidation validation = ConnectionFactory.testConnection(config); if (!FormValidation.ok().equals(validation)) { return validation; } // Test an open connection ConnectionHelper p4 = new ConnectionHelper(test); if (!p4.isConnected()) { return FormValidation.error("Server Connection Error."); } // Test authentication p4.logout(); // invalidate any earlier ticket before test. try { if (!p4.login()) { return FormValidation.error("Authentication Error: Unable to login."); } } catch (Exception e) { return FormValidation.error("Authentication Error: " + e.getMessage()); } // Test minimum server version if (!p4.checkVersion(20121)) { return FormValidation.error("Server version is too old (min 2012.1)"); } return FormValidation.ok("Success"); } catch (Exception e) { return FormValidation.error("Connection Error."); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 23685 | Paul Allen | Copy main -> dev | ||
#1 | 20641 | Paul Allen | Copy main -> dev (jenkinsci/p4-plugin) | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/credentials/P4PasswordImpl.java | |||||
#12 | 20598 | Paul Allen |
P4Credentials Interfaces for Mixins. Updated test cases to match changes from CredentialsNameProvider. @stephenc |
||
#11 | 19716 | Paul Allen | Login error to include exception message. | ||
#10 | 16502 | Paul Allen |
Advanced Credentials option for RPC_SOCKET_SO_TIMEOUT_NICK JENKINS-31196 |
||
#9 | 15656 | Paul Allen |
Updated credentials to extend BaseStandardCredentials. Allows users to set the ID at creation. JENKINS-29702 |
||
#8 | 15293 | Paul Allen |
Add retry attempts to Perforce Tasks. If a task fails due to an exception then the task will retry based on the value specified in the connection Credential. |
||
#7 | 11163 | Paul Allen | Removed unused imports. | ||
#6 | 11157 | Paul Allen |
Remove `@NameWith` annotation The 1.19 Credential release fixes the issue. JENKINS-25682 |
||
#5 | 11142 | Paul Allen |
Remove redundant code for Credential name fix Only the `@NameWith` annotation is required to report the Credential name. JENKINS-25682 |
||
#4 | 11132 | Paul Allen |
Fix Credential name for Template plugin Added `@NameWith` annotation to allow the implementation to override the reported Credential name. JENKINS-25682 |
||
#3 | 10031 | Paul Allen |
Test URI path before connection. Report Perforce Errors and Trust fingerprint if using SSL. |
||
#2 | 9851 | Paul Allen | Merging using p4-jenkins | ||
#1 | 9690 | Paul Allen |
[Branching using p4-jenkins] Release 1.0.1 |
||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4/credentials/P4PasswordImpl.java | |||||
#1 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4_client/credentials/P4PasswordImpl.java | |||||
#13 | 9428 | Paul Allen |
Clarification of Polling Filters in UX and UserGuide - Tidyup unused imports |
||
#12 | 9038 | Paul Allen |
Improved error messages for Form Validate field checks. Uses Perforce Server messages (TPI-80) |
||
#11 | 9032 | Paul Allen |
Perforce Credentials help and form validation checks for misuse of 'ssl:' on P4PORT. (TPI-107) |
||
#10 | 8888 | Paul Allen |
Extended test coverage for Workspace and Credentials. - Removed ununsed methods. |
||
#9 | 8771 | Paul Allen |
Perforce Server 12.1 min check for: Build configuration and password/ticket credentials. Includes: - Added logging for Perforce connections (fine) and set connection pool to 2. - Add 'none' to empty charset list (connection bug?) - Supress P4Java errors for syncing ubinary, xtext, unicode |
||
#8 | 8742 | Paul Allen | Added SSL support to "Test Connection" button for Perforce Credentials. | ||
#7 | 8741 | Paul Allen |
Added "Test Connection" to Perforce Password and Ticket Credentials. Does not support SSL connections...yet |
||
#6 | 8737 | Paul Allen |
Added basic Help for SCM Configuration page. Tidy up descriptions and fix (null:null) in Credential summary. |
||
#5 | 8660 | Paul Allen | Added P4TRUST for SSL connections in the Credentials plugin and ConnectionFactory. | ||
#4 | 8639 | Paul Allen |
Added hint URL to Credentials page when no Credentials are defined. Minor refactor and UX changes. |
||
#3 | 8629 | Paul Allen |
Added p4java with connection/authorisation helper classes. Included SSL support and detection of Unicode servers. |
||
#2 | 8612 | Paul Allen | Job can now select and save/load Credential choice (some cleanup TODO) | ||
#1 | 8611 | Paul Allen | Basic implementation of Credentials Store |