Skip to content

Package: UsernamePasswordCredential

UsernamePasswordCredential

nameinstructionbranchcomplexitylinemethod
UsernamePasswordCredential(String, Password)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
UsernamePasswordCredential(String, String)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
clearCredential()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
compareTo(String, String)
M: 14 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCaller()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPassword()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPasswordAsString()
M: 5 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) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package jakarta.security.enterprise.credential;
18:
19: /**
20: * Represents the credentials typically used by standard caller name/password authentication.
21: */
22: public class UsernamePasswordCredential extends AbstractClearableCredential {
23:
24: private final String caller;
25: private final Password password;
26:
27: /**
28: * Constructor.
29: *
30: * @param callerName The caller name
31: * @param password The password, as a String
32: */
33: public UsernamePasswordCredential(String callerName, String password) {
34: this.caller = callerName;
35: this.password = new Password(password);
36: }
37:
38: /**
39: * Constructor.
40: *
41: * @param callerName The caller name
42: * @param password The password
43: */
44: public UsernamePasswordCredential(String callerName, Password password) {
45: this.caller = callerName;
46: this.password = password;
47: }
48:
49: /**
50: * Determines the password.
51: * @return The password.
52: */
53: public Password getPassword() {
54: return password;
55: }
56:
57: /**
58: * Determines the password.
59: * @return The password, as a String.
60: */
61: public String getPasswordAsString() {
62: return String.valueOf(getPassword().getValue());
63: }
64:
65: @Override
66: public void clearCredential() {
67: password.clear();
68: }
69:
70: public String getCaller() {
71: return caller;
72: }
73:
74: public boolean compareTo(String callerName, String password) {
75:• return getCaller().equals(callerName) && getPassword().compareTo(password);
76: }
77:
78: }