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 jenkins.model.Jenkins; 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.QueryParameter; import org.kohsuke.stapler.verb.POST; import javax.servlet.ServletException; import java.io.IOException; public class P4TicketImpl extends P4BaseCredentials implements P4Ticket { /** * Ensure consistent serialisation. */ private static final long serialVersionUID = 1L; @CheckForNull private final TicketModeImpl ticket; @DataBoundConstructor public P4TicketImpl(CredentialsScope scope, String id, String description, @NonNull String p4port, TrustImpl ssl, @NonNull String username, @CheckForNull String retry, @CheckForNull String timeout, @CheckForNull String p4host, TicketModeImpl ticket) { super(scope, id, description, p4port, ssl, username, retry, timeout, p4host); this.ticket = ticket; } @CheckForNull public String getTicketValue() { return (ticket == null) ? "" : ticket.getTicketValue(); } public boolean isTicketValueSet() { return (ticket == null) ? false : ticket.isTicketValueSet(); } @CheckForNull public String getTicketPath() { return (ticket == null) ? "" : ticket.getTicketPath(); } public boolean isTicketPathSet() { return (ticket == null) ? false : ticket.isTicketPathSet(); } @Extension @Symbol("ticket") public static class DescriptorImpl extends BaseStandardCredentialsDescriptor { @Override public String getDisplayName() { return "Perforce Ticket 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(); } @POST public FormValidation doTestConnection(@QueryParameter("p4port") String p4port, @QueryParameter("ssl") String ssl, @QueryParameter("trust") String trust, @QueryParameter("username") String username, @QueryParameter("p4host") String p4host, @QueryParameter("ticket") String value, @QueryParameter("ticketValue") String ticketValue, @QueryParameter("ticketPath") String ticketPath) throws IOException, ServletException { if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return FormValidation.warning("Insufficient permissions"); } try { // Test connection path to Server TrustImpl sslTrust = ("true".equals(ssl)) ? new TrustImpl(trust) : null; TicketModeImpl ticket = new TicketModeImpl(value, ticketValue, ticketPath); P4TicketImpl test = new P4TicketImpl(null, null, null, p4port, sslTrust, username, null, null, p4host, ticket); 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 // Do not logout, before test (preserve tickets) 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: " + e.getMessage()); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#20 | 27768 | Paul Allen | SECURITY-2327 | ||
#19 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#18 | 21154 | Paul Allen | P4HOST support for connection. | ||
#17 | 20980 | Paul Allen |
Functional test upgrade. Switched to RSH pipe for Perforce connection and upgraded to 15.1 P4D binaries. Made use of ClassRule for Jenkins (faster startup) and a Rule for Perforce with separate roots (to allow for parallel test runs). |
||
#16 | 20598 | Paul Allen |
P4Credentials Interfaces for Mixins. Updated test cases to match changes from CredentialsNameProvider. @stephenc |
||
#15 | 19716 | Paul Allen | Login error to include exception message. | ||
#14 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#13 | 16502 | Paul Allen |
Advanced Credentials option for RPC_SOCKET_SO_TIMEOUT_NICK JENKINS-31196 |
||
#12 | 15656 | Paul Allen |
Updated credentials to extend BaseStandardCredentials. Allows users to set the ID at creation. JENKINS-29702 |
||
#11 | 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. |
||
#10 | 12157 | Paul Allen | minor - serialisation cleanup and pin p4java in the POM | ||
#9 | 11163 | Paul Allen | Removed unused imports. | ||
#8 | 11157 | Paul Allen |
Remove `@NameWith` annotation The 1.19 Credential release fixes the issue. JENKINS-25682 |
||
#7 | 11142 | Paul Allen |
Remove redundant code for Credential name fix Only the `@NameWith` annotation is required to report the Credential name. JENKINS-25682 |
||
#6 | 11132 | Paul Allen |
Fix Credential name for Template plugin Added `@NameWith` annotation to allow the implementation to override the reported Credential name. JENKINS-25682 |
||
#5 | 10031 | Paul Allen |
Test URI path before connection. Report Perforce Errors and Trust fingerprint if using SSL. |
||
#4 | 10012 | Paul Allen |
Do not logout, before test (preserve tickets) https://github.com/p4paul/p4-jenkins/issues/6 |
||
#3 | 9977 | Paul Allen |
Serialisation fix for Credentials Missing `Serializable` implementation https://issues.jenkins-ci.org/browse/JENKINS-24188 |
||
#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/P4TicketImpl.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/P4TicketImpl.java | |||||
#10 | 9428 | Paul Allen |
Clarification of Polling Filters in UX and UserGuide - Tidyup unused imports |
||
#9 | 9032 | Paul Allen |
Perforce Credentials help and form validation checks for misuse of 'ssl:' on P4PORT. (TPI-107) |
||
#8 | 8888 | Paul Allen |
Extended test coverage for Workspace and Credentials. - Removed ununsed methods. |
||
#7 | 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 |
||
#6 | 8742 | Paul Allen | Added SSL support to "Test Connection" button for Perforce Credentials. | ||
#5 | 8741 | Paul Allen |
Added "Test Connection" to Perforce Password and Ticket Credentials. Does not support SSL connections...yet |
||
#4 | 8737 | Paul Allen |
Added basic Help for SCM Configuration page. Tidy up descriptions and fix (null:null) in Credential summary. |
||
#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. |