{"id":21965306,"url":"https://github.com/bytebigboss/bcors","last_synced_at":"2025-03-22T21:28:52.666Z","repository":{"id":256247424,"uuid":"854739525","full_name":"ByteBigBoss/Bcors","owner":"ByteBigBoss","description":"A CORS utility library for Java web applications.","archived":false,"fork":false,"pushed_at":"2024-09-10T04:09:01.000Z","size":14734,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T01:19:06.826Z","etag":null,"topics":["cors","java","java-ee-7"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ByteBigBoss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T17:39:50.000Z","updated_at":"2024-09-10T04:09:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"b737db42-36e5-4e44-8ed5-cc47ec91741e","html_url":"https://github.com/ByteBigBoss/Bcors","commit_stats":null,"previous_names":["bytebigboss/bcors"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBigBoss%2FBcors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBigBoss%2FBcors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBigBoss%2FBcors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteBigBoss%2FBcors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByteBigBoss","download_url":"https://codeload.github.com/ByteBigBoss/Bcors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245022126,"owners_count":20548485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cors","java","java-ee-7"],"created_at":"2024-11-29T12:38:05.782Z","updated_at":"2025-03-22T21:28:52.639Z","avatar_url":"https://github.com/ByteBigBoss.png","language":"Java","readme":"# Bcors Library\n\n## Overview\n\nBcors is a Java library designed to simplify Cross-Origin Resource Sharing (CORS) configuration in Java web applications. It automatically applies CORS headers, handles session cookies, and allows for easy customization of CORS settings.\n\n## Features\n\n- **Automatic CORS Handling**: Automatically applies CORS headers to all incoming requests.\n- **Session Cookie Handling**: Configures session cookies with security attributes like `HttpOnly`, `Secure`, and `SameSite=None`.\n- **Global Configuration**: CORS settings are applied globally when the application starts, with easy customization options.\n\n## Installation\n\n### Download\n\nDownload the latest version of the Bcors library from the link below:\n\n- [Download Bcors-1.1.jar](https://github.com/ByteBigBoss/Bcors/releases/download/Bcors-1.1/Bcors-1.1.jar)\n- View all releases [here](https://github.com/ByteBigBoss/Bcors/releases).\n\n### Adding to Your Project\n\n1. **Add `Bcors.jar` to Your Project**: Add the `Bcors.jar` file to your project's classpath.\n\n## Usage\n\n### Automatic CORS Configuration\n\nThe Bcors library automatically applies CORS headers and handles session cookies through a servlet filter and context listener. No manual CORS configuration in servlets is required.\n\n### Customization\n\nTo customize the default CORS settings, you can create a custom `ServletContextListener`:\n\n```java\nimport com.bytebigboss.bcors.Bcors;\nimport java.util.Arrays;\nimport javax.servlet.ServletContextEvent;\nimport javax.servlet.ServletContextListener;\n\npublic class CustomCorsListener implements ServletContextListener {\n\n    @Override\n    public void contextInitialized(ServletContextEvent sce) {\n        // Customize CORS settings here\n        Bcors corsContext = Bcors.getInstance();\n        corsContext.setAllowedOrigins(Arrays.asList(\"http://yourdomain.com\"));\n        corsContext.setAllowedMethods(Arrays.asList(\"POST\", GET\", \"OPTIONS\"));\n        corsContext.setCookieDomain(\"yourdomain.com\");\n        System.out.println(\"Custom CORS configurations applied.\");\n    }\n\n    @Override\n    public void contextDestroyed(ServletContextEvent sce) {\n        // Clean up code if needed\n    }\n}\n```\n\n### Sample Usage\n\nIf needed, you can still manually set CORS headers in specific servlets:\n\n```java\nimport com.bytebigboss.bcors.Bcors;\nimport java.io.IOException;\nimport javax.servlet.ServletException;\nimport javax.servlet.annotation.WebServlet;\nimport javax.servlet.http.HttpServlet;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\n\n@WebServlet(name = \"SystemStatus\", urlPatterns = {\"/SystemStatus\"})\npublic class SystemStatus extends HttpServlet {\n\n    @Override\n    protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {\n        Bcors.setCors(req, res); // This line is usually not needed due to the automatic filter\n        res.getWriter().write(\"System is up and running!\");\n    }\n}\n```\n\n## How It Works\n\n- **CorsFilter**: Automatically applied to all requests to add the necessary CORS headers and handle `OPTIONS` requests.\n- **CorsListener**: Triggered when the web application starts, ensuring global CORS configuration.\n\n### Note\n\nWith the inclusion of CorsFilter and CorsListener in the Bcors library, there's no need for users to add these manually to their project. The library handles CORS configuration automatically, ensuring a seamless integration experience.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Author\n\nCreated by ByteBigBoss.\n\n## Contributions\n\nContributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or improvements.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebigboss%2Fbcors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytebigboss%2Fbcors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytebigboss%2Fbcors/lists"}