package org.jenkinsci.plugins.p4.credentials; import hudson.Extension; import hudson.util.FormValidation; import hudson.util.Secret; import java.io.IOException; import javax.servlet.ServletException; 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.QueryParameter; import com.cloudbees.plugins.credentials.CredentialsScope; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; public class P4PasswordImpl extends P4StandardCredentials { /** * Ensure consistent serialisation. */ private static final long serialVersionUID = 1L; @NonNull private final Secret password; @DataBoundConstructor public P4PasswordImpl(@CheckForNull CredentialsScope scope, @CheckForNull String id, @CheckForNull String description, @CheckForNull String p4port, TrustImpl ssl, @CheckForNull String username, @CheckForNull String password) { super(scope, id, description, p4port, ssl, username); this.password = Secret.fromString(password); } @NonNull public Secret getPassword() { return password; } @Extension public static class DescriptorImpl extends P4CredentialsDescriptor { @Override public String getDisplayName() { return "Perforce Password Credential"; } public FormValidation doTestConnection( @QueryParameter("p4port") String p4port, @QueryParameter("ssl") String ssl, @QueryParameter("trust") String trust, @QueryParameter("username") String username, @QueryParameter("password") String password) throws IOException, ServletException { try { // Test connection path to Server ConnectionConfig config = new ConnectionConfig(p4port, "true".equals(ssl), trust); FormValidation validation; validation = ConnectionFactory.testConnection(config); if (!FormValidation.ok().equals(validation)) { return validation; } // Test an open connection TrustImpl sslTrust; sslTrust = ("true".equals(ssl)) ? new TrustImpl(trust) : null; P4PasswordImpl test = new P4PasswordImpl(null, null, null, p4port, sslTrust, username, password); ConnectionHelper p4 = new ConnectionHelper(test); if (!p4.isConnected()) { return FormValidation.error("Server Connection Error."); } // Test authentication p4.logout(); // invalidate any earlier ticket before test. if (!p4.login()) { return FormValidation .error("Authentication Error: Unable to login."); } // 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 | 11337 | Paul Allen | Merge down latest changes from MAIN | ||
#1 | 11053 | Paul Allen | Branching using p4-jenkins | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/credentials/P4PasswordImpl.java | |||||
#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 |