Class HALMConnection

    • Constructor Detail

      • HALMConnection

        @DataBoundConstructor
        public HALMConnection​(String connectionUUID,
                              String connectionName,
                              String halmAPIAddress,
                              String credentialsID)
        Constructor.
        Parameters:
        connectionUUID - - Unique connection ID
        connectionName - - the (hopefully unique) connection name.
        halmAPIAddress - - Helix ALM API REST API address
        credentialsID - - ID of the credentials
    • Method Detail

      • getConnectionUUID

        public String getConnectionUUID()
        Returns:
        Unique, unfriendly, connection ID
      • getConnectionName

        public String getConnectionName()
        Returns:
        Friendly connection name. May be empty. Maybe a duplicate of another connection. Prefer this (if it exists) when generating Pipeline syntax.
      • setConnectionName

        @DataBoundSetter
        public final void setConnectionName​(String connectionName)
        Parameters:
        connectionName - New connection ID to set
      • getHalmAPIAddress

        public String getHalmAPIAddress()
        Returns:
        Helix ALM REST API address
      • setHalmAPIAddress

        @DataBoundSetter
        public final void setHalmAPIAddress​(String halmAPIAddress)
        Parameters:
        halmAPIAddress - Helix ALM REST API address
      • getCredentialTypeValue

        public String getCredentialTypeValue()
        Returns:
        Credential type, for use w/ setting the global config dropdown
      • setCredentialTypeValue

        @DataBoundSetter
        public final void setCredentialTypeValue​(String credentialType)
        Parameters:
        credentialType - Credential type, as set on the global config dropdown.
      • getCredentialsType

        public com.perforce.halm.reportingtool.APIAuthType getCredentialsType()
        Returns:
        Type of credentials (basic vs API Key)
      • setCredentialType

        public void setCredentialType​(com.perforce.halm.reportingtool.APIAuthType credentialType)
        Parameters:
        credentialType - Type of credentials (basic vs API Key)
      • getCredentialsID

        public String getCredentialsID()
        Returns:
        ID of the credentials as stored in the Credentials plugin
      • setCredentialsID

        @DataBoundSetter
        public final void setCredentialsID​(String credentialsID)
        Parameters:
        credentialsID - ID of the credentials as stored in the Credentials plugin
      • setAcceptSSLCertificates

        @DataBoundSetter
        public final void setAcceptSSLCertificates​(boolean acceptSSLCertificates)
        This is left for legacy support when 'AcceptSSLCertificates' was a top-level property. Old configurations may be saved with this setting and they need this function to self-upgrade the configuration.
        Parameters:
        acceptSSLCertificates - Are we accepting SSL certificates
      • getAcceptSSLCertificates

        public final boolean getAcceptSSLCertificates()
        This is here due to what looks like an odd bug in Jenkins? I would expect HALMConnection.OptionalConnectionProps to be invoked to retrieve this information, however the setting did not appear to be populated in the UI until I added this.
        Returns:
        Returns the current setting for 'acceptSSLCertificates'
      • getOptionalConnectionPropsIsSet

        public boolean getOptionalConnectionPropsIsSet()
        This governs if the 'optional' checkbox is checked or not.
        Returns:
        Is the optional connection props set?
      • setOptionalConnectionProps

        @DataBoundSetter
        public void setOptionalConnectionProps​(HALMConnection.OptionalConnectionProps optionalConnectionProps)
        Sets the optional connection properties
        Parameters:
        optionalConnectionProps - Optional connection properties to set.
      • getAcceptedSSLCertificates

        public List<String> getAcceptedSSLCertificates()
        Returns:
        List of accepted SSL certificates.
      • setAcceptedSSLCertificates

        @DataBoundSetter
        public void setAcceptedSSLCertificates​(List<String> acceptedSSLCertificates)
        Parameters:
        acceptedSSLCertificates - Set list of accepted SSL certificates
      • saveAcceptedSSLCertificates

        public void saveAcceptedSSLCertificates()
                                         throws IOException
        Saves a new set of accepted SSL certificates. This should only be called if the SSL certificates have changed.
        Throws:
        IOException - Something went wrong while writing the certificates to the file.
      • saveAcceptedSSLCertificates

        public static void saveAcceptedSSLCertificates​(String connectionUUID,
                                                       String connectionName,
                                                       List<String> acceptedSSLCertificates)
                                                throws IOException
        Saves a new set of accepted SSL certificates. This should only be called if the SSL certificates have changed.
        Parameters:
        connectionUUID - UUID for the connection. This may be null.
        connectionName - Connection name. This may NOT be null.
        acceptedSSLCertificates - List of certificates that have been accepted and need to be saved.
        Throws:
        IOException - Something went wrong while writing the certificates to the file.
      • readResolve

        protected Object readResolve()
        This allows upgrading old, saved XML configuration values to the current format.
        Returns:
        The newly resolved // read in object.
      • getCredentialDetails

        public HALMConnection.CredentialDetailsResult getCredentialDetails()
        Retrieves credential info (username // password)
        Returns:
        A CredentialDetailsResult object with either the credentials, or an error.
      • getCredentialDetails

        public static HALMConnection.CredentialDetailsResult getCredentialDetails​(String credentialsID)
        Retrieves credential info (username // password)
        Parameters:
        credentialsID - Jenkins Credentials ID
        Returns:
        A CredentialDetailsResult object with either the credentials, or an error.
      • getAuthInfo

        public HALMConnection.AuthInfoResult getAuthInfo()
        We need to check for a variety of conditions while parsing the credentials. This handles all the odd edge cases and ensures we handle and return appropriate errors.
        Returns:
        An authorization info result which either contains the auth info, or an error message indicating failure.
      • getAuthInfo

        protected static HALMConnection.AuthInfoResult getAuthInfo​(com.perforce.halm.reportingtool.APIAuthType authType,
                                                                   String credentialsID)
        We need to check for a variety of conditions while parsing the credentials. This handles all the odd edge cases and ensures we handle and return appropriate errors.
        Parameters:
        authType - Authorization type (API Key vs Basic)
        credentialsID - Jenkins Credentials ID
        Returns:
        An authorization info result which either contains the auth info, or an error message indicating failure.
      • getConnectionInfo

        public HALMConnection.ConnectionInfoResult getConnectionInfo()
        Build a Helix ALM REST API 'ConnectionInfo' object based on this HALMConnection's settings.
        Returns:
        Various things can go wrong while building the ConnectionInfo. Check the 'IsError' on the result to ensure we successfully built a ConnectionInfo object.
      • isHTTPSConnection

        public boolean isHTTPSConnection()
        Does this HALMConnection reference an HTTPS server?
        Returns:
        True if this references an HTTPS Helix ALM REST API server
      • isHTTPSConnection

        public static boolean isHTTPSConnection​(String apiURL)
        Does the supplied API URL reference an HTTPS server?
        Parameters:
        apiURL - URL to check
        Returns:
        True if this references an HTTPS server
      • getOrRetrieveSSLCertificates

        public List<String> getOrRetrieveSSLCertificates()
        This will either return the currently saved SSL Certificates or it will download new certificates that should work to connect to the configured Helix ALM REST API server.
        Returns:
        List of PEM encoded SSL certificates
      • retrieveSSLCertificates

        public HALMConnection.CertificateResult retrieveSSLCertificates()
        Connect to the configured Helix ALM REST API address and attempt to download the server's SSL certificates.
        Returns:
        The certificate result object. Check 'isError' to see if the request was a success.
      • retrieveSSLCertificates

        public static HALMConnection.CertificateResult retrieveSSLCertificates​(String halmAPIAddress,
                                                                               String connectionName,
                                                                               boolean acceptSSLCertificates,
                                                                               List<String> currentCertificates)
        Connect to the specified Helix ALM REST API address and attempt to download the server's SSL certificates.
        Parameters:
        halmAPIAddress - Helix ALM REST API address.
        connectionName - HALM Connection name in Jenkins (used for logging)
        acceptSSLCertificates - Is the HALM Connection supposed to 'acceptSSLCertificates'?
        currentCertificates - List of the current SSL Certificates.
        Returns:
        The certificate result object. Check 'isError' to see if the request was a success.