001/*
002 * Copyright (C) 2022-2023 The Prometheus jmx_exporter Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package io.prometheus.jmx.common.http.authenticator;
018
019import java.util.Objects;
020
021public class CacheKey {
022
023    private final String username;
024    private final String password;
025
026    /**
027     * Constructor
028     *
029     * @param username username
030     * @param password password
031     */
032    public CacheKey(String username, String password) {
033        this.username = username;
034        this.password = password;
035    }
036
037    @Override
038    public String toString() {
039        return String.format("CacheKey{username=[%s],password=[%s]}", username, password);
040    }
041
042    @Override
043    public boolean equals(Object o) {
044        if (this == o) return true;
045        if (o == null || getClass() != o.getClass()) return false;
046        CacheKey cacheKey = (CacheKey) o;
047        return Objects.equals(username, cacheKey.username) && Objects.equals(password, cacheKey.password);
048    }
049
050    @Override
051    public int hashCode() {
052        return Objects.hash(username, password);
053    }
054}