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

Waffle / waffle / 6364

01 Feb 2026 02:07AM UTC coverage: 46.217%. Remained the same
6364

push

github

web-flow
Merge pull request #3206 from Waffle/renovate/checkstyle.version

Update dependency com.puppycrawl.tools:checkstyle to v13.1.0

276 of 734 branches covered (37.6%)

Branch coverage included in aggregate %.

1019 of 2068 relevant lines covered (49.27%)

1.0 hits per line

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

22.22
/Source/JNA/waffle-jna/src/main/java/waffle/servlet/spi/BasicSecurityFilterProvider.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6
 */
7
package waffle.servlet.spi;
8

9
import java.io.IOException;
10
import java.nio.charset.StandardCharsets;
11
import java.security.InvalidParameterException;
12

13
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpServletResponse;
15

16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

19
import waffle.util.AuthorizationHeader;
20
import waffle.windows.auth.IWindowsAuthProvider;
21
import waffle.windows.auth.IWindowsIdentity;
22

23
/**
24
 * A Basic authentication security filter provider. https://tools.ietf.org/html/rfc2617
25
 */
26
public class BasicSecurityFilterProvider implements SecurityFilterProvider {
27

28
    /** The Constant LOGGER. */
29
    private static final Logger LOGGER = LoggerFactory.getLogger(BasicSecurityFilterProvider.class);
2✔
30

31
    /** The realm. */
32
    private String realm = "BasicSecurityFilterProvider";
2✔
33

34
    /** The auth. */
35
    private final IWindowsAuthProvider auth;
36

37
    /**
38
     * Instantiates a new basic security filter provider.
39
     *
40
     * @param newAuthProvider
41
     *            the new auth provider
42
     */
43
    public BasicSecurityFilterProvider(final IWindowsAuthProvider newAuthProvider) {
2✔
44
        this.auth = newAuthProvider;
2✔
45
    }
2✔
46

47
    @Override
48
    public IWindowsIdentity doFilter(final HttpServletRequest request, final HttpServletResponse response)
49
            throws IOException {
50

51
        final AuthorizationHeader authorizationHeader = new AuthorizationHeader(request);
×
52
        final String usernamePassword = new String(authorizationHeader.getTokenBytes(), StandardCharsets.UTF_8);
×
53
        final String[] usernamePasswordArray = usernamePassword.split(":", 2);
×
54
        if (usernamePasswordArray.length != 2) {
×
55
            throw new RuntimeException("Invalid username:password in Authorization header.");
×
56
        }
57
        BasicSecurityFilterProvider.LOGGER.debug("logging in user: {}", usernamePasswordArray[0]);
×
58
        return this.auth.logonUser(usernamePasswordArray[0], usernamePasswordArray[1]);
×
59
    }
60

61
    @Override
62
    public boolean isPrincipalException(final HttpServletRequest request) {
63
        return false;
×
64
    }
65

66
    @Override
67
    public boolean isSecurityPackageSupported(final String securityPackage) {
68
        return "Basic".equalsIgnoreCase(securityPackage);
2✔
69
    }
70

71
    @Override
72
    public void sendUnauthorized(final HttpServletResponse response) {
73
        response.addHeader("WWW-Authenticate", "Basic realm=\"" + this.realm + "\"");
×
74
    }
×
75

76
    /**
77
     * Protection space.
78
     *
79
     * @return Name of the protection space.
80
     */
81
    public String getRealm() {
82
        return this.realm;
×
83
    }
84

85
    /**
86
     * Set the protection space.
87
     *
88
     * @param value
89
     *            Protection space name.
90
     */
91
    public void setRealm(final String value) {
92
        this.realm = value;
×
93
    }
×
94

95
    /**
96
     * Init configuration parameters.
97
     *
98
     * @param parameterName
99
     *            the parameter name
100
     * @param parameterValue
101
     *            the parameter value
102
     */
103
    @Override
104
    public void initParameter(final String parameterName, final String parameterValue) {
105
        if ("realm".equals(parameterName)) {
×
106
            this.setRealm(parameterValue);
×
107
        } else {
108
            throw new InvalidParameterException(parameterName);
×
109
        }
110
    }
×
111
}
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