package org.jenkinsci.plugins.p4_client.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.client.ConnectionHelper; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import com.cloudbees.plugins.credentials.CredentialsDescriptor; 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 { 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); p4.login(); p4.logout(); if (!p4.login()) { return FormValidation .error("Authentication Error: Unable to login."); } 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: " + e.getMessage()); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#14 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#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 |