├── .gitee
└── ISSUE_TEMPLATE
│ ├── config.yml
│ ├── enterprise_support.yml
│ └── opensource_bug.yml
├── .github
└── workflows
│ ├── pages.yml
│ ├── publish.yml
│ └── tck.yml
├── LICENSE
├── README.md
├── pages
├── README.md
├── astro.config.mjs
├── package.json
├── public
│ ├── favicon.svg
│ ├── logo.svg
│ ├── smart-servlet.svg
│ └── wx.png
├── src
│ ├── assets
│ │ └── houston.webp
│ ├── components
│ │ ├── GithubDownloadCount.astro
│ │ ├── Mermaid.astro
│ │ └── PerformanceChart.astro
│ ├── content
│ │ ├── config.ts
│ │ └── docs
│ │ │ ├── en
│ │ │ ├── guides
│ │ │ │ ├── about.mdx
│ │ │ │ ├── release_note.mdx
│ │ │ │ └── tck_report.mdx
│ │ │ ├── index.mdx
│ │ │ └── reference
│ │ │ │ └── license.mdx
│ │ │ ├── guides
│ │ │ ├── about.mdx
│ │ │ ├── install.mdx
│ │ │ ├── release_note.mdx
│ │ │ └── tck_report.mdx
│ │ │ ├── index.mdx
│ │ │ ├── performance
│ │ │ ├── ab_smart-servlet.jpeg
│ │ │ ├── ab_smart-servlet_1000.jpeg
│ │ │ ├── ab_smart-servlet_150.jpeg
│ │ │ ├── ab_tomcat.jpeg
│ │ │ ├── ab_tomcat_150.jpeg
│ │ │ └── test-data.md
│ │ │ └── reference
│ │ │ ├── license.mdx
│ │ │ └── xinchuang.mdx
│ ├── env.d.ts
│ └── pages
│ │ └── license
│ │ └── [...license].astro
└── tsconfig.json
├── pom.xml
├── servlet-core
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── tech
│ │ └── smartboot
│ │ └── servlet
│ │ ├── AnnotationsLoader.java
│ │ ├── Container.java
│ │ ├── ContainerConfig.java
│ │ ├── DefaultServlet.java
│ │ ├── ServletContextRuntime.java
│ │ ├── SmartHttpServletRequest.java
│ │ ├── WebSocketServerContainer.java
│ │ ├── WebXmlParseEngine.java
│ │ ├── conf
│ │ ├── DeploymentInfo.java
│ │ ├── ErrorPageInfo.java
│ │ ├── FilterInfo.java
│ │ ├── FilterMappingInfo.java
│ │ ├── LoginConfig.java
│ │ ├── OrderMeta.java
│ │ ├── SecurityConstraint.java
│ │ ├── ServletContainerInitializerInfo.java
│ │ ├── ServletInfo.java
│ │ ├── ServletMappingInfo.java
│ │ ├── UrlPattern.java
│ │ ├── WebAppInfo.java
│ │ └── WebFragmentInfo.java
│ │ ├── enums
│ │ ├── FilterMappingType.java
│ │ ├── ServletContextPathType.java
│ │ └── SslCertType.java
│ │ ├── handler
│ │ ├── FilterMatchHandler.java
│ │ ├── Handler.java
│ │ ├── HandlerContext.java
│ │ ├── HandlerPipeline.java
│ │ ├── SecurityHandler.java
│ │ ├── ServletRequestListenerHandler.java
│ │ └── ServletServiceHandler.java
│ │ ├── impl
│ │ ├── ApplicationFilterRegistration.java
│ │ ├── ApplicationServletRegistration.java
│ │ ├── FilterConfigImpl.java
│ │ ├── HttpServletMappingImpl.java
│ │ ├── HttpServletRequestImpl.java
│ │ ├── HttpServletResponseImpl.java
│ │ ├── JspConfigDescriptorImpl.java
│ │ ├── PartImpl.java
│ │ ├── ServletConfigImpl.java
│ │ ├── ServletContextImpl.java
│ │ ├── ServletContextWrapperListener.java
│ │ ├── ServletInputStreamImpl.java
│ │ ├── ServletOutputStreamImpl.java
│ │ ├── ServletPrintWriter.java
│ │ ├── SessionCookieConfigImpl.java
│ │ ├── UpgradeServletInputStream.java
│ │ ├── UpgradeServletOutputStream.java
│ │ ├── WebConnectionImpl.java
│ │ └── WriterOutputStream.java
│ │ ├── plugins
│ │ ├── Plugin.java
│ │ ├── PluginException.java
│ │ ├── async
│ │ │ ├── AsyncContextImpl.java
│ │ │ ├── AsyncContextPlugin.java
│ │ │ └── AsyncContextProviderImpl.java
│ │ ├── basic
│ │ │ ├── BasicPlugin.java
│ │ │ ├── License.java
│ │ │ ├── LicenseEntity.java
│ │ │ ├── LicenseException.java
│ │ │ ├── LicenseTO.java
│ │ │ ├── Md5.java
│ │ │ └── RuntimeExpireStrategy.java
│ │ ├── dispatcher
│ │ │ ├── DispatcherPlugin.java
│ │ │ ├── DispatcherProviderImpl.java
│ │ │ ├── RequestDispatcherImpl.java
│ │ │ ├── ServletRequestDispatcherWrapper.java
│ │ │ └── ServletResponseDispatcherWrapper.java
│ │ ├── mapping
│ │ │ └── MappingProviderImpl.java
│ │ ├── security
│ │ │ ├── LoginAccount.java
│ │ │ ├── SecurityAccount.java
│ │ │ ├── SecurityCheckServlet.java
│ │ │ ├── SecurityProviderImpl.java
│ │ │ └── SecurityTO.java
│ │ ├── session
│ │ │ ├── HttpSessionImpl.java
│ │ │ ├── SessionPlugin.java
│ │ │ └── SessionProviderImpl.java
│ │ └── websocket
│ │ │ ├── WebSocketFilter.java
│ │ │ ├── WebsocketPlugin.java
│ │ │ ├── WebsocketProviderImpl.java
│ │ │ └── impl
│ │ │ ├── AnnotatedEndpoint.java
│ │ │ ├── AnnotatedEndpointConfig.java
│ │ │ ├── HandlerWrapper.java
│ │ │ ├── HandshakeRequestImpl.java
│ │ │ ├── HandshakeResponseImpl.java
│ │ │ ├── OnMessageConfig.java
│ │ │ ├── PathNode.java
│ │ │ ├── ServerEndpointConfigProxy.java
│ │ │ ├── WebSocketServerContainerImpl.java
│ │ │ ├── WebSocketUpgradeHandler.java
│ │ │ ├── WebsocketSession.java
│ │ │ └── WholeMessageHandler.java
│ │ ├── provider
│ │ ├── AsyncContextProvider.java
│ │ ├── DispatcherProvider.java
│ │ ├── FaviconProvider.java
│ │ ├── MappingProvider.java
│ │ ├── SecurityProvider.java
│ │ ├── SessionProvider.java
│ │ ├── VendorProvider.java
│ │ └── WebsocketProvider.java
│ │ ├── sandbox
│ │ ├── MockProvider.java
│ │ └── SandBox.java
│ │ ├── third
│ │ └── bcel
│ │ │ ├── Const.java
│ │ │ └── classfile
│ │ │ ├── AnnotationElementValue.java
│ │ │ ├── AnnotationEntry.java
│ │ │ ├── Annotations.java
│ │ │ ├── ArrayElementValue.java
│ │ │ ├── ClassElementValue.java
│ │ │ ├── ClassFormatException.java
│ │ │ ├── ClassParser.java
│ │ │ ├── Constant.java
│ │ │ ├── ConstantClass.java
│ │ │ ├── ConstantDouble.java
│ │ │ ├── ConstantFloat.java
│ │ │ ├── ConstantInteger.java
│ │ │ ├── ConstantLong.java
│ │ │ ├── ConstantPool.java
│ │ │ ├── ConstantUtf8.java
│ │ │ ├── ElementValue.java
│ │ │ ├── ElementValuePair.java
│ │ │ ├── EnumElementValue.java
│ │ │ ├── JavaClass.java
│ │ │ ├── SimpleElementValue.java
│ │ │ └── Utility.java
│ │ └── util
│ │ ├── DateUtil.java
│ │ ├── PathMatcherUtil.java
│ │ └── WarUtil.java
│ └── resources
│ ├── META-INF
│ └── services
│ │ └── tech.smartboot.servlet.plugins.Plugin
│ ├── favicon.ico
│ ├── smart-servlet
│ ├── banner.txt
│ ├── error.html
│ └── support.txt
│ └── smart_web.xml
├── smart-servlet-maven-plugin
├── pom.xml
└── src
│ └── main
│ └── java
│ └── tech
│ └── smartboot
│ └── maven
│ └── plugin
│ └── jakarta
│ ├── RunMojo.java
│ └── Starter.java
├── spring-boot-starter
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── tech
│ │ └── smartboot
│ │ └── springboot
│ │ └── starter
│ │ ├── ConfigurableSmartWebServerFactory.java
│ │ ├── SmartContainerInitializer.java
│ │ └── SmartServletServer.java
│ └── resources
│ └── META-INF
│ └── spring
│ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports
├── springboot-demo
├── Makefile
├── pom.xml
├── pom_tomcat.xml
├── pom_undertow.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── smartboot
│ │ └── demo
│ │ └── starter
│ │ ├── Bootstrap.java
│ │ ├── MyWebSocketHandler.java
│ │ ├── SecurityConfig.java
│ │ └── WebSocketConfig.java
│ └── resources
│ └── smart-servlet
│ ├── License.shield
│ └── smart-servlet.pem
└── tck
├── conf
├── License.shield
├── smart-servlet.pem
└── smart-servlet.properties
├── pom.xml
└── src
├── main
├── java
│ └── tech
│ │ └── smartboot
│ │ └── servlet
│ │ └── tck
│ │ ├── ArquillianAppProvider.java
│ │ ├── SmartEmbeddedConfiguration.java
│ │ ├── SmartEmbeddedContainer.java
│ │ └── SmartServletExtension.java
└── resources
│ └── META-INF
│ └── services
│ └── org.jboss.arquillian.core.spi.LoadableExtension
└── test
└── resources
├── META-INF
└── services
│ └── jakarta.servlet.ServletContainerInitializer
├── arquillian.xml
├── default.properties
├── servlet_spec_fragment_web
└── webdefault.xml
└── simplelogger.properties
/.gitee/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: true
2 |
3 | contact_links:
4 | - name: 📚使用文档
5 | url: https://smartboot.tech/smart-servlet/
6 | about: smart-servlet in Action,简单、高效、国产化
7 |
8 |
--------------------------------------------------------------------------------
/.gitee/ISSUE_TEMPLATE/enterprise_support.yml:
--------------------------------------------------------------------------------
1 | name: 企业技术支持
2 | description: 如果你是 smart-servlet 的合作企业或客户,使用过程中发现了一个 Bug,或者需要寻求技术支持,请使用此模板。
3 | title:
4 | labels: ["support","bug"]
5 | body:
6 | - type: dropdown
7 | id: version
8 | attributes:
9 | label: 版本号
10 | description: 请选择项目使用的 smart-servlet 版本?
11 | options:
12 | - v3.0 (最新)
13 | - v2.9
14 | - v2.8
15 | - v2.7
16 | - 其他
17 | validations:
18 | required: true
19 | - type: dropdown
20 | id: jdk_version
21 | attributes:
22 | label: SDK Version
23 | description: 请选择项目使用的 Java 版本?
24 | options:
25 | - JDK 1.8
26 | - JDK 11
27 | - JDK 17
28 | - JDK 18
29 | - JDK 19
30 | - JDK 20
31 | - JDK 21
32 | - JDK 22
33 | - JDK 23
34 | validations:
35 | required: true
36 | - type: checkboxes
37 | attributes:
38 | label: 信息确认
39 | options:
40 | - label: 我已获得 smart-servlet 的使用授权?
41 | required: true
42 | - type: dropdown
43 | id: os_type
44 | attributes:
45 | label: 操作系统
46 | description: 请选择操作系统类型?
47 | options:
48 | - Windows
49 | - Linux
50 | - MacOS
51 | validations:
52 | required: true
53 | - type: dropdown
54 | id: environment
55 | attributes:
56 | label: 运行环境
57 | description: 请选择代码运行环境?
58 | options:
59 | - 开发环境 (Development)
60 | - 生产环境 (Production)
61 | - 测试环境 (单元测试/集成测试)
62 | validations:
63 | required: true
64 | - type: checkboxes
65 | attributes:
66 | label: 这个问题是否已经存在?
67 | options:
68 | - label: 我已经搜索过现有的问题 (https://gitee.com/smartboot/smart-servlet/issues)
69 | required: true
70 | - type: textarea
71 | attributes:
72 | label: 如何复现
73 | description: 请详细告诉我们如何复现你遇到的问题,如涉及代码,可提供一个最小代码示例,并使用反引号```附上它
74 | placeholder: |
75 | 1. ...
76 | 2. ...
77 | 3. ...
78 | validations:
79 | required: true
80 | - type: textarea
81 | attributes:
82 | label: 预期结果
83 | description: 请告诉我们你预期会发生什么。
84 | validations:
85 | required: true
86 | - type: textarea
87 | attributes:
88 | label: 实际结果
89 | description: 请告诉我们实际发生了什么。
90 | validations:
91 | required: true
92 | - type: textarea
93 | attributes:
94 | label: 异常信息
95 | description: 如果有异常请把详细异常堆栈粘贴上来。
96 | - type: textarea
97 | attributes:
98 | label: 截图或视频
99 | description: 如果可以的话,上传任何关于 bug 的截图。
100 | placeholder: |
101 | 可在此处进行图片粘贴上传。
102 | validations:
103 | required: true
104 | - type: input
105 | id: demo
106 | attributes:
107 | label: Demo 地址 | 未提供可能影响问题定位效率
108 | description: 请提供复现错误的 Demo 下载
109 | placeholder: https://gitee.com/your_id/your_test_project.git
--------------------------------------------------------------------------------
/.gitee/ISSUE_TEMPLATE/opensource_bug.yml:
--------------------------------------------------------------------------------
1 | name: 开源生态支持
2 | description: 如果你的开源项目承诺遵循 smart-servlet 开源规范,使用过程中发现了一个 Bug,或者需要寻求技术支持,请使用此模板。
3 | title:
4 | labels: ["bug"]
5 | body:
6 | - type: dropdown
7 | id: version
8 | attributes:
9 | label: 版本号
10 | description: 请选择项目使用的 smart-servlet 版本?
11 | options:
12 | - v3.0 (最新)
13 | - v2.9
14 | - v2.8
15 | - v2.7
16 | - 其他
17 | validations:
18 | required: true
19 | - type: dropdown
20 | id: jdk_version
21 | attributes:
22 | label: SDK Version
23 | description: 请选择项目使用的 Java 版本?
24 | options:
25 | - JDK 1.8
26 | - JDK 11
27 | - JDK 17
28 | - JDK 18
29 | - JDK 19
30 | - JDK 20
31 | - JDK 21
32 | - JDK 22
33 | - JDK 23
34 | validations:
35 | required: true
36 | - type: input
37 | attributes:
38 | label: 开源项目地址
39 | validations:
40 | required: true
41 | - type: checkboxes
42 | attributes:
43 | label: 这个问题是否已经存在?
44 | options:
45 | - label: 我已经搜索过现有的问题 (https://gitee.com/smartboot/smart-servlet/issues)
46 | required: true
47 | - type: textarea
48 | attributes:
49 | label: 如何复现
50 | description: 请详细告诉我们如何复现你遇到的问题,如涉及代码,可提供一个最小代码示例,并使用反引号```附上它
51 | placeholder: |
52 | 1. ...
53 | 2. ...
54 | 3. ...
55 | validations:
56 | required: true
57 | - type: textarea
58 | attributes:
59 | label: 预期结果
60 | description: 请告诉我们你预期会发生什么。
61 | validations:
62 | required: true
63 | - type: textarea
64 | attributes:
65 | label: 实际结果
66 | description: 请告诉我们实际发生了什么。
67 | validations:
68 | required: true
69 | - type: textarea
70 | attributes:
71 | label: 异常信息
72 | description: 如果有异常请把详细异常堆栈粘贴上来。
73 | - type: textarea
74 | attributes:
75 | label: 截图或视频
76 | description: 如果可以的话,上传任何关于 bug 的截图。
77 | placeholder: |
78 | 可在此处进行图片粘贴上传。
79 | validations:
80 | required: true
81 | - type: input
82 | id: demo
83 | attributes:
84 | label: Demo 地址 | 未提供可能影响问题定位效率
85 | description: 请提供复现错误的 Demo 下载
86 | placeholder: https://gitee.com/your_id/your_test_project.git
87 |
--------------------------------------------------------------------------------
/.github/workflows/pages.yml:
--------------------------------------------------------------------------------
1 | name: 文档
2 |
3 | on:
4 | # Trigger the workflow every time you push to the `main` branch
5 | # Using a different branch name? Replace `main` with your branch’s name
6 | push:
7 | branches: [master]
8 | paths:
9 | - 'pages/**'
10 | # Allows you to run this workflow manually from the Actions tab on GitHub.
11 | workflow_dispatch:
12 |
13 | # Allow this job to clone the repo and create a page deployment
14 | permissions:
15 | contents: read
16 | pages: write
17 | id-token: write
18 |
19 | jobs:
20 | build:
21 | runs-on: ubuntu-latest
22 | steps:
23 | - name: Checkout your repository using git
24 | uses: actions/checkout@v4
25 | - name: Install, build, and upload your site output
26 | uses: withastro/action@v2
27 | with:
28 | path: pages # The root location of your Astro project inside the repository. (optional)
29 | node-version: 22 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
30 | package-manager: npm # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
31 |
32 | deploy:
33 | needs: build
34 | runs-on: ubuntu-latest
35 | environment:
36 | name: github-pages
37 | url: ${{ steps.deployment.outputs.page_url }}
38 | steps:
39 | - name: Deploy to GitHub Pages
40 | id: deployment
41 | uses: actions/deploy-pages@v4
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: 打包发布
10 |
11 | on:
12 | push:
13 | branches: [ "master" ]
14 | tags:
15 | - 'v*'
16 | paths-ignore:
17 | - 'pages/**'
18 | pull_request:
19 | branches: [ "master" ]
20 |
21 | jobs:
22 | build:
23 |
24 | runs-on: ubuntu-latest
25 |
26 | steps:
27 | - uses: actions/checkout@v4
28 |
29 | # - uses: actions/checkout@v4
30 | # name: 下载 smart-http
31 | # with:
32 | # repository: smartboot/smart-http
33 | # path: smart-http
34 | - name: Set up JDK 17
35 | uses: actions/setup-java@v3
36 | with:
37 | java-version: '17'
38 | distribution: 'temurin'
39 | cache: maven
40 | # - name: Build smart-http
41 | # run: mvn -B install --file smart-http/pom.xml -Dmaven.compiler.source=8 -Dmaven.compiler.target=8
42 | - name: Build smart-servlet with Maven
43 | run: mvn -B install --file pom.xml
44 |
45 | # 企业版打包
46 | - uses: actions/checkout@v4
47 | with:
48 | repository: smartboot/smart-servlet-enterprise
49 | token: ${{ secrets.GH_PAT }}
50 | path: smart-servlet-enterprise
51 |
52 | - name: 构建 smart-servlet-bin 制品
53 | run: mvn clean install -f smart-servlet-enterprise/pom.xml
54 | - name: Build distribution with Maven
55 | run: mvn clean package -Pbin -f smart-servlet-enterprise/deploy/pom.xml
56 | - name: 上传 smart-servlet-bin 制品
57 | uses: actions/upload-artifact@v4
58 | with:
59 | name: smart-servlet-bin-${{ github.ref_name }}
60 | compression-level: 0
61 | path: smart-servlet-enterprise/deploy/target/*.tar.gz
62 |
--------------------------------------------------------------------------------
/.github/workflows/tck.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Servlet TCK测试
10 |
11 | on:
12 | push:
13 | branches: [ "master" ]
14 | paths-ignore:
15 | - 'pages/**'
16 | pull_request:
17 | branches: [ "master" ]
18 |
19 | jobs:
20 | build:
21 |
22 | runs-on: ubuntu-latest
23 |
24 | steps:
25 | - uses: actions/checkout@v4
26 | - uses: actions/checkout@v4
27 | name: 下载servlet TCK
28 | with:
29 | repository: jakartaee/servlet
30 | ref: 99ba4387c6bd0283fd00e6975a2f31f90ffa0963
31 | path: jakartaee/servlet
32 | - uses: actions/checkout@v4
33 | name: 下载 Feat
34 | with:
35 | repository: smartboot/feat
36 | path: feat
37 | - name: Set up JDK 17
38 | uses: actions/setup-java@v3
39 | with:
40 | java-version: '17'
41 | distribution: 'temurin'
42 | cache: maven
43 | - name: Set up Maven 3.9
44 | uses: stCarolas/setup-maven@v5
45 | with:
46 | maven-version: '3.9.0'
47 | - name: Build Feat
48 | run: mvn -B install --file feat/pom.xml -Dmaven.test.skip=true -Dmaven.compiler.source=8 -Dmaven.compiler.target=8
49 | - name: Build servlet TCK with Maven
50 | run: mvn -B install --file jakartaee/servlet/pom.xml
51 | - name: Build smart-servlet with Maven
52 | run: mvn -B install --file pom.xml
53 | # - name: Build with Maven
54 | # run: mvn -B verify --file tck/pom.xml -Dbasedir=tck_tmp -Dmaven.test.failure.ignore=true
55 | - name: 执行 TCK 测试
56 | run: mvn -B surefire-report:report --file tck/pom.xml
57 |
58 | - name: 查看目录
59 | run: ls -lh tck/target/
60 |
61 | - name: 上传TCK报告
62 | uses: actions/upload-artifact@v4
63 | if: always() # 确保即使有失败的测试也会上传报告
64 | with:
65 | name: test-report
66 | path: tck/target/reports
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # smart-servlet
3 | smart-servlet 是一个基于 Jakarta Servlet 6.0 的轻量级 Servlet 容器,适用于 Java 17+ 环境。
4 |
5 | **产品特色**
6 | * 国产血统:核心技术 100% 全栈自研。
7 | * 性能优越:搭载最新版通信微内核 smart-socket。
8 | * 安全可靠:严格遵循协议规范;支持加密传输方式。
9 | * 简洁易用:支持 War 包、springboot、maven-plugin等多种运行模式,使用体验100%兼容 Tomcat。
10 |
11 | **目标用户**
12 | 1. 有着信创需求的企业用户。
13 | 2. 对服务并发能力要求高的企业用户。
14 |
15 | > 本项目可用于个人学习,未经授权不得用于商业场景。
16 |
17 |
18 | **[《使用手册》](https://smartboot.tech/smart-servlet/)**
19 |
20 |
21 | ## 项目推荐
22 | - [smart-socket](https://gitee.com/smartboot/smart-socket)
23 | 极简、易用、高性能的AIO通信框架,5G时代的通信微内核,适用于IM、RPC、IoT等诸多领域
24 | - [smart-http](https://gitee.com/smartboot/smart-http)
25 | 基于smart-socket实现的轻量级http服务器
26 | - [smart-mqtt](https://gitee.com/smartboot/smart-mqtt)
27 | 基于 smart-socket 实现的 MQTT 3.1.1/5.0 Broker&Client 服务。
--------------------------------------------------------------------------------
/pages/README.md:
--------------------------------------------------------------------------------
1 | # Starlight Starter Kit: Basics
2 |
3 | [](https://starlight.astro.build)
4 |
5 | ```
6 | npm create astro@latest -- --template starlight
7 | ```
8 |
9 | [](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
10 | [](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
11 | [](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics)
12 | [](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)
13 |
14 | > 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
15 |
16 | ## 🚀 Project Structure
17 |
18 | Inside of your Astro + Starlight project, you'll see the following folders and files:
19 |
20 | ```
21 | .
22 | ├── public/
23 | ├── src/
24 | │ ├── assets/
25 | │ ├── content/
26 | │ │ ├── docs/
27 | │ │ └── config.ts
28 | │ └── env.d.ts
29 | ├── astro.config.mjs
30 | ├── package.json
31 | └── tsconfig.json
32 | ```
33 |
34 | Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
35 |
36 | Images can be added to `src/assets/` and embedded in Markdown with a relative link.
37 |
38 | Static assets, like favicons, can be placed in the `public/` directory.
39 |
40 | ## 🧞 Commands
41 |
42 | All commands are run from the root of the project, from a terminal:
43 |
44 | | Command | Action |
45 | | :------------------------ | :----------------------------------------------- |
46 | | `npm install` | Installs dependencies |
47 | | `npm run dev` | Starts local dev server at `localhost:4321` |
48 | | `npm run build` | Build your production site to `./dist/` |
49 | | `npm run preview` | Preview your build locally, before deploying |
50 | | `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
51 | | `npm run astro -- --help` | Get help using the Astro CLI |
52 |
53 | ## 👀 Want to learn more?
54 |
55 | Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
56 |
--------------------------------------------------------------------------------
/pages/astro.config.mjs:
--------------------------------------------------------------------------------
1 | import {defineConfig} from 'astro/config';
2 | import starlight from '@astrojs/starlight';
3 | import starlightImageZoomPlugin from "starlight-image-zoom";
4 |
5 | // https://astro.build/config
6 | export default defineConfig({
7 | site: 'https://smartboot.tech/',
8 | base: '/smart-servlet',
9 | trailingSlash: "always",
10 | integrations: [
11 | starlight({
12 | title: 'smart-servlet',
13 | logo: {
14 | src: './public/logo.svg',
15 | },
16 | head: [
17 | {
18 | tag: 'meta',
19 | attrs: {
20 | property: 'keywords',
21 | content: '信创,国产,国产化,替代,tomcat,国产Servlet容器,国产Servlet,smart-servlet,smartservlet,undertow,jetty,自研,自研Tomcat',
22 | }
23 | }, {
24 | tag: 'meta',
25 | attrs: {
26 | property: 'description',
27 | content: 'smart-servlet 提供一个自主可控的轻量级 Tomcat/Undertow 可替代版本,重新定义下一代 Servlet 容器!',
28 | }
29 | },{
30 | tag:'script',
31 | attrs: {
32 | src: 'https://smartboot.tech/js/gitee.js'
33 | }
34 | },
35 | {
36 | tag:'script',
37 | content: 'if(!location.pathname.endsWith("smart-servlet/")){checkStar("smartboot-x","smart-servlet");}'
38 | },
39 | ],
40 | social: {
41 | github: 'https://github.com/smartboot/smart-servlet',
42 | },
43 | plugins: [starlightImageZoomPlugin()],
44 | // 为此网站设置英语为默认语言。
45 | defaultLocale: 'root',
46 | locales: {
47 | // 'zh-cn': {
48 | // label: '简体中文',
49 | // lang: 'zh-CN',
50 | // },
51 | 'en': {
52 | label: 'English',
53 | lang: 'en',
54 | },
55 | // 英文文档在 `src/content/docs/en/` 中。
56 | root: {
57 | label: '简体中文',
58 | lang: 'zh-CN',
59 | }
60 | },
61 | sidebar: [
62 | {
63 | label: '指南',
64 | autogenerate: {directory: 'guides'},
65 | },
66 | {
67 | label: '参考',
68 | autogenerate: {directory: 'reference'},
69 | },
70 | ],
71 | }),
72 | ],
73 | });
74 |
--------------------------------------------------------------------------------
/pages/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "type": "module",
4 | "version": "0.0.1",
5 | "scripts": {
6 | "dev": "astro dev",
7 | "start": "astro dev",
8 | "build": "astro build",
9 | "preview": "astro preview",
10 | "astro": "astro"
11 | },
12 | "dependencies": {
13 | "@astrojs/starlight": "0.30.2",
14 | "astro": "5.0.9",
15 | "sharp": "^0.32.5",
16 | "starlight-image-zoom": "^0.9.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/pages/public/favicon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/pages/public/wx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/public/wx.png
--------------------------------------------------------------------------------
/pages/src/assets/houston.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/assets/houston.webp
--------------------------------------------------------------------------------
/pages/src/components/Mermaid.astro:
--------------------------------------------------------------------------------
1 | ---
2 | // Mermaid.astro
3 | const { code } = Astro.props;
4 | let content = await Astro.slots.render('default');
5 | if (!content) {
6 | content=""
7 | }
8 | console.log(code)
9 | // content=content.replaceAll("
", '\n').replaceAll("
", '\n').replaceAll("—>","-->");
10 |
11 | ---
12 |
13 |
14 |
17 |
--------------------------------------------------------------------------------
/pages/src/components/PerformanceChart.astro:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/pages/src/content/config.ts:
--------------------------------------------------------------------------------
1 | import { defineCollection } from 'astro:content';
2 | import { docsSchema } from '@astrojs/starlight/schema';
3 |
4 | export const collections = {
5 | docs: defineCollection({ schema: docsSchema() }),
6 | };
7 |
--------------------------------------------------------------------------------
/pages/src/content/docs/en/guides/tck_report.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: TCK Report
3 | description: A reference page in my new Starlight docs site.
4 | ---
5 |
6 | ## About Jakarta Servlet TCK
7 | [Jakarta Servlet TCK](https://github.com/jakartaee/servlet/tree/master/tck) defines a server-side API for handling HTTP requests and is based on Junit5 and Arquillian.
8 |
9 |
10 | ## smart-servlet TCK report
11 | | Tests | Errors | Failures |Skipped|Success Rate|Time|Download|
12 | | :---: | :---: | :---: | :---: | :---: | :---: |---|
13 | | 1716 | 199 | 0 | 0 | 88.4% | 2024-07-28 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.0/test-report.zip)|
14 | | 1718 | 95 | 0 | 0 | 94.5% | 2024-08-11 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.1/test-report.zip)|
15 | | 1716 | 29 | 0 | 0 | 98.3% | 2024-08-31 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.2/test-report.zip)|
16 | | 1717 | 8 | 0 | 0 | 99.5% | 2024-11-10 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.3/test-report.zip)|
17 | | 1717 | 5 | 0 | 0 | 99.7% | 2024-11-19 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.4/test-report.zip)|
18 | | 1717 | 3 | 0 | 0 | 99.8% | 2025-01-16 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.8/test-report.zip)|
19 |
--------------------------------------------------------------------------------
/pages/src/content/docs/en/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: A lighter and faster alternative to Tomcat
3 | description: tomcat,undertow,jetty,smart-servlet,smartservlet
4 | template: splash
5 | hero:
6 | tagline: smart-servlet provides an autonomously controlled, lightweight Tomcat/Undertow alternative that redefines the next generation of Servlet containers!
7 | image:
8 | file: ../../../assets/houston.webp
9 | actions:
10 | - text: Product Manual
11 | link: ./guides/about/
12 | icon: right-arrow
13 | variant: primary
14 | - text: Download Latest Version
15 | link: ./guides/release_note/
16 | icon: external
17 | ---
18 |
19 | import { Card, CardGrid } from '@astrojs/starlight/components';
20 |
21 | ## Features
22 |
23 |
24 |
25 | Any framework that follows the Servlet specification can run directly on the smart-servlet.
26 |
27 |
28 | Make the Servlet container with the strongest performance and the smallest volume. Easily achieve 100,000-level QPS and redefine Web speed.
29 |
30 |
31 | Embedded integration, mixed dynamic and static deployment, customized SPI, and easy business expansion.
32 |
33 |
34 | What the times need is no longer just a web server. Concurrency stability, data security and service reliability are guarded by me.
35 |
36 |
37 |
38 | ## Performance Test Report
39 |
40 | Server-side test code:[Bootstrap.java](https://github.com/smartboot/smart-servlet/blob/master/springboot-demo/src/main/java/org/smartboot/demo/starter/Bootstrap.java)
41 | |concurrency|Tomcat|Undertow|smart-servlet|Pressure testing command|
42 | |:---|:---:|:---:|:---:|---|
43 | |10|64311|74860|93812|**`ab -n 1000000 -c 10 -k http://127.0.0.1:8080/plaintext`**|
44 | |100|92047|89037|108844|**`ab -n 1000000 -c 100 -k http://127.0.0.1:8080/plaintext`**|
45 | |1000|88997|102439|111308|**`ab -n 1000000 -c 1000 -k http://127.0.0.1:8080/plaintext`**|
46 |
47 |
--------------------------------------------------------------------------------
/pages/src/content/docs/guides/about.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: 1.1 概述
3 | sidebar:
4 | order: 1
5 | ---
6 | import {Image} from "astro:assets";
7 | import {CardGrid, LinkCard, TabItem, Tabs, FileTree, Aside} from '@astrojs/starlight/components';
8 | import Mermaid from '../../../components/Mermaid.astro';
9 |
10 | smart-servlet 是一个基于 Jakarta Servlet 6.1 规范的轻量级、高性能的 Servlet 容器,专为 Java 17+ 环境设计。
11 |
12 | 它以低资源占用、高并发处理能力和灵活的扩展性著称,是 Tomcat 和 Undertow 的理想替代方案。
13 | 
14 |
15 | **核心优势**
16 |
17 | - **轻量级设计**:内存占用低至 12MB,启动快速,适合资源受限的环境。
18 | - **高性能**:支持十万级 QPS,适用于高并发场景。
19 | - **灵活扩展**:丰富的 SPI 接口和插件机制,支持自定义协议处理、安全策略扩展等。
20 | - **安全可靠**:内置完善的安全机制,支持热部署和高可用性配置。
21 |
22 | **适用场景**
23 |
24 | - 信创需求:满足国产化要求,提供自主可控的解决方案。
25 | - 高并发应用:处理大量并发请求,提升服务性能。
26 | - 微服务架构:无缝支持 Spring Boot、Spring Cloud 等现代化架构。
27 |
28 |
29 | **开源仓库:**
30 |
31 | - Github:[https://github.com/smartboot/smart-servlet](https://github.com/smartboot/smart-servlet)
32 | - Gitee:[https://gitee.com/smartboot/smart-servlet](https://gitee.com/smartboot/smart-servlet)
33 |
34 |
48 |
49 |
50 |
51 | ## 产品对比
52 |
53 | **测试场景:**
54 |
55 | 以工程中的 springboot-demo 模块为压测用例,压测工具为 wrk,1024个并发持续15秒。
56 |
57 | | 产品名称 | smart-servlet | Tomcat | Undertow |
58 | | --- | --- | --- | --- |
59 | | 初始Heap内存 | 12MB | 15MB | 15MB |
60 | |初始Metaspace|29MB|30MB|30MB|
61 | |压测 QPS|42W/s|10W/s|40W/s|
62 | |压测Heap峰值|400MB|550MB|750MB|
63 | |结论|性能高、内存低|性能弱、内存中等|性能高、内存高|
64 |
65 |
68 |
69 |
70 | ## 开始使用
71 |
72 | 1. **快速上手**:
73 | - [下载最新版本](../release_note/)
74 | - [查看安装指南](../install/)
75 |
76 | [//]: # ( - [探索示例项目](./guides/examples/))
77 |
78 | 2. **获取支持**:
79 | - [社区论坛](https://gitee.com/smartboot-x/smart-servlet/issues)
80 | - [联系作者](/smart-servlet/zh-cn/#联系我们)
81 |
82 | ---
--------------------------------------------------------------------------------
/pages/src/content/docs/guides/tck_report.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: TCK Report
3 | description: A reference page in my new Starlight docs site.
4 | ---
5 |
6 | ## About Jakarta Servlet TCK
7 | [Jakarta Servlet TCK](https://github.com/jakartaee/servlet/tree/master/tck) defines a server-side API for handling HTTP requests and is based on Junit5 and Arquillian.
8 |
9 |
10 | ## smart-servlet TCK report
11 | | Tests | Errors | Failures |Skipped|Success Rate|Time|Download|
12 | | :---: | :---: | :---: | :---: | :---: | :---: |---|
13 | | 1716 | 199 | 0 | 0 | 88.4% | 2024-07-28 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.0/test-report.zip)|
14 | | 1718 | 95 | 0 | 0 | 94.5% | 2024-08-11 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.1/test-report.zip)|
15 | | 1716 | 29 | 0 | 0 | 98.3% | 2024-08-31 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.2/test-report.zip)|
16 | | 1717 | 8 | 0 | 0 | 99.5% | 2024-11-10 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.3/test-report.zip)|
17 | | 1717 | 5 | 0 | 0 | 99.7% | 2024-11-19 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.4/test-report.zip)|
18 | | 1717 | 3 | 0 | 0 | 99.8% | 2025-01-16 |[test-report](https://github.com/smartboot/smart-servlet/releases/download/v2.8/test-report.zip)|
19 |
20 |
--------------------------------------------------------------------------------
/pages/src/content/docs/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: 更轻量、更极速的 Tomcat 替代方案
3 | description: 信创,tomcat,国产Tomcat,国产Servlet容器,国产Servlet,smart-servlet,smartservlet,undertow,jetty,自研,自研Tomcat
4 | template: splash
5 | hero:
6 | tagline: smart-servlet 提供一个自主可控的轻量级 Tomcat/Undertow 可替代版本,重新定义下一代 Servlet 容器!
7 | image:
8 | file: ../../assets/houston.webp
9 | actions:
10 | - text: 产品手册
11 | link: ./guides/about/
12 | icon: right-arrow
13 | variant: primary
14 | - text: 下载最新版
15 | link: ./guides/release_note/
16 | icon: external
17 | ---
18 |
19 | import { Card, CardGrid ,LinkButton,Icon} from '@astrojs/starlight/components';
20 | import GithubDownloadCount from '../../components/GithubDownloadCount.astro';
21 | import PerformanceChart from '../../components/PerformanceChart.astro';
22 |
23 |
24 |
25 | ## 特性
26 |
27 |
28 |
29 | 支持所有遵循 Servlet 规范的框架,包括但不限于 Spring Boot、Spring Cloud、Shiro 等。
30 | 无论是传统的 Web 应用,还是现代化的微服务架构,都能无缝运行。
31 |
32 |
33 | 采用轻量级设计和高效 IO 模型,支持十万级 QPS,内存占用低至 12MB。无论是高并发场景,还是资源受限的环境,都能游刃有余。
34 |
35 |
36 | 提供丰富的 SPI 接口和插件机制,支持自定义协议处理、安全策略扩展、性能监控集成等。无论是业务需求还是架构调整,都能轻松应对。
37 |
38 |
39 | 内置完善的安全机制,包括 SSL 加密、访问控制、防注入攻击等。同时具备高可用性和高稳定性,支持热部署、平滑升级等企业级特性。
40 |
41 |
42 |
43 | ## 性能测试报告
44 |
45 | 服务端测试代码:[Bootstrap.java](https://github.com/smartboot/smart-servlet/blob/master/springboot-demo/src/main/java/org/smartboot/demo/starter/Bootstrap.java)
46 |
47 |
48 |
49 | |concurrency|Tomcat|Undertow|smart-servlet|压测指令|
50 | |:---|:---:|:---:|:---:|---|
51 | |10|64311|74860|93812|**`ab -n 1000000 -c 10 -k http://127.0.0.1:8080/plaintext`**|
52 | |100|92047|89037|108844|**`ab -n 1000000 -c 100 -k http://127.0.0.1:8080/plaintext`**|
53 | |1000|88997|102439|111308|**`ab -n 1000000 -c 1000 -k http://127.0.0.1:8080/plaintext`**|
54 |
55 |
56 |
57 |
58 |
59 |
60 | ## 联系我们
61 |
62 |
63 | Hi~ 我是 **三刀**,smart-servlet 的作者。
64 |
65 | 您可以跟我聊聊:如何将应用从 Tomcat 迁移到 smart-servlet;
66 |
67 | 也可以向我了解:更多关于商业版本的授权;
68 |
69 | 也可以跟我讨论:双方如何合作......
70 |
71 | 期待您通过下面方式,与我取得联系。
72 |
73 |
74 | 微信
75 |
76 |
77 | 邮件
78 |
84 | zhengjunweimail @163.com
85 |
86 |
--------------------------------------------------------------------------------
/pages/src/content/docs/performance/ab_smart-servlet.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/content/docs/performance/ab_smart-servlet.jpeg
--------------------------------------------------------------------------------
/pages/src/content/docs/performance/ab_smart-servlet_1000.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/content/docs/performance/ab_smart-servlet_1000.jpeg
--------------------------------------------------------------------------------
/pages/src/content/docs/performance/ab_smart-servlet_150.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/content/docs/performance/ab_smart-servlet_150.jpeg
--------------------------------------------------------------------------------
/pages/src/content/docs/performance/ab_tomcat.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/content/docs/performance/ab_tomcat.jpeg
--------------------------------------------------------------------------------
/pages/src/content/docs/performance/ab_tomcat_150.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/pages/src/content/docs/performance/ab_tomcat_150.jpeg
--------------------------------------------------------------------------------
/pages/src/content/docs/reference/xinchuang.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: 信创指引
3 | ---
4 | import { Badge,Card,LinkCard, CardGrid} from '@astrojs/starlight/components';
5 | import Mermaid from '../../../components/Mermaid.astro';
6 |
7 | ## 1. 信创背景与挑战
8 | 随着国家对信息技术应用创新(信创)的大力推进,国产化替代已成为各行各业数字化转型的重要方向。在 Web 服务领域,传统的 Tomcat 和 Undertow 等容器虽然功能强大,但在信创环境下存在以下挑战:
9 |
10 | - **技术依赖性**:部分组件或协议依赖国外技术栈,存在安全隐患。
11 | - **性能瓶颈**:在高并发、低延迟的场景下,资源占用和性能表现有待优化。
12 | - **生态适配**:与国产操作系统、中间件和数据库的兼容性需要进一步验证。
13 |
14 | smart-servlet 作为一款完全自主研发的 Servlet 容器,从底层架构到功能实现均基于国产化需求进行优化,为信创环境提供了更可靠的选择。
15 |
16 |
17 | Web服务器
29 | smart-socket
通信框架
30 | 特性
31 | Jakarta Servlet 6.1
32 | Websocket
33 | SSE
34 | AI
35 | `}/>
36 |
37 | ## 2. 信创适用领域
38 |
39 | smart-servlet 在信创领域的适用场景广泛,尤其适合以下行业:
40 |
41 |
42 |
43 | 支持高并发、低延迟的金融交易系统,满足证券、银行、保险等行业的信创改造需求。
44 |
45 |
46 | 适配电子政务平台、数据共享系统等场景,确保政府信息化系统的自主可控。
47 |
48 |
49 | 为电力、石油等能源行业的生产管理系统提供稳定高效的 Web 服务支持。
50 |
51 |
52 | 支持在线教育平台、教务管理系统等场景,满足教育信息化的国产化需求。
53 |
54 |
55 | 适配医疗信息管理系统、电子病历系统等场景,保障医疗数据的安全性。
56 |
57 |
58 | 支持交通管理系统、智能调度平台等场景,提升交通信息化的国产化水平。
59 |
60 |
61 |
62 | ---
63 | ## 3. 自研底层平台
64 |
65 | smart-servlet 采用完全自主研发的底层架构,确保核心技术的自主可控:
66 |
67 |
68 |
69 | 基于 Feat 的高性能 Web 服务器框架,支持高并发场景下的低资源占用。
70 |
71 |
72 | 自研通信框架,优化 TCP/UDP 协议栈,提升网络通信效率。
73 |
74 |
75 |
76 | ---
77 |
78 | ## 4. 信创特性
79 |
80 | smart-servlet 在信创环境下的核心特性包括:
81 |
82 |
83 |
84 | 完全适配 Jakarta Servlet 6.1 规范,支持现代化 Web 应用开发。
85 |
86 |
87 | 提供高性能的 WebSocket 和 Server-Sent Events(SSE)支持,满足实时通信需求。
88 |
89 |
90 | 支持与国产 AI 框架的无缝集成,助力智能化应用开发。
91 |
92 |
93 |
94 | ---
95 |
96 | ## 5. 信创服务
97 |
98 | 为了更好地服务信创客户,我们提供以下支持:
99 |
100 |
101 |
102 | 提供专业的信创环境部署和技术指导服务。
103 |
104 |
105 | 根据客户需求,提供信创环境下的定制化开发服务。
106 |
107 |
108 | 提供信创环境下 smart-servlet 的使用和运维培训。
109 |
110 |
111 |
112 | ---
113 |
114 |
115 | ## 6. 总结
116 |
117 | smart-servlet 作为一款完全自主研发的高性能 Servlet 容器,凭借其轻量级设计、高并发性能和灵活的扩展性,正在成为信创领域的首选解决方案。我们致力于为信创客户提供更可靠的技术支持和更完善的生态适配,助力国产化替代的顺利推进。
--------------------------------------------------------------------------------
/pages/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/pages/src/pages/license/[...license].astro:
--------------------------------------------------------------------------------
1 | ---
2 | export function getStaticPaths() {
3 | return [
4 | {
5 | params: {
6 | license: '2932A607C1C5B5260512F59D80D4105F',
7 | },
8 | props: {
9 | user: 'smartboot社区开发者',
10 | beginTime: '2023-01-01',
11 | endTime: '2024-01-01',
12 | type:'开源版',
13 | }
14 | },
15 | {params: {license: undefined}, props: {user: '无效', beginTime: '2023-01-01', endTime: '2024-01-01'}},
16 | ];
17 | }
18 | const {license} = Astro.params;
19 | ---
20 |
21 |
22 |
23 |
24 |
25 | 授权证书-{Astro.props.user}
26 |
27 |
28 |
29 |
30 | smart-servlet 授权证书
31 |
32 |
33 |
34 |
37 |
38 |
授权编号: {license}
39 |
授权用户: {Astro.props.user}
40 |
授权日期: {Astro.props.beginTime}
41 |
有效期至: {Astro.props.endTime}
42 |
授权产品: {Astro.props.type}
43 |
44 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/pages/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "astro/tsconfigs/strict"
3 | }
4 |
--------------------------------------------------------------------------------
/servlet-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 | smart-servlet-parent
17 | tech.smartboot.servlet
18 | 3.1-SNAPSHOT
19 |
20 | servlet-core
21 | 4.0.0
22 | servlet-core
23 |
24 |
25 | tech.smartboot.feat
26 | feat-core
27 |
28 |
29 |
30 | jakarta.servlet
31 | jakarta.servlet-api
32 | 6.1.0
33 |
34 |
35 | jakarta.annotation
36 | jakarta.annotation-api
37 | 2.1.1
38 |
39 |
40 | jakarta.websocket
41 | jakarta.websocket-api
42 | 2.1.1
43 |
44 |
45 | jakarta.websocket
46 | jakarta.websocket-client-api
47 | 2.1.1
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/SmartHttpServletRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet;
12 |
13 | import jakarta.servlet.http.HttpServletRequest;
14 | import tech.smartboot.servlet.conf.ServletInfo;
15 | import tech.smartboot.servlet.conf.ServletMappingInfo;
16 | import tech.smartboot.servlet.plugins.security.LoginAccount;
17 |
18 | import javax.net.ssl.SSLEngine;
19 |
20 | /**
21 | * @author 三刀
22 | * @version V1.0 , 2020/11/22
23 | */
24 | public interface SmartHttpServletRequest extends HttpServletRequest {
25 | void setRequestUri(String requestUri);
26 |
27 | void setServletInfo(ServletInfo servletInfo);
28 |
29 | ServletInfo getServletInfo();
30 |
31 | void setServletMappingInfo(ServletMappingInfo servletMappingInfo);
32 |
33 | ServletMappingInfo getServletMappingInfo();
34 |
35 | void setAsyncSupported(boolean supported);
36 |
37 | void setLoginAccount(LoginAccount loginAccount);
38 |
39 | SSLEngine getSslEngine();
40 | }
41 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/WebSocketServerContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet;
12 |
13 | import jakarta.websocket.server.ServerContainer;
14 |
15 | public interface WebSocketServerContainer extends ServerContainer {
16 | // void doUpgrade(HttpServletRequest request, HttpServletResponse response, final ServerEndpointConfig sec, Endpoint endpoint, Map pathParams) throws ServletException, IOException;
17 | }
18 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/ErrorPageInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | /**
14 | * @author 三刀
15 | * @version V1.0 , 2019/12/13
16 | */
17 | public class ErrorPageInfo {
18 | private final String location;
19 | private final Integer errorCode;
20 | private final String exceptionType;
21 |
22 | public ErrorPageInfo(String location, Integer errorCode, String exceptionType) {
23 | this.location = location;
24 | this.errorCode = errorCode;
25 | this.exceptionType = exceptionType;
26 | }
27 |
28 | public String getLocation() {
29 | return location;
30 | }
31 |
32 | public Integer getErrorCode() {
33 | return errorCode;
34 | }
35 |
36 | public String getExceptionType() {
37 | return exceptionType;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/FilterInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import jakarta.servlet.Filter;
14 |
15 | import java.util.ArrayList;
16 | import java.util.Collections;
17 | import java.util.HashMap;
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | /**
22 | * @author 三刀
23 | * @version V1.0 , 2020/11/14
24 | */
25 | public class FilterInfo {
26 |
27 | private final Map initParams = new HashMap<>();
28 | private String filterClass;
29 | private String filterName;
30 | private Filter filter;
31 | private boolean dynamic;
32 | private boolean asyncSupported;
33 | private final List mappings = new ArrayList<>();
34 |
35 | public Filter getFilter() {
36 | return filter;
37 | }
38 |
39 | public void setFilter(Filter filter) {
40 | this.filter = filter;
41 | }
42 |
43 | public String getFilterClass() {
44 | return filterClass;
45 | }
46 |
47 | public void setFilterClass(String filterClass) {
48 | this.filterClass = filterClass;
49 | }
50 |
51 | public String getFilterName() {
52 | return filterName;
53 | }
54 |
55 | public void setFilterName(String filterName) {
56 | this.filterName = filterName;
57 | }
58 |
59 | public FilterInfo addInitParam(final String name, final String value) {
60 | initParams.put(name, value);
61 | return this;
62 | }
63 |
64 | public Map getInitParams() {
65 | return Collections.unmodifiableMap(initParams);
66 | }
67 |
68 | public boolean isDynamic() {
69 | return dynamic;
70 | }
71 |
72 | public void setDynamic(boolean dynamic) {
73 | this.dynamic = dynamic;
74 | }
75 |
76 | public boolean isAsyncSupported() {
77 | return asyncSupported;
78 | }
79 |
80 | public void setAsyncSupported(boolean asyncSupported) {
81 | this.asyncSupported = asyncSupported;
82 | }
83 |
84 | public List getMappings() {
85 | return mappings;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/LoginConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | public class LoginConfig {
14 | private String authMethod;
15 | private String realmName;
16 | private String loginPage;
17 | private String errorPage;
18 |
19 | public String getRealmName() {
20 | return realmName;
21 | }
22 |
23 | public void setRealmName(String realmName) {
24 | this.realmName = realmName;
25 | }
26 |
27 | public String getLoginPage() {
28 | return loginPage;
29 | }
30 |
31 | public void setLoginPage(String loginPage) {
32 | this.loginPage = loginPage;
33 | }
34 |
35 | public String getErrorPage() {
36 | return errorPage;
37 | }
38 |
39 | public void setErrorPage(String errorPage) {
40 | this.errorPage = errorPage;
41 | }
42 |
43 | public String getAuthMethod() {
44 | return authMethod;
45 | }
46 |
47 | public void setAuthMethod(String authMethod) {
48 | this.authMethod = authMethod;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/OrderMeta.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import java.net.URL;
14 | import java.util.List;
15 |
16 | public class OrderMeta {
17 | private String name;
18 | private List before;
19 | private boolean beforeOthers;
20 | private List after;
21 | private boolean afterOthers;
22 | private URL url;
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public List getBefore() {
33 | return before;
34 | }
35 |
36 | public void setBefore(List before) {
37 | this.before = before;
38 | }
39 |
40 | public List getAfter() {
41 | return after;
42 | }
43 |
44 | public void setAfter(List after) {
45 | this.after = after;
46 | }
47 |
48 | public URL getUrl() {
49 | return url;
50 | }
51 |
52 | public void setUrl(URL url) {
53 | this.url = url;
54 | }
55 |
56 | public boolean isBeforeOthers() {
57 | return beforeOthers;
58 | }
59 |
60 | public void setBeforeOthers(boolean beforeOthers) {
61 | this.beforeOthers = beforeOthers;
62 | }
63 |
64 | public boolean isAfterOthers() {
65 | return afterOthers;
66 | }
67 |
68 | public void setAfterOthers(boolean afterOthers) {
69 | this.afterOthers = afterOthers;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/SecurityConstraint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import jakarta.servlet.annotation.ServletSecurity;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | public class SecurityConstraint {
19 | //13.8 没有指定角色的授权约束表示在任何情况下都不允许访问受约束请求
20 | private ServletSecurity.EmptyRoleSemantic emptyRoleSemantic = ServletSecurity.EmptyRoleSemantic.DENY;
21 | private ServletSecurity.TransportGuarantee transportGuarantee = ServletSecurity.TransportGuarantee.NONE;
22 | // private final List resourceNames = new ArrayList<>();
23 | private final List urlPatterns = new ArrayList<>();
24 | private final List httpMethods = new ArrayList<>();
25 | private final List httpMethodOmissions = new ArrayList();
26 |
27 | private List roleNames;
28 |
29 | public List getUrlPatterns() {
30 | return urlPatterns;
31 | }
32 |
33 | public List getHttpMethods() {
34 | return httpMethods;
35 | }
36 |
37 | public List getHttpMethodOmissions() {
38 | return httpMethodOmissions;
39 | }
40 |
41 | public List getRoleNames() {
42 | return roleNames;
43 | }
44 |
45 | public void setRoleNames(List roleNames) {
46 | this.roleNames = roleNames;
47 | }
48 |
49 | public ServletSecurity.EmptyRoleSemantic getEmptyRoleSemantic() {
50 | return emptyRoleSemantic;
51 | }
52 |
53 | public void setEmptyRoleSemantic(ServletSecurity.EmptyRoleSemantic emptyRoleSemantic) {
54 | this.emptyRoleSemantic = emptyRoleSemantic;
55 | }
56 |
57 | public ServletSecurity.TransportGuarantee getTransportGuarantee() {
58 | return transportGuarantee;
59 | }
60 |
61 | public void setTransportGuarantee(ServletSecurity.TransportGuarantee transportGuarantee) {
62 | this.transportGuarantee = transportGuarantee;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/ServletContainerInitializerInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import jakarta.servlet.ServletContainerInitializer;
14 | import java.util.Set;
15 |
16 | /**
17 | * @author 三刀(zhengjunweimail@163.com)
18 | * @version V1.0 , 2021/5/10
19 | */
20 | public class ServletContainerInitializerInfo {
21 | private final ServletContainerInitializer servletContainerInitializer;
22 | private final Set> handlesTypes;
23 |
24 | public ServletContainerInitializerInfo(ServletContainerInitializer servletContainerInitializer, Set> handlesTypes) {
25 | this.servletContainerInitializer = servletContainerInitializer;
26 | this.handlesTypes = handlesTypes;
27 | }
28 |
29 | public ServletContainerInitializer getServletContainerInitializer() {
30 | return servletContainerInitializer;
31 | }
32 |
33 | public Set> getHandlesTypes() {
34 | return handlesTypes;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/ServletMappingInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | /**
14 | * @author 三刀
15 | * @version V1.0 , 2020/10/11
16 | */
17 | public class ServletMappingInfo extends UrlPattern {
18 | private final ServletInfo servletInfo;
19 |
20 | public ServletMappingInfo(ServletInfo servletName, String mapping) {
21 | super(mapping);
22 | this.servletInfo = servletName;
23 | }
24 |
25 | public ServletInfo getServletInfo() {
26 | return servletInfo;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/UrlPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import jakarta.servlet.http.MappingMatch;
14 | import tech.smartboot.servlet.util.PathMatcherUtil;
15 |
16 | public class UrlPattern {
17 | private final String urlPattern;
18 | private final MappingMatch mappingMatch;
19 |
20 | public UrlPattern(String urlPattern) {
21 | if (urlPattern == null) {
22 | this.urlPattern = null;
23 | this.mappingMatch = null;
24 | } else {
25 | this.urlPattern = PathMatcherUtil.getUrlPattern(urlPattern);
26 | this.mappingMatch = PathMatcherUtil.getMappingType(this.urlPattern);
27 | }
28 |
29 | }
30 |
31 | public String getUrlPattern() {
32 | return urlPattern;
33 | }
34 |
35 | public MappingMatch getMappingMatch() {
36 | return mappingMatch;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/conf/WebFragmentInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.conf;
12 |
13 | import java.util.Optional;
14 |
15 | public class WebFragmentInfo extends WebAppInfo {
16 | private String name;
17 |
18 | public String getName() {
19 | return name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public void mergeTo(WebAppInfo webAppInfo) {
27 | getServlets().values().forEach(servletInfo -> {
28 | ServletInfo mainServletInfo = webAppInfo.getServlets().get(servletInfo.getServletName());
29 | if (mainServletInfo == null) {
30 | webAppInfo.addServlet(servletInfo);
31 | } else {
32 | servletInfo.getInitParams().forEach((key, val) -> {
33 | if (!mainServletInfo.getInitParams().containsKey(key)) {
34 | mainServletInfo.getInitParams().put(key, val);
35 | }
36 | });
37 | }
38 | //具有相同的元素可以添加到多个 web-fragment。在 web.xml 中
39 | //指定的覆盖在 web-fragment 中指定的同名的的
40 | if (webAppInfo.getServletMappings().get(servletInfo.getServletName()) == null && getServletMappings().get(servletInfo.getServletName()) != null) {
41 | webAppInfo.getServletMappings().put(servletInfo.getServletName(), getServletMappings().get(servletInfo.getServletName()));
42 | }
43 |
44 | });
45 | getFilters().stream().filter(filterInfo -> webAppInfo.getFilters().stream().noneMatch(mainFilter -> filterInfo.getFilterName().equals(mainFilter.getFilterName()))).forEach(webAppInfo::addFilter);
46 | getFilters().forEach(filterInfo -> {
47 | Optional optional = webAppInfo.getFilters().stream().filter(mainFilter -> filterInfo.getFilterName().equals(mainFilter.getFilterName())).findFirst();
48 | if (optional.isPresent()) {
49 | filterInfo.getInitParams().forEach((key, val) -> {
50 | if (!optional.get().getInitParams().containsKey(key)) {
51 | optional.get().getInitParams().put(key, val);
52 | }
53 | });
54 | } else {
55 | webAppInfo.addFilter(filterInfo);
56 | }
57 | });
58 | webAppInfo.getFilterMappingInfos().addAll(getFilterMappingInfos());
59 |
60 |
61 | webAppInfo.getListeners().addAll(getListeners());
62 | webAppInfo.getWelcomeFileList().addAll(getWelcomeFileList());
63 | webAppInfo.getErrorPages().addAll(getErrorPages());
64 | getMimeMappings().forEach((key, val) -> {
65 | if (!webAppInfo.getMimeMappings().containsKey(val)) {
66 | webAppInfo.getMimeMappings().put(key, val);
67 | }
68 | });
69 | getContextParams().forEach((key, val) -> {
70 | if (!webAppInfo.getContextParams().containsKey(val)) {
71 | webAppInfo.getContextParams().put(key, val);
72 | }
73 | });
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/enums/FilterMappingType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.enums;
12 |
13 | /**
14 | * Filter映射类型:、
15 | *
16 | * @author 三刀
17 | */
18 | public enum FilterMappingType {
19 | URL,
20 | SERVLET;
21 | }
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/enums/ServletContextPathType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.enums;
12 |
13 | /**
14 | * @author 三刀
15 | * @version V1.0 , 2020/11/14
16 | */
17 | public enum ServletContextPathType {
18 | PATH,
19 | JAR;
20 | }
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/enums/SslCertType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.enums;
12 |
13 | public enum SslCertType {
14 | pem,
15 | jks,
16 | custom;
17 | public static SslCertType getByCode(String type) {
18 | return SslCertType.valueOf(type);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/Handler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import jakarta.servlet.ServletException;
14 |
15 | import java.io.IOException;
16 |
17 | /**
18 | * 请求处理器
19 | *
20 | * @author 三刀
21 | * @version V1.0 , 2019/12/11
22 | */
23 | public abstract class Handler {
24 | /**
25 | * 持有下一个处理器的句柄
26 | */
27 | protected Handler nextHandler;
28 |
29 | /**
30 | * 处理handlerContext中的请求
31 | *
32 | * @param handlerContext
33 | * @throws Exception
34 | */
35 | public abstract void handleRequest(HandlerContext handlerContext) throws ServletException, IOException;
36 |
37 | /**
38 | * 执行下一层处理器
39 | *
40 | * @param handlerContext
41 | * @throws Exception
42 | */
43 | protected final void doNext(HandlerContext handlerContext) throws ServletException, IOException {
44 | if (nextHandler != null) {
45 | nextHandler.handleRequest(handlerContext);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/HandlerContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import tech.smartboot.servlet.SmartHttpServletRequest;
14 | import tech.smartboot.servlet.conf.ServletInfo;
15 | import tech.smartboot.servlet.impl.ServletContextImpl;
16 |
17 | import jakarta.servlet.ServletRequest;
18 | import jakarta.servlet.ServletResponse;
19 |
20 | /**
21 | * 请求处理上下文对象
22 | *
23 | * @author 三刀
24 | * @version V1.0 , 2019/12/11
25 | */
26 | public class HandlerContext {
27 | /**
28 | * 请求
29 | */
30 | private final SmartHttpServletRequest originalRequest;
31 | /**
32 | * 响应
33 | */
34 | private ServletResponse response;
35 | /**
36 | * 匹配的Servlet上下文
37 | */
38 | private final ServletContextImpl servletContext;
39 | private final boolean namedDispatcher;
40 |
41 | /**
42 | * 匹配的Servlet处理器
43 | */
44 | private ServletInfo servletInfo;
45 |
46 | private ServletRequest request;
47 |
48 | public HandlerContext(SmartHttpServletRequest originalRequest, ServletResponse response, ServletContextImpl servletContext, boolean namedDispatcher) {
49 | this.originalRequest = originalRequest;
50 | this.response = response;
51 | this.servletContext = servletContext;
52 | this.namedDispatcher = namedDispatcher;
53 | this.request = originalRequest;
54 | }
55 |
56 | public ServletContextImpl getServletContext() {
57 | return servletContext;
58 | }
59 |
60 |
61 | public SmartHttpServletRequest getOriginalRequest() {
62 | return originalRequest;
63 | }
64 |
65 | public ServletResponse getResponse() {
66 | return response;
67 | }
68 |
69 | public void setResponse(ServletResponse response) {
70 | this.response = response;
71 | }
72 |
73 | public ServletRequest getRequest() {
74 | return request;
75 | }
76 |
77 | public void setRequest(ServletRequest request) {
78 | this.request = request;
79 | }
80 |
81 | public ServletInfo getServletInfo() {
82 | return servletInfo;
83 | }
84 |
85 | public void setServletInfo(ServletInfo servletInfo) {
86 | this.servletInfo = servletInfo;
87 | this.originalRequest.setServletInfo(servletInfo);
88 | }
89 |
90 | public boolean isNamedDispatcher() {
91 | return namedDispatcher;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/HandlerPipeline.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import jakarta.servlet.ServletException;
14 |
15 | import java.io.IOException;
16 |
17 | /**
18 | * @author 三刀
19 | * @version V1.0 , 2019/11/3
20 | */
21 | public final class HandlerPipeline extends Handler {
22 | /**
23 | * 管道尾
24 | */
25 | private Handler tailHandler;
26 |
27 | /**
28 | * 添加HttpHandle至末尾
29 | *
30 | * @param handle 尾部handle
31 | * @return 当前管道对象
32 | */
33 | public HandlerPipeline next(Handler handle) {
34 | if (nextHandler == null) {
35 | nextHandler = tailHandler = handle;
36 | return this;
37 | }
38 | Handler httpHandle = tailHandler;
39 | while (httpHandle.nextHandler != null) {
40 | httpHandle = httpHandle.nextHandler;
41 | }
42 | httpHandle.nextHandler = handle;
43 | return this;
44 | }
45 |
46 | public HandlerPipeline head(Handler handle) {
47 | if (handle == null || handle.nextHandler != null) {
48 | throw new IllegalArgumentException("head handle must be null or head handle nextHandler must be null");
49 | }
50 | handle.nextHandler = nextHandler;
51 | nextHandler = handle;
52 | return this;
53 | }
54 |
55 | @Override
56 | public void handleRequest(HandlerContext handlerContext) throws ServletException, IOException {
57 | nextHandler.handleRequest(handlerContext);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/SecurityHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import jakarta.servlet.ServletException;
14 |
15 | import java.io.IOException;
16 |
17 | public class SecurityHandler extends Handler {
18 | @Override
19 | public void handleRequest(HandlerContext handlerContext) throws ServletException, IOException {
20 | if (handlerContext.getServletContext().getRuntime().getSecurityProvider().login(handlerContext.getOriginalRequest(), handlerContext.getResponse(), handlerContext.getServletInfo())) {
21 | doNext(handlerContext);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/ServletRequestListenerHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import jakarta.servlet.DispatcherType;
14 | import jakarta.servlet.ServletContext;
15 | import jakarta.servlet.ServletException;
16 | import jakarta.servlet.ServletRequestEvent;
17 | import jakarta.servlet.ServletRequestListener;
18 | import tech.smartboot.feat.core.common.logging.Logger;
19 | import tech.smartboot.feat.core.common.logging.LoggerFactory;
20 |
21 | import java.io.IOException;
22 | import java.util.List;
23 |
24 | /**
25 | * @author 三刀
26 | * @version V1.0 , 2019/12/19
27 | */
28 | public class ServletRequestListenerHandler extends Handler {
29 | private static final Logger LOGGER = LoggerFactory.getLogger(ServletRequestListenerHandler.class);
30 |
31 | @Override
32 | public void handleRequest(HandlerContext handlerContext) throws ServletException, IOException {
33 | if (handlerContext.getRequest().getDispatcherType() != DispatcherType.REQUEST) {
34 | doNext(handlerContext);
35 | return;
36 | }
37 | ServletContext servletContext = handlerContext.getServletContext();
38 | List servletRequestListeners = handlerContext.getServletContext().getDeploymentInfo().getServletRequestListeners();
39 | if (servletRequestListeners.isEmpty()) {
40 | doNext(handlerContext);
41 | return;
42 | }
43 | ServletRequestEvent servletRequestEvent = new ServletRequestEvent(servletContext, handlerContext.getRequest());
44 | servletRequestListeners.forEach(requestListener -> {
45 | requestListener.requestInitialized(servletRequestEvent);
46 | LOGGER.info("requestInitialized " + requestListener);
47 | });
48 | try {
49 | doNext(handlerContext);
50 | } finally {
51 | for (int i = servletRequestListeners.size() - 1; i >= 0; i--) {
52 | servletRequestListeners.get(i).requestDestroyed(servletRequestEvent);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/handler/ServletServiceHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.handler;
12 |
13 | import jakarta.servlet.ServletException;
14 | import jakarta.servlet.ServletRequest;
15 | import jakarta.servlet.ServletResponse;
16 | import jakarta.servlet.UnavailableException;
17 | import jakarta.servlet.http.HttpServletRequest;
18 | import jakarta.servlet.http.HttpServletResponse;
19 | import tech.smartboot.feat.core.common.HttpStatus;
20 |
21 | import java.io.IOException;
22 |
23 | /**
24 | * 匹配并执行符合当前请求的Servlet
25 | *
26 | * @author 三刀
27 | * @version V1.0 , 2019/12/11
28 | */
29 | public class ServletServiceHandler extends Handler {
30 |
31 | @Override
32 | public void handleRequest(HandlerContext handlerContext) throws ServletException, IOException {
33 | ServletRequest request = handlerContext.getRequest();
34 | ServletResponse response = handlerContext.getResponse();
35 |
36 | //成功匹配到Servlet,直接执行
37 | try {
38 | handlerContext.getServletInfo().getServlet().service(request, response);
39 | } catch (UnavailableException e) {
40 | //UnavailableException 表示 servlet 暂时或永久不能处理请求。
41 | //如果 UnavailableException 表示的是一个永久性的不可用,Servlet 容器必须从服务中移除这个 Servlet,调用
42 | //它的 destroy 方法,并释放 Servlet 实例。所有由于这种原因被容器拒绝的请求,都会返回一个 SC_NOT_FOUND (404) 响应。
43 | ((HttpServletResponse) response).setStatus(HttpStatus.NOT_FOUND.value());
44 | } catch (Throwable e) {
45 | ((HttpServletResponse) response).setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
46 | Throwable throwable = e;
47 | String location = handlerContext.getServletContext().getDeploymentInfo().getErrorPageLocation(throwable);
48 | while (location == null && throwable.getCause() != null) {
49 | location = handlerContext.getServletContext().getDeploymentInfo().getErrorPageLocation(throwable.getCause());
50 | throwable = throwable.getCause();
51 | }
52 |
53 | if (location == null) {
54 | location = handlerContext.getServletContext().getDeploymentInfo().getErrorPageLocation(HttpStatus.INTERNAL_SERVER_ERROR.value());
55 | }
56 | if (location != null) {
57 | handlerContext.getServletContext().getRuntime().getDispatcherProvider().error(handlerContext.getServletContext(), location, (HttpServletRequest) request, (HttpServletResponse) response, throwable, handlerContext.getServletInfo().getServletName(), throwable.getMessage());
58 | } else {
59 | throw e;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/FilterConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import tech.smartboot.servlet.conf.FilterInfo;
14 |
15 | import jakarta.servlet.FilterConfig;
16 | import jakarta.servlet.ServletContext;
17 | import java.util.Collections;
18 | import java.util.Enumeration;
19 |
20 | /**
21 | * @author 三刀
22 | * @version V1.0 , 2020/11/14
23 | */
24 | public class FilterConfigImpl implements FilterConfig {
25 |
26 | private final FilterInfo filterInfo;
27 | private final ServletContext servletContext;
28 |
29 | public FilterConfigImpl(final FilterInfo filterInfo, final ServletContext servletContext) {
30 | this.filterInfo = filterInfo;
31 | this.servletContext = servletContext;
32 | }
33 |
34 | @Override
35 | public String getFilterName() {
36 | return filterInfo.getFilterName();
37 | }
38 |
39 | @Override
40 | public ServletContext getServletContext() {
41 | return servletContext;
42 | }
43 |
44 | @Override
45 | public String getInitParameter(final String name) {
46 | return filterInfo.getInitParams().get(name);
47 | }
48 |
49 | @Override
50 | public Enumeration getInitParameterNames() {
51 | return Collections.enumeration(filterInfo.getInitParams().keySet());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/HttpServletMappingImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.http.HttpServletMapping;
14 | import jakarta.servlet.http.MappingMatch;
15 | import tech.smartboot.servlet.conf.ServletMappingInfo;
16 |
17 | public class HttpServletMappingImpl implements HttpServletMapping {
18 | private final ServletMappingInfo servletMappingInfo;
19 | private final MappingMatch mappingMatch;
20 | private final String matchValue;
21 |
22 | public HttpServletMappingImpl(MappingMatch mappingMatch, ServletMappingInfo servletMappingInfo, String matchValue) {
23 | this.mappingMatch = mappingMatch;
24 | this.servletMappingInfo = servletMappingInfo;
25 | this.matchValue = matchValue;
26 | }
27 |
28 | @Override
29 | public String getMatchValue() {
30 | return matchValue;
31 | }
32 |
33 | @Override
34 | public String getPattern() {
35 | return servletMappingInfo.getUrlPattern();
36 | }
37 |
38 | @Override
39 | public String getServletName() {
40 | return servletMappingInfo.getServletInfo().getServletName();
41 | }
42 |
43 | @Override
44 | public MappingMatch getMappingMatch() {
45 | return mappingMatch;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/JspConfigDescriptorImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.descriptor.JspConfigDescriptor;
14 | import jakarta.servlet.descriptor.JspPropertyGroupDescriptor;
15 | import jakarta.servlet.descriptor.TaglibDescriptor;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Collection;
19 | import java.util.List;
20 |
21 | public class JspConfigDescriptorImpl implements JspConfigDescriptor {
22 | private final List tagLibs = new ArrayList<>();
23 | private final List jspGroups = new ArrayList<>();
24 |
25 | @Override
26 | public Collection getTaglibs() {
27 | return tagLibs;
28 | }
29 |
30 | @Override
31 | public Collection getJspPropertyGroups() {
32 | return jspGroups;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/PartImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.http.Part;
14 |
15 | import java.io.File;
16 | import java.io.IOException;
17 | import java.io.InputStream;
18 | import java.util.Collection;
19 |
20 | /**
21 | * @author 三刀(zhengjunweimail@163.com)
22 | * @version V1.0 , 2022/11/19
23 | */
24 | public class PartImpl implements Part {
25 |
26 | private final tech.smartboot.feat.core.common.multipart.Part fileItem;
27 | private final File location;
28 |
29 | public PartImpl(tech.smartboot.feat.core.common.multipart.Part fileItem, File location) {
30 | this.fileItem = fileItem;
31 | this.location = location;
32 | }
33 |
34 | @Override
35 | public void delete() throws IOException {
36 | fileItem.delete();
37 | }
38 |
39 | @Override
40 | public String getContentType() {
41 | return fileItem.getContentType();
42 | }
43 |
44 | @Override
45 | public String getHeader(String name) {
46 | return fileItem.getHeader(name);
47 | }
48 |
49 | @Override
50 | public Collection getHeaderNames() {
51 | return fileItem.getHeaderNames();
52 | }
53 |
54 | @Override
55 | public Collection getHeaders(String name) {
56 | return fileItem.getHeaders(name);
57 | }
58 |
59 | @Override
60 | public InputStream getInputStream() throws IOException {
61 | return fileItem.getInputStream();
62 | }
63 |
64 | @Override
65 | public String getName() {
66 | return fileItem.getName();
67 | }
68 |
69 | @Override
70 | public long getSize() {
71 | return fileItem.getSize();
72 | }
73 |
74 | @Override
75 | public void write(String fileName) throws IOException {
76 | fileItem.write(fileName);
77 | }
78 |
79 | /*
80 | * Adapted from FileUploadBase.getFileName()
81 | */
82 | @Override
83 | public String getSubmittedFileName() {
84 | return fileItem.getSubmittedFileName();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/ServletConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import tech.smartboot.servlet.conf.ServletInfo;
14 |
15 | import jakarta.servlet.ServletConfig;
16 | import jakarta.servlet.ServletContext;
17 | import java.util.Collections;
18 | import java.util.Enumeration;
19 | /**
20 | * @author 三刀
21 | * @version V1.0 , 2020/11/14
22 | */
23 | public class ServletConfigImpl implements ServletConfig {
24 |
25 | private final ServletInfo servletInfo;
26 | private final ServletContext servletContext;
27 |
28 | public ServletConfigImpl(final ServletInfo servletInfo, final ServletContext servletContext) {
29 | this.servletInfo = servletInfo;
30 | this.servletContext = servletContext;
31 | }
32 |
33 | @Override
34 | public String getServletName() {
35 | return servletInfo.getServletName();
36 | }
37 |
38 | @Override
39 | public ServletContext getServletContext() {
40 | return servletContext;
41 | }
42 |
43 | @Override
44 | public String getInitParameter(final String name) {
45 | return servletInfo.getInitParams().get(name);
46 | }
47 |
48 | @Override
49 | public Enumeration getInitParameterNames() {
50 | return Collections.enumeration(servletInfo.getInitParams().keySet());
51 | }
52 | }
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/ServletContextWrapperListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.ServletContextListener;
14 |
15 | public class ServletContextWrapperListener {
16 | private final ServletContextListener listener;
17 | private final boolean dynamic;
18 |
19 | public ServletContextWrapperListener(ServletContextListener listener, boolean dynamic) {
20 | this.listener = listener;
21 | this.dynamic = dynamic;
22 | }
23 |
24 | public ServletContextListener getListener() {
25 | return listener;
26 | }
27 |
28 | public boolean isDynamic() {
29 | return dynamic;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/ServletInputStreamImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.ReadListener;
14 | import jakarta.servlet.ServletInputStream;
15 | import tech.smartboot.feat.core.common.io.BodyInputStream;
16 |
17 | import java.io.IOException;
18 |
19 | /**
20 | * @author 三刀(zhengjunweimail@163.com)
21 | * @version V1.0 , 2020/12/12
22 | */
23 | public class ServletInputStreamImpl extends ServletInputStream {
24 | private final BodyInputStream inputStream;
25 | private final HttpServletRequestImpl request;
26 |
27 | public ServletInputStreamImpl(HttpServletRequestImpl request, BodyInputStream inputStream) {
28 | this.request = request;
29 | this.inputStream = inputStream;
30 | }
31 |
32 | @Override
33 | public boolean isFinished() {
34 | return inputStream.isFinished();
35 | }
36 |
37 | @Override
38 | public boolean isReady() {
39 | if (request.isAsyncStarted()) {
40 | return inputStream.isReady();
41 | } else {
42 | return false;
43 | }
44 | }
45 |
46 | @Override
47 | public void setReadListener(ReadListener readListener) {
48 | if (readListener == null) {
49 | throw new NullPointerException();
50 | }
51 | if (!request.isAsyncStarted()) {
52 | throw new IllegalStateException();
53 | }
54 |
55 | inputStream.setReadListener(new tech.smartboot.feat.core.common.io.ReadListener() {
56 | @Override
57 | public void onDataAvailable() throws IOException {
58 | readListener.onDataAvailable();
59 | }
60 |
61 | @Override
62 | public void onAllDataRead() throws IOException {
63 | readListener.onAllDataRead();
64 | }
65 |
66 | @Override
67 | public void onError(Throwable t) {
68 | readListener.onError(t);
69 | }
70 | });
71 | }
72 |
73 | @Override
74 | public int read() throws IOException {
75 | return inputStream.read();
76 | }
77 |
78 | @Override
79 | public int read(byte[] b, int off, int len) throws IOException {
80 | return inputStream.read(b, off, len);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/ServletPrintWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import tech.smartboot.feat.core.common.logging.Logger;
14 | import tech.smartboot.feat.core.common.logging.LoggerFactory;
15 |
16 | import java.io.IOException;
17 | import java.io.UnsupportedEncodingException;
18 | import java.io.Writer;
19 | import java.nio.ByteBuffer;
20 | import java.nio.CharBuffer;
21 | import java.nio.charset.Charset;
22 | import java.nio.charset.CharsetEncoder;
23 | import java.nio.charset.CoderResult;
24 | import java.nio.charset.CodingErrorAction;
25 | import java.nio.charset.UnsupportedCharsetException;
26 |
27 | /**
28 | * @author 三刀
29 | * @version V1.0 , 2020/11/10
30 | */
31 | public class ServletPrintWriter extends Writer {
32 | private static final Logger LOGGER = LoggerFactory.getLogger(ServletPrintWriter.class);
33 | private final ServletOutputStreamImpl servletOutputStream;
34 | private final CharsetEncoder charsetEncoder;
35 |
36 | public ServletPrintWriter(ServletOutputStreamImpl servletOutputStream, String charset) throws UnsupportedEncodingException {
37 | super(servletOutputStream);
38 | this.servletOutputStream = servletOutputStream;
39 | try {
40 | this.charsetEncoder = Charset.forName(charset).newEncoder();
41 | charsetEncoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
42 | charsetEncoder.onMalformedInput(CodingErrorAction.REPLACE);
43 | } catch (UnsupportedCharsetException e) {
44 | throw new UnsupportedEncodingException(e.getMessage());
45 | }
46 | }
47 |
48 | @Override
49 | public void write(char[] cbuf, int off, int len) throws IOException {
50 | if (len == 0) {
51 | return;
52 | }
53 | write(CharBuffer.wrap(cbuf, off, len));
54 | }
55 |
56 | @Override
57 | public void write(String str, int off, int len) throws IOException {
58 | if (len == 0) {
59 | return;
60 | }
61 | write(CharBuffer.wrap(str, off, len));
62 | }
63 |
64 | private void write(CharBuffer buffer) throws IOException {
65 | while (buffer.hasRemaining()) {
66 | ByteBuffer virtualBuffer = ByteBuffer.allocate(buffer.remaining() < 32 ? 32 : buffer.remaining() << 1);
67 |
68 | //第二步:编码
69 | CoderResult result = charsetEncoder.encode(buffer, virtualBuffer, true);
70 | if (result.isError()) {
71 | LOGGER.info("encoding result:{} ,remaining", result);
72 | }
73 |
74 | //第三步:输出
75 | virtualBuffer.flip();
76 | servletOutputStream.write(virtualBuffer.array(), 0, virtualBuffer.remaining());
77 | if (buffer.hasRemaining()) {
78 | LOGGER.info("continue encoding ,remaining:" + buffer.remaining());
79 | }
80 | }
81 | }
82 |
83 | @Override
84 | public void flush() throws IOException {
85 | servletOutputStream.flush();
86 | }
87 |
88 | @Override
89 | public void close() throws IOException {
90 | servletOutputStream.close();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/UpgradeServletInputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.ReadListener;
14 | import jakarta.servlet.ServletInputStream;
15 | import tech.smartboot.feat.core.common.io.BodyInputStream;
16 |
17 | import java.io.IOException;
18 |
19 | public class UpgradeServletInputStream extends ServletInputStream {
20 | private final BodyInputStream inputStream;
21 |
22 | public UpgradeServletInputStream(BodyInputStream inputStream) {
23 | this.inputStream = inputStream;
24 | }
25 |
26 | @Override
27 | public boolean isFinished() {
28 | return inputStream.isFinished();
29 | }
30 |
31 | @Override
32 | public boolean isReady() {
33 | return inputStream.isReady();
34 | }
35 |
36 | @Override
37 | public void setReadListener(ReadListener readListener) {
38 | inputStream.setReadListener(new tech.smartboot.feat.core.common.io.ReadListener() {
39 | @Override
40 | public void onDataAvailable() throws IOException {
41 | readListener.onDataAvailable();
42 | }
43 |
44 | @Override
45 | public void onAllDataRead() throws IOException {
46 | readListener.onAllDataRead();
47 | }
48 |
49 | @Override
50 | public void onError(Throwable t) {
51 | readListener.onError(t);
52 | }
53 | });
54 | }
55 |
56 | @Override
57 | public int read() throws IOException {
58 | return inputStream.read();
59 | }
60 |
61 | @Override
62 | public int read(byte[] b, int off, int len) throws IOException {
63 | return inputStream.read(b, off, len);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/UpgradeServletOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.ServletOutputStream;
14 | import jakarta.servlet.WriteListener;
15 |
16 | import java.io.IOException;
17 |
18 | public class UpgradeServletOutputStream extends ServletOutputStream {
19 | @Override
20 | public boolean isReady() {
21 | return false;
22 | }
23 |
24 | @Override
25 | public void setWriteListener(WriteListener writeListener) {
26 |
27 | }
28 |
29 | @Override
30 | public void write(int b) throws IOException {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/WebConnectionImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import jakarta.servlet.http.WebConnection;
14 | import tech.smartboot.feat.core.server.HttpRequest;
15 |
16 | public abstract class WebConnectionImpl implements WebConnection {
17 | private final HttpRequest request;
18 |
19 | public WebConnectionImpl(HttpRequest httpRequest) {
20 | this.request = httpRequest;
21 | }
22 |
23 |
24 | public HttpRequest getRequest() {
25 | return request;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/impl/WriterOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.impl;
12 |
13 | import java.io.IOException;
14 | import java.io.OutputStream;
15 | import java.io.Writer;
16 |
17 | public class WriterOutputStream extends OutputStream {
18 | private final Writer writer;
19 |
20 | public WriterOutputStream(Writer writer) {
21 | this.writer = writer;
22 | }
23 |
24 | @Override
25 | public void write(byte[] b) throws IOException {
26 | write(b, 0, b.length);
27 | }
28 |
29 | @Override
30 | public void write(byte[] b, int off, int len) throws IOException {
31 | writer.write(new String(b, off, len));
32 | }
33 |
34 | @Override
35 | public void flush() throws IOException {
36 | writer.flush();
37 | }
38 |
39 | @Override
40 | public void close() throws IOException {
41 | writer.close();
42 | }
43 |
44 | @Override
45 | public void write(int b) throws IOException {
46 | write(new byte[]{(byte) b});
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/PluginException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins;
12 |
13 | /**
14 | * @author 三刀
15 | * @version V1.0 , 2020/11/27
16 | */
17 | public class PluginException extends RuntimeException {
18 | public PluginException(String message) {
19 | super(message);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/async/AsyncContextPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.async;
12 |
13 | import tech.smartboot.servlet.ServletContextRuntime;
14 | import tech.smartboot.servlet.plugins.Plugin;
15 |
16 | public class AsyncContextPlugin extends Plugin {
17 | @Override
18 | public void addServletContext(ServletContextRuntime runtime) {
19 | runtime.setAsyncContextProvider(new AsyncContextProviderImpl());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/async/AsyncContextProviderImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.async;
12 |
13 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
14 | import tech.smartboot.servlet.provider.AsyncContextProvider;
15 |
16 | import jakarta.servlet.AsyncContext;
17 | import jakarta.servlet.ServletRequest;
18 | import jakarta.servlet.ServletResponse;
19 |
20 | public class AsyncContextProviderImpl implements AsyncContextProvider {
21 | @Override
22 | public AsyncContext startAsync(HttpServletRequestImpl request, ServletRequest servletRequest, ServletResponse servletResponse, AsyncContext asyncContext) throws IllegalStateException {
23 | return new AsyncContextImpl(request.getServletContext().getRuntime(), request, servletRequest, servletResponse, request.getCompletableFuture(), (AsyncContextImpl) asyncContext);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/basic/LicenseEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.basic;
12 |
13 | import java.io.Serializable;
14 |
15 | /**
16 | * @author 三刀
17 | * @version V1.0 , 2020/3/26
18 | */
19 | public final class LicenseEntity implements Serializable {
20 |
21 | /**
22 | * 魔数
23 | */
24 | public static final byte[] MAGIC_NUM = new byte[]{115, 109, 97, 114, 116, 45, 108, 105, 99, 101, 110, 115, 101};
25 | /**
26 | * 公钥
27 | */
28 | private final byte[] publicKeys;
29 | /**
30 | * 申请时间
31 | */
32 | private final long applyTime = System.currentTimeMillis();
33 |
34 | /**
35 | * 过期时间
36 | */
37 | private final long expireTime;
38 |
39 | /**
40 | * 申请方
41 | */
42 | private String applicant;
43 |
44 | /**
45 | * 联系方式
46 | */
47 | private String contact;
48 |
49 | /**
50 | * 试用时长
51 | */
52 | private int trialDuration;
53 |
54 | /**
55 | * 原文
56 | */
57 | private transient byte[] data;
58 |
59 | public LicenseEntity(long expireTime, byte[] publicKeys) {
60 | this.expireTime = expireTime;
61 | this.publicKeys = publicKeys;
62 | }
63 |
64 | public long getExpireTime() {
65 | return expireTime;
66 | }
67 |
68 | public byte[] getPublicKeys() {
69 | return publicKeys;
70 | }
71 |
72 | public long getApplyTime() {
73 | return applyTime;
74 | }
75 |
76 | public byte[] getData() {
77 | return data;
78 | }
79 |
80 | public void setData(byte[] data) {
81 | this.data = data;
82 | }
83 |
84 | public String getApplicant() {
85 | return applicant;
86 | }
87 |
88 | public void setApplicant(String applicant) {
89 | this.applicant = applicant;
90 | }
91 |
92 | public String getContact() {
93 | return contact;
94 | }
95 |
96 | public void setContact(String contact) {
97 | this.contact = contact;
98 | }
99 |
100 | public int getTrialDuration() {
101 | return trialDuration;
102 | }
103 |
104 | public void setTrialDuration(int trialDuration) {
105 | this.trialDuration = trialDuration;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/basic/LicenseException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.basic;
12 |
13 | /**
14 | * @author 三刀
15 | * @version V1.0 , 2020/3/21
16 | */
17 | public class LicenseException extends RuntimeException {
18 | public LicenseException(String message) {
19 | super(message);
20 | }
21 |
22 | public LicenseException(String message, Throwable cause) {
23 | super(message, cause);
24 | }
25 |
26 | @Override
27 | public synchronized Throwable fillInStackTrace() {
28 | return this;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/basic/LicenseTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.basic;
12 |
13 | public class LicenseTO {
14 | private final long startTime = System.currentTimeMillis();
15 | private String sn;
16 | /**
17 | * 试用时长
18 | */
19 | private int trialDuration;
20 | /**
21 | * 授权对象
22 | */
23 | private String applicant;
24 |
25 | /**
26 | * 过期时间
27 | */
28 | private long expireTime;
29 |
30 | /**
31 | * 联系方式
32 | */
33 | private String contact;
34 |
35 | /**
36 | * 产品供应商
37 | */
38 | private String vendor;
39 |
40 | public String getApplicant() {
41 | return applicant;
42 | }
43 |
44 | public void setApplicant(String applicant) {
45 | this.applicant = applicant;
46 | }
47 |
48 | public long getExpireTime() {
49 | return expireTime;
50 | }
51 |
52 | public void setExpireTime(long expireTime) {
53 | this.expireTime = expireTime;
54 | }
55 |
56 | public int getTrialDuration() {
57 | return trialDuration;
58 | }
59 |
60 | public void setTrialDuration(int trialDuration) {
61 | this.trialDuration = trialDuration;
62 | }
63 |
64 | public long getStartTime() {
65 | return startTime;
66 | }
67 |
68 | public String getSn() {
69 | return sn;
70 | }
71 |
72 | public void setSn(String sn) {
73 | this.sn = sn;
74 | }
75 |
76 | public String getContact() {
77 | return contact;
78 | }
79 |
80 | public void setContact(String contact) {
81 | this.contact = contact;
82 | }
83 |
84 | public String getVendor() {
85 | return vendor;
86 | }
87 |
88 | public void setVendor(String vendor) {
89 | this.vendor = vendor;
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/basic/Md5.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.basic;
12 |
13 | import java.security.MessageDigest;
14 |
15 | public final class Md5 {
16 | private Md5() {
17 |
18 | }
19 |
20 | public static String md5(byte[] data) {
21 | final int m = 2;
22 | final int n = 4;
23 | final int a = 0xf;
24 | char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
25 | 'a', 'b', 'c', 'd', 'e', 'f'};
26 |
27 | try {
28 | MessageDigest mdTemp = MessageDigest.getInstance("MD5");
29 | mdTemp.update(data);
30 | byte[] md = mdTemp.digest();
31 | int j = md.length;
32 | char[] str = new char[j * m];
33 | int k = 0;
34 | for (byte b : md) {
35 | str[k++] = hexDigits[b >>> n & a];
36 | str[k++] = hexDigits[b & a];
37 | }
38 | return new String(str);
39 | } catch (Exception e) {
40 | return null;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/basic/RuntimeExpireStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.basic;
12 |
13 | /**
14 | * 软件运行时过期
15 | *
16 | * @author 三刀
17 | * @version V1.0 , 2020/4/13
18 | */
19 | public interface RuntimeExpireStrategy {
20 | void expire(LicenseEntity entity);
21 | }
22 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/dispatcher/DispatcherPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.dispatcher;
12 |
13 | import tech.smartboot.servlet.ServletContextRuntime;
14 | import tech.smartboot.servlet.plugins.Plugin;
15 |
16 | /**
17 | * @author 三刀
18 | * @version V1.0 , 2020/11/27
19 | */
20 | public class DispatcherPlugin extends Plugin {
21 |
22 | @Override
23 | public void willStartServletContext(ServletContextRuntime containerRuntime) {
24 | containerRuntime.setDispatcherProvider(new DispatcherProviderImpl());
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/dispatcher/DispatcherProviderImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.dispatcher;
12 |
13 | import jakarta.servlet.DispatcherType;
14 | import jakarta.servlet.RequestDispatcher;
15 | import jakarta.servlet.ServletException;
16 | import jakarta.servlet.http.HttpServletRequest;
17 | import jakarta.servlet.http.HttpServletResponse;
18 | import tech.smartboot.feat.core.common.utils.StringUtils;
19 | import tech.smartboot.servlet.conf.ServletInfo;
20 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
21 | import tech.smartboot.servlet.impl.ServletContextImpl;
22 | import tech.smartboot.servlet.provider.DispatcherProvider;
23 |
24 | import java.io.IOException;
25 |
26 | /**
27 | * @author 三刀
28 | * @version V1.0 , 2020/11/27
29 | */
30 | class DispatcherProviderImpl implements DispatcherProvider {
31 |
32 | @Override
33 | public RequestDispatcherImpl getRequestDispatcher(ServletContextImpl servletContext, String path) {
34 | //这个路径必须是相对于 ServletContext 的根路径,并且以‟/‟开头,或者为空
35 | if (path == null) {
36 | return null;
37 | }
38 | if (!path.startsWith("/")) {
39 | throw new IllegalArgumentException("");
40 | }
41 | return new RequestDispatcherImpl(servletContext, StringUtils.isBlank(servletContext.getContextPath()) ? path : servletContext.getContextPath() + path);
42 | }
43 |
44 | @Override
45 | public RequestDispatcher getNamedDispatcher(ServletContextImpl servletContext, String name) {
46 | System.out.println("getNamedDispatcher:" + name);
47 | ServletInfo servletInfo = servletContext.getDeploymentInfo().getServlets().get(name);
48 | if (servletInfo != null) {
49 | return new RequestDispatcherImpl(servletContext, servletInfo);
50 | }
51 | return null;
52 | }
53 |
54 | @Override
55 | public RequestDispatcher getRequestDispatcher(HttpServletRequestImpl request, String path) {
56 | if (path == null) {
57 | return null;
58 | }
59 | //If the path begins with a "/" it is interpreted as relative to the current context root
60 | if (path.startsWith("/")) {
61 | return getRequestDispatcher(request.getServletContext(), path);
62 | }
63 | int lastIndex = request.getRequestURI().lastIndexOf("/");
64 | if (lastIndex != -1) {
65 | return getRequestDispatcher(request.getServletContext(), request.getRequestURI().substring(request.getContextPath().length(), lastIndex + 1) + path);
66 | } else {
67 | return null;
68 | }
69 | }
70 |
71 | @Override
72 | public void error(ServletContextImpl servletContext, String path, HttpServletRequest req, HttpServletResponse resp, Throwable throwable, String errorServletName, String errorMessage) throws IOException {
73 | RequestDispatcherImpl requestDispatcher = getRequestDispatcher(servletContext, path);
74 | try {
75 | requestDispatcher.forward(req, resp, false, DispatcherType.ERROR, throwable, errorServletName, errorMessage);
76 | } catch (ServletException e) {
77 | throw new IOException(e);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/security/LoginAccount.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.security;
12 |
13 | import java.security.Principal;
14 | import java.util.Collections;
15 | import java.util.Set;
16 |
17 | public class LoginAccount implements Principal {
18 | private final String name;
19 | private final String password;
20 | private final Set roles;
21 | private final String authType;
22 |
23 | public LoginAccount(String name, String password, Set roles, String authType) {
24 | this.name = name;
25 | this.password = password;
26 | this.roles = roles == null ? Collections.emptySet() : roles;
27 | this.authType = authType;
28 | }
29 |
30 |
31 | public String getPassword() {
32 | return password;
33 | }
34 |
35 | public Set getRoles() {
36 | return roles;
37 | }
38 |
39 | @Override
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public String getAuthType() {
45 | return authType;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/security/SecurityAccount.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.security;
12 |
13 | import java.util.Collections;
14 | import java.util.Set;
15 |
16 | /**
17 | * 当前容器配置的认证信息
18 | *
19 | * @author 三刀
20 | */
21 | public class SecurityAccount {
22 | public static final String AUTH_TYPE_BASIC = "BASIC";
23 | public static final String FORM = "FORM";
24 | public static final String DIGEST = "DIGEST";
25 | public static final String CLIENT_CERT = "CLIENT_CERT";
26 | public static final String NONE = "NONE";
27 | private final String username;
28 | private final String password;
29 | private final String authType;
30 | private final Set roles;
31 |
32 | public SecurityAccount(String username, String password, String authType, Set roles) {
33 | this.username = username;
34 | this.password = password;
35 | this.authType = authType;
36 | this.roles = Collections.unmodifiableSet(roles);
37 | }
38 |
39 | public String getUsername() {
40 | return username;
41 | }
42 |
43 | public String getPassword() {
44 | return password;
45 | }
46 |
47 | public Set getRoles() {
48 | return roles;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/security/SecurityCheckServlet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.security;
12 |
13 | import jakarta.servlet.ServletException;
14 | import jakarta.servlet.http.HttpServlet;
15 | import jakarta.servlet.http.HttpServletRequest;
16 | import jakarta.servlet.http.HttpServletResponse;
17 | import jakarta.servlet.http.HttpSession;
18 | import tech.smartboot.servlet.conf.DeploymentInfo;
19 | import tech.smartboot.servlet.conf.LoginConfig;
20 | import tech.smartboot.servlet.provider.SecurityProvider;
21 |
22 | import java.io.IOException;
23 |
24 | public class SecurityCheckServlet extends HttpServlet {
25 | private DeploymentInfo deploymentInfo;
26 |
27 | public SecurityCheckServlet(DeploymentInfo deploymentInfo) {
28 | this.deploymentInfo = deploymentInfo;
29 | }
30 |
31 | @Override
32 | protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
33 | LoginConfig loginConfig = deploymentInfo.getLoginConfig();
34 | if (loginConfig != null && "FORM".equals(loginConfig.getAuthMethod())) {
35 | req.login(req.getParameter("j_username"), req.getParameter("j_password"));
36 | if(req.getUserPrincipal()==null){
37 | req.getRequestDispatcher(loginConfig.getErrorPage()).forward(req, resp);
38 | }else{
39 | HttpSession session = req.getSession();
40 | req.setAttribute(SecurityProvider.LOGIN_REDIRECT_METHOD, session.getAttribute(SecurityProvider.LOGIN_REDIRECT_METHOD));
41 | req.getRequestDispatcher((String) session.getAttribute(SecurityProvider.LOGIN_REDIRECT_URI)).forward(req, resp);
42 | }
43 |
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/security/SecurityTO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.security;
12 |
13 | import jakarta.servlet.annotation.ServletSecurity;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 | import java.util.Set;
18 |
19 | public class SecurityTO {
20 | private Set roles;
21 | private final List httpMethods = new ArrayList<>();
22 | private ServletSecurity.EmptyRoleSemantic emptyRoleSemantic;
23 | private ServletSecurity.TransportGuarantee transportGuarantee;
24 | }
25 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/session/SessionPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.session;
12 |
13 | import tech.smartboot.servlet.Container;
14 | import tech.smartboot.servlet.ServletContextRuntime;
15 | import tech.smartboot.servlet.plugins.Plugin;
16 |
17 | /**
18 | * @author 三刀
19 | * @version V1.0 , 2020/11/27
20 | */
21 | public class SessionPlugin extends Plugin {
22 |
23 | @Override
24 | public void initPlugin(Container container) {
25 |
26 | }
27 |
28 | @Override
29 | public void willStartServletContext(ServletContextRuntime containerRuntime) {
30 | SessionProviderImpl sessionProvider = new SessionProviderImpl();
31 | sessionProvider.setMaxInactiveInterval(containerRuntime.getDeploymentInfo().getSessionTimeout());
32 | containerRuntime.setSessionProvider(sessionProvider);
33 | }
34 |
35 | @Override
36 | public void onServletContextStopped(ServletContextRuntime runtime) {
37 | runtime.getSessionProvider().destroy();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/WebsocketPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket;
12 |
13 | import jakarta.servlet.DispatcherType;
14 | import jakarta.websocket.server.ServerContainer;
15 | import tech.smartboot.servlet.ServletContextRuntime;
16 | import tech.smartboot.servlet.conf.FilterInfo;
17 | import tech.smartboot.servlet.conf.FilterMappingInfo;
18 | import tech.smartboot.servlet.enums.FilterMappingType;
19 | import tech.smartboot.servlet.plugins.Plugin;
20 |
21 | import java.util.Collections;
22 |
23 | /**
24 | * @author 三刀(zhengjunweimail@163.com)
25 | * @version V1.0 , 2021/3/28
26 | */
27 | public class WebsocketPlugin extends Plugin {
28 |
29 |
30 | @Override
31 | public void willStartServletContext(ServletContextRuntime containerRuntime) {
32 | containerRuntime.setWebsocketProvider(new WebsocketProviderImpl());
33 | containerRuntime.getServletContext().setAttribute(ServerContainer.class.getName(), containerRuntime.getWebsocketProvider().getWebSocketServerContainer());
34 |
35 | //通过Filter触发WebSocket的Upgrade
36 | FilterInfo filterInfo = new FilterInfo();
37 | filterInfo.setFilterName("wsFilter");
38 | filterInfo.setFilterClass(WebSocketFilter.class.getName());
39 | filterInfo.setAsyncSupported(true);
40 | containerRuntime.getDeploymentInfo().addFilter(filterInfo);
41 | filterInfo.getMappings().add(new FilterMappingInfo(filterInfo.getFilterName(), FilterMappingType.URL, null, "/*", Collections.singleton(DispatcherType.REQUEST)));
42 | }
43 |
44 | @Override
45 | public String pluginName() {
46 | return "websocket";
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/WebsocketProviderImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket;
12 |
13 | import jakarta.websocket.server.ServerContainer;
14 | import tech.smartboot.servlet.plugins.websocket.impl.WebSocketServerContainerImpl;
15 | import tech.smartboot.servlet.provider.WebsocketProvider;
16 |
17 | /**
18 | * @author 三刀(zhengjunweimail@163.com)
19 | * @version V1.0 , 2021/3/31
20 | */
21 | public class WebsocketProviderImpl implements WebsocketProvider {
22 |
23 | private final WebSocketServerContainerImpl serverContainer = new WebSocketServerContainerImpl();
24 |
25 | @Override
26 | public ServerContainer getWebSocketServerContainer() {
27 | return serverContainer;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/HandlerWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import jakarta.websocket.MessageHandler;
14 |
15 | /**
16 | * @author 三刀(zhengjunweimail@163.com)
17 | * @version V1.0 , 2021/4/26
18 | */
19 | public class HandlerWrapper {
20 | private final MessageHandler.Whole> wholeHandler;
21 | private final MessageHandler.Partial> partialHandler;
22 | private final Class> messageType;
23 | private final boolean partial;
24 |
25 | public HandlerWrapper(MessageHandler.Whole> wholeHandler, final Class> messageType) {
26 | this(wholeHandler, null, messageType, false);
27 | }
28 |
29 | public HandlerWrapper(MessageHandler.Partial> partialHandler, final Class> messageType) {
30 | this(null, partialHandler, messageType, true);
31 | }
32 |
33 | HandlerWrapper(MessageHandler.Whole> wholeHandler, MessageHandler.Partial> partialHandler, Class> messageType, boolean partial) {
34 | this.wholeHandler = wholeHandler;
35 | this.partialHandler = partialHandler;
36 | this.messageType = messageType;
37 | this.partial = partial;
38 | }
39 |
40 |
41 | public Class getMessageType() {
42 | return messageType;
43 | }
44 |
45 | public MessageHandler.Whole getWholeHandler() {
46 | return wholeHandler;
47 | }
48 |
49 | public MessageHandler.Partial getPartialHandler() {
50 | return partialHandler;
51 | }
52 |
53 | public boolean isPartial() {
54 | return partial;
55 | }
56 | }
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/HandshakeRequestImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import jakarta.servlet.http.HttpServletRequest;
14 | import jakarta.websocket.server.HandshakeRequest;
15 | import java.net.URI;
16 | import java.security.Principal;
17 | import java.util.Arrays;
18 | import java.util.Collections;
19 | import java.util.Enumeration;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * @author 三刀(zhengjunweimail@163.com)
26 | * @version V1.0 , 2021/3/28
27 | */
28 | public class HandshakeRequestImpl implements HandshakeRequest {
29 |
30 | private final HttpServletRequest request;
31 |
32 | public HandshakeRequestImpl(HttpServletRequest request) {
33 | this.request = request;
34 | }
35 |
36 | @Override
37 | public Map> getHeaders() {
38 | Map> headers = new HashMap<>();
39 | Enumeration enumeration = request.getHeaderNames();
40 | while (enumeration.hasMoreElements()) {
41 | String name = enumeration.nextElement();
42 | headers.put(name, Collections.list(request.getHeaders(name)));
43 | }
44 | return headers;
45 | }
46 |
47 | @Override
48 | public Principal getUserPrincipal() {
49 | return request.getUserPrincipal();
50 | }
51 |
52 | @Override
53 | public URI getRequestURI() {
54 | return URI.create(request.getRequestURI());
55 | }
56 |
57 | @Override
58 | public boolean isUserInRole(String s) {
59 | return request.isUserInRole(s);
60 | }
61 |
62 | @Override
63 | public Object getHttpSession() {
64 | return request.getSession();
65 | }
66 |
67 | @Override
68 | public Map> getParameterMap() {
69 | Map parameters = request.getParameterMap();
70 | if (parameters == null || parameters.size() == 0) {
71 | return Collections.emptyMap();
72 | }
73 | Map> map = new HashMap<>();
74 | parameters.forEach((key, value) -> {
75 | map.put(key, Arrays.asList(value));
76 | });
77 | return Collections.unmodifiableMap(map);
78 | }
79 |
80 | @Override
81 | public String getQueryString() {
82 | return request.getQueryString();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/HandshakeResponseImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import jakarta.servlet.http.HttpServletResponse;
14 | import jakarta.websocket.HandshakeResponse;
15 | import java.util.Collections;
16 | import java.util.List;
17 | import java.util.Map;
18 |
19 | public class HandshakeResponseImpl implements HandshakeResponse {
20 | public HandshakeResponseImpl(HttpServletResponse response) {
21 |
22 | }
23 |
24 | @Override
25 | public Map> getHeaders() {
26 | return Collections.emptyMap();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/OnMessageConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import java.lang.annotation.Annotation;
14 | import java.lang.reflect.Method;
15 |
16 | /**
17 | * @author 三刀(zhengjunweimail@163.com)
18 | * @version V1.0 , 2021/4/27
19 | */
20 | public class OnMessageConfig {
21 | private final Method method;
22 | private final Object instance;
23 | private final Annotation[][] annotations;
24 | private Class> messageType;
25 |
26 | public OnMessageConfig(Method method, Object instance) {
27 | this.method = method;
28 | this.instance = instance;
29 | this.annotations = method.getParameterAnnotations();
30 | }
31 |
32 | public Method getMethod() {
33 | return method;
34 | }
35 |
36 | public Object getInstance() {
37 | return instance;
38 | }
39 |
40 | public Class getMessageType() {
41 | return messageType;
42 | }
43 |
44 | public void setMessageType(Class> messageType) {
45 | this.messageType = messageType;
46 | }
47 |
48 | public Annotation[][] getAnnotations() {
49 | return annotations;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/PathNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | /**
17 | * @author 三刀(zhengjunweimail@163.com)
18 | * @version V1.0 , 2021/5/2
19 | */
20 | public class PathNode {
21 |
22 | /**
23 | * 路径节点名称
24 | */
25 | private String nodeName;
26 | /**
27 | * 是否模式匹配
28 | */
29 | private boolean patternMatching;
30 |
31 | public static List convertToPathNodes(String path) {
32 | if (path.charAt(0) != '/') {
33 | throw new IllegalStateException("invalid path:" + path);
34 | }
35 | List pathNodes = new ArrayList<>();
36 | for (int i = 1; i < path.length(); i++) {
37 | if (path.charAt(i) == '/') {
38 | throw new IllegalStateException("invalid path:" + path);
39 | }
40 | int start = i++;
41 | for (; i < path.length(); i++) {
42 | if (path.charAt(i) == '/') {
43 | break;
44 | }
45 | }
46 | PathNode pathNode = new PathNode();
47 | pathNode.setPatternMatching(path.charAt(start) == '{' && path.charAt(i - 1) == '}');
48 | if (pathNode.isPatternMatching()) {
49 | pathNode.setNodeName(path.substring(start + 1, i - 1));
50 | } else {
51 | pathNode.setNodeName(path.substring(start, i));
52 | }
53 |
54 |
55 | pathNodes.add(pathNode);
56 | }
57 | return pathNodes;
58 | }
59 |
60 | public String getNodeName() {
61 | return nodeName;
62 | }
63 |
64 | public void setNodeName(String nodeName) {
65 | this.nodeName = nodeName;
66 | }
67 |
68 | public boolean isPatternMatching() {
69 | return patternMatching;
70 | }
71 |
72 | public void setPatternMatching(boolean patternMatching) {
73 | this.patternMatching = patternMatching;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/plugins/websocket/impl/WholeMessageHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.plugins.websocket.impl;
12 |
13 | import jakarta.websocket.MessageHandler;
14 | import jakarta.websocket.Session;
15 | import jakarta.websocket.server.PathParam;
16 | import java.lang.annotation.Annotation;
17 | import java.lang.reflect.InvocationTargetException;
18 | import java.lang.reflect.Method;
19 | import java.util.Map;
20 |
21 | class WholeMessageHandler implements MessageHandler.Whole {
22 | private final OnMessageConfig messageConfig;
23 | private final Session session;
24 | private final Map data;
25 |
26 | public WholeMessageHandler(OnMessageConfig messageConfig, Session session, Map data) {
27 | this.messageConfig = messageConfig;
28 | this.session = session;
29 | this.data = data;
30 | }
31 |
32 | @Override
33 | public void onMessage(T message) {
34 | try {
35 | Method method = messageConfig.getMethod();
36 | Object[] args = new Object[method.getParameterTypes().length];
37 | int i = 0;
38 | for (Class> paramType : method.getParameterTypes()) {
39 | Object value = null;
40 | PathParam pathParam = null;
41 | for (Annotation annotation : messageConfig.getAnnotations()[i]) {
42 | if (annotation.annotationType() == PathParam.class) {
43 | pathParam = (PathParam) annotation;
44 | }
45 | }
46 | if (pathParam != null) {
47 | value = data.get(pathParam.value());
48 | } else if (Session.class == paramType) {
49 | value = session;
50 | } else if (messageConfig.getMessageType() == paramType) {
51 | value = message;
52 | }
53 | args[i++] = value;
54 | }
55 | method.invoke(messageConfig.getInstance(), args);
56 | } catch (IllegalAccessException | InvocationTargetException e) {
57 | e.printStackTrace();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/AsyncContextProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
14 |
15 | import jakarta.servlet.AsyncContext;
16 | import jakarta.servlet.ServletRequest;
17 | import jakarta.servlet.ServletResponse;
18 |
19 | public interface AsyncContextProvider {
20 | AsyncContext startAsync(HttpServletRequestImpl request, ServletRequest servletRequest, ServletResponse servletResponse, AsyncContext asyncContext) throws IllegalStateException;
21 | }
22 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/DispatcherProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import jakarta.servlet.RequestDispatcher;
14 | import jakarta.servlet.http.HttpServletRequest;
15 | import jakarta.servlet.http.HttpServletResponse;
16 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
17 | import tech.smartboot.servlet.impl.ServletContextImpl;
18 |
19 | import java.io.IOException;
20 |
21 | /**
22 | * @author 三刀
23 | * @version V1.0 , 2020/11/27
24 | */
25 | public interface DispatcherProvider {
26 | RequestDispatcher getRequestDispatcher(ServletContextImpl servletContext, String path);
27 |
28 | RequestDispatcher getNamedDispatcher(ServletContextImpl servletContext, String name);
29 |
30 | RequestDispatcher getRequestDispatcher(HttpServletRequestImpl request, String path);
31 |
32 | default void error(ServletContextImpl servletContext, String path, HttpServletRequest req, HttpServletResponse resp) throws IOException {
33 | error(servletContext, path, req, resp, null, null, null);
34 | }
35 |
36 | default void error(ServletContextImpl servletContext, String path, HttpServletRequest req, HttpServletResponse resp, Throwable throwable, String errorServletName, String errorMessage) throws IOException {
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/FaviconProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import tech.smartboot.servlet.ServletContextRuntime;
14 |
15 | public interface FaviconProvider {
16 | void resister(ServletContextRuntime runtime);
17 | }
18 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/MappingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import tech.smartboot.servlet.conf.ServletMappingInfo;
14 |
15 | public interface MappingProvider {
16 | default void addMapping(ServletMappingInfo servletMappingInfo) {
17 | }
18 |
19 | ServletMappingInfo matchWithContextPath(String url);
20 |
21 | ServletMappingInfo matchWithoutContextPath(String url);
22 | }
23 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/SecurityProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import jakarta.servlet.ServletException;
14 | import jakarta.servlet.ServletResponse;
15 | import jakarta.servlet.http.HttpServletResponse;
16 | import tech.smartboot.servlet.SmartHttpServletRequest;
17 | import tech.smartboot.servlet.conf.ServletInfo;
18 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
19 | import tech.smartboot.servlet.plugins.security.LoginAccount;
20 | import tech.smartboot.servlet.plugins.security.SecurityAccount;
21 |
22 | import java.io.IOException;
23 | import java.util.Set;
24 |
25 | public interface SecurityProvider {
26 | String LOGIN_REDIRECT_URI = SecurityProvider.class.getName() + "_login_redirect_uri";
27 | String LOGIN_REDIRECT_METHOD = SecurityProvider.class.getName() + "_login_redirect_method";
28 |
29 | void addUser(String username, String password, Set roles);
30 |
31 | public SecurityAccount login(String username, String password) throws ServletException;
32 |
33 | public boolean authenticate(HttpServletRequestImpl httpServletRequest, HttpServletResponse response) throws IOException, ServletException;
34 |
35 | public boolean isUserInRole(String role, LoginAccount loginAccount, HttpServletRequestImpl httpServletRequest);
36 |
37 |
38 | public void logout(HttpServletRequestImpl httpServletRequest) throws ServletException;
39 |
40 | public boolean login(SmartHttpServletRequest request, ServletResponse response, ServletInfo servletInfo) throws ServletException, IOException;
41 | }
42 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/SessionProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import jakarta.servlet.http.HttpServletResponse;
14 | import jakarta.servlet.http.HttpSession;
15 | import tech.smartboot.servlet.impl.HttpServletRequestImpl;
16 |
17 | /**
18 | * @author 三刀
19 | * @version V1.0 , 2020/11/27
20 | */
21 | public interface SessionProvider {
22 | String DEFAULT_SESSION_PARAMETER_NAME = "jsessionid";
23 | String DEFAULT_SESSION_COOKIE_NAME = "JSESSIONID";
24 |
25 | HttpSession getSession(HttpServletRequestImpl request, HttpServletResponse response, boolean create);
26 |
27 | void changeSessionId(HttpSession httpSession);
28 |
29 | void updateAccessTime(HttpServletRequestImpl request);
30 |
31 | void pauseAccessTime(HttpServletRequestImpl request);
32 |
33 | void destroy();
34 |
35 | boolean isRequestedSessionIdValid(HttpServletRequestImpl request);
36 | }
37 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/VendorProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import jakarta.servlet.http.HttpServletResponse;
14 |
15 | public interface VendorProvider {
16 | void signature(HttpServletResponse response);
17 | }
18 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/provider/WebsocketProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.provider;
12 |
13 | import jakarta.websocket.server.ServerContainer;
14 |
15 | /**
16 | * @author 三刀(zhengjunweimail@163.com)
17 | * @version V1.0 , 2021/3/28
18 | */
19 | public interface WebsocketProvider {
20 | ServerContainer getWebSocketServerContainer();
21 | }
22 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/sandbox/SandBox.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.sandbox;
12 |
13 | import tech.smartboot.servlet.provider.AsyncContextProvider;
14 | import tech.smartboot.servlet.provider.DispatcherProvider;
15 | import tech.smartboot.servlet.provider.FaviconProvider;
16 | import tech.smartboot.servlet.provider.VendorProvider;
17 | import tech.smartboot.servlet.provider.WebsocketProvider;
18 |
19 | /**
20 | * 沙箱环境
21 | *
22 | * @author 三刀
23 | * @version V1.0 , 2020/11/28
24 | */
25 | public class SandBox {
26 | public static final String UPGRADE_MESSAGE_ZH = "请升级至 smart-servlet 企业版以启用该功能";
27 | public static final SandBox INSTANCE = new SandBox();
28 | private final DispatcherProvider dispatcherProvider = MockProvider.INSTANCE;
29 | private final WebsocketProvider websocketProvider = MockProvider.INSTANCE;
30 |
31 | private final VendorProvider vendorProvider = MockProvider.INSTANCE;
32 | private final AsyncContextProvider asyncContextProvider = MockProvider.INSTANCE;
33 | private final FaviconProvider faviconProvider = MockProvider.INSTANCE;
34 |
35 | public VendorProvider getVendorProvider() {
36 | return vendorProvider;
37 | }
38 |
39 | public DispatcherProvider getDispatcherProvider() {
40 | return dispatcherProvider;
41 | }
42 |
43 | public WebsocketProvider getWebsocketProvider() {
44 | return websocketProvider;
45 | }
46 |
47 |
48 | public AsyncContextProvider getAsyncContextProvider() {
49 | return asyncContextProvider;
50 | }
51 |
52 | public FaviconProvider getFaviconProvider() {
53 | return faviconProvider;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/AnnotationElementValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | public class AnnotationElementValue extends ElementValue
13 | {
14 | // For annotation element values, this is the annotation
15 | private final AnnotationEntry annotationEntry;
16 |
17 | AnnotationElementValue(final int type, final AnnotationEntry annotationEntry,
18 | final ConstantPool cpool)
19 | {
20 | super(type, cpool);
21 | if (type != ANNOTATION) {
22 | throw new RuntimeException(
23 | "Only element values of type annotation can be built with this ctor - type specified: " + type);
24 | }
25 | this.annotationEntry = annotationEntry;
26 | }
27 |
28 | @Override
29 | public String stringifyValue()
30 | {
31 | return annotationEntry.toString();
32 | }
33 |
34 | public AnnotationEntry getAnnotationEntry()
35 | {
36 | return annotationEntry;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/AnnotationEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * represents one annotation in the annotation table
21 | */
22 | public class AnnotationEntry {
23 |
24 | private final int type_index;
25 | private final ConstantPool constant_pool;
26 |
27 | private final List element_value_pairs;
28 |
29 | /*
30 | * Creates an AnnotationEntry from a DataInputStream
31 | *
32 | * @param input
33 | * @param constant_pool
34 | * @throws IOException
35 | */
36 | AnnotationEntry(final DataInput input, final ConstantPool constant_pool) throws IOException {
37 |
38 | this.constant_pool = constant_pool;
39 |
40 | type_index = input.readUnsignedShort();
41 | final int num_element_value_pairs = input.readUnsignedShort();
42 |
43 | element_value_pairs = new ArrayList<>(num_element_value_pairs);
44 | for (int i = 0; i < num_element_value_pairs; i++) {
45 | element_value_pairs.add(new ElementValuePair(input, constant_pool));
46 | }
47 | }
48 |
49 | /**
50 | * @return the annotation type name
51 | */
52 | public String getAnnotationType() {
53 | final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(type_index, Const.CONSTANT_Utf8);
54 | return c.getBytes();
55 | }
56 |
57 | /**
58 | * @return the element value pairs in this annotation entry
59 | */
60 | public List getElementValuePairs() {
61 | return element_value_pairs;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/Annotations.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import java.io.DataInput;
13 | import java.io.IOException;
14 |
15 | /**
16 | * base class for annotations
17 | */
18 | public class Annotations {
19 |
20 | private final AnnotationEntry[] annotation_table;
21 |
22 | /**
23 | * @param input Input stream
24 | * @param constant_pool Array of constants
25 | */
26 | Annotations(final DataInput input, final ConstantPool constant_pool) throws IOException {
27 | final int annotation_table_length = input.readUnsignedShort();
28 | annotation_table = new AnnotationEntry[annotation_table_length];
29 | for (int i = 0; i < annotation_table_length; i++) {
30 | annotation_table[i] = new AnnotationEntry(input, constant_pool);
31 | }
32 | }
33 |
34 |
35 | /**
36 | * @return the array of annotation entries in this annotation
37 | */
38 | public AnnotationEntry[] getAnnotationEntries() {
39 | return annotation_table;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ArrayElementValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | public class ArrayElementValue extends ElementValue
13 | {
14 | // For array types, this is the array
15 | private final ElementValue[] evalues;
16 |
17 | ArrayElementValue(final int type, final ElementValue[] datums, final ConstantPool cpool)
18 | {
19 | super(type, cpool);
20 | if (type != ARRAY) {
21 | throw new RuntimeException(
22 | "Only element values of type array can be built with this ctor - type specified: " + type);
23 | }
24 | this.evalues = datums;
25 | }
26 |
27 | @Override
28 | public String stringifyValue()
29 | {
30 | final StringBuilder sb = new StringBuilder();
31 | sb.append("[");
32 | for (int i = 0; i < evalues.length; i++)
33 | {
34 | sb.append(evalues[i].stringifyValue());
35 | if ((i + 1) < evalues.length) {
36 | sb.append(",");
37 | }
38 | }
39 | sb.append("]");
40 | return sb.toString();
41 | }
42 |
43 | public ElementValue[] getElementValuesArray()
44 | {
45 | return evalues;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ClassElementValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | public class ClassElementValue extends ElementValue
15 | {
16 | // For primitive types and string type, this points to the value entry in
17 | // the cpool
18 | // For 'class' this points to the class entry in the cpool
19 | private final int idx;
20 |
21 | ClassElementValue(final int type, final int idx, final ConstantPool cpool) {
22 | super(type, cpool);
23 | this.idx = idx;
24 | }
25 |
26 |
27 | @Override
28 | public String stringifyValue()
29 | {
30 | final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(idx,
31 | Const.CONSTANT_Utf8);
32 | return cu8.getBytes();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ClassFormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | /**
13 | * Thrown when the BCEL attempts to read a class file and determines
14 | * that the file is malformed or otherwise cannot be interpreted as a
15 | * class file.
16 | */
17 | public class ClassFormatException extends RuntimeException {
18 |
19 | private static final long serialVersionUID = 3243149520175287759L;
20 |
21 | public ClassFormatException() {
22 | super();
23 | }
24 |
25 |
26 | public ClassFormatException(final String s) {
27 | super(s);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract {@link Constant}
19 | * and represents a reference to a (external) class.
20 | *
21 | * @see Constant
22 | */
23 | public final class ConstantClass extends Constant {
24 |
25 | private final int name_index; // Identical to ConstantString except for the name
26 |
27 |
28 | /**
29 | * Constructs an instance from file data.
30 | *
31 | * @param dataInput Input stream
32 | * @throws IOException if an I/O error occurs reading from the given {@code dataInput}.
33 | */
34 | ConstantClass(final DataInput dataInput) throws IOException {
35 | super(Const.CONSTANT_Class);
36 | this.name_index = dataInput.readUnsignedShort();
37 | }
38 |
39 |
40 | /**
41 | * @return Name index in constant pool of class name.
42 | */
43 | public final int getNameIndex() {
44 | return name_index;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantDouble.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract {@link Constant}
19 | * and represents a reference to a Double object.
20 | *
21 | * @see Constant
22 | */
23 | public final class ConstantDouble extends Constant {
24 |
25 | private final double bytes;
26 |
27 |
28 | /**
29 | * Initialize instance from file data.
30 | *
31 | * @param file Input stream
32 | * @throws IOException
33 | */
34 | ConstantDouble(final DataInput file) throws IOException {
35 | super(Const.CONSTANT_Double);
36 | this.bytes = file.readDouble();
37 | }
38 |
39 |
40 | /**
41 | * @return data, i.e., 8 bytes.
42 | */
43 | public final double getBytes() {
44 | return bytes;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantFloat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract {@link Constant}
19 | * and represents a reference to a float object.
20 | *
21 | * @see Constant
22 | */
23 | public final class ConstantFloat extends Constant {
24 |
25 | private final float bytes;
26 |
27 |
28 | /**
29 | * Initialize instance from file data.
30 | *
31 | * @param file Input stream
32 | * @throws IOException
33 | */
34 | ConstantFloat(final DataInput file) throws IOException {
35 | super(Const.CONSTANT_Float);
36 | this.bytes = file.readFloat();
37 | }
38 |
39 |
40 | /**
41 | * @return data, i.e., 4 bytes.
42 | */
43 | public final float getBytes() {
44 | return bytes;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantInteger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract {@link Constant}
19 | * and represents a reference to an int object.
20 | *
21 | * @see Constant
22 | */
23 | public final class ConstantInteger extends Constant {
24 |
25 | private final int bytes;
26 |
27 |
28 | /**
29 | * Initialize instance from file data.
30 | *
31 | * @param file Input stream
32 | * @throws IOException
33 | */
34 | ConstantInteger(final DataInput file) throws IOException {
35 | super(Const.CONSTANT_Integer);
36 | this.bytes = file.readInt();
37 | }
38 |
39 |
40 | /**
41 | * @return data, i.e., 4 bytes.
42 | */
43 | public final int getBytes() {
44 | return bytes;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantLong.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract {@link Constant}
19 | * and represents a reference to a long object.
20 | *
21 | * @see Constant
22 | */
23 | public final class ConstantLong extends Constant {
24 |
25 | private final long bytes;
26 |
27 |
28 | /**
29 | * Initialize instance from file data.
30 | *
31 | * @param file Input stream
32 | * @throws IOException
33 | */
34 | ConstantLong(final DataInput input) throws IOException {
35 | super(Const.CONSTANT_Long);
36 | this.bytes = input.readLong();
37 | }
38 |
39 |
40 | /**
41 | * @return data, i.e., 8 bytes.
42 | */
43 | public final long getBytes() {
44 | return bytes;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ConstantUtf8.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 | /**
18 | * This class is derived from the abstract
19 | * Constant class
20 | * and represents a reference to a Utf8 encoded string.
21 | *
22 | * @see Constant
23 | */
24 | public final class ConstantUtf8 extends Constant {
25 |
26 | private final String bytes;
27 |
28 |
29 | static ConstantUtf8 getInstance(final DataInput input) throws IOException {
30 | return new ConstantUtf8(input.readUTF());
31 | }
32 |
33 |
34 | /**
35 | * @param bytes Data
36 | */
37 | private ConstantUtf8(final String bytes) {
38 | super(Const.CONSTANT_Utf8);
39 | if (bytes == null) {
40 | throw new IllegalArgumentException("bytes must not be null!");
41 | }
42 | this.bytes = bytes;
43 | }
44 |
45 |
46 | /**
47 | * @return Data converted to string.
48 | */
49 | public final String getBytes() {
50 | return bytes;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/ElementValuePair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.IOException;
16 |
17 |
18 | /**
19 | * an annotation's element value pair
20 | *
21 | * @since 6.0
22 | */
23 | public class ElementValuePair
24 | {
25 | private final ElementValue elementValue;
26 |
27 | private final ConstantPool constantPool;
28 |
29 | private final int elementNameIndex;
30 |
31 | ElementValuePair(final DataInput file, final ConstantPool constantPool) throws IOException {
32 | this.constantPool = constantPool;
33 | this.elementNameIndex = file.readUnsignedShort();
34 | this.elementValue = ElementValue.readElementValue(file, constantPool);
35 | }
36 |
37 | public String getNameString()
38 | {
39 | final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(
40 | elementNameIndex, Const.CONSTANT_Utf8);
41 | return c.getBytes();
42 | }
43 |
44 | public final ElementValue getValue()
45 | {
46 | return elementValue;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/EnumElementValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | public class EnumElementValue extends ElementValue
15 | {
16 | private final int valueIdx;
17 |
18 | EnumElementValue(final int type, final int valueIdx, final ConstantPool cpool) {
19 | super(type, cpool);
20 | if (type != ENUM_CONSTANT)
21 | throw new RuntimeException(
22 | "Only element values of type enum can be built with this ctor - type specified: " + type);
23 | this.valueIdx = valueIdx;
24 | }
25 |
26 | @Override
27 | public String stringifyValue()
28 | {
29 | final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(valueIdx,
30 | Const.CONSTANT_Utf8);
31 | return cu8.getBytes();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/SimpleElementValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | public class SimpleElementValue extends ElementValue
15 | {
16 | private final int index;
17 |
18 | SimpleElementValue(final int type, final int index, final ConstantPool cpool) {
19 | super(type, cpool);
20 | this.index = index;
21 | }
22 |
23 | /**
24 | * @return Value entry index in the cpool
25 | */
26 | public int getIndex()
27 | {
28 | return index;
29 | }
30 |
31 |
32 | // Whatever kind of value it is, return it as a string
33 | @Override
34 | public String stringifyValue()
35 | {
36 | final ConstantPool cpool = super.getConstantPool();
37 | final int _type = super.getType();
38 | switch (_type)
39 | {
40 | case PRIMITIVE_INT:
41 | final ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(),
42 | Const.CONSTANT_Integer);
43 | return Integer.toString(c.getBytes());
44 | case PRIMITIVE_LONG:
45 | final ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(),
46 | Const.CONSTANT_Long);
47 | return Long.toString(j.getBytes());
48 | case PRIMITIVE_DOUBLE:
49 | final ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex(),
50 | Const.CONSTANT_Double);
51 | return Double.toString(d.getBytes());
52 | case PRIMITIVE_FLOAT:
53 | final ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex(),
54 | Const.CONSTANT_Float);
55 | return Float.toString(f.getBytes());
56 | case PRIMITIVE_SHORT:
57 | final ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex(),
58 | Const.CONSTANT_Integer);
59 | return Integer.toString(s.getBytes());
60 | case PRIMITIVE_BYTE:
61 | final ConstantInteger b = (ConstantInteger) cpool.getConstant(getIndex(),
62 | Const.CONSTANT_Integer);
63 | return Integer.toString(b.getBytes());
64 | case PRIMITIVE_CHAR:
65 | final ConstantInteger ch = (ConstantInteger) cpool.getConstant(
66 | getIndex(), Const.CONSTANT_Integer);
67 | return String.valueOf((char)ch.getBytes());
68 | case PRIMITIVE_BOOLEAN:
69 | final ConstantInteger bo = (ConstantInteger) cpool.getConstant(
70 | getIndex(), Const.CONSTANT_Integer);
71 | if (bo.getBytes() == 0) {
72 | return "false";
73 | }
74 | return "true";
75 | case STRING:
76 | final ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(),
77 | Const.CONSTANT_Utf8);
78 | return cu8.getBytes();
79 | default:
80 | throw new RuntimeException("SimpleElementValue class does not know how to stringify type " + _type);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/third/bcel/classfile/Utility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.third.bcel.classfile;
11 |
12 | import tech.smartboot.servlet.third.bcel.Const;
13 |
14 | import java.io.DataInput;
15 | import java.io.EOFException;
16 | import java.io.IOException;
17 |
18 | /**
19 | * Utility functions that do not really belong to any class in particular.
20 | */
21 | final class Utility {
22 |
23 | private Utility() {
24 | // Hide default constructor
25 | }
26 |
27 | /**
28 | * Shorten long class name str, i.e., chop off the prefix,
29 | * if the
30 | * class name starts with this string and the flag chopit is true.
31 | * Slashes / are converted to dots ..
32 | *
33 | * @param str The long class name
34 | * @return Compacted class name
35 | */
36 | static String compactClassName(final String str) {
37 | return str.replace('/', '.'); // Is `/' on all systems, even DOS
38 | }
39 |
40 | static String getClassName(final ConstantPool constant_pool, final int index) {
41 | Constant c = constant_pool.getConstant(index, Const.CONSTANT_Class);
42 | int i = ((ConstantClass) c).getNameIndex();
43 |
44 | // Finally get the string from the constant pool
45 | c = constant_pool.getConstant(i, Const.CONSTANT_Utf8);
46 | String name = ((ConstantUtf8) c).getBytes();
47 |
48 | return compactClassName(name);
49 | }
50 |
51 | static void skipFully(final DataInput file, final int length) throws IOException {
52 | int total = file.skipBytes(length);
53 | if (total != length) {
54 | throw new EOFException();
55 | }
56 | }
57 |
58 | static void swallowFieldOrMethod(final DataInput file)
59 | throws IOException {
60 | // file.readUnsignedShort(); // Unused access flags
61 | // file.readUnsignedShort(); // name index
62 | // file.readUnsignedShort(); // signature index
63 | skipFully(file, 6);
64 |
65 | int attributes_count = file.readUnsignedShort();
66 | for (int i = 0; i < attributes_count; i++) {
67 | swallowAttribute(file);
68 | }
69 | }
70 |
71 | static void swallowAttribute(final DataInput file)
72 | throws IOException {
73 | //file.readUnsignedShort(); // Unused name index
74 | skipFully(file, 2);
75 | // Length of data in bytes
76 | int length = file.readInt();
77 | skipFully(file, length);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/util/DateUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.util;
12 |
13 | import java.text.ParseException;
14 | import java.text.SimpleDateFormat;
15 | import java.util.Date;
16 | import java.util.Locale;
17 | import java.util.TimeZone;
18 |
19 | /**
20 | * @author 三刀
21 | * @version V1.0 , 2020/11/10
22 | */
23 | public class DateUtil {
24 | private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
25 | private static final String[] DATE_FORMATS = new String[]{
26 | "EEE, dd MMM yyyy HH:mm:ss zzz",
27 | "EEE, dd-MMM-yy HH:mm:ss zzz",
28 | "EEE MMM dd HH:mm:ss yyyy"
29 | };
30 | private static final String DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
31 |
32 | public static long parseDateHeader(String name, String value) {
33 | for (String dateFormat : DATE_FORMATS) {
34 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat, Locale.US);
35 | simpleDateFormat.setTimeZone(GMT);
36 | try {
37 | return simpleDateFormat.parse(value).getTime();
38 | } catch (ParseException ignored) {
39 | }
40 | }
41 | throw new IllegalArgumentException("Cannot parse date value '" + value + "' for '" + name + "' header");
42 | }
43 |
44 | public static String formatDate(long time) {
45 | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.US);
46 | dateFormat.setTimeZone(GMT);
47 | return dateFormat.format(new Date(time));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/servlet-core/src/main/java/tech/smartboot/servlet/util/WarUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.servlet.util;
12 |
13 | import java.io.File;
14 | import java.io.FileOutputStream;
15 | import java.io.InputStream;
16 | import java.util.Enumeration;
17 | import java.util.zip.ZipEntry;
18 | import java.util.zip.ZipFile;
19 |
20 | /**
21 | * @author 三刀(zhengjunweimail@163.com)
22 | * @version V1.0 , 2022/11/1
23 | */
24 | public class WarUtil {
25 | /**
26 | * 解压War包
27 | *
28 | * @param warFile
29 | * @param destDirPath
30 | * @throws RuntimeException
31 | */
32 | public static void unZip(File warFile, File destDirPath) throws RuntimeException {
33 | long start = System.currentTimeMillis();
34 | try (ZipFile zipFile = new ZipFile(warFile)) {
35 | Enumeration> entries = zipFile.entries();
36 | while (entries.hasMoreElements()) {
37 | ZipEntry entry = (ZipEntry) entries.nextElement();
38 | if (entry.isDirectory()) {
39 | continue;
40 | }
41 | File targetFile = new File(destDirPath, entry.getName());
42 | if (!targetFile.getParentFile().exists()) {
43 | targetFile.getParentFile().mkdirs();
44 | }
45 | try (InputStream zipFileInputStream = zipFile.getInputStream(entry);
46 | FileOutputStream zipFileOutputStream = new FileOutputStream(targetFile)) {
47 | int len;
48 |
49 | byte[] buf = new byte[1024];
50 |
51 | while ((len = zipFileInputStream.read(buf)) != -1) {
52 | zipFileOutputStream.write(buf, 0, len);
53 | }
54 | }
55 | }
56 |
57 | long end = System.currentTimeMillis();
58 |
59 | System.out.println("解压[" + warFile.getName() + "]完成,耗时:" + (end - start) + " ms");
60 |
61 | } catch (Exception e) {
62 | throw new RuntimeException("unzip error from ZipUtils", e);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/servlet-core/src/main/resources/META-INF/services/tech.smartboot.servlet.plugins.Plugin:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | #
4 | # 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | #
6 | # Enterprise users are required to use this project reasonably
7 | # and legally in accordance with the AGPL-3.0 open source agreement
8 | # without special permission from the smartboot organization.
9 | #
10 | tech.smartboot.servlet.plugins.basic.BasicPlugin
11 | tech.smartboot.servlet.plugins.session.SessionPlugin
12 | tech.smartboot.servlet.plugins.dispatcher.DispatcherPlugin
13 | tech.smartboot.servlet.plugins.websocket.WebsocketPlugin
14 | tech.smartboot.servlet.plugins.async.AsyncContextPlugin
--------------------------------------------------------------------------------
/servlet-core/src/main/resources/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/servlet-core/src/main/resources/favicon.ico
--------------------------------------------------------------------------------
/servlet-core/src/main/resources/smart-servlet/banner.txt:
--------------------------------------------------------------------------------
1 | _ _ _
2 | ( )_ (_ ) ( )_
3 | ___ ___ ___ _ _ _ __ | ,_) ___ __ _ __ _ _ | | __ | ,_)
4 | /',__)/' _ ` _ `\ /'_` )( '__)| | /',__) /'__`\( '__)( ) ( ) | | /'__`\| |
5 | \__, \| ( ) ( ) |( (_| || | | |_ \__, \( ___/| | | \_/ | | | ( ___/| |_
6 | (____/(_) (_) (_)`\__,_)(_) `\__) (____/`\____)(_) `\___/'(___)`\____)`\__)
--------------------------------------------------------------------------------
/servlet-core/src/main/resources/smart-servlet/error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
40 |
49 |
50 |
51 |
52 |
53 | {{statusCode}} : {{statusDesc}}
54 |
55 |
56 |
57 |
58 | {{stackTrace}}
59 |
60 |
61 |
62 | smart-servlet {{version}}
63 | |
64 | Gitee
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/servlet-core/src/main/resources/smart-servlet/support.txt:
--------------------------------------------------------------------------------
1 | · Document: https://smartboot.tech
2 | · Gitee: https://gitee.com/smartboot/smart-servlet
3 | · Github: https://github.com/smartboot/smart-servlet
4 | · E-mail: zhengjunweimail@163.com
5 | · 温馨提示:开源不易,拒绝盗版,请通过正规渠道获取产品授权
--------------------------------------------------------------------------------
/smart-servlet-maven-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 | smart-servlet-parent
17 | tech.smartboot.servlet
18 | 3.1-SNAPSHOT
19 |
20 | 4.0.0
21 | maven-plugin
22 |
23 | smart-servlet-maven-plugin
24 |
25 |
26 |
27 | org.apache.maven
28 | maven-plugin-api
29 | 3.9.4
30 | provided
31 |
32 |
33 | org.apache.maven.plugin-tools
34 | maven-plugin-annotations
35 | 3.5
36 | provided
37 |
38 |
39 | tech.smartboot.servlet
40 | servlet-core
41 |
42 |
43 |
--------------------------------------------------------------------------------
/smart-servlet-maven-plugin/src/main/java/tech/smartboot/maven/plugin/jakarta/Starter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.maven.plugin.jakarta;
12 |
13 | import tech.smartboot.servlet.Container;
14 |
15 | /**
16 | * @author 三刀
17 | * @version V1.0 , 2020/11/4
18 | */
19 | public class Starter {
20 |
21 | public Starter(String path, String contentPath, int port, ClassLoader classLoader) throws Throwable {
22 | System.out.println("path: " + path);
23 | System.out.println("contentPath: " + contentPath);
24 | Container container = new Container();
25 | container.addRuntime(path, contentPath, classLoader);
26 | container.initialize();
27 | container.getConfiguration().setPort(port);
28 | container.start();
29 | Runtime.getRuntime().addShutdownHook(new Thread(container::stop));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 | smart-servlet-parent
17 | tech.smartboot.servlet
18 | 3.1-SNAPSHOT
19 |
20 |
21 | 3.3.1
22 |
23 | 4.0.0
24 |
25 | smart-servlet-spring-boot-starter
26 |
27 |
28 | tech.smartboot.servlet
29 | servlet-core
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-websocket
34 | ${springboot.version}
35 | true
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-web
40 | ${springboot.version}
41 | true
42 |
43 |
44 |
45 | org.springframework.boot
46 | spring-boot-starter-tomcat
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/spring-boot-starter/src/main/java/tech/smartboot/springboot/starter/SmartContainerInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.springboot.starter;
12 |
13 | import org.springframework.boot.web.servlet.ServletContextInitializer;
14 |
15 | import jakarta.servlet.ServletContainerInitializer;
16 | import jakarta.servlet.ServletContext;
17 | import jakarta.servlet.ServletException;
18 | import java.util.Set;
19 |
20 | /**
21 | * @author 三刀
22 | * @version V1.0 , 2020/10/13
23 | */
24 | public class SmartContainerInitializer implements ServletContainerInitializer {
25 |
26 | private final ServletContextInitializer[] initializers;
27 |
28 | public SmartContainerInitializer(ServletContextInitializer[] initializers) {
29 | this.initializers = initializers;
30 | }
31 |
32 | @Override
33 | public void onStartup(Set> c, ServletContext ctx) throws ServletException {
34 | if (initializers == null) {
35 | return;
36 | }
37 | for (ServletContextInitializer initializer : initializers) {
38 | initializer.onStartup(ctx);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/spring-boot-starter/src/main/java/tech/smartboot/springboot/starter/SmartServletServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package tech.smartboot.springboot.starter;
12 |
13 | import org.springframework.boot.web.server.WebServer;
14 | import org.springframework.boot.web.server.WebServerException;
15 | import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
16 | import tech.smartboot.servlet.Container;
17 | import tech.smartboot.servlet.ServletContextRuntime;
18 |
19 | /**
20 | * @author 三刀
21 | * @version V1.0 , 2020/10/12
22 | */
23 | public class SmartServletServer implements WebServer {
24 | private final Object monitor = new Object();
25 | private final Container container;
26 | private volatile boolean started = false;
27 | private final AbstractServletWebServerFactory factory;
28 |
29 | public SmartServletServer(ServletContextRuntime runtime, AbstractServletWebServerFactory factory) throws Throwable {
30 | this.factory = factory;
31 | container = new Container();
32 | container.addRuntime(runtime);
33 | container.initialize();
34 | }
35 |
36 | public Container getContainer() {
37 | return container;
38 | }
39 |
40 | @Override
41 | public void start() throws WebServerException {
42 | synchronized (this.monitor) {
43 | if (this.started) {
44 | return;
45 | }
46 | try {
47 | container.start();
48 | this.started = true;
49 | } catch (Throwable ex) {
50 | ex.printStackTrace();
51 | }
52 | }
53 | }
54 |
55 | @Override
56 | public void stop() throws WebServerException {
57 | synchronized (this.monitor) {
58 | if (!this.started) {
59 | return;
60 | }
61 | this.started = false;
62 | container.stop();
63 | }
64 | }
65 |
66 | @Override
67 | public int getPort() {
68 | return factory.getPort();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:
--------------------------------------------------------------------------------
1 | tech.smartboot.springboot.starter.ConfigurableSmartWebServerFactory
--------------------------------------------------------------------------------
/springboot-demo/Makefile:
--------------------------------------------------------------------------------
1 | build:
2 | mvn -f pom.xml clean package
3 | mv target/*.jar smart-servlet.jar
4 | mvn -f pom_tomcat.xml clean package
5 | mv target/*.jar tomcat.jar
6 | mvn -f pom_undertow.xml clean package
7 | mv target/*.jar undertow.jar
8 |
--------------------------------------------------------------------------------
/springboot-demo/pom_tomcat.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 | 4.0.0
16 |
17 | tech.smartboot.servlet
18 | springboot-demo
19 | 1.0-SNAPSHOT
20 |
21 |
22 | 21
23 | 21
24 | UTF-8
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-parent
30 | 3.3.1
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-websocket
36 | 3.3.1
37 | true
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-web
42 | 3.3.1
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-maven-plugin
50 |
51 |
52 | true
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/springboot-demo/pom_undertow.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 | 4.0.0
16 |
17 | tech.smartboot.servlet
18 | springboot-demo
19 | 1.0-SNAPSHOT
20 |
21 |
22 | 21
23 | 21
24 | UTF-8
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-parent
30 | 3.3.1
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-websocket
36 | 3.3.1
37 | true
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-web
42 | 3.3.1
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter-tomcat
48 |
49 |
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-starter-undertow
55 | 3.3.1
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-maven-plugin
64 |
65 |
66 | true
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/springboot-demo/src/main/java/org/smartboot/demo/starter/MyWebSocketHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package org.smartboot.demo.starter;
12 |
13 | import org.springframework.web.socket.CloseStatus;
14 | import org.springframework.web.socket.WebSocketHandler;
15 | import org.springframework.web.socket.WebSocketMessage;
16 | import org.springframework.web.socket.WebSocketSession;
17 |
18 | public class MyWebSocketHandler implements WebSocketHandler {
19 |
20 | @Override
21 | public void afterConnectionEstablished(WebSocketSession session) throws Exception {
22 | System.out.println("afterConnectionEstablished");
23 | }
24 |
25 | @Override
26 | public void handleMessage(WebSocketSession session, WebSocketMessage> message) throws Exception {
27 | System.out.println(message);
28 | }
29 |
30 | @Override
31 | public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
32 | System.out.println("aaa");
33 | }
34 |
35 | @Override
36 | public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
37 | System.out.println("afterConnectionClosed");
38 | }
39 |
40 | @Override
41 | public boolean supportsPartialMessages() {
42 | System.out.println("supportsPartialMessages");
43 | return true;
44 | }
45 | }
--------------------------------------------------------------------------------
/springboot-demo/src/main/java/org/smartboot/demo/starter/SecurityConfig.java:
--------------------------------------------------------------------------------
1 | //package org.smartboot.demo.starter;
2 | //
3 | //import org.springframework.context.annotation.Bean;
4 | //import org.springframework.context.annotation.Configuration;
5 | //import org.springframework.security.config.Customizer;
6 | //import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7 | //import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
8 | //import org.springframework.security.core.userdetails.User;
9 | //import org.springframework.security.core.userdetails.UserDetails;
10 | //import org.springframework.security.core.userdetails.UserDetailsService;
11 | //import org.springframework.security.provisioning.InMemoryUserDetailsManager;
12 | //import org.springframework.security.web.SecurityFilterChain;
13 | //
14 | //@Configuration
15 | //@EnableWebSecurity
16 | //public class SecurityConfig {
17 | //
18 | //// @Bean
19 | //// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
20 | //// http
21 | //// .authorizeHttpRequests((authorize) -> authorize
22 | //// .mvcMatchers("/index").hasRole("USER")
23 | //// .mvcMatchers("/hello/world").hasRole("ADMIN")
24 | //// .mvcMatchers("/").authenticated()
25 | //// )
26 | //// .httpBasic();
27 | ////
28 | //// return http.build();
29 | //// }
30 | //
31 | // @Bean
32 | // public UserDetailsService userDetailsService() {
33 | // UserDetails userDetails = User.withDefaultPasswordEncoder()
34 | // .username("user")
35 | // .password("111")
36 | // .roles("USER")
37 | // .build();
38 | //
39 | // return new InMemoryUserDetailsManager(userDetails);
40 | // }
41 | //
42 | //}
--------------------------------------------------------------------------------
/springboot-demo/src/main/java/org/smartboot/demo/starter/WebSocketConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 |
11 | package org.smartboot.demo.starter;
12 |
13 | import org.springframework.context.annotation.Configuration;
14 | import org.springframework.web.socket.config.annotation.EnableWebSocket;
15 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
16 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
17 |
18 | @Configuration
19 | @EnableWebSocket
20 | public class WebSocketConfig implements WebSocketConfigurer {
21 |
22 | @Override
23 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
24 | registry.addHandler(new MyWebSocketHandler(), "/myHandler").setAllowedOrigins("*");
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/springboot-demo/src/main/resources/smart-servlet/License.shield:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/springboot-demo/src/main/resources/smart-servlet/License.shield
--------------------------------------------------------------------------------
/springboot-demo/src/main/resources/smart-servlet/smart-servlet.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIEhTCCAu2gAwIBAgIQF5C4/s1tNk9arohyD4J2UDANBgkqhkiG9w0BAQsFADCB
3 | nzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTowOAYDVQQLDDF6aGVu
4 | Z2p3MjJtYWMxMjNAemhlbmdqdzIyTWFjMTIzLmxvY2FsICh6aGVuZ2p3MjIpMUEw
5 | PwYDVQQDDDhta2NlcnQgemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5s
6 | b2NhbCAoemhlbmdqdzIyKTAeFw0yNDAyMTUwNzU3NTNaFw0yNjA1MTUwNzU3NTNa
7 | MGUxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTE6MDgG
8 | A1UECwwxemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5sb2NhbCAoemhl
9 | bmdqdzIyKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALvMsE1RIalU
10 | Kzy+4U+Ixw+Z8FL3KHiKLk1513qsn40Po4bsE8zgsrd4lLx1lHpEkmKK3dpHREP1
11 | a1goi8Jqypmiz4oBUzrBMKBVo60wom3Al/XslgiZdzrhtFMOhwcjfGhkthq3ps5q
12 | wHyqRneijfeB/YICfF+e0K6fnbiSPd8rBJP6F7de2oafawIV9jNtIpqUQpfk+b+F
13 | Y3oDE2xCiz1chx/AfY6CaSICHYoHR9beugnm9RO45mjw/84Fs5AnneTUkZbeozYo
14 | I0FyqplhfExglU3k/S0Fvkbd+GT5RPkhwwC3SQGldORHR9/+yoAsNjKlrLMD+aTo
15 | 5G618AEldr0CAwEAAaN2MHQwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsG
16 | AQUFBwMBMB8GA1UdIwQYMBaAFDnyay2H0T65/ghxa7Ap7kKXyEefMCwGA1UdEQQl
17 | MCOCCWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAATANBgkqhkiG9w0B
18 | AQsFAAOCAYEAu31uRYtB+5dYbtOTVJDNw94nRXNkkh/u1Gv/WcEaauwsgoaeyy6P
19 | kIavx1RiNrCkAO5aYIVCF407OadMzixRurvc4hVatAJVaj6zNfSs4HCViB7BCfLu
20 | oYmqEYwjaPdqLq04uA/ZEeklqeKRJ0gzKXToaoQ8xcxIJcCjojaSi4usqSI5bi4y
21 | Md79AtB3fxv+RipaHOPAqs2i2Eo7wCENEnUs8Uqu/VI3hZEljVOOFHbak33iFdwM
22 | Gg4NfE3QSxVOctseB+2lcNjuk8Wxee1CIvH/imskgZl25dg4B2nHG9TEiYbabJ7/
23 | K5MOWg81lNAF+pmUJ01OaoFcXyDPc5hh5Unv3zHJrhRc86JwxqwhThkXRwAgh8fA
24 | gjQIfE9byUD9o/HTeTdC7B8Tb3EnvYxkj83fi0fDj90022sjsRD/JMLfigx+T4rA
25 | C4FKqpXgqfry0QUfibX6sxRWw7QwWtf9AInAEVgukx2ollxLGoVeK6hYG26d94YE
26 | QtxEn3cOVqU+
27 | -----END CERTIFICATE-----
28 | -----BEGIN PRIVATE KEY-----
29 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7zLBNUSGpVCs8
30 | vuFPiMcPmfBS9yh4ii5Nedd6rJ+ND6OG7BPM4LK3eJS8dZR6RJJiit3aR0RD9WtY
31 | KIvCasqZos+KAVM6wTCgVaOtMKJtwJf17JYImXc64bRTDocHI3xoZLYat6bOasB8
32 | qkZ3oo33gf2CAnxfntCun524kj3fKwST+he3XtqGn2sCFfYzbSKalEKX5Pm/hWN6
33 | AxNsQos9XIcfwH2OgmkiAh2KB0fW3roJ5vUTuOZo8P/OBbOQJ53k1JGW3qM2KCNB
34 | cqqZYXxMYJVN5P0tBb5G3fhk+UT5IcMAt0kBpXTkR0ff/sqALDYypayzA/mk6ORu
35 | tfABJXa9AgMBAAECggEAHGOV5yozj3hUzOsB/lbr2JTpunD4YjhpRXb8tuOvftB1
36 | ZOj9GUSCX6/PtCmGF3GUO2dIoD2TuT45SuteLTadh9oPy4nlvgUER8iKZJzsgPDT
37 | R+7Kw2QHnRQPgVq52L9piBJpYOKQSbXjgTTwUBd3pIm2+9dKW94TJ8KjQgqBZeHF
38 | jBFrqqAVLvgRm5nOeNx98H6bhLd/GoB1RSj61jIcNNpDRnPxzq3IYLgv2zjXWasJ
39 | +IvVCTlxapbVBgzvp6burmJ8eYBruW3FAR0tGBJi3imySDLs3EbB1F2ox0pOJjOw
40 | c2bdZVgPdKY2wbmk+/2pyG4le5/64ByLxqX7Gux9dQKBgQDT/25SzZF9sVGkOo0u
41 | 5WUYqBA0ni2O7mFJR9KdHKrEeN6IcvPL+ttp92ESBAZf/rxN4KZs1OPeg7MABN/3
42 | caQQIqQNaFBdPrX0E5fs+gTKb38r1hXxpsCEhDjxMXroBen2RaTf7Q7AyxQFKFXZ
43 | wjFyOWHR0tL1pO+O7dt3YgMB7wKBgQDix3pisWzUAeXOVVXRzfe9H9n5KmY0rnmC
44 | raXa00Aq2RnBxtdIDf2whX6wOBOz3cHxsFMSDOVy36DfzGeBjMJjhvwq4Mdzu9HV
45 | fYqUJHQBGdK/wGOMOto32E/hbIVhWwxsPZvpeb3h8lhOHVTJN0HbqrZbDLPObjlE
46 | Dlx67ILOEwKBgB4CUV6dRNQTDqh9tVCHHllwKOMZ5P8PlWvnI9Qjo7SuG2obQ5GD
47 | UB3e67m+IhzilUs82rIbLKpp4CPHjOCdEIlMLgbL1lxsrRsAzwe3mIgDYnAVHQQZ
48 | A7V+dgUGaQyBEc5Pq3gbOXRnCs10GTr69z7hCozGGCC3mUWVO/TZRe23AoGBAOFI
49 | y0LaAUPHstS8H2oyU8a0qqSFQ01YemugN+Bf9iHa1GSVNO5mv7upkkZbHu+TAAUq
50 | ZgvLdfEdSUKqW7Tt8XpP8Zhi/qDxV63fblhmsjsZvSwyYnI/UOMjZ4+IcCRb/8ZT
51 | mdxhzYl1Z9YJ+119IFapi0h+IO2UwBzkq2iOJg+zAoGBALJSi+nD7/lhA/HKu8Nr
52 | sh4G6tczLMOHN+jvngf5WoGEnBM1ENUtmMiH0YvBIpyHSHgyKwq+H29fgA5f42Eb
53 | xe7HfOye3a3OmmJvzkckEs5Ms1J4ahErwRUvM5+xsCG5bdpA/p61sy14W3eYyA/r
54 | tSSrxN4ernLg7k/vNHB0NIjK
55 | -----END PRIVATE KEY-----
56 |
--------------------------------------------------------------------------------
/tck/conf/License.shield:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smartboot/smart-servlet/aa023ff8bca297c93ceb3b1d63fdfa96779a05c1/tck/conf/License.shield
--------------------------------------------------------------------------------
/tck/conf/smart-servlet.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIEhTCCAu2gAwIBAgIQF5C4/s1tNk9arohyD4J2UDANBgkqhkiG9w0BAQsFADCB
3 | nzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTowOAYDVQQLDDF6aGVu
4 | Z2p3MjJtYWMxMjNAemhlbmdqdzIyTWFjMTIzLmxvY2FsICh6aGVuZ2p3MjIpMUEw
5 | PwYDVQQDDDhta2NlcnQgemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5s
6 | b2NhbCAoemhlbmdqdzIyKTAeFw0yNDAyMTUwNzU3NTNaFw0yNjA1MTUwNzU3NTNa
7 | MGUxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTE6MDgG
8 | A1UECwwxemhlbmdqdzIybWFjMTIzQHpoZW5nancyMk1hYzEyMy5sb2NhbCAoemhl
9 | bmdqdzIyKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALvMsE1RIalU
10 | Kzy+4U+Ixw+Z8FL3KHiKLk1513qsn40Po4bsE8zgsrd4lLx1lHpEkmKK3dpHREP1
11 | a1goi8Jqypmiz4oBUzrBMKBVo60wom3Al/XslgiZdzrhtFMOhwcjfGhkthq3ps5q
12 | wHyqRneijfeB/YICfF+e0K6fnbiSPd8rBJP6F7de2oafawIV9jNtIpqUQpfk+b+F
13 | Y3oDE2xCiz1chx/AfY6CaSICHYoHR9beugnm9RO45mjw/84Fs5AnneTUkZbeozYo
14 | I0FyqplhfExglU3k/S0Fvkbd+GT5RPkhwwC3SQGldORHR9/+yoAsNjKlrLMD+aTo
15 | 5G618AEldr0CAwEAAaN2MHQwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsG
16 | AQUFBwMBMB8GA1UdIwQYMBaAFDnyay2H0T65/ghxa7Ap7kKXyEefMCwGA1UdEQQl
17 | MCOCCWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAATANBgkqhkiG9w0B
18 | AQsFAAOCAYEAu31uRYtB+5dYbtOTVJDNw94nRXNkkh/u1Gv/WcEaauwsgoaeyy6P
19 | kIavx1RiNrCkAO5aYIVCF407OadMzixRurvc4hVatAJVaj6zNfSs4HCViB7BCfLu
20 | oYmqEYwjaPdqLq04uA/ZEeklqeKRJ0gzKXToaoQ8xcxIJcCjojaSi4usqSI5bi4y
21 | Md79AtB3fxv+RipaHOPAqs2i2Eo7wCENEnUs8Uqu/VI3hZEljVOOFHbak33iFdwM
22 | Gg4NfE3QSxVOctseB+2lcNjuk8Wxee1CIvH/imskgZl25dg4B2nHG9TEiYbabJ7/
23 | K5MOWg81lNAF+pmUJ01OaoFcXyDPc5hh5Unv3zHJrhRc86JwxqwhThkXRwAgh8fA
24 | gjQIfE9byUD9o/HTeTdC7B8Tb3EnvYxkj83fi0fDj90022sjsRD/JMLfigx+T4rA
25 | C4FKqpXgqfry0QUfibX6sxRWw7QwWtf9AInAEVgukx2ollxLGoVeK6hYG26d94YE
26 | QtxEn3cOVqU+
27 | -----END CERTIFICATE-----
28 | -----BEGIN PRIVATE KEY-----
29 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7zLBNUSGpVCs8
30 | vuFPiMcPmfBS9yh4ii5Nedd6rJ+ND6OG7BPM4LK3eJS8dZR6RJJiit3aR0RD9WtY
31 | KIvCasqZos+KAVM6wTCgVaOtMKJtwJf17JYImXc64bRTDocHI3xoZLYat6bOasB8
32 | qkZ3oo33gf2CAnxfntCun524kj3fKwST+he3XtqGn2sCFfYzbSKalEKX5Pm/hWN6
33 | AxNsQos9XIcfwH2OgmkiAh2KB0fW3roJ5vUTuOZo8P/OBbOQJ53k1JGW3qM2KCNB
34 | cqqZYXxMYJVN5P0tBb5G3fhk+UT5IcMAt0kBpXTkR0ff/sqALDYypayzA/mk6ORu
35 | tfABJXa9AgMBAAECggEAHGOV5yozj3hUzOsB/lbr2JTpunD4YjhpRXb8tuOvftB1
36 | ZOj9GUSCX6/PtCmGF3GUO2dIoD2TuT45SuteLTadh9oPy4nlvgUER8iKZJzsgPDT
37 | R+7Kw2QHnRQPgVq52L9piBJpYOKQSbXjgTTwUBd3pIm2+9dKW94TJ8KjQgqBZeHF
38 | jBFrqqAVLvgRm5nOeNx98H6bhLd/GoB1RSj61jIcNNpDRnPxzq3IYLgv2zjXWasJ
39 | +IvVCTlxapbVBgzvp6burmJ8eYBruW3FAR0tGBJi3imySDLs3EbB1F2ox0pOJjOw
40 | c2bdZVgPdKY2wbmk+/2pyG4le5/64ByLxqX7Gux9dQKBgQDT/25SzZF9sVGkOo0u
41 | 5WUYqBA0ni2O7mFJR9KdHKrEeN6IcvPL+ttp92ESBAZf/rxN4KZs1OPeg7MABN/3
42 | caQQIqQNaFBdPrX0E5fs+gTKb38r1hXxpsCEhDjxMXroBen2RaTf7Q7AyxQFKFXZ
43 | wjFyOWHR0tL1pO+O7dt3YgMB7wKBgQDix3pisWzUAeXOVVXRzfe9H9n5KmY0rnmC
44 | raXa00Aq2RnBxtdIDf2whX6wOBOz3cHxsFMSDOVy36DfzGeBjMJjhvwq4Mdzu9HV
45 | fYqUJHQBGdK/wGOMOto32E/hbIVhWwxsPZvpeb3h8lhOHVTJN0HbqrZbDLPObjlE
46 | Dlx67ILOEwKBgB4CUV6dRNQTDqh9tVCHHllwKOMZ5P8PlWvnI9Qjo7SuG2obQ5GD
47 | UB3e67m+IhzilUs82rIbLKpp4CPHjOCdEIlMLgbL1lxsrRsAzwe3mIgDYnAVHQQZ
48 | A7V+dgUGaQyBEc5Pq3gbOXRnCs10GTr69z7hCozGGCC3mUWVO/TZRe23AoGBAOFI
49 | y0LaAUPHstS8H2oyU8a0qqSFQ01YemugN+Bf9iHa1GSVNO5mv7upkkZbHu+TAAUq
50 | ZgvLdfEdSUKqW7Tt8XpP8Zhi/qDxV63fblhmsjsZvSwyYnI/UOMjZ4+IcCRb/8ZT
51 | mdxhzYl1Z9YJ+119IFapi0h+IO2UwBzkq2iOJg+zAoGBALJSi+nD7/lhA/HKu8Nr
52 | sh4G6tczLMOHN+jvngf5WoGEnBM1ENUtmMiH0YvBIpyHSHgyKwq+H29fgA5f42Eb
53 | xe7HfOye3a3OmmJvzkckEs5Ms1J4ahErwRUvM5+xsCG5bdpA/p61sy14W3eYyA/r
54 | tSSrxN4ernLg7k/vNHB0NIjK
55 | -----END PRIVATE KEY-----
56 |
--------------------------------------------------------------------------------
/tck/conf/smart-servlet.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2017-2020, org.smartboot. All rights reserved.
3 | # project name: smart-servlet
4 | # file name: smart-servlet.properties
5 | # Date: 2020-12-10
6 | # Author: sandao (zhengjunweimail@163.com)
7 | #
8 | #
9 | http.port=8080
10 | http.readBufferSize=1048576
11 | http.threadNum=8
12 | root.context=ROOT
13 | ## tls/ssl
14 | ssl.enable=false
15 | ssl.port=443
16 |
--------------------------------------------------------------------------------
/tck/src/main/java/tech/smartboot/servlet/tck/SmartServletExtension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) [2022] smartboot [zhengjunweimail@163.com]
3 | *
4 | * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。
5 | *
6 | * Enterprise users are required to use this project reasonably
7 | * and legally in accordance with the AGPL-3.0 open source agreement
8 | * without special permission from the smartboot organization.
9 | */
10 | package tech.smartboot.servlet.tck;
11 |
12 | import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
13 | import org.jboss.arquillian.core.spi.LoadableExtension;
14 |
15 | /**
16 | * Jetty Embedded 10.x extension.
17 | *
18 | * @author Aslak Knutsen
19 | */
20 | public class SmartServletExtension implements LoadableExtension {
21 | @Override
22 | public void register(ExtensionBuilder builder) {
23 | builder.service(DeployableContainer.class, SmartEmbeddedContainer.class);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tck/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension:
--------------------------------------------------------------------------------
1 | tech.smartboot.servlet.tck.SmartServletExtension
--------------------------------------------------------------------------------
/tck/src/test/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer:
--------------------------------------------------------------------------------
1 | org.apache.jasper.servlet.JasperInitializer
--------------------------------------------------------------------------------
/tck/src/test/resources/arquillian.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 8080
15 |
16 | RFC6265
17 |
18 | RFC6265
19 | src/test/resources/default.properties
20 | true
21 |
22 | text/html iso-8859-1
23 |
24 | true
25 |
26 | relativeRedirectAllowed false
27 |
28 |
29 |
30 |
31 |
32 |
33 | 8081
34 |
35 | RFC6265
36 |
37 | RFC6265
38 | src/test/resources/default.properties
39 | true
40 |
41 | text/html iso-8859-1
42 |
43 | true
44 | target/test-classes/certificates/clientcert.jks
45 | target/cacerts.jks
46 | OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
47 | OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
48 | true
49 | false
50 | false
51 | true
52 | false
53 |
54 | relativeRedirectAllowed false
55 |
56 | true
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/tck/src/test/resources/default.properties:
--------------------------------------------------------------------------------
1 | #
2 | # This file defines users passwords and roles for a HashUserRealm
3 | #
4 | # The format is
5 | # : [, ...]
6 | #
7 | # Passwords may be clear text, obfuscated or checksummed. The class
8 | # org.eclipse.util.Password should be used to generate obfuscated
9 | # passwords or password checksums
10 | #
11 | # If DIGEST Authentication is used, the password must be in a recoverable
12 | # format, either plain text or OBF:.
13 | #
14 | jetty: MD5:164c88b302622e17050af52c89945d44,user
15 | admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user
16 | other: OBF:1xmk1w261u9r1w1c1xmq,user
17 | plain: plain,user
18 | user: password,user
19 |
20 | # This entry is for digest auth. The credential is a MD5 hash of username:realmname:password
21 | digest: MD5:6e120743ad67abfbc385bc2bb754e297,user
22 |
23 | j2ee: j2ee,Administrator,Employee
24 | javajoe: javajoe,VP,Manager
25 |
26 | # CN=CTS, OU=Java Software, O=Sun Microsystems Inc., L=Burlington, ST=MA, C=US
27 | CN\=CTS,\ OU\=Java\ Software,\ O\=Sun\ Microsystems\ Inc.,\ L\=Burlington,\ ST\=MA,\ C\=US=,,Administrator
--------------------------------------------------------------------------------
/tck/src/test/resources/simplelogger.properties:
--------------------------------------------------------------------------------
1 | org.slf4j.simpleLogger.defaultLogLevel=info
2 | #org.slf4j.simpleLogger.log.org.eclipse.jetty=debug
3 | #org.slf4j.simpleLogger.log.org.eclipse.jetty.security=info
4 | #org.slf4j.simpleLogger.log.org.eclipse.jetty.annotations=debug
5 | org.slf4j.simpleLogger.log.org.eclipse.jetty.io=info
6 | org.slf4j.simpleLogger.log.org.eclipse.jetty.server=info
7 | org.slf4j.simpleLogger.log.org.eclipse.jetty.util=info
8 |
9 |
--------------------------------------------------------------------------------