• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3642

23 Oct 2023 02:33PM UTC coverage: 75.784% (+1.4%) from 74.413%
#3642

push

web-flow
Sonar code smell issue fixes (#4450)

Signed-off-by: Gino Augustine <ginoaugustine@gmail.com>

200 of 200 new or added lines in 39 files covered. (100.0%)

44390 of 58574 relevant lines covered (75.78%)

0.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.25
/plugins/src/main/java/opengrok/auth/plugin/entity/User.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
22
 */
23
package opengrok.auth.plugin.entity;
24

25
import java.util.Date;
26
import java.util.HashMap;
27
import java.util.Map;
28

29
public class User {
30

31
    private String id;
32
    private String username;
33
    private Date cookieTimestamp;
34
    private boolean timeouted;
35
    private final Map<String, Object> attrs = new HashMap<>();
1✔
36

37
    public User(String username) {
1✔
38
        this.username = username;
1✔
39
    }
1✔
40

41
    /**
42
     * Construct User object.
43
     * @param username username
44
     * @param id user ID
45
     */
46
    public User(String username, String id) {
1✔
47
        this.username = username;
1✔
48
        this.id = id;
1✔
49
    }
1✔
50

51
    /**
52
     * Construct User object.
53
     * @param username username
54
     * @param id user ID
55
     * @param cookieTimestamp cookie time stamp
56
     * @param timeouted is the user timed out
57
     */
58
    public User(String username, String id, Date cookieTimestamp, boolean timeouted) {
59
        this(username, id);
1✔
60
        this.cookieTimestamp = cookieTimestamp;
1✔
61
        this.timeouted = timeouted;
1✔
62
    }
1✔
63

64
    public String getId() {
65
        return id;
1✔
66
    }
67

68
    public void setId(String id) {
69
        this.id = id;
×
70
    }
×
71

72
    public String getUsername() {
73
        return username;
1✔
74
    }
75

76
    public void setUsername(String username) {
77
        this.username = username;
×
78
    }
×
79

80
    public Date getCookieTimestamp() {
81
        return cookieTimestamp;
1✔
82
    }
83

84
    public void setCookieTimestamp(Date cookieTimestamp) {
85
        this.cookieTimestamp = cookieTimestamp;
×
86
    }
×
87

88
    public boolean getTimeouted() {
89
        return isTimeouted();
×
90
    }
91

92
    public void setTimeouted(boolean timeouted) {
93
        this.timeouted = timeouted;
×
94
    }
×
95

96
    public boolean isTimeouted() {
97
        return timeouted;
1✔
98
    }
99

100
    /**
101
     * Implemented for the forced authentication as described in
102
     * <a href="https://docs.oracle.com/cd/B28196_01/idmanage.1014/b15997/mod_osso.htm#i1006381">mod_osso documentation</a>.
103
     *
104
     * @param forcedAuthDate the date of the forced authentication trigger
105
     * @param newLoginDate the date of the new login
106
     * @return true if login date was before forced auth date or cookie timestamp
107
     */
108
    public boolean isForcedTimeouted(Date forcedAuthDate, Date newLoginDate) {
109
        if (cookieTimestamp == null || forcedAuthDate == null || newLoginDate == null) {
×
110
            return true;
×
111
        }
112

113
        return newLoginDate.before(forcedAuthDate) || newLoginDate.before(cookieTimestamp);
×
114
    }
115

116
    /**
117
     * Get custom user property.
118
     *
119
     * @param key the key
120
     * @return the the value associated with the key
121
     */
122
    public Object getAttribute(String key) {
123
        return attrs.get(key);
×
124
    }
125

126
    /**
127
     * Set custom user property.
128
     *
129
     * @param key the key
130
     * @param value the value
131
     * @return the value previously associated with the key
132
     */
133
    public Object setAttribute(String key, Object value) {
134
        return attrs.put(key, value);
1✔
135
    }
136

137
    /**
138
     * Remote custom user property.
139
     *
140
     * @param key the key
141
     * @return the value previously associated with the key
142
     */
143
    public Object removeAttribute(String key) {
144
        return attrs.remove(key);
×
145
    }
146

147
    @Override
148
    public String toString() {
149
        return "User{" + "id=" + id + ", username=" + username + ", cookieTimestamp=" + cookieTimestamp +
1✔
150
                ", timeouted=" + timeouted + ", attrs=" + attrs + '}';
151
    }
152
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc