2 * Copyright (c) 2014, 2017 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.aaa.shiro.tokenauthrealm.auth;
10 import java.util.Objects;
11 import org.opendaylight.aaa.api.PasswordCredentials;
14 * {@link PasswordCredentials} builder.
18 public class PasswordCredentialBuilder {
19 private final MutablePasswordCredentials pc = new MutablePasswordCredentials();
21 public PasswordCredentialBuilder setUserName(String username) {
22 pc.username = username;
26 public PasswordCredentialBuilder setPassword(String password) {
27 pc.password = password;
31 public PasswordCredentialBuilder setDomain(String domain) {
36 public PasswordCredentials build() {
40 private static class MutablePasswordCredentials implements PasswordCredentials {
41 private int hashCode = 0;
42 private String username;
43 private String password;
44 private String domain;
47 public String username() {
52 public String password() {
57 public String domain() {
62 public boolean equals(Object object) {
66 if (!(object instanceof PasswordCredentials)) {
69 PasswordCredentials passwordCredentials = (PasswordCredentials) object;
70 return Objects.equals(username, passwordCredentials.username())
71 && Objects.equals(password, passwordCredentials.password());
75 public int hashCode() {
77 hashCode = Objects.hash(username, password);