001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 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 * Contributors: 017 * Florent Guillaume 018 */ 019 020package org.nuxeo.ecm.core.storage; 021 022/** 023 * Simple username + password. 024 * 025 * @author Florent Guillaume 026 */ 027public final class Credentials { 028 029 private final String username; 030 031 private final String password; 032 033 public Credentials(String username, String password) { 034 this.username = username; 035 this.password = password; 036 } 037 038 public String getUserName() { 039 return username; 040 } 041 042 public String getPassword() { 043 return password; 044 } 045 046 @Override 047 public int hashCode() { 048 int result = 31 + ((username == null) ? 0 : username.hashCode()); 049 return 31 * result + ((password == null) ? 0 : password.hashCode()); 050 } 051 052 @Override 053 public boolean equals(Object other) { 054 if (other == this) { 055 return true; 056 } 057 if (other instanceof Credentials) { 058 return equals((Credentials) other); 059 } 060 return false; 061 } 062 063 private boolean equals(Credentials other) { 064 if (username == null) { 065 if (other.username != null) { 066 return false; 067 } 068 } else if (!username.equals(other.username)) { 069 return false; 070 } 071 if (password == null) { 072 if (other.password != null) { 073 return false; 074 } 075 } else if (!password.equals(other.password)) { 076 return false; 077 } 078 return true; 079 } 080 081}