Skip to content

Package: Credentials

Credentials

nameinstructionbranchcomplexitylinemethod
userAndPassword(String, String)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
userAndPassword(String, char[])
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2020 Red Hat Inc and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Red Hat Inc - initial API and implementation
11: *******************************************************************************/
12: package org.eclipse.kapua.client.gateway;
13:
14: /**
15: * Utility class for credentials
16: */
17: public final class Credentials {
18:
19: private Credentials() {
20: }
21:
22: public static class UserAndPassword {
23:
24: private final String username;
25: private final char[] password;
26:
27: private UserAndPassword(final String username, final char[] password) {
28: this.username = username;
29: this.password = password;
30: }
31:
32: public String getUsername() {
33: return username;
34: }
35:
36: public char[] getPassword() {
37: return password;
38: }
39:
40: public String getPasswordAsString() {
41: if (password == null) {
42: return null;
43: }
44:
45: return String.valueOf(password);
46: }
47: }
48:
49: public static UserAndPassword userAndPassword(final String username, final String password) {
50:• return new UserAndPassword(username, password != null ? password.toCharArray() : null);
51: }
52:
53: public static UserAndPassword userAndPassword(final String username, final char[] password) {
54: return new UserAndPassword(username, password);
55: }
56: }