diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c5ddbec --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + car + Copyright (C) 2022 Jottyfan + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..35b4d33 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# car + +fuel recorder for my car + +# installation + +```bash +gradlew clean build +``` + +copy the corresponding jar file from `build/libs` to the folder of your destination + +# running the app + +create your own `application.properties` file and put it on your server; call that file on runtime + +```bash +java -Dspring.config.location=/wherever/you/have/it/application.properties -jar car-VERSION.jar +``` diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e87b1cf --- /dev/null +++ b/build.gradle @@ -0,0 +1,71 @@ +plugins { + id 'org.springframework.boot' version '3.4.2' + id 'java' + id 'war' +} + +apply plugin: 'io.spring.dependency-management' + +group = 'de.jottyfan' +version = '0.1.4' +sourceCompatibility = 17 +targetCompatibility = 17 + +repositories { + mavenCentral() + maven { + url "https://gitlab.com/jottyfan/libs/-/raw/main/" + } + maven { url "https://www.jottyfan.de/libs" } +} + +dependencies { + implementation 'org.apache.logging.log4j:log4j-api:2.24.3' + implementation 'org.apache.logging.log4j:log4j-core:2.24.3' + implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.24.3' + + implementation 'org.webjars:bootstrap:5.3.3' + implementation 'org.webjars:font-awesome:6.7.2' + implementation 'org.webjars:jquery:3.7.1' + implementation 'org.webjars:popper.js:2.11.7' + + implementation 'org.webjars.npm:datatables.net:2.2.1' + implementation 'org.webjars.npm:datatables.net-buttons:3.2.0' + implementation 'org.webjars.npm:datatables.net-responsive:3.0.3' + implementation 'org.webjars.npm:datatables.net-bs5:2.2.1' + + implementation 'org.springframework.boot:spring-boot-starter-jooq' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation "org.springframework.boot:spring-boot-starter-oauth2-client" + implementation 'org.springframework.security:spring-security-oauth2-authorization-server:1.4.2' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6' + implementation 'de.jottyfan:carjooq:0.0.1' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'org.postgresql:postgresql' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.security:spring-security-test' +} + +war { + doFirst { + manifest { + attributes("Implementation-Title": project.name, + "Implementation-Version": version, + "Implementation-Timestamp": new Date()) + } + } + archiveBaseName = project.name + archiveVersion = version + archiveFileName = 'car.war' +} + +test { + useJUnitPlatform() +} + +// add version to manifest +springBoot { + buildInfo() +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..41d9927 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e382118 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..9d9cdba --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS --illegal-access=permit $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/init b/init deleted file mode 100644 index cdb8d0e..0000000 --- a/init +++ /dev/null @@ -1 +0,0 @@ -init \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..231a4e5 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'car' diff --git a/src/main/java/de/jottyfan/car/CarApplication.java b/src/main/java/de/jottyfan/car/CarApplication.java new file mode 100644 index 0000000..4a46d85 --- /dev/null +++ b/src/main/java/de/jottyfan/car/CarApplication.java @@ -0,0 +1,28 @@ +package de.jottyfan.car; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +/** + * + * @author jotty + * + */ +@SpringBootApplication +@EnableTransactionManagement +public class CarApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure( + SpringApplicationBuilder application) { + return application.sources(CarApplication.class); + } + + public static void main(String[] args) { + SpringApplication.run(CarApplication.class, args); + } + +} diff --git a/src/main/java/de/jottyfan/car/config/InitialConfiguration.java b/src/main/java/de/jottyfan/car/config/InitialConfiguration.java new file mode 100644 index 0000000..006a5da --- /dev/null +++ b/src/main/java/de/jottyfan/car/config/InitialConfiguration.java @@ -0,0 +1,41 @@ +package de.jottyfan.car.config; + +import javax.sql.DataSource; + +import org.jooq.SQLDialect; +import org.jooq.impl.DataSourceConnectionProvider; +import org.jooq.impl.DefaultConfiguration; +import org.jooq.impl.DefaultDSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; + +/** + * + * @author henkej + * + */ +@Configuration +public class InitialConfiguration { + @Autowired + private DataSource dataSource; + + @Bean + public DataSourceConnectionProvider connectionProvider() { + return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource)); + } + + @Bean + public DefaultDSLContext dsl() { + return new DefaultDSLContext(configuration()); + } + + public DefaultConfiguration configuration() { + DefaultConfiguration jooqConfiguration = new DefaultConfiguration(); + jooqConfiguration.set(connectionProvider()); + jooqConfiguration.set(SQLDialect.POSTGRES); +// jooqConfiguration.set(new DefaultExecuteListenerProvider(exceptionTransformer())); + return jooqConfiguration; + } +} diff --git a/src/main/java/de/jottyfan/car/config/SecurityConfiguration.java b/src/main/java/de/jottyfan/car/config/SecurityConfiguration.java new file mode 100644 index 0000000..ef827bb --- /dev/null +++ b/src/main/java/de/jottyfan/car/config/SecurityConfiguration.java @@ -0,0 +1,54 @@ +package de.jottyfan.car.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler; +import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter; +import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.authentication.session.NullAuthenticatedSessionStrategy; +import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; + +/** + * + * @author henkej + * + */ +@Configuration +@EnableWebSecurity +@EnableMethodSecurity +public class SecurityConfiguration { + + @Bean + protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { + return new NullAuthenticatedSessionStrategy(); + } + + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity sec, InMemoryClientRegistrationRepository crr) + throws Exception { + sec.csrf(o -> o.disable()).anonymous(o -> o.disable()) + // @formatter:off + .oauth2Login(o -> o.defaultSuccessUrl("/")) + .logout(o -> o.logoutSuccessHandler(new OidcClientInitiatedLogoutSuccessHandler(crr))) + .authorizeHttpRequests(o -> o.requestMatchers("/public/**").permitAll().anyRequest().authenticated()) + .oauth2ResourceServer(o -> o.jwt(j -> roleConverter())) + .sessionManagement(o -> o.init(sec)); + // @formatter:on + return sec.build(); + } + + @Bean + public JwtAuthenticationConverter roleConverter() { + JwtGrantedAuthoritiesConverter gac = new JwtGrantedAuthoritiesConverter(); + gac.setAuthorityPrefix("ROLE_"); + gac.setAuthoritiesClaimName("roles"); + JwtAuthenticationConverter jac = new JwtAuthenticationConverter(); + jac.setJwtGrantedAuthoritiesConverter(gac); + return jac; + } +} diff --git a/src/main/java/de/jottyfan/car/fuel/FuelController.java b/src/main/java/de/jottyfan/car/fuel/FuelController.java new file mode 100644 index 0000000..595d253 --- /dev/null +++ b/src/main/java/de/jottyfan/car/fuel/FuelController.java @@ -0,0 +1,169 @@ +package de.jottyfan.car.fuel; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import de.jottyfan.car.fuel.model.FuelBean; +import jakarta.annotation.security.RolesAllowed; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; + +/** + * + * @author henkej + * + */ +@Controller +public class FuelController { + private static final Logger LOGGER = LogManager.getLogger(FuelController.class); + + @Autowired + private FuelService fuelService; + + private List cachedFuels; + + @GetMapping("/logout") + public String getLogout(HttpServletRequest request) throws ServletException { + request.logout(); + return "redirect:/"; + } + + @RolesAllowed("car_user") + @GetMapping("/secure/welcome") + public String getWelcome() { + return "secure/welcome"; + } + + @GetMapping("/") + public String getIndex() { + this.cachedFuels = null; + return "public/index"; + } + + @RolesAllowed("car_user") + @GetMapping("/secure/to_table") + public String getTable() { + this.cachedFuels = null; + return "secure/table"; + } + + @RolesAllowed("car_user") + @RequestMapping(value = "/secure/to_bean", method = RequestMethod.GET) + public String getBean(Model model) { + FuelBean bean = model.containsAttribute("fuelBean") ? (FuelBean) model.getAttribute("fuelBean") : new FuelBean(); + model.addAttribute("fuelBean", bean); + return "secure/bean"; + } + + @RolesAllowed("car_user") + @RequestMapping(value = "/secure/to_existing_bean/{fkFuelBean}", method = RequestMethod.GET) + public String getBean(Model model, @PathVariable("fkFuelBean") Integer fkFuelBean) throws Exception { + FuelBean bean = getFuelBean(fkFuelBean); + model.addAttribute("fuelBean", bean); + return "secure/bean"; + } + + private FuelBean getFuelBean(Integer fkFuelBean) throws Exception { + for (FuelBean bean : getFuels()) { + if (bean.getPk().equals(fkFuelBean)) { + return bean; + } + } + throw new Exception("bean not found"); + } + + @RolesAllowed("car_user") + @RequestMapping(value = "/secure/do_upsert", method = RequestMethod.POST) + public String getUpsert(Model model, @ModelAttribute("fuelBean") FuelBean fuelBean) { + Integer affected = fuelService.upsert(fuelBean); + model.addAttribute("fuelBean", fuelBean); + LOGGER.info("affected rows: {}", affected); + return affected > 0 ? getTable() : getBean(model); + } + + @RolesAllowed("car_user") + @GetMapping("/secure/jsonfuels") + @ResponseBody + public List getJsonFuels() { + List fuels = fuelService.findAll(); + return fuels; + } + + @ModelAttribute("fuels") + public List getFuels() { + if (cachedFuels == null || cachedFuels.size() < 1) { + cachedFuels = fuelService.findAll(); + } + return cachedFuels; + } + + @ModelAttribute("averagelkm") + @ResponseBody + public BigDecimal getAverageLiterPerKm() { + List fuels = getFuels(); + Integer minMileage = 1000000; // my car won't even reach this milestone :) + Integer maxMileage = 0; + BigDecimal summedAmount = new BigDecimal(0); + for (FuelBean bean : fuels) { + summedAmount = summedAmount.add(bean.getAmount()); + minMileage = bean.getMileage() < minMileage ? bean.getMileage() : minMileage; + maxMileage = bean.getMileage() > maxMileage ? bean.getMileage() : maxMileage; + } + BigDecimal totalMileage = new BigDecimal(maxMileage - minMileage); + BigDecimal calculated = totalMileage.intValue() != 0 + ? new BigDecimal((summedAmount.doubleValue() / totalMileage.doubleValue()) * 100d) + : new BigDecimal(0); + return calculated; + } + + @ModelAttribute("averageel") + @ResponseBody + public BigDecimal getAverageEuroPerLiter() { + List fuels = getFuels(); + BigDecimal summedLiter = new BigDecimal(0); + BigDecimal summedEuro = new BigDecimal(0); + for (FuelBean bean : fuels) { + summedLiter = summedLiter.add(bean.getAmount()); + summedEuro = summedEuro.add(bean.getPrice()); + } + BigDecimal calculated = summedLiter.intValue() != 0 + ? new BigDecimal(summedEuro.doubleValue() / summedLiter.doubleValue()) + : new BigDecimal(0); + return calculated; + } + + @ModelAttribute("chartjsdata") + @ResponseBody + public List getChartjsData() { + List fuels = getFuels(); + List list = new ArrayList<>(); + for (FuelBean bean : fuels) { + list.add(bean.getEuro_per_l()); + } + return list; + } + + @ModelAttribute("chartjslabel") + @ResponseBody + public List getChartjsLabel() { + List fuels = getFuels(); + List list = new ArrayList<>(); + for (FuelBean bean : fuels) { + list.add(bean.getMileage()); + } + return list; + } +} diff --git a/src/main/java/de/jottyfan/car/fuel/FuelRepository.java b/src/main/java/de/jottyfan/car/fuel/FuelRepository.java new file mode 100644 index 0000000..d477389 --- /dev/null +++ b/src/main/java/de/jottyfan/car/fuel/FuelRepository.java @@ -0,0 +1,88 @@ +package de.jottyfan.car.fuel; + +import static de.jottyfan.car.db.jooq.Tables.T_MILEAGE; +import static de.jottyfan.car.db.jooq.Tables.V_MILEAGE; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jooq.DSLContext; +import org.jooq.InsertValuesStep8; +import org.jooq.Record; +import org.jooq.SelectSeekStep1; +import org.jooq.UpdateConditionStep; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import de.jottyfan.car.db.jooq.tables.records.TMileageRecord; +import de.jottyfan.car.db.jooq.tables.records.VMileageRecord; +import de.jottyfan.car.fuel.model.FuelBean; + +/** + * + * @author henkej + * + */ +@Repository +public class FuelRepository { + private static final Logger LOGGER = LogManager.getLogger(FuelRepository.class); + + @Autowired + private DSLContext jooq; + + /** + * get all records from v_mileage + * + * @return the mileage records + */ + public List getMileages() { + SelectSeekStep1 sql = jooq.selectFrom(V_MILEAGE).orderBy(V_MILEAGE.MILEAGE); + LOGGER.trace("{}", sql.toString()); + List list = new ArrayList<>(); + for (Record r : sql.fetch()) { + Integer pk = r.get(V_MILEAGE.PK); + BigDecimal amount = r.get(V_MILEAGE.AMOUNT); + LocalDateTime buydate = r.get(V_MILEAGE.BUYDATE); + String fuel = r.get(V_MILEAGE.FUEL); + String location = r.get(V_MILEAGE.LOCATION); + Integer mileage = r.get(V_MILEAGE.MILEAGE); + BigDecimal price = r.get(V_MILEAGE.PRICE); + String provider = r.get(V_MILEAGE.PROVIDER); + String annotation = r.get(V_MILEAGE.ANNOTATION); + BigDecimal euro_per_l = r.get(V_MILEAGE.EURO_2fL); + list.add(new FuelBean(pk, amount, buydate, fuel, location, mileage, price, provider, annotation, euro_per_l)); + } + return list; + } + + /** + * upsert fuel bean + * + * @param bean the bean + * @return the number of affected database rows, should be 1 + */ + public Integer upsertMileage(FuelBean bean) { + if (bean.getPk() == null) { + InsertValuesStep8 sql = jooq + .insertInto(T_MILEAGE, T_MILEAGE.MILEAGE, T_MILEAGE.AMOUNT, T_MILEAGE.ANNOTATION, T_MILEAGE.BUYDATE, + T_MILEAGE.FUEL, T_MILEAGE.LOCATION, T_MILEAGE.PRICE, T_MILEAGE.PROVIDER) + .values(bean.getMileage(), bean.getAmount(), bean.getAnnotation(), bean.getBuydate(), bean.getFuel(), + bean.getLocation(), bean.getPrice(), bean.getProvider()); + LOGGER.trace("{}", sql.toString()); + return sql.execute(); + } else { + UpdateConditionStep sql = jooq.update(T_MILEAGE) + .set(T_MILEAGE.MILEAGE, bean.getMileage()) + .set(T_MILEAGE.ANNOTATION, bean.getAnnotation()) + .set(T_MILEAGE.BUYDATE, bean.getBuydate()).set(T_MILEAGE.FUEL, bean.getFuel()) + .set(T_MILEAGE.LOCATION, bean.getLocation()).set(T_MILEAGE.PRICE, bean.getPrice()) + .set(T_MILEAGE.PROVIDER, bean.getProvider()).where(T_MILEAGE.PK.eq(bean.getPk())); + LOGGER.trace("{}", sql.toString()); + return sql.execute(); + } + } +} diff --git a/src/main/java/de/jottyfan/car/fuel/FuelService.java b/src/main/java/de/jottyfan/car/fuel/FuelService.java new file mode 100644 index 0000000..1c6fa0d --- /dev/null +++ b/src/main/java/de/jottyfan/car/fuel/FuelService.java @@ -0,0 +1,30 @@ +package de.jottyfan.car.fuel; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import de.jottyfan.car.fuel.model.FuelBean; + +/** + * + * @author henkej + * + */ +@Service +@Transactional(transactionManager = "transactionManager") +public class FuelService { + + @Autowired + private FuelRepository repository; + + public List findAll() { + return repository.getMileages(); + } + + public Integer upsert(FuelBean fuelBean) { + return repository.upsertMileage(fuelBean); + } +} diff --git a/src/main/java/de/jottyfan/car/fuel/model/FuelBean.java b/src/main/java/de/jottyfan/car/fuel/model/FuelBean.java new file mode 100644 index 0000000..b247f64 --- /dev/null +++ b/src/main/java/de/jottyfan/car/fuel/model/FuelBean.java @@ -0,0 +1,237 @@ +package de.jottyfan.car.fuel.model; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.format.annotation.NumberFormat; + +/** + * + * @author henkej + * + */ +public class FuelBean implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer pk; + + @NumberFormat(style = NumberFormat.Style.NUMBER) + private BigDecimal amount; + + @DateTimeFormat + private LocalDateTime buydate; + + private String fuel; + private String location; + private Integer mileage; + + @NumberFormat(style = NumberFormat.Style.CURRENCY) + private BigDecimal price; + + private String provider; + private String annotation; + private BigDecimal euro_per_l; + + public FuelBean() { + this.pk = null; + } + + public FuelBean(Integer pk, BigDecimal amount, LocalDateTime buydate, String fuel, String location, Integer mileage, + BigDecimal price, String provider, String annotation, BigDecimal euro_per_l) { + super(); + this.pk = pk; + this.amount = amount; + this.buydate = buydate; + this.fuel = fuel; + this.location = location; + this.mileage = mileage; + this.price = price; + this.provider = provider; + this.annotation = annotation; + this.euro_per_l = euro_per_l; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append("FuelBean@{pk=").append(pk); + buf.append(", amount=").append(amount); + buf.append(", buydate=").append(buydate); + buf.append(", fuel=").append(fuel); + buf.append(", location=").append(location); + buf.append(", mileage=").append(mileage); + buf.append(", price=").append(price); + buf.append(", provider=").append(provider); + buf.append(", annotation=").append(annotation); + buf.append(", euro_per_l=").append(euro_per_l); + buf.append("}"); + return buf.toString(); + } + + public void setAmountString(String string) { + this.amount = string == null ? null : new BigDecimal(string); + } + + public String getAmountString() { + return this.amount == null ? "" : this.amount.toPlainString(); + } + + public void setPriceString(String string) { + this.price = string == null ? null : new BigDecimal(string); + } + + public String getPriceString() { + return this.price == null ? "" : this.price.toPlainString(); + } + + public void setBuydateString(String stringDate) { + this.buydate = LocalDateTime.parse(stringDate, DateTimeFormatter.ISO_LOCAL_DATE_TIME); + } + + public String getBuydateString() { + return this.buydate == null ? null : this.buydate.toString(); + } + + /** + * @return the amount + */ + public BigDecimal getAmount() { + return amount; + } + + /** + * @param amount the amount to set + */ + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + /** + * @return the buydate + */ + public LocalDateTime getBuydate() { + return buydate; + } + + /** + * @param buydate the buydate to set + */ + public void setBuydate(LocalDateTime buydate) { + this.buydate = buydate; + } + + /** + * @return the fuel + */ + public String getFuel() { + return fuel; + } + + /** + * @param fuel the fuel to set + */ + public void setFuel(String fuel) { + this.fuel = fuel; + } + + /** + * @return the location + */ + public String getLocation() { + return location; + } + + /** + * @param location the location to set + */ + public void setLocation(String location) { + this.location = location; + } + + /** + * @return the mileage + */ + public Integer getMileage() { + return mileage; + } + + /** + * @param mileage the mileage to set + */ + public void setMileage(Integer mileage) { + this.mileage = mileage; + } + + /** + * @return the price + */ + public BigDecimal getPrice() { + return price; + } + + /** + * @param price the price to set + */ + public void setPrice(BigDecimal price) { + this.price = price; + } + + /** + * @return the provider + */ + public String getProvider() { + return provider; + } + + /** + * @param provider the provider to set + */ + public void setProvider(String provider) { + this.provider = provider; + } + + /** + * @return the annotation + */ + public String getAnnotation() { + return annotation; + } + + /** + * @param annotation the annotation to set + */ + public void setAnnotation(String annotation) { + this.annotation = annotation; + } + + /** + * @return the euro_per_l + */ + public BigDecimal getEuro_per_l() { + return euro_per_l; + } + + /** + * @param euro_per_l the euro_per_l to set + */ + public void setEuro_per_l(BigDecimal euro_per_l) { + this.euro_per_l = euro_per_l; + } + + /** + * @return the pk + */ + public Integer getPk() { + return pk; + } + + /** + * @param pk the pk to set + */ + public void setPk(Integer pk) { + this.pk = pk; + } +} diff --git a/src/main/java/de/jottyfan/car/help/ManifestBean.java b/src/main/java/de/jottyfan/car/help/ManifestBean.java new file mode 100644 index 0000000..40b3fa0 --- /dev/null +++ b/src/main/java/de/jottyfan/car/help/ManifestBean.java @@ -0,0 +1,16 @@ +package de.jottyfan.car.help; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.info.BuildProperties; +import org.springframework.stereotype.Component; + +@Component +public class ManifestBean { + + @Autowired(required = false) + private BuildProperties buildProperties; + + public String getVersion() { + return buildProperties != null ? buildProperties.getVersion() : "0.0.0"; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..98003d6 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,23 @@ +# include properties file from /etc +spring.config.import = /etc/car.properties + +# jooq +spring.datasource.driver-class-name = org.postgresql.Driver +spring.datasource.url = ${db.url} +spring.datasource.username = ${db.username} +spring.datasource.password = ${db.password} + +server.servlet.context-path = /car + +# security +spring.security.oauth2.client.registration.keycloak.client-id = car +spring.security.oauth2.client.registration.keycloak.scope = openid +spring.security.oauth2.client.registration.keycloak.authorization-grant-type = authorization_code +spring.security.oauth2.client.registration.keycloak.redirect-uri = ${keycloak.redirect-uri} +spring.security.oauth2.client.provider.keycloak.issuer-uri = ${keycloak.issuer-uri} +spring.security.oauth2.client.provider.keycloak.authorization-uri = ${keycloak.openid-url}/auth +spring.security.oauth2.client.provider.keycloak.token-uri = ${keycloak.openid-url}/token +spring.security.oauth2.client.provider.keycloak.user-info-uri = ${keycloak.openid-url}/userinfo +spring.security.oauth2.client.provider.keycloak.jwk-set-uri = ${keycloak.openid-url}/certs +spring.security.oauth2.client.provider.keycloak.user-name-attribute = preferred_username + diff --git a/src/main/resources/realm-export.json b/src/main/resources/realm-export.json new file mode 100644 index 0000000..6abb30b --- /dev/null +++ b/src/main/resources/realm-export.json @@ -0,0 +1,2240 @@ +{ + "id": "jottyfan_auto", + "realm": "jottyfan_auto", + "notBefore": 1643221140, + "defaultSignatureAlgorithm": "RS256", + "revokeRefreshToken": false, + "refreshTokenMaxReuse": 0, + "accessTokenLifespan": 300, + "accessTokenLifespanForImplicitFlow": 900, + "ssoSessionIdleTimeout": 1800, + "ssoSessionMaxLifespan": 36000, + "ssoSessionIdleTimeoutRememberMe": 0, + "ssoSessionMaxLifespanRememberMe": 0, + "offlineSessionIdleTimeout": 2592000, + "offlineSessionMaxLifespanEnabled": false, + "offlineSessionMaxLifespan": 5184000, + "clientSessionIdleTimeout": 0, + "clientSessionMaxLifespan": 0, + "clientOfflineSessionIdleTimeout": 0, + "clientOfflineSessionMaxLifespan": 0, + "accessCodeLifespan": 60, + "accessCodeLifespanUserAction": 300, + "accessCodeLifespanLogin": 1800, + "actionTokenGeneratedByAdminLifespan": 43200, + "actionTokenGeneratedByUserLifespan": 300, + "oauth2DeviceCodeLifespan": 600, + "oauth2DevicePollingInterval": 5, + "enabled": true, + "sslRequired": "external", + "registrationAllowed": false, + "registrationEmailAsUsername": false, + "rememberMe": false, + "verifyEmail": false, + "loginWithEmailAllowed": false, + "duplicateEmailsAllowed": false, + "resetPasswordAllowed": false, + "editUsernameAllowed": false, + "bruteForceProtected": false, + "permanentLockout": false, + "maxFailureWaitSeconds": 900, + "minimumQuickLoginWaitSeconds": 60, + "waitIncrementSeconds": 60, + "quickLoginCheckMilliSeconds": 1000, + "maxDeltaTimeSeconds": 43200, + "failureFactor": 30, + "roles": { + "realm": [ + { + "id": "c8b3f343-3a6b-4437-a6f0-a60628ff0a91", + "name": "car_user", + "description": "a user for the car app", + "composite": false, + "clientRole": false, + "containerId": "jottyfan_auto", + "attributes": {} + }, + { + "id": "e0dfdfb2-7480-4f40-b78a-dfd090ad1412", + "name": "default-roles-jottyfan_auto", + "description": "${role_default-roles}", + "composite": true, + "composites": { + "realm": [ + "offline_access", + "uma_authorization" + ], + "client": { + "account": [ + "view-profile", + "manage-account" + ] + } + }, + "clientRole": false, + "containerId": "jottyfan_auto", + "attributes": {} + }, + { + "id": "8f6b0fe0-46e5-4153-b23a-f35c2337af33", + "name": "offline_access", + "description": "${role_offline-access}", + "composite": false, + "clientRole": false, + "containerId": "jottyfan_auto", + "attributes": {} + }, + { + "id": "e47b6b19-6f8d-4778-828e-e2628f0d770c", + "name": "uma_authorization", + "description": "${role_uma_authorization}", + "composite": false, + "clientRole": false, + "containerId": "jottyfan_auto", + "attributes": {} + } + ], + "client": { + "realm-management": [ + { + "id": "1eff53c3-f980-4ce7-a7dc-0236896fa0cf", + "name": "create-client", + "description": "${role_create-client}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "8257f695-6d08-4ec2-bdfb-2c05bbd291dc", + "name": "manage-users", + "description": "${role_manage-users}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "34505dcd-c2b5-4f36-acd0-bef9048bf623", + "name": "query-groups", + "description": "${role_query-groups}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "5f6b01ea-efb2-4b3c-a780-d9e02e2d6832", + "name": "realm-admin", + "description": "${role_realm-admin}", + "composite": true, + "composites": { + "client": { + "realm-management": [ + "create-client", + "manage-users", + "query-groups", + "view-authorization", + "view-clients", + "manage-authorization", + "query-realms", + "manage-clients", + "impersonation", + "manage-realm", + "manage-identity-providers", + "query-users", + "view-users", + "view-events", + "query-clients", + "view-identity-providers", + "view-realm", + "manage-events" + ] + } + }, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "82716f24-3f2e-415d-a192-cf556f19ea9b", + "name": "view-authorization", + "description": "${role_view-authorization}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "ebde2010-5247-4712-986b-6bc900eb560e", + "name": "view-clients", + "description": "${role_view-clients}", + "composite": true, + "composites": { + "client": { + "realm-management": [ + "query-clients" + ] + } + }, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "72acf292-d9d7-4ef6-8ddd-240b93f9819b", + "name": "manage-authorization", + "description": "${role_manage-authorization}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "ac7b252c-5781-4257-b712-cdb214bd9166", + "name": "query-realms", + "description": "${role_query-realms}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "3b6155d0-c8cc-4b62-8ea4-9cc903c37765", + "name": "manage-clients", + "description": "${role_manage-clients}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "3d0011a5-bb97-41a5-8c8d-eb0dc8255c5c", + "name": "impersonation", + "description": "${role_impersonation}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "bf7ab57c-1021-4668-8b89-ea18395f33cd", + "name": "manage-realm", + "description": "${role_manage-realm}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "a19a58b8-478f-4d66-ac8a-fedc72055963", + "name": "manage-identity-providers", + "description": "${role_manage-identity-providers}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "e8d8f75c-8659-42ab-93f6-7595351d4d5e", + "name": "query-users", + "description": "${role_query-users}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "5712e35e-32d3-4509-b307-07138184185e", + "name": "view-users", + "description": "${role_view-users}", + "composite": true, + "composites": { + "client": { + "realm-management": [ + "query-users", + "query-groups" + ] + } + }, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "1244bd0e-5131-4e82-8aea-50438f6e7429", + "name": "view-events", + "description": "${role_view-events}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "e040fe16-bef1-4536-b3c4-1540ec311a72", + "name": "query-clients", + "description": "${role_query-clients}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "24bd13e7-2282-418a-a735-72b977bafa76", + "name": "view-identity-providers", + "description": "${role_view-identity-providers}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "b3a6f95a-6185-47ce-ac72-10405c3b3cc1", + "name": "view-realm", + "description": "${role_view-realm}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + }, + { + "id": "f671f4f4-3d85-4977-a23f-d2ff62332b18", + "name": "manage-events", + "description": "${role_manage-events}", + "composite": false, + "clientRole": true, + "containerId": "8c886141-2439-4218-9380-34c9c5ce2665", + "attributes": {} + } + ], + "car": [ + { + "id": "f12b1444-5928-43a3-b3c1-1d0bccdd0dca", + "name": "car_user", + "composite": false, + "clientRole": true, + "containerId": "5863e5d3-567f-4d5f-bd50-d1f196ec41cf", + "attributes": {} + }, + { + "id": "878e8a83-0561-4fd5-94b3-463c0ecc6f08", + "name": "uma_protection", + "composite": false, + "clientRole": true, + "containerId": "5863e5d3-567f-4d5f-bd50-d1f196ec41cf", + "attributes": {} + } + ], + "security-admin-console": [], + "admin-cli": [], + "account-console": [], + "broker": [ + { + "id": "198a705c-aacf-4062-923c-0bf6dbab172e", + "name": "read-token", + "description": "${role_read-token}", + "composite": false, + "clientRole": true, + "containerId": "eab5aefa-0404-4b3d-afd1-ec08b80cae18", + "attributes": {} + } + ], + "account": [ + { + "id": "0b4562e6-2c39-490b-9b5e-06d26ed47cbd", + "name": "view-profile", + "description": "${role_view-profile}", + "composite": false, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "5d06a2bc-fbcf-40d9-9193-ab5636508831", + "name": "delete-account", + "description": "${role_delete-account}", + "composite": false, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "dd7d0508-2bf8-440b-8b63-ad19a8b3f75f", + "name": "manage-account", + "description": "${role_manage-account}", + "composite": true, + "composites": { + "client": { + "account": [ + "manage-account-links" + ] + } + }, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "2eca21ed-3a8d-4f9f-be4c-841c6086fecf", + "name": "manage-consent", + "description": "${role_manage-consent}", + "composite": true, + "composites": { + "client": { + "account": [ + "view-consent" + ] + } + }, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "41a0571a-83d8-4a59-85d9-1d31eb6e0c51", + "name": "view-consent", + "description": "${role_view-consent}", + "composite": false, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "a16f69fa-73da-4d52-89bc-0716bfc217a9", + "name": "view-applications", + "description": "${role_view-applications}", + "composite": false, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + }, + { + "id": "c81b3008-ac56-44ff-ae35-4648beba9ea1", + "name": "manage-account-links", + "description": "${role_manage-account-links}", + "composite": false, + "clientRole": true, + "containerId": "6c978188-6232-4458-b792-772e8291a2c3", + "attributes": {} + } + ] + } + }, + "groups": [], + "defaultRole": { + "id": "e0dfdfb2-7480-4f40-b78a-dfd090ad1412", + "name": "default-roles-jottyfan_auto", + "description": "${role_default-roles}", + "composite": true, + "clientRole": false, + "containerId": "jottyfan_auto" + }, + "requiredCredentials": [ + "password" + ], + "otpPolicyType": "totp", + "otpPolicyAlgorithm": "HmacSHA1", + "otpPolicyInitialCounter": 0, + "otpPolicyDigits": 6, + "otpPolicyLookAheadWindow": 1, + "otpPolicyPeriod": 30, + "otpSupportedApplications": [ + "FreeOTP", + "Google Authenticator" + ], + "webAuthnPolicyRpEntityName": "keycloak", + "webAuthnPolicySignatureAlgorithms": [ + "ES256" + ], + "webAuthnPolicyRpId": "", + "webAuthnPolicyAttestationConveyancePreference": "not specified", + "webAuthnPolicyAuthenticatorAttachment": "not specified", + "webAuthnPolicyRequireResidentKey": "not specified", + "webAuthnPolicyUserVerificationRequirement": "not specified", + "webAuthnPolicyCreateTimeout": 0, + "webAuthnPolicyAvoidSameAuthenticatorRegister": false, + "webAuthnPolicyAcceptableAaguids": [], + "webAuthnPolicyPasswordlessRpEntityName": "keycloak", + "webAuthnPolicyPasswordlessSignatureAlgorithms": [ + "ES256" + ], + "webAuthnPolicyPasswordlessRpId": "", + "webAuthnPolicyPasswordlessAttestationConveyancePreference": "not specified", + "webAuthnPolicyPasswordlessAuthenticatorAttachment": "not specified", + "webAuthnPolicyPasswordlessRequireResidentKey": "not specified", + "webAuthnPolicyPasswordlessUserVerificationRequirement": "not specified", + "webAuthnPolicyPasswordlessCreateTimeout": 0, + "webAuthnPolicyPasswordlessAvoidSameAuthenticatorRegister": false, + "webAuthnPolicyPasswordlessAcceptableAaguids": [], + "scopeMappings": [ + { + "clientScope": "offline_access", + "roles": [ + "offline_access" + ] + } + ], + "clientScopeMappings": { + "account": [ + { + "client": "account-console", + "roles": [ + "manage-account" + ] + } + ] + }, + "clients": [ + { + "id": "6c978188-6232-4458-b792-772e8291a2c3", + "clientId": "account", + "name": "${client_account}", + "rootUrl": "${authBaseUrl}", + "baseUrl": "/realms/jottyfan_auto/account/", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [ + "/realms/jottyfan_auto/account/*" + ], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": false, + "publicClient": true, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": {}, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "0a4d0d59-45eb-46eb-aab8-5931207121f8", + "clientId": "account-console", + "name": "${client_account-console}", + "rootUrl": "${authBaseUrl}", + "baseUrl": "/realms/jottyfan_auto/account/", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [ + "/realms/jottyfan_auto/account/*" + ], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": false, + "publicClient": true, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": { + "pkce.code.challenge.method": "S256" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "protocolMappers": [ + { + "id": "6ea2e580-5e4c-4489-ab84-5fbdf4022601", + "name": "audience resolve", + "protocol": "openid-connect", + "protocolMapper": "oidc-audience-resolve-mapper", + "consentRequired": false, + "config": {} + } + ], + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "e894c3fc-5f60-469f-8a6a-5742c7bb9285", + "clientId": "admin-cli", + "name": "${client_admin-cli}", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": false, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": true, + "serviceAccountsEnabled": false, + "publicClient": true, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": {}, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "eab5aefa-0404-4b3d-afd1-ec08b80cae18", + "clientId": "broker", + "name": "${client_broker}", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": true, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": false, + "publicClient": false, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": {}, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "5863e5d3-567f-4d5f-bd50-d1f196ec41cf", + "clientId": "car", + "rootUrl": "", + "adminUrl": "http://localhost:8081/public/index", + "baseUrl": "", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [ + "http://localhost:8081/*" + ], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": true, + "publicClient": true, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": { + "id.token.as.detached.signature": "false", + "saml.assertion.signature": "false", + "saml.force.post.binding": "false", + "saml.multivalued.roles": "false", + "saml.encrypt": "false", + "login_theme": "keycloak", + "oauth2.device.authorization.grant.enabled": "false", + "backchannel.logout.revoke.offline.tokens": "false", + "saml.server.signature": "false", + "saml.server.signature.keyinfo.ext": "false", + "use.refresh.tokens": "true", + "exclude.session.state.from.auth.response": "false", + "oidc.ciba.grant.enabled": "false", + "saml.artifact.binding": "false", + "backchannel.logout.session.required": "true", + "client_credentials.use_refresh_token": "false", + "saml_force_name_id_format": "false", + "require.pushed.authorization.requests": "false", + "saml.client.signature": "false", + "tls.client.certificate.bound.access.tokens": "false", + "saml.authnstatement": "false", + "display.on.consent.screen": "false", + "saml.onetimeuse.condition": "false" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": true, + "nodeReRegistrationTimeout": -1, + "protocolMappers": [ + { + "id": "bcb37cf8-405c-42c5-a9e9-346490e4a314", + "name": "Client ID", + "protocol": "openid-connect", + "protocolMapper": "oidc-usersessionmodel-note-mapper", + "consentRequired": false, + "config": { + "user.session.note": "clientId", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "clientId", + "jsonType.label": "String" + } + }, + { + "id": "43a726aa-3267-4ce6-9a9d-5bc444f7e093", + "name": "Client Host", + "protocol": "openid-connect", + "protocolMapper": "oidc-usersessionmodel-note-mapper", + "consentRequired": false, + "config": { + "user.session.note": "clientHost", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "clientHost", + "jsonType.label": "String" + } + }, + { + "id": "400d9bf1-8160-4073-bf8c-c4e625cc253b", + "name": "Client IP Address", + "protocol": "openid-connect", + "protocolMapper": "oidc-usersessionmodel-note-mapper", + "consentRequired": false, + "config": { + "user.session.note": "clientAddress", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "clientAddress", + "jsonType.label": "String" + } + } + ], + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "8c886141-2439-4218-9380-34c9c5ce2665", + "clientId": "realm-management", + "name": "${client_realm-management}", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [], + "webOrigins": [], + "notBefore": 0, + "bearerOnly": true, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": false, + "publicClient": false, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": {}, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + }, + { + "id": "2838674a-1cc1-437b-ae78-2b9e833cd41d", + "clientId": "security-admin-console", + "name": "${client_security-admin-console}", + "rootUrl": "${authAdminUrl}", + "baseUrl": "/admin/jottyfan_auto/console/", + "surrogateAuthRequired": false, + "enabled": true, + "alwaysDisplayInConsole": false, + "clientAuthenticatorType": "client-secret", + "redirectUris": [ + "/admin/jottyfan_auto/console/*" + ], + "webOrigins": [ + "+" + ], + "notBefore": 0, + "bearerOnly": false, + "consentRequired": false, + "standardFlowEnabled": true, + "implicitFlowEnabled": false, + "directAccessGrantsEnabled": false, + "serviceAccountsEnabled": false, + "publicClient": true, + "frontchannelLogout": false, + "protocol": "openid-connect", + "attributes": { + "pkce.code.challenge.method": "S256" + }, + "authenticationFlowBindingOverrides": {}, + "fullScopeAllowed": false, + "nodeReRegistrationTimeout": 0, + "protocolMappers": [ + { + "id": "81151817-242d-4d62-bb02-077a16a17393", + "name": "locale", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "locale", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "locale", + "jsonType.label": "String" + } + } + ], + "defaultClientScopes": [ + "web-origins", + "profile", + "roles", + "email" + ], + "optionalClientScopes": [ + "address", + "phone", + "offline_access", + "microprofile-jwt" + ] + } + ], + "clientScopes": [ + { + "id": "11116a21-fbd9-4b04-bfa8-de64612d86bf", + "name": "microprofile-jwt", + "description": "Microprofile - JWT built-in scope", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "true", + "display.on.consent.screen": "false" + }, + "protocolMappers": [ + { + "id": "14fbeaf1-7265-4afe-beb2-80a7362ec56c", + "name": "upn", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "username", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "upn", + "jsonType.label": "String" + } + }, + { + "id": "8b9635dc-1d23-47c6-bd63-395dd11eeb6e", + "name": "groups", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-realm-role-mapper", + "consentRequired": false, + "config": { + "multivalued": "true", + "user.attribute": "foo", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "groups", + "jsonType.label": "String" + } + } + ] + }, + { + "id": "89debbfc-7233-4c81-a49f-40eb3ff86a35", + "name": "email", + "description": "OpenID Connect built-in scope: email", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "true", + "display.on.consent.screen": "true", + "consent.screen.text": "${emailScopeConsentText}" + }, + "protocolMappers": [ + { + "id": "59db0dcd-060d-4f8c-9d73-d4cbe7d1c027", + "name": "email verified", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "emailVerified", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "email_verified", + "jsonType.label": "boolean" + } + }, + { + "id": "424b76f2-fb70-49cf-9afa-d1bd276ec0f5", + "name": "email", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "email", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "email", + "jsonType.label": "String" + } + } + ] + }, + { + "id": "323ac711-7171-4fd9-b51f-ef1a1dac60ab", + "name": "profile", + "description": "OpenID Connect built-in scope: profile", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "true", + "display.on.consent.screen": "true", + "consent.screen.text": "${profileScopeConsentText}" + }, + "protocolMappers": [ + { + "id": "d901c6e4-40ea-4221-94eb-9acee72a7e6d", + "name": "gender", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "gender", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "gender", + "jsonType.label": "String" + } + }, + { + "id": "73d55130-d980-47c0-a1f5-b6036bd7754b", + "name": "full name", + "protocol": "openid-connect", + "protocolMapper": "oidc-full-name-mapper", + "consentRequired": false, + "config": { + "id.token.claim": "true", + "access.token.claim": "true", + "userinfo.token.claim": "true" + } + }, + { + "id": "150ff05d-9c45-433e-b8af-23d24d72b197", + "name": "username", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "username", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "preferred_username", + "jsonType.label": "String" + } + }, + { + "id": "2fa2b8b0-1637-4be6-99a4-3004f2d86df1", + "name": "profile", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "profile", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "profile", + "jsonType.label": "String" + } + }, + { + "id": "e104c599-3710-4c00-b203-620ca6784426", + "name": "given name", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "firstName", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "given_name", + "jsonType.label": "String" + } + }, + { + "id": "8c5135ca-f294-4cc7-8c3e-bec5417b0465", + "name": "locale", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "locale", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "locale", + "jsonType.label": "String" + } + }, + { + "id": "59a44f30-3497-4887-9eb2-57c3cc327da5", + "name": "nickname", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "nickname", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "nickname", + "jsonType.label": "String" + } + }, + { + "id": "638ecf23-b484-48e2-87f3-5864954eadb6", + "name": "zoneinfo", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "zoneinfo", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "zoneinfo", + "jsonType.label": "String" + } + }, + { + "id": "e9893b36-72e1-4143-8b8d-4bfb89095df8", + "name": "website", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "website", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "website", + "jsonType.label": "String" + } + }, + { + "id": "78f4313d-b656-4e3e-896f-39059f54a077", + "name": "birthdate", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "birthdate", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "birthdate", + "jsonType.label": "String" + } + }, + { + "id": "903a838f-112f-41fa-bfd5-eee158443141", + "name": "family name", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-property-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "lastName", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "family_name", + "jsonType.label": "String" + } + }, + { + "id": "4712c2b9-541b-42ae-9bd8-82267d9d07e3", + "name": "updated at", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "updatedAt", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "updated_at", + "jsonType.label": "String" + } + }, + { + "id": "9e6b4805-5ff4-4e9d-856b-664bdda4ad15", + "name": "middle name", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "middleName", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "middle_name", + "jsonType.label": "String" + } + }, + { + "id": "3d942b62-828f-42cf-a523-aaf3fbdf4d69", + "name": "picture", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "picture", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "picture", + "jsonType.label": "String" + } + } + ] + }, + { + "id": "0e465621-d9c2-4f89-a2ac-0f204c578ef7", + "name": "roles", + "description": "OpenID Connect scope for add user roles to the access token", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "false", + "display.on.consent.screen": "true", + "consent.screen.text": "${rolesScopeConsentText}" + }, + "protocolMappers": [ + { + "id": "b46e06d7-5db8-44b6-b4ca-d04c6fa7860d", + "name": "audience resolve", + "protocol": "openid-connect", + "protocolMapper": "oidc-audience-resolve-mapper", + "consentRequired": false, + "config": {} + }, + { + "id": "17ab054d-2aec-4e90-a2ce-79b196a95bee", + "name": "client roles", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-client-role-mapper", + "consentRequired": false, + "config": { + "user.attribute": "foo", + "access.token.claim": "true", + "claim.name": "resource_access.${client_id}.roles", + "jsonType.label": "String", + "multivalued": "true" + } + }, + { + "id": "b28f111f-c02a-4ace-8dd0-7d4a4cae3559", + "name": "realm roles", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-realm-role-mapper", + "consentRequired": false, + "config": { + "user.attribute": "foo", + "access.token.claim": "true", + "claim.name": "realm_access.roles", + "jsonType.label": "String", + "multivalued": "true" + } + } + ] + }, + { + "id": "bda65800-4ada-4362-b182-c0b25d316418", + "name": "address", + "description": "OpenID Connect built-in scope: address", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "true", + "display.on.consent.screen": "true", + "consent.screen.text": "${addressScopeConsentText}" + }, + "protocolMappers": [ + { + "id": "9a5fae4c-3a40-4af7-8167-99b047aeb106", + "name": "address", + "protocol": "openid-connect", + "protocolMapper": "oidc-address-mapper", + "consentRequired": false, + "config": { + "user.attribute.formatted": "formatted", + "user.attribute.country": "country", + "user.attribute.postal_code": "postal_code", + "userinfo.token.claim": "true", + "user.attribute.street": "street", + "id.token.claim": "true", + "user.attribute.region": "region", + "access.token.claim": "true", + "user.attribute.locality": "locality" + } + } + ] + }, + { + "id": "d38ecda9-6310-4182-b6c3-5821c76372e0", + "name": "web-origins", + "description": "OpenID Connect scope for add allowed web origins to the access token", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "false", + "display.on.consent.screen": "false", + "consent.screen.text": "" + }, + "protocolMappers": [ + { + "id": "0a7026ab-a737-43d5-8518-59c41b28564f", + "name": "allowed web origins", + "protocol": "openid-connect", + "protocolMapper": "oidc-allowed-origins-mapper", + "consentRequired": false, + "config": {} + } + ] + }, + { + "id": "a7fd2925-3071-4bb6-a324-5bd0c6334ec2", + "name": "role_list", + "description": "SAML role list", + "protocol": "saml", + "attributes": { + "consent.screen.text": "${samlRoleListScopeConsentText}", + "display.on.consent.screen": "true" + }, + "protocolMappers": [ + { + "id": "10bf88f9-4645-4ffc-ab8f-5f684e4eb7a0", + "name": "role list", + "protocol": "saml", + "protocolMapper": "saml-role-list-mapper", + "consentRequired": false, + "config": { + "single": "false", + "attribute.nameformat": "Basic", + "attribute.name": "Role" + } + } + ] + }, + { + "id": "2f1bce01-0914-4a54-a916-3304525edef8", + "name": "offline_access", + "description": "OpenID Connect built-in scope: offline_access", + "protocol": "openid-connect", + "attributes": { + "consent.screen.text": "${offlineAccessScopeConsentText}", + "display.on.consent.screen": "true" + } + }, + { + "id": "d4060b65-7eac-48a1-9947-c80e3b8ec83c", + "name": "phone", + "description": "OpenID Connect built-in scope: phone", + "protocol": "openid-connect", + "attributes": { + "include.in.token.scope": "true", + "display.on.consent.screen": "true", + "consent.screen.text": "${phoneScopeConsentText}" + }, + "protocolMappers": [ + { + "id": "c986c6a0-118b-4f89-8ab4-c61aa4727059", + "name": "phone number verified", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "phoneNumberVerified", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "phone_number_verified", + "jsonType.label": "boolean" + } + }, + { + "id": "b7f8e9b3-ee68-4b81-997c-b42644b928ee", + "name": "phone number", + "protocol": "openid-connect", + "protocolMapper": "oidc-usermodel-attribute-mapper", + "consentRequired": false, + "config": { + "userinfo.token.claim": "true", + "user.attribute": "phoneNumber", + "id.token.claim": "true", + "access.token.claim": "true", + "claim.name": "phone_number", + "jsonType.label": "String" + } + } + ] + } + ], + "defaultDefaultClientScopes": [ + "role_list", + "profile", + "email", + "roles", + "web-origins" + ], + "defaultOptionalClientScopes": [ + "offline_access", + "address", + "phone", + "microprofile-jwt" + ], + "browserSecurityHeaders": { + "contentSecurityPolicyReportOnly": "", + "xContentTypeOptions": "nosniff", + "xRobotsTag": "none", + "xFrameOptions": "SAMEORIGIN", + "contentSecurityPolicy": "frame-src 'self'; frame-ancestors 'self'; object-src 'none';", + "xXSSProtection": "1; mode=block", + "strictTransportSecurity": "max-age=31536000; includeSubDomains" + }, + "smtpServer": {}, + "loginTheme": "keycloak", + "accountTheme": "keycloak.v2", + "adminTheme": "keycloak", + "emailTheme": "keycloak", + "eventsEnabled": false, + "eventsListeners": [ + "jboss-logging" + ], + "enabledEventTypes": [], + "adminEventsEnabled": false, + "adminEventsDetailsEnabled": false, + "identityProviders": [], + "identityProviderMappers": [], + "components": { + "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy": [ + { + "id": "257c9230-ed1e-493a-8731-903b97526c44", + "name": "Allowed Protocol Mapper Types", + "providerId": "allowed-protocol-mappers", + "subType": "authenticated", + "subComponents": {}, + "config": { + "allowed-protocol-mapper-types": [ + "saml-user-property-mapper", + "oidc-usermodel-property-mapper", + "oidc-address-mapper", + "oidc-full-name-mapper", + "saml-role-list-mapper", + "saml-user-attribute-mapper", + "oidc-sha256-pairwise-sub-mapper", + "oidc-usermodel-attribute-mapper" + ] + } + }, + { + "id": "812cb347-f9f8-4653-acce-a423f9a4cf30", + "name": "Allowed Protocol Mapper Types", + "providerId": "allowed-protocol-mappers", + "subType": "anonymous", + "subComponents": {}, + "config": { + "allowed-protocol-mapper-types": [ + "saml-user-property-mapper", + "oidc-full-name-mapper", + "oidc-sha256-pairwise-sub-mapper", + "oidc-address-mapper", + "saml-user-attribute-mapper", + "oidc-usermodel-attribute-mapper", + "saml-role-list-mapper", + "oidc-usermodel-property-mapper" + ] + } + }, + { + "id": "05005f9d-e5c6-476a-8dc0-a988e969c5ab", + "name": "Trusted Hosts", + "providerId": "trusted-hosts", + "subType": "anonymous", + "subComponents": {}, + "config": { + "host-sending-registration-request-must-match": [ + "true" + ], + "client-uris-must-match": [ + "true" + ] + } + }, + { + "id": "52f089d0-614a-4578-9c6a-cecdd4742f6f", + "name": "Full Scope Disabled", + "providerId": "scope", + "subType": "anonymous", + "subComponents": {}, + "config": {} + }, + { + "id": "1abfd121-1f69-4659-803d-b9a26e4ef187", + "name": "Max Clients Limit", + "providerId": "max-clients", + "subType": "anonymous", + "subComponents": {}, + "config": { + "max-clients": [ + "200" + ] + } + }, + { + "id": "9a6dc812-83c5-4bb6-b879-fa17eb6e5192", + "name": "Allowed Client Scopes", + "providerId": "allowed-client-templates", + "subType": "anonymous", + "subComponents": {}, + "config": { + "allow-default-scopes": [ + "true" + ] + } + }, + { + "id": "9c34f3df-851c-49e9-9a69-35712ec8370e", + "name": "Consent Required", + "providerId": "consent-required", + "subType": "anonymous", + "subComponents": {}, + "config": {} + }, + { + "id": "f920dc67-2d1e-46a2-92a8-66797352ba5b", + "name": "Allowed Client Scopes", + "providerId": "allowed-client-templates", + "subType": "authenticated", + "subComponents": {}, + "config": { + "allow-default-scopes": [ + "true" + ] + } + } + ], + "org.keycloak.keys.KeyProvider": [ + { + "id": "a50d75f1-52e3-48a5-9fa3-2baceaabbfe6", + "name": "aes-generated", + "providerId": "aes-generated", + "subComponents": {}, + "config": { + "priority": [ + "100" + ] + } + }, + { + "id": "21a44625-6251-4ed8-bee6-5d8c800088d0", + "name": "rsa-enc-generated", + "providerId": "rsa-enc-generated", + "subComponents": {}, + "config": { + "priority": [ + "100" + ], + "algorithm": [ + "RSA-OAEP" + ] + } + }, + { + "id": "1361dfad-3302-4efa-bd09-26311738c535", + "name": "rsa-generated", + "providerId": "rsa-generated", + "subComponents": {}, + "config": { + "priority": [ + "100" + ] + } + }, + { + "id": "88d7f1c9-ff76-4542-a4f3-c06bdd378b8b", + "name": "hmac-generated", + "providerId": "hmac-generated", + "subComponents": {}, + "config": { + "priority": [ + "100" + ], + "algorithm": [ + "HS256" + ] + } + } + ] + }, + "internationalizationEnabled": false, + "supportedLocales": [ + "" + ], + "authenticationFlows": [ + { + "id": "d5a084ac-2628-41a1-b582-2b4d90aa8bbe", + "alias": "Account verification options", + "description": "Method with which to verity the existing account", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "idp-email-verification", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "ALTERNATIVE", + "priority": 20, + "flowAlias": "Verify Existing Account by Re-authentication", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "5dbd6a37-3ee9-4327-9b0d-9e1a2d8c0d57", + "alias": "Authentication Options", + "description": "Authentication options.", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "basic-auth", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "basic-auth-otp", + "authenticatorFlow": false, + "requirement": "DISABLED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "auth-spnego", + "authenticatorFlow": false, + "requirement": "DISABLED", + "priority": 30, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "4f4b2a59-5c19-43e8-82c4-a671143637f6", + "alias": "Browser - Conditional OTP", + "description": "Flow to determine if the OTP is required for the authentication", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "conditional-user-configured", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "auth-otp-form", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "300edd98-b481-4474-b8e9-28d331a3fe31", + "alias": "Direct Grant - Conditional OTP", + "description": "Flow to determine if the OTP is required for the authentication", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "conditional-user-configured", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "direct-grant-validate-otp", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "46c49ff7-fd34-4d61-83a9-e251825e8f90", + "alias": "First broker login - Conditional OTP", + "description": "Flow to determine if the OTP is required for the authentication", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "conditional-user-configured", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "auth-otp-form", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "932cc3af-4956-4937-bfc8-b7bcc9374b51", + "alias": "Handle Existing Account", + "description": "Handle what to do if there is existing account with same email/username like authenticated identity provider", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "idp-confirm-link", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "REQUIRED", + "priority": 20, + "flowAlias": "Account verification options", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "ab23bfd0-9853-4009-a4a0-1b77d778fd42", + "alias": "Reset - Conditional OTP", + "description": "Flow to determine if the OTP should be reset or not. Set to REQUIRED to force.", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "conditional-user-configured", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "reset-otp", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "f80b8856-05f1-44e3-94f2-a42d80ba1878", + "alias": "User creation or linking", + "description": "Flow for the existing/non-existing user alternatives", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticatorConfig": "create unique user config", + "authenticator": "idp-create-user-if-unique", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "ALTERNATIVE", + "priority": 20, + "flowAlias": "Handle Existing Account", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "49524877-d50d-44ef-9095-afc905c4cf9b", + "alias": "Verify Existing Account by Re-authentication", + "description": "Reauthentication of existing account", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "idp-username-password-form", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "CONDITIONAL", + "priority": 20, + "flowAlias": "First broker login - Conditional OTP", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "1ee3d244-cabe-4251-8cd4-051fc3160c2b", + "alias": "browser", + "description": "browser based authentication", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "auth-cookie", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "auth-spnego", + "authenticatorFlow": false, + "requirement": "DISABLED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "identity-provider-redirector", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 25, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "ALTERNATIVE", + "priority": 30, + "flowAlias": "forms", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "c98252a1-01dc-4907-81f6-a181ae94bd99", + "alias": "clients", + "description": "Base authentication for clients", + "providerId": "client-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "client-secret", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "client-jwt", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "client-secret-jwt", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 30, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "client-x509", + "authenticatorFlow": false, + "requirement": "ALTERNATIVE", + "priority": 40, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "3f4f5c2f-f0d3-4e4d-b8e9-d3582f9cfea5", + "alias": "direct grant", + "description": "OpenID Connect Resource Owner Grant", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "direct-grant-validate-username", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "direct-grant-validate-password", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "CONDITIONAL", + "priority": 30, + "flowAlias": "Direct Grant - Conditional OTP", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "26a7020b-17f7-4049-a92e-ec75cd68771b", + "alias": "docker auth", + "description": "Used by Docker clients to authenticate against the IDP", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "docker-http-basic-authenticator", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "b6d41f85-92e8-4021-9fa5-22a283a5e4c4", + "alias": "first broker login", + "description": "Actions taken after first broker login with identity provider account, which is not yet linked to any Keycloak account", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticatorConfig": "review profile config", + "authenticator": "idp-review-profile", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "REQUIRED", + "priority": 20, + "flowAlias": "User creation or linking", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "5da4a8f2-d7d2-41e6-a85e-71d4fbcbbb69", + "alias": "forms", + "description": "Username, password, otp and other auth forms.", + "providerId": "basic-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "auth-username-password-form", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "CONDITIONAL", + "priority": 20, + "flowAlias": "Browser - Conditional OTP", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "46634f18-f35b-46fc-a555-ce2942481953", + "alias": "http challenge", + "description": "An authentication flow based on challenge-response HTTP Authentication Schemes", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "no-cookie-redirect", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "REQUIRED", + "priority": 20, + "flowAlias": "Authentication Options", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "df8862dd-f99b-431f-9233-5d09314f425c", + "alias": "registration", + "description": "registration flow", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "registration-page-form", + "authenticatorFlow": true, + "requirement": "REQUIRED", + "priority": 10, + "flowAlias": "registration form", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "678a9c43-faea-4bf4-a9f6-3f9ecab6e132", + "alias": "registration form", + "description": "registration form", + "providerId": "form-flow", + "topLevel": false, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "registration-user-creation", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "registration-profile-action", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 40, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "registration-password-action", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 50, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "registration-recaptcha-action", + "authenticatorFlow": false, + "requirement": "DISABLED", + "priority": 60, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + }, + { + "id": "215b01c9-f19c-4dfe-a5f7-c132b1e570c5", + "alias": "reset credentials", + "description": "Reset credentials for a user if they forgot their password or something", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "reset-credentials-choose-user", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "reset-credential-email", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 20, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticator": "reset-password", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 30, + "userSetupAllowed": false, + "autheticatorFlow": false + }, + { + "authenticatorFlow": true, + "requirement": "CONDITIONAL", + "priority": 40, + "flowAlias": "Reset - Conditional OTP", + "userSetupAllowed": false, + "autheticatorFlow": true + } + ] + }, + { + "id": "c84d2b65-35d5-4561-9994-e8b929aaaa87", + "alias": "saml ecp", + "description": "SAML ECP Profile Authentication Flow", + "providerId": "basic-flow", + "topLevel": true, + "builtIn": true, + "authenticationExecutions": [ + { + "authenticator": "http-basic-authenticator", + "authenticatorFlow": false, + "requirement": "REQUIRED", + "priority": 10, + "userSetupAllowed": false, + "autheticatorFlow": false + } + ] + } + ], + "authenticatorConfig": [ + { + "id": "95fdbca1-3c4a-48da-8bc8-7904f4dca16b", + "alias": "create unique user config", + "config": { + "require.password.update.after.registration": "false" + } + }, + { + "id": "9497e7a3-2de3-46d3-88a4-7e35904db11e", + "alias": "review profile config", + "config": { + "update.profile.on.first.login": "missing" + } + } + ], + "requiredActions": [ + { + "alias": "CONFIGURE_TOTP", + "name": "Configure OTP", + "providerId": "CONFIGURE_TOTP", + "enabled": true, + "defaultAction": false, + "priority": 10, + "config": {} + }, + { + "alias": "terms_and_conditions", + "name": "Terms and Conditions", + "providerId": "terms_and_conditions", + "enabled": false, + "defaultAction": false, + "priority": 20, + "config": {} + }, + { + "alias": "UPDATE_PASSWORD", + "name": "Update Password", + "providerId": "UPDATE_PASSWORD", + "enabled": true, + "defaultAction": false, + "priority": 30, + "config": {} + }, + { + "alias": "UPDATE_PROFILE", + "name": "Update Profile", + "providerId": "UPDATE_PROFILE", + "enabled": true, + "defaultAction": false, + "priority": 40, + "config": {} + }, + { + "alias": "VERIFY_EMAIL", + "name": "Verify Email", + "providerId": "VERIFY_EMAIL", + "enabled": true, + "defaultAction": false, + "priority": 50, + "config": {} + }, + { + "alias": "delete_account", + "name": "Delete Account", + "providerId": "delete_account", + "enabled": false, + "defaultAction": false, + "priority": 60, + "config": {} + }, + { + "alias": "update_user_locale", + "name": "Update User Locale", + "providerId": "update_user_locale", + "enabled": true, + "defaultAction": false, + "priority": 1000, + "config": {} + } + ], + "browserFlow": "browser", + "registrationFlow": "registration", + "directGrantFlow": "direct grant", + "resetCredentialsFlow": "reset credentials", + "clientAuthenticationFlow": "clients", + "dockerAuthenticationFlow": "docker auth", + "attributes": { + "cibaBackchannelTokenDeliveryMode": "poll", + "cibaExpiresIn": "120", + "cibaAuthRequestedUserHint": "login_hint", + "oauth2DeviceCodeLifespan": "600", + "oauth2DevicePollingInterval": "5", + "clientOfflineSessionMaxLifespan": "0", + "clientSessionIdleTimeout": "0", + "parRequestUriLifespan": "60", + "clientSessionMaxLifespan": "0", + "clientOfflineSessionIdleTimeout": "0", + "cibaInterval": "5" + }, + "keycloakVersion": "16.1.0", + "userManagedAccessAllowed": false, + "clientProfiles": { + "profiles": [] + }, + "clientPolicies": { + "policies": [] + } +} \ No newline at end of file diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css new file mode 100644 index 0000000..20005e1 --- /dev/null +++ b/src/main/resources/static/css/style.css @@ -0,0 +1,78 @@ +html { + width: 100%; + height: 100% +} + +body { + background: linear-gradient(white, silver); +} + +[data-bs-theme="dark"] body { + background: linear-gradient(black, #333); +} + +.topright { + position: fixed; + right: 8px; + top: 8px; + margin: 8px; +} + +.middlecenter { + text-align: center; + padding-top: 45vh; +} + +.halfmiddlecenter { + text-align: center; + padding-top: 25vh; +} + +.errorframe { + border: 2px solid red; + border-radius: 4px; + margin-left: 20vh; + margin-right: 20vh; + padding-bottom: 16px; + padding-top: -10vh; +} + +.inputError { + color: white; + background-color: red; + font-weight: bolder; +} + +.linkbtn { + background: transparent; + border: 2px solid transparent; + padding: 8px; +} + +.linkbtn:hover { + background-color: white; + border: 2px solid silver; + border-radius: 4px; +} + +[data-bs-theme="dark"] .linkbtn:hover { + background-color: #333; +} + +.mypanel { + border: 1px solid silver; + border-left: 1px solid gray; + border-top: 1px solid gray; + background-color: #eee; + padding: 8px; + margin: 8px; +} + +[data-bs-theme="dark"] .mypanel { + background-color: #333; +} + +.myheadline { + padding: 8px; + margin: 8px; +} diff --git a/src/main/resources/static/favicon.ico b/src/main/resources/static/favicon.ico new file mode 100644 index 0000000..6424719 Binary files /dev/null and b/src/main/resources/static/favicon.ico differ diff --git a/src/main/resources/static/img/logo.png b/src/main/resources/static/img/logo.png new file mode 100644 index 0000000..55552a4 Binary files /dev/null and b/src/main/resources/static/img/logo.png differ diff --git a/src/main/resources/static/js/bootstrap-input-spinner.js b/src/main/resources/static/js/bootstrap-input-spinner.js new file mode 100644 index 0000000..24d360b --- /dev/null +++ b/src/main/resources/static/js/bootstrap-input-spinner.js @@ -0,0 +1,369 @@ +/** + * Author and copyright: Stefan Haack (https://shaack.com) + * Repository: https://github.com/shaack/bootstrap-input-spinner + * License: MIT, see file 'LICENSE' + */ + +;(function ($) { + "use strict" + + // the default editor for parsing and rendering + var I18nEditor = function (props, element) { + var locale = props.locale || "en-US" + + this.parse = function (customFormat) { + var numberFormat = new Intl.NumberFormat(locale) + var thousandSeparator = numberFormat.format(11111).replace(/1/g, '') || '.' + var decimalSeparator = numberFormat.format(1.1).replace(/1/g, '') + return parseFloat(customFormat + .replace(new RegExp(' ', 'g'), '') + .replace(new RegExp('\\' + thousandSeparator, 'g'), '') + .replace(new RegExp('\\' + decimalSeparator), '.') + ) + } + + this.render = function (number) { + var decimals = parseInt(element.getAttribute("data-decimals")) || 0 + var digitGrouping = !(element.getAttribute("data-digit-grouping") === "false") + var numberFormat = new Intl.NumberFormat(locale, { + minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + useGrouping: digitGrouping + }) + return numberFormat.format(number) + } + } + + var triggerKeyPressed = false + var originalVal = $.fn.val + $.fn.val = function (value) { + if (arguments.length >= 1) { + for (var i = 0; i < this.length; i++) { + if (this[i]["bootstrap-input-spinner"] && this[i].setValue) { + this[i].setValue(value) + } + } + } + return originalVal.apply(this, arguments) + } + + $.fn.inputSpinner = function (methodOrProps) { + + if (methodOrProps === "destroy") { + this.each(function () { + if (this["bootstrap-input-spinner"]) { + this.destroyInputSpinner() + } else { + console.warn("element", this, "is no bootstrap-input-spinner") + } + }) + return this + } + + var props = { + decrementButton: "", // button text + incrementButton: "+", // .. + groupClass: "", // css class of the resulting input-group + buttonsClass: "btn-outline-secondary", + buttonsWidth: "2.5rem", + textAlign: "center", // alignment of the entered number + autoDelay: 500, // ms threshold before auto value change + autoInterval: 50, // speed of auto value change, set to `undefined` to disable auto-change + buttonsOnly: false, // set this `true` to disable the possibility to enter or paste the number via keyboard + keyboardStepping: true, // set this to `false` to disallow the use of the up and down arrow keys to step + locale: navigator.language, // the locale, per default detected automatically from the browser + editor: I18nEditor, // the editor (parsing and rendering of the input) + template: // the template of the input + '
' + + '' + + '' + + '' + + '
' + } + + for (var option in methodOrProps) { + // noinspection JSUnfilteredForInLoop + props[option] = methodOrProps[option] + } + + var html = props.template + .replace(/\${groupClass}/g, props.groupClass) + .replace(/\${buttonsWidth}/g, props.buttonsWidth) + .replace(/\${buttonsClass}/g, props.buttonsClass) + .replace(/\${decrementButton}/g, props.decrementButton) + .replace(/\${incrementButton}/g, props.incrementButton) + .replace(/\${textAlign}/g, props.textAlign) + + this.each(function () { + + if (this["bootstrap-input-spinner"]) { + console.warn("element", this, "is already a bootstrap-input-spinner") + } else { + + var $original = $(this) + $original[0]["bootstrap-input-spinner"] = true + $original.hide() + $original[0].inputSpinnerEditor = new props.editor(props, this) + + var autoDelayHandler = null + var autoIntervalHandler = null + + var $inputGroup = $(html) + var $buttonDecrement = $inputGroup.find(".btn-decrement") + var $buttonIncrement = $inputGroup.find(".btn-increment") + var $input = $inputGroup.find("input") + var $label = $("label[for='" + $original.attr("id") + "']") + if (!$label[0]) { + $label = $original.closest("label") + } + + var min = null + var max = null + var step = null + + updateAttributes() + + var value = parseFloat($original[0].value) + var pointerState = false + + var prefix = $original.attr("data-prefix") || "" + var suffix = $original.attr("data-suffix") || "" + + if (prefix) { + var prefixElement = $('' + prefix + '') + $inputGroup.find("input").before(prefixElement) + } + if (suffix) { + var suffixElement = $('' + suffix + '') + $inputGroup.find("input").after(suffixElement) + } + + $original[0].setValue = function (newValue) { + setValue(newValue) + } + $original[0].destroyInputSpinner = function () { + destroy() + } + + var observer = new MutationObserver(function () { + updateAttributes() + setValue(value, true) + }) + observer.observe($original[0], {attributes: true}) + + $original.after($inputGroup) + + setValue(value) + + $input.on("paste input change focusout", function (event) { + var newValue = $input[0].value + var focusOut = event.type === "focusout" + newValue = $original[0].inputSpinnerEditor.parse(newValue) + setValue(newValue, focusOut) + dispatchEvent($original, event.type) + }).on("keydown", function (event) { + if (props.keyboardStepping) { + if (event.which === 38) { // up arrow pressed + event.preventDefault() + if (!$buttonDecrement.prop("disabled")) { + stepHandling(step) + } + } else if (event.which === 40) { // down arrow pressed + event.preventDefault() + if (!$buttonIncrement.prop("disabled")) { + stepHandling(-step) + } + } + } + }).on("keyup", function (event) { + // up/down arrow released + if (props.keyboardStepping && (event.which === 38 || event.which === 40)) { + event.preventDefault() + resetTimer() + } + }) + + // decrement button + onPointerDown($buttonDecrement[0], function () { + if (!$buttonDecrement.prop("disabled")) { + pointerState = true + stepHandling(-step) + } + }) + // increment button + onPointerDown($buttonIncrement[0], function () { + if (!$buttonIncrement.prop("disabled")) { + pointerState = true + stepHandling(step) + } + }) + onPointerUp(document.body, function () { + if(pointerState === true) { + resetTimer() + dispatchEvent($original, "change") + pointerState = false + } + }) + } + + function setValue(newValue, updateInput) { + if (updateInput === undefined) { + updateInput = true + } + if (isNaN(newValue) || newValue === "") { + $original[0].value = "" + if (updateInput) { + $input[0].value = "" + } + value = NaN + } else { + newValue = parseFloat(newValue) + newValue = Math.min(Math.max(newValue, min), max) + $original[0].value = newValue + if (updateInput) { + $input[0].value = $original[0].inputSpinnerEditor.render(newValue) + } + value = newValue + } + } + + function destroy() { + $original.prop("required", $input.prop("required")) + observer.disconnect() + resetTimer() + $input.off("paste input change focusout") + $inputGroup.remove() + $original.show() + $original[0]["bootstrap-input-spinner"] = undefined + if ($label[0]) { + $label.attr("for", $original.attr("id")) + } + } + + function dispatchEvent($element, type) { + if (type) { + setTimeout(function () { + var event + if (typeof (Event) === 'function') { + event = new Event(type, {bubbles: true}) + } else { // IE + event = document.createEvent('Event') + event.initEvent(type, true, true) + } + $element[0].dispatchEvent(event) + }) + } + } + + function stepHandling(step) { + calcStep(step) + resetTimer() + if(props.autoInterval !== undefined) { + autoDelayHandler = setTimeout(function () { + autoIntervalHandler = setInterval(function () { + calcStep(step) + }, props.autoInterval) + }, props.autoDelay) + } + } + + function calcStep(step) { + if (isNaN(value)) { + value = 0 + } + setValue(Math.round(value / step) * step + step) + dispatchEvent($original, "input") + } + + function resetTimer() { + clearTimeout(autoDelayHandler) + clearTimeout(autoIntervalHandler) + } + + function updateAttributes() { + // copy properties from original to the new input + if ($original.prop("required")) { + $input.prop("required", $original.prop("required")) + $original.removeAttr('required') + } + $input.prop("placeholder", $original.prop("placeholder")) + $input.attr("inputmode", $original.attr("inputmode") || "decimal") + var disabled = $original.prop("disabled") + var readonly = $original.prop("readonly") + $input.prop("disabled", disabled) + $input.prop("readonly", readonly || props.buttonsOnly) + $buttonIncrement.prop("disabled", disabled || readonly) + $buttonDecrement.prop("disabled", disabled || readonly) + if (disabled || readonly) { + resetTimer() + } + var originalClass = $original.prop("class") + var groupClass = "" + // sizing + if (/form-control-sm/g.test(originalClass)) { + groupClass = "input-group-sm" + } else if (/form-control-lg/g.test(originalClass)) { + groupClass = "input-group-lg" + } + var inputClass = originalClass.replace(/form-control(-(sm|lg))?/g, "") + $inputGroup.prop("class", "input-group " + groupClass + " " + props.groupClass) + $input.prop("class", "form-control " + inputClass) + + // update the main attributes + min = isNaN($original.prop("min")) || $original.prop("min") === "" ? -Infinity : parseFloat($original.prop("min")) + max = isNaN($original.prop("max")) || $original.prop("max") === "" ? Infinity : parseFloat($original.prop("max")) + step = parseFloat($original.prop("step")) || 1 + if ($original.attr("hidden")) { + $inputGroup.attr("hidden", $original.attr("hidden")) + } else { + $inputGroup.removeAttr("hidden") + } + if ($original.attr("id")) { + $input.attr("id", $original.attr("id") + "_MP_cBdLN29i2") + if ($label[0]) { + $label.attr("for", $input.attr("id")) + } + } + } + }) + + return this + } + + function onPointerUp(element, callback) { + element.addEventListener("mouseup", function (e) { + callback(e) + }) + element.addEventListener("touchend", function (e) { + callback(e) + }) + element.addEventListener("keyup", function (e) { + if ((e.keyCode === 32 || e.keyCode === 13)) { + triggerKeyPressed = false + callback(e) + } + }) + } + + function onPointerDown(element, callback) { + element.addEventListener("mousedown", function (e) { + if (e.button === 0) { + e.preventDefault() + callback(e) + } + }) + element.addEventListener("touchstart", function (e) { + if (e.cancelable) { + e.preventDefault() + } + callback(e) + }) + element.addEventListener("keydown", function (e) { + if ((e.keyCode === 32 || e.keyCode === 13) && !triggerKeyPressed) { + triggerKeyPressed = true + callback(e) + } + }) + } + +}(jQuery)) diff --git a/src/main/resources/static/js/script.js b/src/main/resources/static/js/script.js new file mode 100644 index 0000000..a2d4477 --- /dev/null +++ b/src/main/resources/static/js/script.js @@ -0,0 +1,4 @@ +toggleDarkmode = function toggleDarkMode() { + var oldTheme = $("html").attr("data-bs-theme"); + $("html").attr("data-bs-theme", oldTheme === "light" ? "dark" : "light"); +} diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..5a2c1ea --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,18 @@ + + + + +Fehler + + + + +
+
+

Es ist ein Fehler aufgetreten.

+ Ach, Mist... +
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/public/index.html b/src/main/resources/templates/public/index.html new file mode 100644 index 0000000..dcdda40 --- /dev/null +++ b/src/main/resources/templates/public/index.html @@ -0,0 +1,15 @@ + + + + +Fuels + + + + +
+
+ einsteigen +
+ + diff --git a/src/main/resources/templates/secure/bean.html b/src/main/resources/templates/secure/bean.html new file mode 100644 index 0000000..165b281 --- /dev/null +++ b/src/main/resources/templates/secure/bean.html @@ -0,0 +1,73 @@ + + + + +Eintrag + + + + + +
+
+

+ Inhalt von Eintrag : +

+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ Abbrechen +
+
+ +
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/secure/table.html b/src/main/resources/templates/secure/table.html new file mode 100644 index 0000000..bbc12e3 --- /dev/null +++ b/src/main/resources/templates/secure/table.html @@ -0,0 +1,70 @@ + + + + +Fuels + + + + + + + + + + +
+

+ Übersicht    neuer Eintrag +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KilometerstandMenge (in l)KraftstoffPreis (in €)AnbieterOrtKaufdatumAnmerkungen€/l 
mileage0.00fuel0.00providerlocationbuydateannotation0.00ändern
+
+
+
+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/secure/welcome.html b/src/main/resources/templates/secure/welcome.html new file mode 100644 index 0000000..848b21f --- /dev/null +++ b/src/main/resources/templates/secure/welcome.html @@ -0,0 +1,51 @@ + + + + + Fuels + + + + + + +
+

als JSON-Format  vollständige Tabelle  neuer Eintrag +

+
+ +
+ +
+ +
+ Zusammenfassung über die gesamte Zeit: +

nicht ermittelbar l/100 km

+

nicht ermittelbar €/l

+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/templatefile.html b/src/main/resources/templates/templatefile.html new file mode 100644 index 0000000..c639f68 --- /dev/null +++ b/src/main/resources/templates/templatefile.html @@ -0,0 +1,27 @@ + + + + + + Layout Title + + + + + + + + + + + +
+
+ [[${#authentication.principal.name}]] abmelden
+ Version
+ Layout header +
+
Layout content
+ + + \ No newline at end of file diff --git a/src/test/java/de/jottyfan/car/CarApplicationTests.java b/src/test/java/de/jottyfan/car/CarApplicationTests.java new file mode 100644 index 0000000..411f214 --- /dev/null +++ b/src/test/java/de/jottyfan/car/CarApplicationTests.java @@ -0,0 +1,13 @@ +package de.jottyfan.car; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CarApplicationTests { + + @Test + void contextLoads() { + } + +}