Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

OpenWiseSolutions / openhub-framework / 1198

4 Feb 2021 - 14:46 coverage decreased (-0.5%) to 70.196%
1198

Pull #129

travis-ci

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
Merge b150e80af into 382999a38
Pull Request #129: [OHFJIRA-85]: Upgrade to Spring Boot 2.0.9.RELEASE

23 of 66 new or added lines in 12 files covered. (34.85%)

28 existing lines in 4 files now uncovered.

4329 of 6167 relevant lines covered (70.2%)

0.7 hits per line

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

40.0
/web/src/main/java/org/openhubframework/openhub/web/common/OhfBasicAuthenticationEntryPoint.java
1
/*
2
 * Copyright 2002-2021 the original author or authors.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package org.openhubframework.openhub.web.common;
18

19
import org.springframework.beans.factory.annotation.Value;
20
import org.springframework.security.core.AuthenticationException;
21
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
22
import org.springframework.stereotype.Component;
23

24
import javax.servlet.ServletException;
25
import javax.servlet.http.HttpServletRequest;
26
import javax.servlet.http.HttpServletResponse;
27
import java.io.IOException;
28
import java.io.PrintWriter;
29

30
@Component
31
public class OhfBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
1×
32

33
    @Value("${security.realm.realm-name}")
34
    private String realmName;
35

36
    /**
37
     * WWW-Authenticate header name.
38
     */
39
    static final String WWW_AUTHENTICATE_HEADER = "WWW-Authenticate";
40

41
    @Override
42
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
NEW
43
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
!
NEW
44
        response.addHeader(
!
NEW
45
                WWW_AUTHENTICATE_HEADER, "Basic realm=\"" + getRealmName() + "\"");
!
NEW
46
        PrintWriter writer = response.getWriter();
!
NEW
47
        writer.println("HTTP Status 401 - " + authException.getMessage());
!
NEW
48
    }
!
49

50
    @Override
51
    public void afterPropertiesSet() throws Exception {
52
        setRealmName(realmName);
1×
53
        super.afterPropertiesSet();
1×
54
    }
1×
55
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2021 Coveralls, Inc