All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.petstore3.authentication.CustomHeaderAuthenticationManager Maven / Gradle / Ivy

/*
 * SwaggerPetstoreOpenAPI30Lib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

package io.swagger.petstore3.authentication;

import io.apimatic.core.authentication.HeaderAuth;
import io.swagger.petstore3.CustomHeaderAuthenticationCredentials;
import java.util.HashMap;

public class CustomHeaderAuthenticationManager extends HeaderAuth implements CustomHeaderAuthenticationCredentials {

    /**
     * Private instance of the auth model containing the auth credentials.
     */
    private CustomHeaderAuthenticationModel authModel;

    /**
     * Constructor that sets custom header parameters.
     */
    public CustomHeaderAuthenticationManager(CustomHeaderAuthenticationModel authModel) {

        super(new HashMap() {
            private static final long serialVersionUID = 1L;
            {
                put("api_key", authModel.getApiKey());
            }
        });

        this.authModel = authModel;
    }

    /**
     * String value for apiKey.
     * @return apiKey
     */
    public String getApiKey() {
        return authModel.getApiKey();
    }

    /**
     * Checks if provided credentials matched with existing ones.
     * @param apiKey String value for credentials.
     * @return true if credentials matched.
     */
    public boolean equals(String apiKey) {
        return apiKey.equals(getApiKey());
    }

    /**
     * Converts this CustomHeaderAuthenticationManager into string format.
     * @return String representation of this class
     */
    @Override
    public String toString() {
        return "CustomHeaderAuthenticationManager [" + "apiKey=" + getApiKey() + "]";
    }
    /**
    * Returns the error message if the auth credentials are not valid.
    * @return the auth specific error message.
    */
    @Override
    public String getErrorMessage() {
        String errorMessage = super.getErrorMessage();
        if (errorMessage == null) {
            return null;
        }

        return "CustomHeaderAuthentication - " + errorMessage;
     }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy