001/*******************************************************************************
002 * Copyright (c) 2017 Red Hat Inc and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Red Hat Inc - initial API and implementation
011 *******************************************************************************/
012package org.eclipse.kapua.gateway.client;
013
014public final class Credentials {
015
016    private Credentials() {
017    }
018
019    public static class UserAndPassword {
020
021        private final String username;
022        private final char[] password;
023
024        private UserAndPassword(final String username, final char[] password) {
025            this.username = username;
026            this.password = password;
027        }
028
029        public String getUsername() {
030            return this.username;
031        }
032
033        public char[] getPassword() {
034            return this.password;
035        }
036
037        public String getPasswordAsString() {
038            return String.valueOf(password);
039        }
040    }
041
042    public static UserAndPassword userAndPassword(final String username, final String password) {
043        return new UserAndPassword(username, password.toCharArray());
044    }
045
046    public static UserAndPassword userAndPassword(final String username, final char[] password) {
047        return new UserAndPassword(username, password);
048    }
049}