@eui/cli 15.4.0 → 15.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.version.properties +1 -1
- package/LICENSE +296 -296
- package/README.md +26 -26
- package/bin/eui-cli.js +70 -70
- package/lib/build.js +153 -153
- package/lib/cli.js +111 -111
- package/lib/config.js +54 -54
- package/lib/generators.js +64 -64
- package/lib/install.js +54 -54
- package/lib/maven-build/build.xml +115 -115
- package/lib/maven-build/pom.xml +64 -64
- package/lib/post-build.js +33 -33
- package/lib/skeletons/_angular/base/.browserslistrc +16 -16
- package/lib/skeletons/_angular/base/.editorconfig +16 -16
- package/lib/skeletons/_angular/base/.euirc.json +8 -8
- package/lib/skeletons/_angular/base/.stylelintrc +24 -24
- package/lib/skeletons/_angular/base/README.md +26 -26
- package/lib/skeletons/_angular/base/angular.json +176 -175
- package/lib/skeletons/_angular/base/gitignore_TO_REPLACE +50 -50
- package/lib/skeletons/_angular/base/mock/app/models/user.js +8 -8
- package/lib/skeletons/_angular/base/mock/app/routes/index.js +5 -5
- package/lib/skeletons/_angular/base/mock/app/routes/user_routes.js +24 -24
- package/lib/skeletons/_angular/base/mock/db/db.json +12 -12
- package/lib/skeletons/_angular/base/mock/server.js +21 -21
- package/lib/skeletons/_angular/base/package.json +24 -24
- package/lib/skeletons/_angular/base/proxy-mock.conf.json +6 -6
- package/lib/skeletons/_angular/base/proxy.conf.json +6 -6
- package/lib/skeletons/_angular/base/src/.eslintrc.json +118 -118
- package/lib/skeletons/_angular/base/src/app/app-routing.module.ts +17 -17
- package/lib/skeletons/_angular/base/src/app/app-starter.service.ts +66 -66
- package/lib/skeletons/_angular/base/src/app/app.component.html +29 -29
- package/lib/skeletons/_angular/base/src/app/app.component.ts +51 -51
- package/lib/skeletons/_angular/base/src/app/app.module.ts +35 -35
- package/lib/skeletons/_angular/base/src/app/core/core.module.ts +87 -87
- package/lib/skeletons/_angular/base/src/app/core/reducers/index.ts +31 -31
- package/lib/skeletons/_angular/base/src/app/features/home/home-routing.module.ts +15 -15
- package/lib/skeletons/_angular/base/src/app/features/home/home.component.html +39 -39
- package/lib/skeletons/_angular/base/src/app/features/home/home.component.ts +11 -11
- package/lib/skeletons/_angular/base/src/app/features/home/home.module.ts +18 -18
- package/lib/skeletons/_angular/base/src/app/features/module1/components/page1/page1.component.html +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module1/components/page1/page1.component.ts +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module1/components/page2/page2.component.html +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module1/components/page2/page2.component.ts +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module1/module1-routing.module.ts +18 -18
- package/lib/skeletons/_angular/base/src/app/features/module1/module1.component.html +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module1/module1.component.ts +8 -8
- package/lib/skeletons/_angular/base/src/app/features/module1/module1.module.ts +21 -21
- package/lib/skeletons/_angular/base/src/app/features/module2/module2-routing.module.ts +16 -16
- package/lib/skeletons/_angular/base/src/app/features/module2/module2.component.html +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module2/module2.component.ts +7 -7
- package/lib/skeletons/_angular/base/src/app/features/module2/module2.module.ts +17 -17
- package/lib/skeletons/_angular/base/src/app/shared/shared.module.ts +45 -45
- package/lib/skeletons/_angular/base/src/app/shared/testing/router.mock.ts +18 -18
- package/lib/skeletons/_angular/base/src/assets/config/env-json-config-dev.json +8 -8
- package/lib/skeletons/_angular/base/src/assets/config/env-json-config-prod.json +8 -8
- package/lib/skeletons/_angular/base/src/assets/config/env-json-config.json +7 -7
- package/lib/skeletons/_angular/base/src/assets/i18n/en.json +6 -6
- package/lib/skeletons/_angular/base/src/assets/i18n/fr.json +6 -6
- package/lib/skeletons/_angular/base/src/config/global.ts +20 -20
- package/lib/skeletons/_angular/base/src/config/index.ts +8 -8
- package/lib/skeletons/_angular/base/src/config/modules.ts +7 -7
- package/lib/skeletons/_angular/base/src/dummy.spec.ts +6 -6
- package/lib/skeletons/_angular/base/src/environments/environment.prod.ts +11 -11
- package/lib/skeletons/_angular/base/src/environments/environment.ts +11 -11
- package/lib/skeletons/_angular/base/src/index.html +21 -21
- package/lib/skeletons/_angular/base/src/karma.conf.js +7 -7
- package/lib/skeletons/_angular/base/src/main.ts +14 -14
- package/lib/skeletons/_angular/base/src/polyfills.ts +89 -89
- package/lib/skeletons/_angular/base/src/styles.scss +1 -1
- package/lib/skeletons/_angular/base/src/tsconfig.app.json +18 -18
- package/lib/skeletons/_angular/base/src/tsconfig.spec.json +14 -14
- package/lib/skeletons/_angular/base/tsconfig.json +27 -27
- package/lib/skeletons/_angular/base-mobile/angular.json +160 -160
- package/lib/skeletons/_angular/base-mobile/ionic.config.json +5 -5
- package/lib/skeletons/_angular/base-mobile/ngsw-config.json +33 -33
- package/lib/skeletons/_angular/base-mobile/package.json +28 -28
- package/lib/skeletons/_angular/base-mobile/src/app/app-routing.module.ts +17 -17
- package/lib/skeletons/_angular/base-mobile/src/app/app-starter.service.ts +73 -73
- package/lib/skeletons/_angular/base-mobile/src/app/app.component.html +27 -27
- package/lib/skeletons/_angular/base-mobile/src/app/app.component.ts +55 -55
- package/lib/skeletons/_angular/base-mobile/src/app/app.module.ts +44 -44
- package/lib/skeletons/_angular/base-mobile/src/app/core/core.module.ts +89 -89
- package/lib/skeletons/_angular/base-mobile/src/app/core/reducers/index.ts +31 -31
- package/lib/skeletons/_angular/base-mobile/src/app/features/home/home-routing.module.ts +15 -15
- package/lib/skeletons/_angular/base-mobile/src/app/features/home/home.component.html +14 -14
- package/lib/skeletons/_angular/base-mobile/src/app/features/home/home.component.ts +11 -11
- package/lib/skeletons/_angular/base-mobile/src/app/features/home/home.module.ts +18 -18
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/components/page1/page1.component.html +11 -11
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/components/page1/page1.component.ts +7 -7
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/components/page2/page2.component.html +11 -11
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/components/page2/page2.component.ts +7 -7
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/module1-routing.module.ts +18 -18
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/module1.component.html +15 -15
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/module1.component.ts +17 -17
- package/lib/skeletons/_angular/base-mobile/src/app/features/module1/module1.module.ts +21 -21
- package/lib/skeletons/_angular/base-mobile/src/app/features/module2/module2-routing.module.ts +16 -16
- package/lib/skeletons/_angular/base-mobile/src/app/features/module2/module2.component.html +11 -11
- package/lib/skeletons/_angular/base-mobile/src/app/features/module2/module2.component.ts +7 -7
- package/lib/skeletons/_angular/base-mobile/src/app/features/module2/module2.module.ts +17 -17
- package/lib/skeletons/_angular/base-mobile/src/app/shared/shared.module.ts +16 -16
- package/lib/skeletons/_angular/base-mobile/src/app/shared/testing/router.mock.ts +18 -18
- package/lib/skeletons/_angular/base-mobile/src/index.html +27 -27
- package/lib/skeletons/_angular/base-mobile/src/manifest.webmanifest +51 -51
- package/lib/skeletons/_angular/base-mobile/src/tsconfig.app.json +19 -19
- package/lib/skeletons/_angular/options/ecl/angular.json +193 -193
- package/lib/skeletons/_angular/options/ecl/src/app/app.component.html +262 -262
- package/lib/skeletons/_angular/options/ecl/src/app/app.component.ts +59 -59
- package/lib/skeletons/_angular/options/ecl/src/app/features/home/home.component.html +70 -70
- package/lib/skeletons/_angular/options/ecl/src/app/features/module1/components/page1/page1.component.html +1 -1
- package/lib/skeletons/_angular/options/ecl/src/app/features/module1/components/page2/page2.component.html +1 -1
- package/lib/skeletons/_angular/options/ecl/src/app/features/module1/module1.component.html +1 -1
- package/lib/skeletons/_angular/options/ecl/src/app/features/module2/module2.component.html +1 -1
- package/lib/skeletons/_angular/options/ecl/src/app/shared/shared.module.ts +19 -19
- package/lib/skeletons/_angular/options/ecl/src/config/global.ts +20 -20
- package/lib/skeletons/_angular/options/openid-jwt/package.json +22 -22
- package/lib/skeletons/_angular/options/openid-jwt/src/app/core/core.module.ts +94 -94
- package/lib/skeletons/_angular/options/openid-jwt/src/assets/config/env-json-config-dev.json +24 -24
- package/lib/skeletons/_angular/options/openid-jwt/src/assets/config/env-json-config-local-mock.json +10 -10
- package/lib/skeletons/_angular/options/openid-jwt/src/assets/config/env-json-config-local.json +23 -23
- package/lib/skeletons/_angular/options/openid-jwt/src/assets/config/env-json-config-prod.json +23 -23
- package/lib/skeletons/_angular/options/openid-jwt/src/assets/config/env-json-config.json +10 -10
- package/lib/skeletons/_angular/options/openid-jwt/src/environments/environment.prod.ts +11 -11
- package/lib/skeletons/_angular/options/openid-jwt/src/environments/environment.ts +11 -11
- package/lib/skeletons/_angular/options/openid-jwt/src/index.html +21 -21
- package/lib/skeletons/web-maven/package.json +17 -17
- package/lib/skeletons/web-maven/pom.xml +55 -55
- package/lib/skeletons/web-maven/src/main/java/eu/europa/ec/digit/eui/angular2clistarter/servlet/SpringWebApplicationInitializer.java +22 -22
- package/lib/skeletons/web-maven/src/main/java/eu/europa/ec/digit/eui/angular2clistarter/spring/SpringRestConfiguration.java +24 -24
- package/lib/skeletons/web-maven/src/main/java/eu/europa/ec/digit/eui/angular2clistarter/spring/rest/UserDetailsResource.java +23 -23
- package/lib/skeletons/web-maven/src/main/resources/ecas-config-application-name.xml +7 -7
- package/lib/skeletons/web-maven/src/main/webapp/WEB-INF/dispatcher-servlet.xml +10 -10
- package/lib/skeletons/web-maven/src/main/webapp/WEB-INF/web.xml +38 -38
- package/lib/skeletons/web-maven/src/main/webapp/WEB-INF/weblogic.xml +15 -15
- package/lib/skeletons/web-maven/src/main/webapp/index.jsp +29 -29
- package/lib/skeletons/web-spring-boot/myapp-web/pom.xml +77 -77
- package/lib/skeletons/web-spring-boot/myapp-web-rest/pom.xml +84 -84
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/MyappApplication.java +46 -46
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/domain/Address.java +65 -65
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/domain/Building.java +44 -44
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/repositories/BuildingRepository.java +10 -10
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/resources/BuildingResource.java +26 -26
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/resources/SwaggerConfig.java +20 -20
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/resources/support/HateoasPageableHandlerMethodArgumentResolver.java +45 -45
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/resources/support/HypermediaSupport.java +25 -25
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/resources/support/PageJsonSerializer.java +17 -17
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/security/CachingPreventionFilter.java +29 -29
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/security/CsrfPreventionFilter.java +35 -35
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/security/FakeAuthenticationFilter.java +372 -372
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/security/SecurityConfig.java +47 -47
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/services/BuildingSearchCriteria.java +25 -25
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/services/BuildingService.java +9 -9
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/services/BuildingServiceImpl.java +25 -25
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/resources/data.sql +10 -10
- package/lib/skeletons/web-spring-boot/pom.xml +30 -30
- package/lib/skeletons/web-symfony/myapp-web/angular.json +170 -170
- package/lib/skeletons/web-symfony/myapp-web/package.json +23 -23
- package/lib/skeletons/web-symfony/myapp-web/src/app/app-routing.module.ts +18 -18
- package/lib/skeletons/web-symfony/myapp-web/src/app/app.component.ts +77 -77
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/components/products.component.html +160 -160
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/components/products.component.ts +104 -104
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/models/product.model.ts +6 -6
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/products-routing.module.ts +16 -16
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/products.module.ts +16 -16
- package/lib/skeletons/web-symfony/myapp-web/src/app/features/products/services/products.service.ts +29 -29
- package/lib/skeletons/web-symfony/myapp-web/src/environments/environment.ts +17 -17
- package/lib/skeletons/web-symfony/myapp-web-rest/.env +28 -28
- package/lib/skeletons/web-symfony/myapp-web-rest/bin/console +42 -42
- package/lib/skeletons/web-symfony/myapp-web-rest/composer.json +67 -67
- package/lib/skeletons/web-symfony/myapp-web-rest/composer.lock +3572 -3572
- package/lib/skeletons/web-symfony/myapp-web-rest/config/bootstrap.php +21 -21
- package/lib/skeletons/web-symfony/myapp-web-rest/config/bundles.php +12 -12
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/cache.yaml +19 -19
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/dev/routing.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/doctrine.yaml +29 -29
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/doctrine_migrations.yaml +5 -5
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/framework.yaml +17 -17
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/prod/doctrine.yaml +32 -32
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/routing.yaml +4 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/sensio_framework_extra.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/test/framework.yaml +4 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/test/routing.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/packages/twig.yaml +4 -4
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes/annotations.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes/dev/twig.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/routes.yaml +3 -3
- package/lib/skeletons/web-symfony/myapp-web-rest/config/services.yaml +27 -27
- package/lib/skeletons/web-symfony/myapp-web-rest/public/index.php +27 -27
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Controller/ProductController.php +196 -196
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Entity/Product.php +99 -99
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Kernel.php +53 -53
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Migrations/Version20190604101623.php +31 -31
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Migrations/Version20190604101638.php +35 -35
- package/lib/skeletons/web-symfony/myapp-web-rest/src/Repository/ProductRepository.php +51 -51
- package/lib/skeletons/web-symfony/myapp-web-rest/symfony.lock +274 -274
- package/lib/skeletons/web-symfony/myapp-web-rest/templates/base.html.twig +12 -12
- package/lib/skeletons/web-symfony/myapp-web-rest/templates/product/index.html.twig +20 -20
- package/lib/utils.js +17 -17
- package/package.json +2 -2
|
@@ -1,372 +1,372 @@
|
|
|
1
|
-
package @app.group.id@.@app.name@.security;
|
|
2
|
-
|
|
3
|
-
import com.sun.security.auth.UserPrincipal;
|
|
4
|
-
import org.springframework.security.core.Authentication;
|
|
5
|
-
import org.springframework.security.core.GrantedAuthority;
|
|
6
|
-
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
7
|
-
import org.springframework.security.core.context.SecurityContextHolder;
|
|
8
|
-
import org.springframework.stereotype.Component;
|
|
9
|
-
|
|
10
|
-
import jakarta.servlet.*;
|
|
11
|
-
import jakarta.servlet.http.*;
|
|
12
|
-
import java.io.BufferedReader;
|
|
13
|
-
import java.io.IOException;
|
|
14
|
-
import java.io.UnsupportedEncodingException;
|
|
15
|
-
import java.security.AuthProvider;
|
|
16
|
-
import java.security.Principal;
|
|
17
|
-
import java.util.*;
|
|
18
|
-
|
|
19
|
-
// Filter used to fake user login. This allows for testing different user roles in the same application.
|
|
20
|
-
// WARNING: do NOT use this in production; security will be compromised! For now, it will only be activated from requests coming from localhost.
|
|
21
|
-
@Component
|
|
22
|
-
public class FakeAuthenticationFilter implements Filter {
|
|
23
|
-
@Override
|
|
24
|
-
public void init(FilterConfig filterConfig) throws ServletException {
|
|
25
|
-
// do nothing
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Override
|
|
29
|
-
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
|
30
|
-
final HttpServletRequest request = (HttpServletRequest) servletRequest;
|
|
31
|
-
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
|
32
|
-
|
|
33
|
-
if (!"localhost".equals(request.getServerName())) {
|
|
34
|
-
filterChain.doFilter(request, response);
|
|
35
|
-
} else {
|
|
36
|
-
final String fakeUsername = request.getHeader("x-fake-authentication");
|
|
37
|
-
if (fakeUsername == null) {
|
|
38
|
-
filterChain.doFilter(request, response);
|
|
39
|
-
} else {
|
|
40
|
-
/*
|
|
41
|
-
System.out.println("---------- got fake userid: " + fakeUsername);
|
|
42
|
-
HttpServletRequest fakeRequest = new HttpServletRequest() {
|
|
43
|
-
public Principal getUserPrincipal() {
|
|
44
|
-
return new UserPrincipal(fakeUsername);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Delegate all the other methods:
|
|
48
|
-
public String getAuthType() {
|
|
49
|
-
return request.getAuthType();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public Cookie[] getCookies() {
|
|
53
|
-
return request.getCookies();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public long getDateHeader(String s) {
|
|
57
|
-
return request.getDateHeader(s);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public String getHeader(String s) {
|
|
61
|
-
return request.getHeader(s);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public Enumeration<String> getHeaders(String s) {
|
|
65
|
-
return request.getHeaders(s);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public Enumeration<String> getHeaderNames() {
|
|
69
|
-
return request.getHeaderNames();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public int getIntHeader(String s) {
|
|
73
|
-
return request.getIntHeader(s);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public String getMethod() {
|
|
77
|
-
return request.getMethod();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public String getPathInfo() {
|
|
81
|
-
return request.getPathInfo();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public String getPathTranslated() {
|
|
85
|
-
return request.getPathTranslated();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public String getContextPath() {
|
|
89
|
-
return request.getContextPath();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public String getQueryString() {
|
|
93
|
-
return request.getQueryString();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public String getRemoteUser() {
|
|
97
|
-
return request.getRemoteUser();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public boolean isUserInRole(String s) {
|
|
101
|
-
return request.isUserInRole(s);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public String getRequestedSessionId() {
|
|
105
|
-
return request.getRequestedSessionId();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public String getRequestURI() {
|
|
109
|
-
return request.getRequestURI();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public StringBuffer getRequestURL() {
|
|
113
|
-
return request.getRequestURL();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public String getServletPath() {
|
|
117
|
-
return request.getServletPath();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public HttpSession getSession(boolean b) {
|
|
121
|
-
return request.getSession(b);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public HttpSession getSession() {
|
|
125
|
-
return request.getSession();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public String changeSessionId() {
|
|
129
|
-
return request.changeSessionId();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public boolean isRequestedSessionIdValid() {
|
|
133
|
-
return request.isRequestedSessionIdValid();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public boolean isRequestedSessionIdFromCookie() {
|
|
137
|
-
return request.isRequestedSessionIdFromCookie();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public boolean isRequestedSessionIdFromURL() {
|
|
141
|
-
return request.isRequestedSessionIdFromURL();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public boolean isRequestedSessionIdFromUrl() {
|
|
145
|
-
return request.isRequestedSessionIdFromUrl();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
|
|
149
|
-
return request.authenticate(httpServletResponse);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public void login(String s, String s1) throws ServletException {
|
|
153
|
-
request.login(s, s1);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public void logout() throws ServletException {
|
|
157
|
-
request.logout();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public Collection<Part> getParts() throws IOException, ServletException {
|
|
161
|
-
return request.getParts();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
public Part getPart(String s) throws IOException, ServletException {
|
|
165
|
-
return request.getPart(s);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
|
|
169
|
-
return request.upgrade(aClass);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public Object getAttribute(String s) {
|
|
173
|
-
return request.getAttribute(s);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public Enumeration<String> getAttributeNames() {
|
|
177
|
-
return request.getAttributeNames();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public String getCharacterEncoding() {
|
|
181
|
-
return request.getCharacterEncoding();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public void setCharacterEncoding(String s) throws UnsupportedEncodingException {
|
|
185
|
-
request.setCharacterEncoding(s);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public int getContentLength() {
|
|
189
|
-
return request.getContentLength();
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public long getContentLengthLong() {
|
|
193
|
-
return request.getContentLengthLong();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
public String getContentType() {
|
|
197
|
-
return request.getContentType();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
public ServletInputStream getInputStream() throws IOException {
|
|
201
|
-
return request.getInputStream();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
public String getParameter(String s) {
|
|
205
|
-
return request.getParameter(s);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
public Enumeration<String> getParameterNames() {
|
|
209
|
-
return request.getParameterNames();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
public String[] getParameterValues(String s) {
|
|
213
|
-
return request.getParameterValues(s);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
public Map<String, String[]> getParameterMap() {
|
|
217
|
-
return request.getParameterMap();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
public String getProtocol() {
|
|
221
|
-
return request.getProtocol();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
public String getScheme() {
|
|
225
|
-
return request.getScheme();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public String getServerName() {
|
|
229
|
-
return request.getServerName();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public int getServerPort() {
|
|
233
|
-
return request.getServerPort();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public BufferedReader getReader() throws IOException {
|
|
237
|
-
return request.getReader();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public String getRemoteAddr() {
|
|
241
|
-
return request.getRemoteAddr();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public String getRemoteHost() {
|
|
245
|
-
return request.getRemoteHost();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public void setAttribute(String s, Object o) {
|
|
249
|
-
request.setAttribute(s, o);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public void removeAttribute(String s) {
|
|
253
|
-
request.removeAttribute(s);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
public Locale getLocale() {
|
|
257
|
-
return request.getLocale();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
public Enumeration<Locale> getLocales() {
|
|
261
|
-
return request.getLocales();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
public boolean isSecure() {
|
|
265
|
-
return request.isSecure();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
public RequestDispatcher getRequestDispatcher(String s) {
|
|
269
|
-
return request.getRequestDispatcher(s);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
public String getRealPath(String s) {
|
|
273
|
-
return request.getRealPath(s);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
public int getRemotePort() {
|
|
277
|
-
return request.getRemotePort();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
public String getLocalName() {
|
|
281
|
-
return request.getLocalName();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
public String getLocalAddr() {
|
|
285
|
-
return request.getLocalAddr();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
public int getLocalPort() {
|
|
289
|
-
return request.getLocalPort();
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
public ServletContext getServletContext() {
|
|
293
|
-
return request.getServletContext();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
public AsyncContext startAsync() throws IllegalStateException {
|
|
297
|
-
return request.startAsync();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
|
|
301
|
-
return request.startAsync(servletRequest, servletResponse);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
public boolean isAsyncStarted() {
|
|
305
|
-
return request.isAsyncStarted();
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
public boolean isAsyncSupported() {
|
|
309
|
-
return request.isAsyncSupported();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
public AsyncContext getAsyncContext() {
|
|
313
|
-
return request.getAsyncContext();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
public DispatcherType getDispatcherType() {
|
|
317
|
-
return request.getDispatcherType();
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
*/
|
|
321
|
-
|
|
322
|
-
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
323
|
-
Authentication fakeAuthentication = new Authentication() {
|
|
324
|
-
@Override
|
|
325
|
-
public Collection<? extends GrantedAuthority> getAuthorities() {
|
|
326
|
-
Collection<GrantedAuthority> authorities = new LinkedList<GrantedAuthority>();
|
|
327
|
-
|
|
328
|
-
if ("admin".equalsIgnoreCase(fakeUsername)) {
|
|
329
|
-
GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ADMIN");
|
|
330
|
-
authorities.add(grantedAuthority);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return authorities;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// delegate the rest of the methods:
|
|
337
|
-
public Object getCredentials() {
|
|
338
|
-
return authentication.getCredentials();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
public Object getDetails() {
|
|
342
|
-
return authentication.getDetails();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
public Object getPrincipal() {
|
|
346
|
-
return authentication.getPrincipal();
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
public boolean isAuthenticated() {
|
|
350
|
-
return authentication.isAuthenticated();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
public void setAuthenticated(boolean b) throws IllegalArgumentException {
|
|
354
|
-
authentication.setAuthenticated(b);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
public String getName() {
|
|
358
|
-
return authentication.getName();
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
SecurityContextHolder.getContext().setAuthentication(fakeAuthentication);
|
|
362
|
-
|
|
363
|
-
filterChain.doFilter(request, response);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
@Override
|
|
369
|
-
public void destroy() {
|
|
370
|
-
// do nothing
|
|
371
|
-
}
|
|
372
|
-
}
|
|
1
|
+
package @app.group.id@.@app.name@.security;
|
|
2
|
+
|
|
3
|
+
import com.sun.security.auth.UserPrincipal;
|
|
4
|
+
import org.springframework.security.core.Authentication;
|
|
5
|
+
import org.springframework.security.core.GrantedAuthority;
|
|
6
|
+
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
7
|
+
import org.springframework.security.core.context.SecurityContextHolder;
|
|
8
|
+
import org.springframework.stereotype.Component;
|
|
9
|
+
|
|
10
|
+
import jakarta.servlet.*;
|
|
11
|
+
import jakarta.servlet.http.*;
|
|
12
|
+
import java.io.BufferedReader;
|
|
13
|
+
import java.io.IOException;
|
|
14
|
+
import java.io.UnsupportedEncodingException;
|
|
15
|
+
import java.security.AuthProvider;
|
|
16
|
+
import java.security.Principal;
|
|
17
|
+
import java.util.*;
|
|
18
|
+
|
|
19
|
+
// Filter used to fake user login. This allows for testing different user roles in the same application.
|
|
20
|
+
// WARNING: do NOT use this in production; security will be compromised! For now, it will only be activated from requests coming from localhost.
|
|
21
|
+
@Component
|
|
22
|
+
public class FakeAuthenticationFilter implements Filter {
|
|
23
|
+
@Override
|
|
24
|
+
public void init(FilterConfig filterConfig) throws ServletException {
|
|
25
|
+
// do nothing
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Override
|
|
29
|
+
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
|
30
|
+
final HttpServletRequest request = (HttpServletRequest) servletRequest;
|
|
31
|
+
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
|
32
|
+
|
|
33
|
+
if (!"localhost".equals(request.getServerName())) {
|
|
34
|
+
filterChain.doFilter(request, response);
|
|
35
|
+
} else {
|
|
36
|
+
final String fakeUsername = request.getHeader("x-fake-authentication");
|
|
37
|
+
if (fakeUsername == null) {
|
|
38
|
+
filterChain.doFilter(request, response);
|
|
39
|
+
} else {
|
|
40
|
+
/*
|
|
41
|
+
System.out.println("---------- got fake userid: " + fakeUsername);
|
|
42
|
+
HttpServletRequest fakeRequest = new HttpServletRequest() {
|
|
43
|
+
public Principal getUserPrincipal() {
|
|
44
|
+
return new UserPrincipal(fakeUsername);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Delegate all the other methods:
|
|
48
|
+
public String getAuthType() {
|
|
49
|
+
return request.getAuthType();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public Cookie[] getCookies() {
|
|
53
|
+
return request.getCookies();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public long getDateHeader(String s) {
|
|
57
|
+
return request.getDateHeader(s);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public String getHeader(String s) {
|
|
61
|
+
return request.getHeader(s);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public Enumeration<String> getHeaders(String s) {
|
|
65
|
+
return request.getHeaders(s);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Enumeration<String> getHeaderNames() {
|
|
69
|
+
return request.getHeaderNames();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public int getIntHeader(String s) {
|
|
73
|
+
return request.getIntHeader(s);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public String getMethod() {
|
|
77
|
+
return request.getMethod();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public String getPathInfo() {
|
|
81
|
+
return request.getPathInfo();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public String getPathTranslated() {
|
|
85
|
+
return request.getPathTranslated();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public String getContextPath() {
|
|
89
|
+
return request.getContextPath();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public String getQueryString() {
|
|
93
|
+
return request.getQueryString();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public String getRemoteUser() {
|
|
97
|
+
return request.getRemoteUser();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public boolean isUserInRole(String s) {
|
|
101
|
+
return request.isUserInRole(s);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public String getRequestedSessionId() {
|
|
105
|
+
return request.getRequestedSessionId();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public String getRequestURI() {
|
|
109
|
+
return request.getRequestURI();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public StringBuffer getRequestURL() {
|
|
113
|
+
return request.getRequestURL();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public String getServletPath() {
|
|
117
|
+
return request.getServletPath();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public HttpSession getSession(boolean b) {
|
|
121
|
+
return request.getSession(b);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public HttpSession getSession() {
|
|
125
|
+
return request.getSession();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public String changeSessionId() {
|
|
129
|
+
return request.changeSessionId();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public boolean isRequestedSessionIdValid() {
|
|
133
|
+
return request.isRequestedSessionIdValid();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public boolean isRequestedSessionIdFromCookie() {
|
|
137
|
+
return request.isRequestedSessionIdFromCookie();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public boolean isRequestedSessionIdFromURL() {
|
|
141
|
+
return request.isRequestedSessionIdFromURL();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public boolean isRequestedSessionIdFromUrl() {
|
|
145
|
+
return request.isRequestedSessionIdFromUrl();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
|
|
149
|
+
return request.authenticate(httpServletResponse);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public void login(String s, String s1) throws ServletException {
|
|
153
|
+
request.login(s, s1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public void logout() throws ServletException {
|
|
157
|
+
request.logout();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public Collection<Part> getParts() throws IOException, ServletException {
|
|
161
|
+
return request.getParts();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public Part getPart(String s) throws IOException, ServletException {
|
|
165
|
+
return request.getPart(s);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
|
|
169
|
+
return request.upgrade(aClass);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public Object getAttribute(String s) {
|
|
173
|
+
return request.getAttribute(s);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public Enumeration<String> getAttributeNames() {
|
|
177
|
+
return request.getAttributeNames();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public String getCharacterEncoding() {
|
|
181
|
+
return request.getCharacterEncoding();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public void setCharacterEncoding(String s) throws UnsupportedEncodingException {
|
|
185
|
+
request.setCharacterEncoding(s);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public int getContentLength() {
|
|
189
|
+
return request.getContentLength();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public long getContentLengthLong() {
|
|
193
|
+
return request.getContentLengthLong();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public String getContentType() {
|
|
197
|
+
return request.getContentType();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public ServletInputStream getInputStream() throws IOException {
|
|
201
|
+
return request.getInputStream();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public String getParameter(String s) {
|
|
205
|
+
return request.getParameter(s);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public Enumeration<String> getParameterNames() {
|
|
209
|
+
return request.getParameterNames();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public String[] getParameterValues(String s) {
|
|
213
|
+
return request.getParameterValues(s);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public Map<String, String[]> getParameterMap() {
|
|
217
|
+
return request.getParameterMap();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public String getProtocol() {
|
|
221
|
+
return request.getProtocol();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public String getScheme() {
|
|
225
|
+
return request.getScheme();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public String getServerName() {
|
|
229
|
+
return request.getServerName();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public int getServerPort() {
|
|
233
|
+
return request.getServerPort();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public BufferedReader getReader() throws IOException {
|
|
237
|
+
return request.getReader();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public String getRemoteAddr() {
|
|
241
|
+
return request.getRemoteAddr();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public String getRemoteHost() {
|
|
245
|
+
return request.getRemoteHost();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public void setAttribute(String s, Object o) {
|
|
249
|
+
request.setAttribute(s, o);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void removeAttribute(String s) {
|
|
253
|
+
request.removeAttribute(s);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public Locale getLocale() {
|
|
257
|
+
return request.getLocale();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public Enumeration<Locale> getLocales() {
|
|
261
|
+
return request.getLocales();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public boolean isSecure() {
|
|
265
|
+
return request.isSecure();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
public RequestDispatcher getRequestDispatcher(String s) {
|
|
269
|
+
return request.getRequestDispatcher(s);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public String getRealPath(String s) {
|
|
273
|
+
return request.getRealPath(s);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
public int getRemotePort() {
|
|
277
|
+
return request.getRemotePort();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
public String getLocalName() {
|
|
281
|
+
return request.getLocalName();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public String getLocalAddr() {
|
|
285
|
+
return request.getLocalAddr();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public int getLocalPort() {
|
|
289
|
+
return request.getLocalPort();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public ServletContext getServletContext() {
|
|
293
|
+
return request.getServletContext();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
public AsyncContext startAsync() throws IllegalStateException {
|
|
297
|
+
return request.startAsync();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
|
|
301
|
+
return request.startAsync(servletRequest, servletResponse);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
public boolean isAsyncStarted() {
|
|
305
|
+
return request.isAsyncStarted();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
public boolean isAsyncSupported() {
|
|
309
|
+
return request.isAsyncSupported();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public AsyncContext getAsyncContext() {
|
|
313
|
+
return request.getAsyncContext();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
public DispatcherType getDispatcherType() {
|
|
317
|
+
return request.getDispatcherType();
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
323
|
+
Authentication fakeAuthentication = new Authentication() {
|
|
324
|
+
@Override
|
|
325
|
+
public Collection<? extends GrantedAuthority> getAuthorities() {
|
|
326
|
+
Collection<GrantedAuthority> authorities = new LinkedList<GrantedAuthority>();
|
|
327
|
+
|
|
328
|
+
if ("admin".equalsIgnoreCase(fakeUsername)) {
|
|
329
|
+
GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ADMIN");
|
|
330
|
+
authorities.add(grantedAuthority);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return authorities;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// delegate the rest of the methods:
|
|
337
|
+
public Object getCredentials() {
|
|
338
|
+
return authentication.getCredentials();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
public Object getDetails() {
|
|
342
|
+
return authentication.getDetails();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
public Object getPrincipal() {
|
|
346
|
+
return authentication.getPrincipal();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
public boolean isAuthenticated() {
|
|
350
|
+
return authentication.isAuthenticated();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
public void setAuthenticated(boolean b) throws IllegalArgumentException {
|
|
354
|
+
authentication.setAuthenticated(b);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
public String getName() {
|
|
358
|
+
return authentication.getName();
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
SecurityContextHolder.getContext().setAuthentication(fakeAuthentication);
|
|
362
|
+
|
|
363
|
+
filterChain.doFilter(request, response);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
@Override
|
|
369
|
+
public void destroy() {
|
|
370
|
+
// do nothing
|
|
371
|
+
}
|
|
372
|
+
}
|