1 | /*- | |
2 | * #%L | |
3 | * io.earcam.utilitarian.security | |
4 | * %% | |
5 | * Copyright (C) 2017 earcam | |
6 | * %% | |
7 | * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT) | |
8 | * | |
9 | * You <b>must</b> choose to accept, in full - any individual or combination of | |
10 | * the following licenses: | |
11 | * <ul> | |
12 | * <li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li> | |
13 | * <li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li> | |
14 | * <li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li> | |
15 | * <li><a href="https://opensource.org/licenses/MIT">MIT</a></li> | |
16 | * </ul> | |
17 | * #L% | |
18 | */ | |
19 | package io.earcam.utilitarian.security; | |
20 | ||
21 | import java.util.Arrays; | |
22 | import java.util.Objects; | |
23 | ||
24 | import javax.security.auth.Destroyable; | |
25 | ||
26 | /** | |
27 | * Implements {@link AutoCloseable} to provoke compiler warnings, where the | |
28 | * implementation of {@link #close()} calls {@link #destroy()} | |
29 | * | |
30 | */ | |
31 | public class Credential implements Destroyable, AutoCloseable { | |
32 | ||
33 | private String name; | |
34 | private char[] password; | |
35 | ||
36 | ||
37 | public Credential(String name, char[] password) | |
38 | { | |
39 | Objects.requireNonNull(name, "name"); | |
40 | this.name = name; | |
41 | this.password = password; | |
42 | } | |
43 | ||
44 | ||
45 | @Override | |
46 | public void destroy() | |
47 | { | |
48 | name = null; | |
49 |
1
1. destroy : removed call to java/util/Arrays::fill → SURVIVED |
Arrays.fill(password, ' '); |
50 | password = null; | |
51 | } | |
52 | ||
53 | ||
54 | @Override | |
55 | public boolean isDestroyed() | |
56 | { | |
57 |
2
1. isDestroyed : negated conditional → KILLED 2. isDestroyed : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return name == null; |
58 | } | |
59 | ||
60 | ||
61 | public String name() | |
62 | { | |
63 |
1
1. name : mutated return of Object value for io/earcam/utilitarian/security/Credential::name to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return name; |
64 | } | |
65 | ||
66 | ||
67 | public char[] password() | |
68 | { | |
69 |
1
1. password : mutated return of Object value for io/earcam/utilitarian/security/Credential::password to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return password; |
70 | } | |
71 | ||
72 | ||
73 | @Override | |
74 | public void close() | |
75 | { | |
76 |
1
1. close : removed call to io/earcam/utilitarian/security/Credential::destroy → KILLED |
destroy(); |
77 | } | |
78 | } | |
Mutations | ||
49 |
1.1 |
|
57 |
1.1 2.2 |
|
63 |
1.1 |
|
69 |
1.1 |
|
76 |
1.1 |