{"id":16510522,"url":"https://github.com/bednar/security","last_synced_at":"2026-05-13T06:03:36.674Z","repository":{"id":11427714,"uuid":"13880586","full_name":"bednar/security","owner":"bednar","description":"Java Security Library","archived":false,"fork":false,"pushed_at":"2013-12-17T17:08:22.000Z","size":364,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T07:44:19.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/bednar/security","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bednar.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}},"created_at":"2013-10-26T09:01:50.000Z","updated_at":"2013-12-17T17:08:23.000Z","dependencies_parsed_at":"2022-08-31T05:40:44.002Z","dependency_job_id":null,"html_url":"https://github.com/bednar/security","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bednar/security","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bednar%2Fsecurity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bednar%2Fsecurity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bednar%2Fsecurity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bednar%2Fsecurity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bednar","download_url":"https://codeload.github.com/bednar/security/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bednar%2Fsecurity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"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","status":"online","status_checked_at":"2025-11-27T02:00:05.795Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T15:55:43.095Z","updated_at":"2025-11-27T07:04:57.399Z","avatar_url":"https://github.com/bednar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Security Library\n====\n[![Build Status](https://api.travis-ci.org/bednar/security.png?branch=master)](https://travis-ci.org/bednar/security) [![Coverage Status](https://coveralls.io/repos/bednar/security/badge.png)](https://coveralls.io/r/bednar/security)\n\n## Authorize Persist Events\n\nPersist events -\n[save](https://github.com/bednar/persistence/blob/master/src/main/java/com/github/bednar/persistence/event/SaveEvent.java),\n[read](https://github.com/bednar/persistence/blob/master/src/main/java/com/github/bednar/persistence/event/ReadEvent.java),\n[delete](https://github.com/bednar/persistence/blob/master/src/main/java/com/github/bednar/persistence/event/DeleteEvent.java),\n[list](https://github.com/bednar/persistence/blob/master/src/main/java/com/github/bednar/persistence/event/ListEvent.java)\nare protected by [authorization subquery](https://github.com/bednar/security/blob/master/src/main/java/com/github/bednar/security/contract/ResourceAuthorize.java).\n\n### Create New\n\nCriterion for select [Authenticable Resource](https://github.com/bednar/security/blob/master/src/main/java/com/github/bednar/security/contract/Authenticable.java) which can create `Chat Room`.\n\n    /**\n     * Only account with principal (unique user identifier)  Admin can create new Chat Room\n     */\n    @Nonnull\n    public Criterion createNew(@Nonnull final String principal)\n    {\n        return Restrictions.eq(\"account\", \"admin\");\n    }\n    \n### Update\n\nCriterion for select `Resources` which can `principal` update.\n\n    /**\n     * Principal (unique user identifier) can update Chat Rooms where is admin.\n     */\n    @Nonnull\n    public Criterion update(@Nonnull final String principal)\n    {\n        return Restrictions.eq(\"admin\", principal);\n    }\n    \n### Read\n\nCriterion for select `Resources` which can `principal` read (list).\n\n    /**\n     * Principal (unique user identifier) can read Chat Rooms where is admin or is subscribed to in.\n     */\n    @Nonnull\n    public Criterion read(@Nonnull final String principal)\n    {\n        DetachedCriteria subscribers = DetachedCriteria\n            .forClass(ChatRoomUserAssoc.class, \"roomUser\")\n            .setProjection(Property.forName(\"chat.id\"))\n            .add(Restrictions.eq(\"user\", principal));\n\n        return Restrinctions.or(\n            Restrictions.eq(\"admin\", principal),\n            Subqueries.propertyIn(\"id\", subscribers)\n        );\n    }\n\n### Delete\n\nCriterion for select `Resources` which can `principal` delete.\n\n    /**\n     * Principal (unique user identifier) can delete Chat Rooms where is admin.\n     */\n    @Nonnull\n    public Criterion delete(@Nonnull final String principal)\n    {\n        return Restrictions.eq(\"admin\", principal);\n    }\n    \n## Security Annotation for API Resource\n\n### RequiresAuthentication\n\n[RequiresAuthentication](http://shiro.apache.org/static/current/apidocs/org/apache/shiro/authz/annotation/RequiresAuthentication.html) \nfrom [Shiro](http://shiro.apache.org) can be use for annotate API Resource method which require authenticated Subject.\n\n    @Path(\"/account\")\n    public class AccountResource implements ApiResource\n    {\n        @GET\n        @Path(\"/me\")\n        @RequiresAuthentication\n        public void me(@Nonnull @Suspend final AsynchronousResponse response)\n        {\n            //Subject is authenticated =\u003e generate regular response\n            response.setResponse(...);\n        }\n    }\n\n## Maven Repository\n\n    \u003crepository\u003e\n        \u003cid\u003epublic\u003c/id\u003e\n        \u003cname\u003ePublic\u003c/name\u003e\n        \u003curl\u003ehttp://nexus-bednar.rhcloud.com/nexus/content/groups/public/\u003c/url\u003e\n    \u003c/repository\u003e\n\n## License\n\n    Copyright (c) 2013, Jakub Bednář\n    All rights reserved.\n\n    Redistribution and use in source and binary forms, with or without modification,\n    are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright notice, this\n      list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above copyright notice, this\n      list of conditions and the following disclaimer in the documentation and/or\n      other materials provided with the distribution.\n\n    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbednar%2Fsecurity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbednar%2Fsecurity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbednar%2Fsecurity/lists"}