├── LICENSE ├── README.md ├── backend ├── build-lib │ └── geronimo-servlet_3.0_spec-1.0.jar └── src │ ├── java │ └── com │ │ └── aralink │ │ └── sslsignature │ │ └── sso │ │ └── jwt │ │ ├── AuthenticationOperation.java │ │ ├── HMACKeyContainer.java │ │ ├── JWTManager.java │ │ └── JWTServlet.java │ └── web │ └── WEB-INF │ └── web.xml ├── build ├── build.xml ├── gruntfile.js ├── ivy.xml └── package.json ├── client └── resources │ ├── html │ ├── sso.html │ ├── sso.js │ ├── sso_common.js │ └── sso_rest.js │ └── js │ └── sslssso.js ├── dist └── sso.war └── test ├── java └── com │ └── aralink │ └── sslsignature │ └── sso │ └── jwt │ └── test │ ├── JWTTest.java │ ├── RestClient.java │ └── SimpleConsoleLogger.java └── web ├── hosted ├── img │ ├── android-icon.png │ ├── android2.png │ ├── cert.png │ ├── checkmark.png │ ├── clave.gif │ ├── cryptokeys.png │ ├── favicon.ico │ ├── ios-icon.png │ ├── key-icon.png │ ├── no_entry.png │ ├── pwd.png │ ├── w3c-icon.png │ └── yield.png ├── index.html ├── js │ ├── config.js │ ├── index.js │ ├── jwtcreator.js │ ├── keystore.js │ ├── login.js │ └── register.js ├── jwtcreator.html ├── keystore.html ├── login.html ├── register.html └── sso.html └── standalone ├── index.html └── sso.html /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cross domain Single sign-on with Json Web Tokens (JWT) 2 | > Federate your websites using only javascript 3 | 4 | Access to several web sites with a unique identification. Uses JSON Web Tokens (RFC7519) to represent the information exchanged between the identification provider (IDP) and service provider (SP). The JWT is shared and synchronized among all your websites through the browser local storage without need of server session 5 | 6 | ![alt tag](https://produccion.sslsignature.com/web/images/ssoiframe.png) 7 | 8 | 9 | ## How does it work 10 | You have an excellent introduction to JWT in (https://jwt.io/introduction/) and single sign-on (SSO) on our website (spanish) (https://produccion.sslsignature.com/web/sso.html) 11 | 12 | ## Getting started 13 | > With hosted version (it is free) 14 | 15 | Define on page a `` field to indicate the sslsignature accountId 16 | ``` 17 | 18 | ``` 19 | Include javascript 20 | ``` 21 | 22 | ``` 23 | Create a function to receive the authenticated user 24 | ``` 25 | function onIdentification(operation){ 26 | console.log("eidentifier: "+ operation.eIdentifier); 27 | console.log("name: "+ operation.name); 28 | console.log("jwt: "+ operation.jwt); 29 | } 30 | ``` 31 | Now, we are going to see it in action (download the demo for the third step) 32 | 33 | 1. Create a JWT [here](https://produccion.sslsignature.com/sso/hosted/jwtcreator.html). This would be done in your login form 34 | 2. Open a new tab in your browser with [this URL](https://produccion.sslsignature.com/sso/hosted/sso.html). You will see that you are logged in and the content of the JWT token 35 | 3. Now, here is the magic, download [sso.html](/test/web/hosted/sso.html) and open from your computer, and you will see that you are registered with the same user. Try to logout and see the opened page in second step (do not use IE11 at this moment, please...) 36 | 37 | ##Install 38 | ### Content of the repository 39 | * /backend -->The sample server 40 | * /build -->Build scripts 41 | * /client -->Javascript library for your pages 42 | * /dist -->Precompiled sso.war to deploy javascript, sample server and demos on a container like tomcat 43 | * /test -->Demo pages (hosted and standalone) and a java sample client to issue/validate tokens 44 | 45 | ### Javascript library 46 | Simply copy the library 'sslssso.js' and its dependencies on a web server. 47 | {yourserver.com}/{ssopath}/js/sslssso.js 48 | {yourserver.com}/{ssopath}/html/sso.html 49 | sslssso will access sso.html and related .js, therefore expect to find this structure 50 | 51 | Include a javascript reference in your page to sslssso.js 52 | ``` 53 | 54 | ``` 55 | or use hosted 56 | ``` 57 | 58 | ``` 59 | ### Backend server 60 | The signature key to issue tokens (and validate) must be well protected, usually on the server. You can use a hosted account from SSLSignature (free of charges) or issue tokens from your own server. The project includes a sample server with autogenerated HMAC keys 61 | 62 | ####Use your own server 63 | Yo need to provide a REST service to validate the JWT from the client side. If you plan to do it only on server side, move on to the next section 64 | ``` 65 | POST /{ssoValidationUri} HTTPS 66 | Content-Type=application/x-www-form-urlencoded 67 | Host: yourserver.com 68 | jwt={jwt} 69 | ``` 70 | The answer must have code 200, status = FAILED / SUCCESS, and the JWT parsed fields in JSON format 71 | ``` 72 | { 73 | "status": "SUCCESS", //SUCCESS, FAIL. Mandatory 74 | "sub": "123456", //User unique identifier. Recommended 75 | "eidentifier":"john.smith" //username,Recommended 76 | "name": "John Smith", //User Full Name. Recommended 77 | "other": "value", //More fields (email, phone, etc). Optional 78 | "jwt": "eyJhbGciOiJIUzI..." //JWT new token if necessary. Optional 79 | } 80 | 81 | ``` 82 | 83 | 84 | ####Use the sample server 85 | Take care that it is only an example and it is not intended for a production system 86 | 87 | Deploy sso.war in a J2EE container like tomcat. The first time you run the HMAC signing key will be created in a file called jwt.hmac (configure location in WEB-INF/web.xml) 88 | 89 | The JWT validation service will be available on {yourserver.com}/sso/jwt 90 | The sample server also allow you to issue JWT. Invoke the service providing the fields to be included in JWT 91 | ``` 92 | POST /sso/jwt HTTPS 93 | Content-Type=application/x-www-form-urlencoded 94 | Host: yourserver.com 95 | sub=123456&eidentifier=john.smith&name=John+Smith&phone=34+661661661&email=john.smith%40mycompany.com&other=... 96 | ``` 97 | The response will be the JWT string 98 | ``` 99 | eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTYiLCJpc3MiOiJKV1QgU0FNUExFIElTU1VFUiIsImlhdCI6MTQ2MzU4MTg4MSwiZXhwIjoxNDYzNjY4MjgxLCJwaG9uZSI6IjM0IDY2MTY2MTY2MSIsIm90aGVyIjoiLi4uIiwiZWlkZW50aWZpZXIiOiJqb2huLnNtaXRoIiwiZW1haWwiOiJqb2huLnNtaXRoQG15Y29tcGFueS5jb20iLCJuYW1lIjoiSm9obiBTbWl0aCJ9.eaihxfyO8zWJJm0o97T6p-Cql9oe6n_3SLj0MphGbBA 100 | ``` 101 | Configure expiration or issuer in JWTServlet class. 102 | 103 | ####Use the hosted server 104 | The SSLSignature could issue and validate the JWT for your system. You need an account. After that, the configuration is simple as shown in 'Getting started'. 105 | 106 | After a successful authentication in your system, invoke this service to issue a new token . Provide a JSON with your required fields. 107 | 108 | ``` 109 | POST /sslsignature/account/jwt HTTPS 110 | Authorization=Basic YWNjb3VudElkOmFwaUtleQ== 111 | Content-Type=application/json 112 | Host: produccion.sslsignature.com 113 | { 114 | sub: "yourInternalId", 115 | eidentifier: "yourUserIdentifier", 116 | name: "user name", 117 | other: "other..." 118 | } 119 | ``` 120 | Also is needed an authorization header (basic http auth) in the way `Basic Base64(accountId:apiKey)`. The string 'Basic' followed by the base64 encoding of the provided accountId, ':' and apiKey 121 | 122 | ##Usage 123 | ### Page configuration 124 | 125 | Configure the accountId and custom validation URL in the tags of the page or using javascript. The accountId will reference the identifier that will take the token in the local storage. 126 | ``` 127 | 128 | 129 | 130 | 131 | 132 | //Optional javascript config 133 | var ssls_accountId=myTokenId; 134 | var ssls_validationUrl={yourserver.com}/{ssoValidationUri}; 135 | ``` 136 | 137 | ### SSO Events 138 | The sso generates events for onload, onIdentification and onLogout. Simply create a function on the page with these names. 139 | ``` 140 | // Invoked after page load if you have a valid token or after new JWT correct identification (if page is still loaded) 141 | // If you do not have identification token, this function is not executed 142 | function onIdentification(operation){ 143 | console.log(operation.sub); //Your User internal ID 144 | console.log(operation.eidentifier); //Your user unique identifier (for example the username) 145 | console.log(operation.name); //User full name 146 | console.log("operation.jwt); //The token itself 147 | } 148 | //Invoked when the script finish loading the SSO. It is always after onIdentification 149 | function onLoad(){ 150 | } 151 | //Invoked when user logs out 152 | function onLogout(){ 153 | } 154 | ``` 155 | In you need several event listeners use 156 | ``` 157 | sslssso.listen ("sso.onload", function (observable, eventType, data) {}); 158 | ``` 159 | ### JWT Validation 160 | The token is validated during script execution to check that has been issued by the server and has not been altered. The electronic signature is verified cryptographically on the server. If the token is correct will occur a call to onIdentification. If the validation is unsuccessful, the token is deleted and acts as if there had been token. 161 | 162 | Validation URL is configured with `` (see server instalation). If you do not want the tokens are validated on the client side, set `validate = false` (default is true). Then no server configuration is needed, and `sslssso.js` only will decode jwt token and check expiration on the client side. 163 | 164 | On hosted version, use the provided accountId and do not set the validationUrl 165 | 166 | ### Login 167 | In a standard authentication flow, when an identification is required, the website redirects the user to the IDP (identification provider). The IDP authenticates user with the organization defined method, for example, and username/password form. After successful authentication, the IDP server returns a valid JWT that includes the identification information and the electronic signature. The JWT is stored locally on the browser 168 | ![alt tag](https://produccion.sslsignature.com/web/images/ssoflow.png) 169 | 170 | Calls SSO to store the jwt issued token on localStorage of browser. An `onIdentification` event will be fired on all tabs 171 | ``` 172 | sslssso.login(jwt); 173 | ``` 174 | 175 | 176 | ### Logout 177 | ``` 178 | sslssso.logout(); 179 | ``` 180 | The token will be cleaned and an `onLogout` event will be fired on all tabs 181 | 182 | ##Known issues 183 | ###IE11 & Edge 184 | JWT update events do not syncronize tabs. See [Microsoft doc](https://connect.microsoft.com/IE/feedback/details/812563/ie-11-local-storage-synchronization-issues) 185 | 186 | ## Support 187 | https://soporte.aralink.com 188 | https://github.com/Aralink/ssojwt/issues 189 | -------------------------------------------------------------------------------- /backend/build-lib/geronimo-servlet_3.0_spec-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/backend/build-lib/geronimo-servlet_3.0_spec-1.0.jar -------------------------------------------------------------------------------- /backend/src/java/com/aralink/sslsignature/sso/jwt/AuthenticationOperation.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt; 2 | 3 | import java.io.StringReader; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | 8 | 9 | 10 | import com.fasterxml.jackson.core.type.TypeReference; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | 13 | import io.jsonwebtoken.Claims; 14 | 15 | 16 | 17 | public class AuthenticationOperation { 18 | 19 | private Map params = new HashMap(); 20 | 21 | /** 22 | * FAIL operation 23 | * @param e error produced parsing or validating JWT 24 | */ 25 | public AuthenticationOperation(Exception e){ 26 | params.put("status", "FAIL"); 27 | params.put("error", e.getMessage()); 28 | } 29 | 30 | /** 31 | * Success operation. 32 | * Return all fields parsed 33 | * @param the body of JWT 34 | */ 35 | public AuthenticationOperation(Claims body){ 36 | params.put("status", "SUCCESS"); 37 | 38 | for (String key: body.keySet()){ 39 | Object value = body.get(key); 40 | if (value instanceof String){ 41 | params.put(key, (String)value); 42 | } 43 | } 44 | } 45 | 46 | /** 47 | * JSON Coder. 48 | * Use jackson or your preferred dependendy 49 | * @return 50 | */ 51 | public String toJSON(){ 52 | 53 | StringBuffer buf = new StringBuffer(); 54 | buf.append("{"); 55 | String prefix = ""; 56 | for (String key:params.keySet()){ 57 | buf.append(prefix).append("\"").append(key).append("\":\"").append(params.get(key)).append("\""); 58 | prefix=","; 59 | } 60 | 61 | buf.append("}"); 62 | return buf.toString(); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /backend/src/java/com/aralink/sslsignature/sso/jwt/HMACKeyContainer.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt; 2 | 3 | 4 | import io.jsonwebtoken.impl.crypto.MacProvider; 5 | 6 | import java.io.IOException; 7 | import java.nio.file.Files; 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import java.security.Key; 11 | 12 | import javax.crypto.spec.SecretKeySpec; 13 | 14 | 15 | 16 | public class HMACKeyContainer { 17 | 18 | 19 | private Key key; 20 | 21 | public HMACKeyContainer()throws IOException{ 22 | this(null); 23 | } 24 | public HMACKeyContainer(String keyFile) throws IOException{ 25 | if (keyFile == null || keyFile.length()==0){ 26 | keyFile = "jwthmac.key"; 27 | } 28 | 29 | Path path = Paths.get(keyFile); 30 | if (!path.toFile().exists()){ 31 | //File not exists. Create new File 32 | generateKey(path); 33 | } else { 34 | //Reads the HMAC key from file 35 | byte[] data = Files.readAllBytes(path); 36 | key = hmacKeyFromEncoded(data); 37 | System.out.println("init HMAC key from file: "+path.toAbsolutePath()); 38 | } 39 | 40 | } 41 | public Key getHmacKey(){ 42 | return key; 43 | } 44 | private Key generateKey(Path path) throws IOException{ 45 | //path..createNewFile(); 46 | key = MacProvider.generateKey(JWTManager.DEFAULT_HMAC_KEY_ALGORITHM); 47 | byte data[] = key.getEncoded(); 48 | Files.write(path, data); 49 | System.out.println("created new HMAC key in file: "+path.toAbsolutePath()); 50 | return key; 51 | } 52 | 53 | public static Key hmacKeyFromEncoded(byte encodedHmacKey[]){ 54 | if (encodedHmacKey != null && encodedHmacKey.length>0){ 55 | Key key = new SecretKeySpec(encodedHmacKey,JWTManager.DEFAULT_HMAC_KEY_ALGORITHM.getJcaName()); 56 | return key; 57 | } 58 | return null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /backend/src/java/com/aralink/sslsignature/sso/jwt/JWTManager.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.ExpiredJwtException; 5 | import io.jsonwebtoken.JwtBuilder; 6 | import io.jsonwebtoken.Jwts; 7 | import io.jsonwebtoken.MalformedJwtException; 8 | import io.jsonwebtoken.SignatureAlgorithm; 9 | import io.jsonwebtoken.SignatureException; 10 | import io.jsonwebtoken.UnsupportedJwtException; 11 | 12 | 13 | 14 | import java.security.Key; 15 | import java.util.Calendar; 16 | import java.util.Date; 17 | import java.util.GregorianCalendar; 18 | 19 | 20 | import java.util.Map; 21 | 22 | 23 | 24 | public class JWTManager { 25 | public final static SignatureAlgorithm DEFAULT_HMAC_SIGNATURE_ALGORITHM = SignatureAlgorithm.HS256; 26 | public final static SignatureAlgorithm DEFAULT_HMAC_KEY_ALGORITHM = SignatureAlgorithm.HS512; 27 | 28 | private HMACKeyContainer hmacKeyContainer; 29 | private String issuer = "JWT SAMPLE ISSUER"; 30 | private int expirationTimeInHours = 24; 31 | 32 | public JWTManager(HMACKeyContainer hmacKeyContainer){ 33 | this.hmacKeyContainer = hmacKeyContainer; 34 | } 35 | 36 | public String getIssuer() { 37 | return issuer; 38 | } 39 | 40 | public void setIssuer(String issuer) { 41 | this.issuer = issuer; 42 | } 43 | 44 | public int getExpirationTimeInHours() { 45 | return expirationTimeInHours; 46 | } 47 | 48 | public void setExpirationTimeInHours(int expirationTimeInHours) { 49 | this.expirationTimeInHours = expirationTimeInHours; 50 | } 51 | 52 | 53 | 54 | private Date exp (int calendar,int len){ 55 | GregorianCalendar gc = new GregorianCalendar(); 56 | gc.add(calendar,len); 57 | Date expires = gc.getTime(); 58 | return expires; 59 | } 60 | 61 | private boolean isExpired(Claims body, Date actual){ 62 | return body.getExpiration().before(actual); 63 | } 64 | 65 | 66 | private boolean isExpired(Claims body){ 67 | return isExpired(body,new Date()); 68 | } 69 | 70 | 71 | public String issueJWT(@SuppressWarnings("rawtypes") Map extra){ 72 | 73 | //get hmac signature key 74 | Key key = hmacKeyContainer.getHmacKey(); 75 | 76 | String subject = "none"; 77 | //Get required subject ID 78 | if (extra.get("sub") != null) 79 | subject = ((String[])extra.get("sub"))[0]; 80 | 81 | //Build token 82 | JwtBuilder builder = Jwts.builder() 83 | .setSubject(subject) 84 | .setIssuer(getIssuer()) 85 | .setIssuedAt(new java.util.Date()) 86 | .setExpiration(exp (Calendar.HOUR,getExpirationTimeInHours())); 87 | 88 | 89 | //Body with extra fields 90 | for (Object extKey: extra.keySet()){ 91 | if (!extKey.equals("sub")) 92 | builder.claim((String)extKey,((String[])extra.get(extKey))[0]); 93 | } 94 | 95 | String token = builder.signWith(JWTManager.DEFAULT_HMAC_SIGNATURE_ALGORITHM, key).compact(); 96 | 97 | return token; 98 | } 99 | 100 | 101 | 102 | 103 | public Claims validateJWT ( String jwtToken)throws Exception{ 104 | 105 | //Get signature key 106 | Key key = hmacKeyContainer.getHmacKey(); 107 | 108 | try{ 109 | //Check signature and parse body 110 | Claims body = Jwts.parser().setSigningKey(key).parseClaimsJws(jwtToken).getBody(); 111 | 112 | //Check expiration 113 | if (isExpired(body)) 114 | throw new Exception ( "key expired"); 115 | 116 | return body; 117 | }catch (UnsupportedJwtException e){ 118 | System.err.println("Bad JWT token: "+e.getMessage()); 119 | throw new Exception ( " Bad JWT token"); 120 | }catch (MalformedJwtException e){ 121 | System.err.println("Bad JWT token: "+e.getMessage()); 122 | throw new Exception ( " Bad JWT token"); 123 | }catch (IllegalArgumentException e){ 124 | System.err.println("Bad JWT token: "+e.getMessage()); 125 | throw new Exception ( " Bad JWT token"); 126 | }catch (SignatureException e){ 127 | System.err.println(" BAD PUBLIC KEY"); 128 | throw new Exception ( "Bad signature in JWT token"); 129 | } catch (ExpiredJwtException e){ 130 | System.err.println("Expired JWT token: "+e.getMessage()); 131 | throw new Exception ( "Expired JWT token: "+e.getMessage()); 132 | } 133 | 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /backend/src/java/com/aralink/sslsignature/sso/jwt/JWTServlet.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt; 2 | 3 | import io.jsonwebtoken.Claims; 4 | 5 | import java.io.IOException; 6 | 7 | import javax.servlet.ServletConfig; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | 14 | @SuppressWarnings("serial") 15 | public class JWTServlet extends HttpServlet { 16 | 17 | private HMACKeyContainer hmacKeyContainer; 18 | private JWTManager jwtManager; 19 | 20 | public void init(ServletConfig config) throws ServletException { 21 | super.init(config); 22 | String keyFile = config.getInitParameter("keyFile"); 23 | // String issuer = config.getInitParameter("issuer"); 24 | 25 | try{ 26 | //Init HMAC key from file. If it not exists, creates a new one 27 | hmacKeyContainer = new HMACKeyContainer(keyFile); 28 | jwtManager = new JWTManager (hmacKeyContainer); 29 | 30 | }catch (IOException e){ 31 | throw new ServletException(e); 32 | } 33 | 34 | System.out.println("servlet init: "+keyFile); 35 | } 36 | 37 | public void doOptions(HttpServletRequest request, HttpServletResponse response) 38 | throws ServletException, IOException { 39 | System.out.println("OPTIONS REQUESTS "); 40 | response.addHeader("Access-Control-Allow-Origin", "*"); 41 | } 42 | 43 | public void doGet(HttpServletRequest request, HttpServletResponse response) 44 | throws ServletException, IOException { 45 | doPost(request,response); 46 | } 47 | 48 | public void doPost(HttpServletRequest request, HttpServletResponse response) 49 | throws ServletException, IOException { 50 | 51 | String jwt = request.getParameter("jwt"); 52 | if (jwt != null){ 53 | AuthenticationOperation result = null; 54 | //validateToken 55 | try{ 56 | Claims body = jwtManager.validateJWT(jwt); 57 | //Validation successful 58 | result = new AuthenticationOperation(body); 59 | System.out.println("JWT validation SUCCESS for SUB: "+body.getSubject()); 60 | }catch (Exception e){ 61 | //Validation fail 62 | result = new AuthenticationOperation(e); 63 | System.err.println("JWT validation failed: "+e.getMessage()); 64 | } 65 | 66 | //Response JSON & enable CORS 67 | response.setContentType("application/json"); 68 | response.addHeader("Access-Control-Allow-Origin", "*"); 69 | System.out.println(result.toJSON()); 70 | response.getWriter().print(result.toJSON()); 71 | } else { 72 | 73 | //Issue new token 74 | jwt = jwtManager.issueJWT(request.getParameterMap()); 75 | System.out.println("Issued new JWT "+jwt); 76 | 77 | //Response TEXT & enable CORS 78 | response.setContentType("text/html"); 79 | response.addHeader("Access-Control-Allow-Origin", "*"); 80 | response.getWriter().print(jwt); 81 | } 82 | } 83 | 84 | public void destroy() { 85 | // do nothing. 86 | } 87 | 88 | 89 | } -------------------------------------------------------------------------------- /backend/src/web/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | SSLSIGNATURE {env.SVN_REVISION} 7 | 8 | 300 9 | 10 | 11 | 12 | jwt 13 | com.aralink.sslsignature.sso.jwt.JWTServlet 14 | 15 | keyFile 16 | jwt.hmac 17 | 18 | 19 | 20 | jwt 21 | /jwt 22 | 23 | -------------------------------------------------------------------------------- /build/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /build/gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | // Project configuration. 4 | grunt.initConfig({ 5 | pkg: grunt.file.readJSON('package.json'), 6 | uglify: { 7 | options: { 8 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' 9 | }, 10 | build: { 11 | src: '../client/resources/js/<%= pkg.name %>*.js', 12 | dest: '<%= pkg.name %>.min.js' 13 | } 14 | }, 15 | uglify: { 16 | build: { 17 | src: '../client/resources/html/*.js', 18 | dest: 'sso.min.js' 19 | } 20 | } 21 | }); 22 | 23 | // Load the plugin that provides the "uglify" task. 24 | grunt.loadNpmTasks('grunt-contrib-uglify'); 25 | 26 | // Default task(s). 27 | grunt.registerTask('default', ['uglify']); 28 | 29 | }; -------------------------------------------------------------------------------- /build/ivy.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sslssso", 3 | "version": "1.0.0", 4 | "devDependencies": { 5 | "grunt": "~0.4.5", 6 | "grunt-contrib-jshint": "~0.10.0", 7 | "grunt-contrib-nodeunit": "~0.4.1", 8 | "grunt-contrib-uglify": "~0.5.0" 9 | } 10 | } -------------------------------------------------------------------------------- /client/resources/html/sso.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSLSignature SSO IFRAME 5 | 6 | 7 | 8 | 9 | 31 | 32 | -------------------------------------------------------------------------------- /client/resources/html/sso.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/client/resources/html/sso.js -------------------------------------------------------------------------------- /client/resources/html/sso_common.js: -------------------------------------------------------------------------------- 1 | 2 | var LogLevels = {DEBUG:0, INFO:1, WARN:2, ERROR:3}; 3 | var logLevel = LogLevels.DEBUG; 4 | var console = window.console || { log: function() {} }; 5 | var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}} 6 | 7 | function log(level, object){ 8 | if (level >= logLevel){ 9 | console.log (object); 10 | } 11 | } 12 | 13 | function getOrigin(){ 14 | if (!window.location.origin) { 15 | window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); 16 | } 17 | return window.location.origin; 18 | } 19 | 20 | function getGetParam (vr){ 21 | var src = String( window.location.href ).split('?')[1]; 22 | 23 | if (src != null) { 24 | var vrs = src.split('&'); 25 | 26 | for (var x = 0, c = vrs.length; x < c; x++) { 27 | if (vrs[x].indexOf(vr) == 0){ 28 | return decodeURI( vrs[x].split('=')[1] ); 29 | break; 30 | }; 31 | }; 32 | } else { 33 | return ""; 34 | } 35 | }; 36 | 37 | 38 | function JWT (jwt){ 39 | "use strict"; 40 | this.header = function() { 41 | var headerB64u = jwt.substring(0,jwt.indexOf('.')); 42 | var headerB64 = _b64utob64(headerB64u); 43 | var headerJSON = Base64.decode(headerB64); 44 | var header = JSON.parse( headerJSON ); 45 | return header; 46 | }; 47 | this.payload = function() { 48 | var payloadB64u = jwt.substring(jwt.indexOf('.') + 1, jwt.lastIndexOf('.')); 49 | var payloadB64 = _b64utob64(payloadB64u); 50 | var payloadJSON = Base64.decode(payloadB64); 51 | var payload = JSON.parse( payloadJSON ); 52 | return payload; 53 | }; 54 | 55 | this.isExpired = function(){ 56 | var body = this.payload(); 57 | if (body.exp){ 58 | return body.exp <= Date.now()/1000; 59 | } else { 60 | return true; 61 | } 62 | 63 | }; 64 | 65 | 66 | 67 | function _b64tob64u(a){ 68 | a=a.replace(/\=/g,""); 69 | a=a.replace(/\+/g,"-"); 70 | a=a.replace(/\//g,"_"); 71 | return a; 72 | }; 73 | 74 | function _b64utob64(a){ 75 | if(a.length%4==2){ 76 | a=a+"=="; 77 | }else{ 78 | if(a.length%4==3){ 79 | a=a+"="; 80 | } 81 | } 82 | a=a.replace(/-/g,"+"); 83 | a=a.replace(/_/g,"/"); 84 | return a; 85 | }; 86 | }; 87 | -------------------------------------------------------------------------------- /client/resources/html/sso_rest.js: -------------------------------------------------------------------------------- 1 | 2 | function RestClient (host,accountId,apiKey,scheme){ 3 | "use strict"; 4 | 5 | //this.host = host; 6 | //this.accountId = accountId; 7 | //this.apiKey = apiKey; 8 | scheme = _validateScheme(scheme); 9 | 10 | 11 | 12 | 13 | this.validateJWT = function (jwt,fulfill,reject){ 14 | //var uri = host+'/sso/' + accountId + '/jwt'; 15 | var uri = host; 16 | var request = {'jwt':jwt}; 17 | return _postFormNoJQuery(uri,request,fulfill,reject); 18 | }; 19 | 20 | function _validateScheme(scheme){ 21 | if (!scheme) 22 | scheme = "Basic"; 23 | 24 | if ( !(scheme == 'Basic' || scheme == 'JWT' || scheme == 'CJWT' )) 25 | throw "Scheme " + scheme + "not valid"; 26 | 27 | return scheme; 28 | } 29 | 30 | function _makeAuth(scheme, user, password) { 31 | var tok = user + ':' + password; 32 | var hash; 33 | if (window.btoa){ 34 | hash = btoa(tok); 35 | } else { 36 | hash = Base64.encode(tok); 37 | } 38 | return scheme + " " + hash; 39 | } 40 | 41 | function _get(url,fulfill,reject){ 42 | var contentType = "application/json; charset=utf-8"; 43 | 44 | log(LogLevels.INFO, "GET "+url+ " "+contentType); 45 | 46 | $.support.cors = true; 47 | $.ajax({ 48 | type: "GET", //GET or POST or PUT or DELETE verb 49 | url: url, // Location of the service 50 | crossdomain: true, 51 | contentType: contentType, 52 | accepts: { text: "application/json" }, 53 | dataType: "json", 54 | beforeSend: function (xhr) { 55 | xhr.setRequestHeader("Authorization", _makeAuth(scheme, accountId,apiKey)); 56 | } 57 | }).done(function (response) { 58 | response = _decodeJson(response); 59 | fulfill(response); 60 | }).fail(function (err) { 61 | reject(err); 62 | }); 63 | } 64 | 65 | 66 | 67 | function _post(url, request,fulfill,reject){ 68 | 69 | var contentType = "application/json; charset=utf-8"; 70 | var jsondata = null; 71 | if (request) 72 | jsondata = JSON.stringify(request, null, 4); 73 | 74 | log(LogLevels.INFO, "POST "+url+ " "+contentType); 75 | log(LogLevels.DEBUG, " Request: "+jsondata); 76 | 77 | $.support.cors = true; 78 | $.ajax({ 79 | type: "POST", //GET or POST or PUT or DELETE verb 80 | url: url, // Location of the service 81 | data: jsondata, //Data sent to server 82 | contentType: contentType, 83 | crossdomain: true, 84 | beforeSend: function (xhr) { 85 | xhr.setRequestHeader("Authorization", _makeAuth(scheme, accountId,apiKey)); 86 | } 87 | }).done(function (response) { 88 | 89 | response = _decodeJson(response); 90 | fulfill(response); 91 | }).fail(function (err) { 92 | reject(err); 93 | }); 94 | 95 | 96 | } 97 | 98 | function _postForm(url, request,fulfill,reject){ 99 | //return new Promise(function(fulfill, reject) { 100 | //var contentType = "application/json; charset=utf-8"; 101 | var contentType = "application/x-www-form-urlencoded"; 102 | var jsondata = null; 103 | if (request) 104 | jsondata = JSON.stringify(request, null, 4); 105 | 106 | log(LogLevels.INFO, "POST "+url+ " "+contentType); 107 | log(LogLevels.DEBUG, " Request: "+jsondata); 108 | 109 | $.support.cors = true; 110 | $.ajax({ 111 | type: "POST", //GET or POST or PUT or DELETE verb 112 | url: url, // Location of the service 113 | data: request, //Data sent to server 114 | contentType: contentType, 115 | crossdomain: true, 116 | beforeSend: function (xhr) { 117 | xhr.setRequestHeader("Authorization", _makeAuth(scheme, accountId,apiKey)); 118 | } 119 | }).done(function (response) { 120 | 121 | response = _decodeJson(response); 122 | fulfill(response); 123 | }).fail(function (err) { 124 | reject(err); 125 | }); 126 | //}); 127 | 128 | } 129 | 130 | function _postFormNoJQuery(url, request,fulfill,reject){ 131 | 132 | var contentType = "application/x-www-form-urlencoded"; 133 | var jsondata = null; 134 | if (request) 135 | jsondata = JSON.stringify(request, null, 4); 136 | 137 | log(LogLevels.INFO, "POST "+url+ " "+contentType); 138 | log(LogLevels.DEBUG, " Request: "+jsondata); 139 | 140 | _ajax.post( 141 | url, 142 | request, 143 | function (response) { 144 | 145 | response = _decodeJson(response); 146 | fulfill(response); 147 | }); 148 | } 149 | 150 | function _delete(url,fulfill,reject){ 151 | 152 | var contentType = "application/json; charset=utf-8"; 153 | var jsondata = null; 154 | 155 | log(LogLevels.INFO, "DELETE "+url+ " "+contentType); 156 | 157 | $.support.cors = true; 158 | $.ajax({ 159 | type: "DELETE", //GET or POST or PUT or DELETE verb 160 | url: url, // Location of the service 161 | data: jsondata, //Data sent to server 162 | contentType: contentType, 163 | crossdomain: true, 164 | beforeSend: function (xhr) { 165 | xhr.setRequestHeader("Authorization", _makeAuth(scheme, accountId,apiKey)); 166 | } 167 | }).done(function (response) { 168 | response = _decodeJson(response); 169 | fulfill(response); 170 | }).fail(function (err) { 171 | reject(err); 172 | }); 173 | } 174 | 175 | 176 | function _isAbv(value) { 177 | var ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array)).constructor; 178 | return value instanceof ArrayBufferView; 179 | } 180 | function _isAb(value) { 181 | return value && value instanceof ArrayBuffer && value.byteLength; 182 | } 183 | 184 | function _postStream(url, data,fulfill,reject){ 185 | 186 | var contentType = "application/octet-stream"; 187 | 188 | log(LogLevels.INFO, "POST "+url+ " "+contentType); 189 | log(LogLevels.DEBUG, data); 190 | 191 | if (!_isAbv(data) && !_isAb(data)) 192 | throw "data is not an ArrayBuffer"; 193 | 194 | $.support.cors = true; 195 | $.ajax({ 196 | type: "POST", //GET or POST or PUT or DELETE verb 197 | url: url, // Location of the service 198 | data: data, //Data sent to server 199 | contentType: contentType, 200 | processData: false, 201 | crossdomain: true, 202 | beforeSend: function (xhr) { 203 | xhr.setRequestHeader("Authorization", _makeAuth(scheme, accountId,apiKey)); 204 | } 205 | }).done(function (response) { 206 | response = _decodeJson(response); 207 | fulfill(response); 208 | }).fail(function (err) { 209 | reject(err); 210 | }); 211 | 212 | } 213 | 214 | function _decodeJson(response) { 215 | if (response){ 216 | var jsonresponse = response; 217 | if (typeof response === 'object') 218 | jsonresponse = JSON.stringify(response, null, 4); 219 | log(LogLevels.DEBUG, " Response: "+jsonresponse); 220 | var obj = JSON.parse( jsonresponse ); 221 | return obj; 222 | }else { 223 | log(LogLevels.DEBUG, " Response: NULL"); 224 | return; 225 | } 226 | } 227 | 228 | function _convertMimetype(mimetype){ 229 | if (mimetype == 'gallery/manual') 230 | return 'application/pdf'; 231 | else if (mimetype == 'application/binary') 232 | return 'application/pdf'; 233 | return mimetype; 234 | } 235 | 236 | var _ajax = {}; 237 | _ajax.x = function () { 238 | if (typeof XMLHttpRequest !== 'undefined') { 239 | return new XMLHttpRequest(); 240 | } 241 | var versions = [ 242 | "MSXML2.XmlHttp.6.0", 243 | "MSXML2.XmlHttp.5.0", 244 | "MSXML2.XmlHttp.4.0", 245 | "MSXML2.XmlHttp.3.0", 246 | "MSXML2.XmlHttp.2.0", 247 | "Microsoft.XmlHttp" 248 | ]; 249 | 250 | var xhr; 251 | for (var i = 0; i < versions.length; i++) { 252 | try { 253 | xhr = new ActiveXObject(versions[i]); 254 | break; 255 | } catch (e) { 256 | } 257 | } 258 | return xhr; 259 | }; 260 | 261 | _ajax.send = function (url, callback, method, data, async) { 262 | if (async === undefined) { 263 | async = true; 264 | } 265 | var x = _ajax.x(); 266 | x.open(method, url, async); 267 | x.onreadystatechange = function () { 268 | if (x.readyState == 4) { 269 | callback(x.responseText); 270 | } 271 | }; 272 | if (method == 'POST') { 273 | x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); 274 | } 275 | x.send(data); 276 | }; 277 | 278 | _ajax.get = function (url, data, callback, async) { 279 | var query = []; 280 | for (var key in data) { 281 | query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); 282 | } 283 | _ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, 'GET', null, async); 284 | }; 285 | 286 | _ajax.post = function (url, data, callback, async) { 287 | var query = []; 288 | for (var key in data) { 289 | query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); 290 | } 291 | _ajax.send(url, callback, 'POST', query.join('&'), async); 292 | }; 293 | 294 | 295 | 296 | }; 297 | 298 | 299 | -------------------------------------------------------------------------------- /client/resources/js/sslssso.js: -------------------------------------------------------------------------------- 1 | sslssso = new sslssso(); 2 | var console = window.console || { log: function() {} }; 3 | 4 | function Observable(){ 5 | 6 | this.listen = function(type, method, scope, context) { 7 | var listeners, handlers; 8 | if (!(listeners = this.listeners)) { 9 | listeners = this.listeners = {}; 10 | } 11 | if (!(handlers = listeners[type])){ 12 | handlers = listeners[type] = []; 13 | } 14 | scope = (scope ? scope : window); 15 | handlers.push({ 16 | method: method, 17 | scope: scope, 18 | context: (context ? context : scope) 19 | }); 20 | } 21 | this.fireEvent = function(type, data, context) { 22 | var listeners, handlers, i, n, handler, scope; 23 | if (!(listeners = this.listeners)) { 24 | return; 25 | } 26 | if (!(handlers = listeners[type])){ 27 | return; 28 | } 29 | for (i = 0, n = handlers.length; i < n; i++){ 30 | handler = handlers[i]; 31 | if (typeof(context)!=="undefined" && context !== handler.context) continue; 32 | if (handler.method.call( 33 | handler.scope, this, type, data 34 | )===false) { 35 | return false; 36 | } 37 | } 38 | return true; 39 | } 40 | }; 41 | 42 | function sslssso (){ 43 | //"use strict"; 44 | 45 | 46 | var DEFAULT_IFRAME_URI = "../html/sso.html"; 47 | 48 | var obs = new Observable(); 49 | var config = {}; 50 | /* 51 | obs.listen("sso.onload", function(observable, eventType, data){ 52 | console.log("----------------"); 53 | console.log("sso.onload"); 54 | console.log("----------------"); 55 | }); 56 | */ 57 | this.listen = function(type, method, scope, context){ 58 | obs.listen(type,method,scope,context); 59 | } 60 | 61 | this.logout = function (){ 62 | var message = {action: "logout"}; 63 | postSSOMessage(message, _getUrl()); 64 | } 65 | 66 | this.login = function (jwt){ 67 | var message = {action: "login",jwt:jwt}; 68 | postSSOMessage(message, _getUrl()); 69 | } 70 | 71 | 72 | function _getMeta(name){ 73 | var metas = document.getElementsByTagName('meta'); 74 | 75 | for (var i=0; i jwtInfo = new HashMap(); 54 | jwtInfo.put("sub", "theSub"); 55 | jwtInfo.put("eidentifier", "theEidentifier"); 56 | jwtInfo.put("name", "theName"); 57 | jwtInfo.put("phone", "thePhone"); 58 | jwtInfo.put("other", "theOther"); 59 | 60 | //REquest a new JWT to server 61 | String jwt = client.postForm("/sso/jwt", jwtInfo); 62 | SimpleConsoleLogger.info(jwt); 63 | Assert.assertNotNull(jwt); 64 | 65 | //Validate the token signature 66 | Map jwtValidationInfo = new HashMap(); 67 | jwtValidationInfo.put("jwt", jwt); 68 | String authenticationResponseJson = client.postForm("/sso/jwt", jwtValidationInfo); 69 | SimpleConsoleLogger.info(authenticationResponseJson); 70 | 71 | //JWT token validated on server to Java Object 72 | Map map = new HashMap(); 73 | ObjectMapper mapper = new ObjectMapper(); 74 | map = mapper.readValue(authenticationResponseJson, new TypeReference>(){}); 75 | 76 | SimpleConsoleLogger.info("STATUS: "+map.get("status")+ " eidentifier"+ map.get("eidentifier")); 77 | 78 | Assert.assertEquals("SUCCESS", map.get("status")); 79 | 80 | } 81 | 82 | @Test 83 | public void alteredJWT() throws Exception { 84 | Map jwtInfo = new HashMap(); 85 | jwtInfo.put("sub", "theSub"); 86 | jwtInfo.put("eidentifier", "theEidentifier"); 87 | jwtInfo.put("name", "theName"); 88 | jwtInfo.put("phone", "thePhone"); 89 | jwtInfo.put("other", "theOther"); 90 | 91 | //REquest a new JWT to server 92 | String jwt = client.postForm("/sso/jwt", jwtInfo); 93 | SimpleConsoleLogger.info(jwt); 94 | Assert.assertNotNull(jwt); 95 | 96 | //Signature modified 97 | jwt = jwt + "XXX"; 98 | 99 | //Validate the token signature 100 | Map jwtValidationInfo = new HashMap(); 101 | jwtValidationInfo.put("jwt", jwt); 102 | String authenticationResponseJson = client.postForm("/sso/jwt", jwtValidationInfo); 103 | SimpleConsoleLogger.info(authenticationResponseJson); 104 | 105 | //JWT token validated on server to Java Object 106 | Map map = new HashMap(); 107 | ObjectMapper mapper = new ObjectMapper(); 108 | map = mapper.readValue(authenticationResponseJson, new TypeReference>(){}); 109 | 110 | SimpleConsoleLogger.info("STATUS: "+map.get("status")+ " eidentifier"+ map.get("eidentifier")); 111 | 112 | Assert.assertEquals("FAIL", map.get("status")); 113 | 114 | } 115 | 116 | @Test 117 | public void fakeJWT() throws Exception { 118 | //Create a token with a key autogenerated (not server key) 119 | Key key = MacProvider.generateKey(JWTManager.DEFAULT_HMAC_KEY_ALGORITHM); 120 | String jwt = Jwts.builder() 121 | .setSubject("fake") 122 | .signWith(JWTManager.DEFAULT_HMAC_SIGNATURE_ALGORITHM, key).compact(); 123 | 124 | //Validate token 125 | Map jwtValidationInfo = new HashMap(); 126 | jwtValidationInfo.put("jwt", jwt); 127 | String authenticationResponseJson = client.postForm("/sso/jwt", jwtValidationInfo); 128 | SimpleConsoleLogger.info(authenticationResponseJson); 129 | 130 | 131 | //JWT token validated on server to Java Object 132 | Map map = new HashMap(); 133 | ObjectMapper mapper = new ObjectMapper(); 134 | map = mapper.readValue(authenticationResponseJson, new TypeReference>(){}); 135 | 136 | SimpleConsoleLogger.info("STATUS: "+map.get("status")+ " eidentifier"+ map.get("eidentifier")); 137 | 138 | Assert.assertEquals("FAIL", map.get("status")); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /test/java/com/aralink/sslsignature/sso/jwt/test/RestClient.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt.test; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.io.OutputStream; 8 | import java.net.HttpURLConnection; 9 | import java.net.URL; 10 | import java.util.Map; 11 | 12 | import javax.xml.bind.DatatypeConverter; 13 | 14 | 15 | public class RestClient { 16 | private static final String CONTENT_TYPE_OCTET_STREAM = "application/octet-stream"; 17 | private static final String CONTENT_TYPE_JSON = "application/json"; 18 | private static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; 19 | 20 | private String baseurl; 21 | private String user; 22 | private String password; 23 | 24 | public RestClient (String url){ 25 | setUrl(url); 26 | } 27 | 28 | public RestClient (String url, String user, String password){ 29 | setUrl(url); 30 | setUser(user); 31 | setPassword(password); 32 | } 33 | 34 | 35 | public String getUrl() { 36 | return baseurl; 37 | } 38 | public void setUrl(String url) { 39 | this.baseurl = url; 40 | } 41 | public String getUser() { 42 | return user; 43 | } 44 | public void setUser(String user) { 45 | this.user = user; 46 | } 47 | public String getPassword() { 48 | return password; 49 | } 50 | public void setPassword(String password) { 51 | this.password = password; 52 | } 53 | 54 | 55 | 56 | public String postJson(String uri, String jsonRequest) throws IOException{ 57 | 58 | HttpURLConnection conn = getConnection("POST",uri,CONTENT_TYPE_JSON); 59 | conn.connect(); 60 | SimpleConsoleLogger.debug("request body: "+jsonRequest); 61 | upload(conn,jsonRequest.getBytes()); 62 | 63 | return processJsonResponse(conn); 64 | } 65 | 66 | public String postForm(String uri, Map formParams) throws IOException{ 67 | 68 | HttpURLConnection conn = getConnection("POST",uri,CONTENT_TYPE_FORM); 69 | conn.connect(); 70 | String request = serialize(formParams); 71 | SimpleConsoleLogger.debug("request body: "+formParams); 72 | upload(conn,request.getBytes()); 73 | 74 | return processJsonResponse(conn); 75 | } 76 | 77 | public String post(String uri) throws IOException{ 78 | 79 | HttpURLConnection conn = getConnection("POST",uri,CONTENT_TYPE_JSON); 80 | conn.connect(); 81 | return processJsonResponse(conn); 82 | } 83 | 84 | public String get(String uri) throws IOException{ 85 | 86 | HttpURLConnection conn = getConnection("GET",uri,CONTENT_TYPE_JSON); 87 | conn.setRequestProperty("Accept", CONTENT_TYPE_JSON); 88 | conn.connect(); 89 | return processJsonResponse(conn); 90 | 91 | } 92 | 93 | public InputStream getStream(String uri) throws IOException{ 94 | 95 | HttpURLConnection conn = getConnection("GET",uri,CONTENT_TYPE_JSON); 96 | conn.connect(); 97 | return processStreamResponse(conn); 98 | 99 | } 100 | 101 | public String delete(String uri) throws IOException{ 102 | 103 | HttpURLConnection conn = getConnection("DELETE",uri,CONTENT_TYPE_JSON); 104 | conn.connect(); 105 | return processJsonResponse(conn); 106 | } 107 | 108 | public String postStream(String uri, byte data[])throws IOException{ 109 | 110 | HttpURLConnection conn = getConnection("POST",uri,CONTENT_TYPE_OCTET_STREAM); 111 | conn.connect(); 112 | upload(conn,data); 113 | return processJsonResponse(conn); 114 | } 115 | 116 | private String processJsonResponse(HttpURLConnection conn)throws IOException{ 117 | 118 | int statusCode = conn.getResponseCode(); 119 | SimpleConsoleLogger.info("response code: "+statusCode); 120 | if (statusCode == 200 ||statusCode == 201 ||statusCode == 204) { 121 | //OK 122 | InputStream is = conn.getInputStream(); 123 | String responseString = read(is); 124 | SimpleConsoleLogger.debug("response body: "+responseString); 125 | return responseString; 126 | } else { 127 | InputStream is =conn.getErrorStream(); 128 | String error = read(is); 129 | 130 | throw new IOException(error); 131 | } 132 | } 133 | 134 | private InputStream processStreamResponse(HttpURLConnection conn)throws IOException{ 135 | 136 | //Recibe respuesta 137 | int statusCode = conn.getResponseCode(); 138 | SimpleConsoleLogger.info("response code: "+statusCode); 139 | if (statusCode == 200 ||statusCode == 201) { 140 | InputStream is = conn.getInputStream(); 141 | return is; 142 | } else { 143 | InputStream is =conn.getErrorStream(); 144 | String error = read(is); 145 | 146 | throw new IOException(error); 147 | } 148 | } 149 | 150 | private void upload(HttpURLConnection conn, byte data[]) throws IOException{ 151 | OutputStream os = conn.getOutputStream(); 152 | os.write(data); 153 | os.flush(); 154 | os.close(); 155 | } 156 | 157 | private HttpURLConnection getConnection(String method,String uri, String contentType) throws IOException{ 158 | String URL = baseurl + uri; 159 | SimpleConsoleLogger.info(method+" "+URL); 160 | SimpleConsoleLogger.debug("username:"+user+ " PASSWORD:"+password); 161 | URL url = new URL(URL); 162 | HttpURLConnection conn = (HttpURLConnection)url.openConnection(); 163 | conn.setRequestMethod(method); 164 | if ("POST".equals(method)) 165 | conn.setDoOutput(true); 166 | 167 | if (user != null){ 168 | String basicAuth = "Basic " + DatatypeConverter.printBase64Binary((user+":"+password).getBytes()); 169 | conn.setRequestProperty ("Authorization", basicAuth); 170 | conn.setRequestProperty("Content-Type",contentType); 171 | } 172 | return conn; 173 | 174 | } 175 | 176 | private static String read(InputStream in) throws IOException{ 177 | 178 | InputStreamReader is = new InputStreamReader(in); 179 | StringBuilder sb=new StringBuilder(); 180 | BufferedReader br = new BufferedReader(is); 181 | String read = br.readLine(); 182 | 183 | while(read != null) { 184 | sb.append(read); 185 | read =br.readLine(); 186 | 187 | } 188 | is.close(); 189 | 190 | return sb.toString(); 191 | } 192 | 193 | private static String serialize(Map params){ 194 | StringBuffer buf = new StringBuffer(); 195 | 196 | String prefix = ""; 197 | for (String key:params.keySet()){ 198 | buf.append(prefix).append(key).append("=").append(params.get(key)); 199 | prefix="&"; 200 | } 201 | 202 | return buf.toString(); 203 | } 204 | 205 | 206 | } 207 | -------------------------------------------------------------------------------- /test/java/com/aralink/sslsignature/sso/jwt/test/SimpleConsoleLogger.java: -------------------------------------------------------------------------------- 1 | package com.aralink.sslsignature.sso.jwt.test; 2 | 3 | public class SimpleConsoleLogger { 4 | public enum Level { ERROR, WARN, INFO, DEBUG,TRACE} 5 | /* 6 | public enum Level { 7 | ERROR(0), WARN(1), INFO(2), DEBUG(3),TRACE(4); 8 | private final int id; 9 | Level(int id) { this.id = id; } 10 | public int getValue() { return id; } 11 | }; 12 | */ 13 | private static Level level = Level.INFO; 14 | public static void setLevel (Level l){ 15 | level = l; 16 | } 17 | public static Level getLevel(){ 18 | return level; 19 | } 20 | 21 | public static void info(String message){ 22 | log(Level.INFO,message); 23 | } 24 | public static void error(String message){ 25 | log(Level.ERROR,message); 26 | } 27 | public static void warn(String message){ 28 | log(Level.WARN,message); 29 | } 30 | public static void debug(String message){ 31 | log(Level.DEBUG,message); 32 | } 33 | public static void trace(String message){ 34 | log(Level.TRACE,message); 35 | } 36 | 37 | public static void log(Level level, String message){ 38 | log(level,message,null); 39 | } 40 | public static void log(Level level, String message, Throwable throwable){ 41 | if (level.ordinal() <= getLevel().ordinal()){ 42 | System.out.println(level.name()+ " "+message); 43 | if (throwable != null) 44 | throwable.printStackTrace(); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /test/web/hosted/img/android-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/android-icon.png -------------------------------------------------------------------------------- /test/web/hosted/img/android2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/android2.png -------------------------------------------------------------------------------- /test/web/hosted/img/cert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/cert.png -------------------------------------------------------------------------------- /test/web/hosted/img/checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/checkmark.png -------------------------------------------------------------------------------- /test/web/hosted/img/clave.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/clave.gif -------------------------------------------------------------------------------- /test/web/hosted/img/cryptokeys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/cryptokeys.png -------------------------------------------------------------------------------- /test/web/hosted/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/favicon.ico -------------------------------------------------------------------------------- /test/web/hosted/img/ios-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/ios-icon.png -------------------------------------------------------------------------------- /test/web/hosted/img/key-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/key-icon.png -------------------------------------------------------------------------------- /test/web/hosted/img/no_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/no_entry.png -------------------------------------------------------------------------------- /test/web/hosted/img/pwd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/pwd.png -------------------------------------------------------------------------------- /test/web/hosted/img/w3c-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/w3c-icon.png -------------------------------------------------------------------------------- /test/web/hosted/img/yield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/img/yield.png -------------------------------------------------------------------------------- /test/web/hosted/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SSLSignature - CryptoKeys 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 43 | 44 | 45 | 126 | 127 | 146 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 178 | 179 | -------------------------------------------------------------------------------- /test/web/hosted/js/config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | apiUrl: 'https://produccion.sslsignature.com/sslsignature', 3 | accountId: '5995a3c9-678b-4338-a674-362af68b9ef9', 4 | apiKey: "Qt89SdnW", 5 | tokenType: "Basic", 6 | cryptobankingAppImage: "../images/qr_cb_des.jpg", 7 | cryptobankingAppKey:"AIzaSyASSQmFExB9NNfNzhlsihdI0TQi5m8G6uY", 8 | registerSuccessUrl: 'https://produccion.sslsignature.com/sso/hosted/index.html', 9 | signInSuccessUrl: 'https://produccion.sslsignature.com/sso/hosted/index.html', 10 | signInOptions: ["CERTIFICATE", "CLAVE","CRYPTOKEYS","WEBCRYPTO", "PASSWORD"], 11 | siteTitle: "SSLSignature Sample Login Form", 12 | siteDescription: "Select ID method" 13 | }; 14 | -------------------------------------------------------------------------------- /test/web/hosted/js/index.js: -------------------------------------------------------------------------------- 1 | var uAg = navigator.userAgent.toLowerCase(); 2 | var isMobile = !!uAg.match(/android|iphone|ipad|ipod|blackberry|symbianos/i); 3 | 4 | var keyStore = null; 5 | var ssls = null; 6 | var userId = null; 7 | var userConnected = null; 8 | var keyRequest =null; 9 | var currentKey = null; 10 | var jwt = null; 11 | var otp = null; 12 | 13 | var deviceId = null; 14 | var deviceDescription = null; 15 | var deviceCharacteristics = null; 16 | var identified = false; 17 | 18 | function start(conf){ 19 | config = conf; 20 | ssls = new SSLSignature(config.apiUrl, config.accountId, config.apiKey,config.tokenType); 21 | console.log ("Create sslsignature service agent url:"+config.apiUrl+ " accountId:"+config.accountId+ " "+config.apiKey); 22 | } 23 | 24 | $(document).ready(function(){ 25 | 26 | //Evita que IE11 cachee peticiones 27 | $.ajaxSetup({ cache: false }) 28 | 29 | //$('.modificable').on('change input',initRequest); 30 | //$('#abortButton').hide(); 31 | 32 | $('#showOnlyActive').change(function() { 33 | listDevices(userId); 34 | }); 35 | otp = getGetParam('otp'); 36 | var browserInfo = getBrowserInfo(); 37 | deviceDescription = browserInfo.name+ " "+browserInfo.version+ "("+navigator.platform+")"; 38 | deviceCharacteristics = navigator.userAgent; 39 | /* 40 | new Fingerprint2().get(function(result){ 41 | console.log("deviceId:"+ result); 42 | deviceId = result; 43 | }); 44 | */ 45 | console.log ("deviceDescription: "+deviceDescription); 46 | console.log ("deviceCharacteristics: "+deviceCharacteristics); 47 | }); 48 | 49 | ///////////////////// 50 | //////// SSO METHODS 51 | ///////////////////// 52 | function onIdentification(operation){ 53 | console.log("SSO PAGE onIdentification"); 54 | identificationPerformed({AuthenticationOperation:operation}); 55 | identified = true; 56 | } 57 | function onLoad(){ 58 | console.log("SSO PAGE onLoad"); 59 | if (!identified){ 60 | if (otp){ 61 | recoverFailedIdentification (otp); 62 | } else { 63 | configureForm('notidentified'); 64 | } 65 | } 66 | } 67 | function onLogout(){ 68 | console.log("SSO PAGE onLogout"); 69 | configureForm('notidentified'); 70 | } 71 | 72 | ///////////////////// 73 | //////// 74 | ///////////////////// 75 | 76 | function configureForm(mode){ 77 | if (mode == 'notidentified'){ 78 | $('#notIdentified').show(); 79 | $('#identified').hide(); 80 | $("#logged").hide(); 81 | 82 | }else if (mode == 'identificationFailed'){ 83 | $('#notIdentified').hide(); 84 | $('#identified').show(); 85 | $('#idOk').hide(); 86 | $('#idFailed').show(); 87 | $("#logged").hide(); 88 | 89 | }else if (mode == 'notregistered'){ 90 | $('#notIdentified').hide(); 91 | $('#identified').show(); 92 | $('#idOk').show(); 93 | $('#idFailed').hide(); 94 | $("#logged").hide(); 95 | 96 | } else if (mode =='logged'){ 97 | $('#notIdentified').hide(); 98 | $('#identified').hide(); 99 | $("#logged").show(); 100 | $("#newDevice").show(); 101 | $("#registeredDevice").hide(); 102 | $("#signedTransaction").hide(); 103 | } else if (mode =='registeredDevice'){ 104 | $('#notIdentified').hide(); 105 | $('#identified').hide(); 106 | $("#logged").show(); 107 | $("#newDevice").hide(); 108 | $("#registeredDevice").show(); 109 | $("#signedTransaction").show(); 110 | } 111 | } 112 | 113 | function recoverFailedIdentification(otp){ 114 | console.log("Identification failed. OTP with description = "+otp) 115 | ssls.login(otp).then(function (obj){ 116 | identificationPerformed(obj); 117 | }).catch (function (result){ 118 | console.log(result); 119 | configureForm('notidentified'); 120 | }); 121 | } 122 | 123 | 124 | function identificationPerformed(obj){ 125 | console.log ("Identification performed with status: "+obj.AuthenticationOperation.status); 126 | //Muestra la información de la autenticación, sea correcta o no 127 | if (obj.AuthenticationOperation.status == 'SUCCESS') { 128 | var userId = obj.AuthenticationOperation.userId; 129 | var jwt = obj.AuthenticationOperation.jwt; 130 | if (jwt){ 131 | console.log ("JWT: "+jwt); 132 | } 133 | 134 | infoSignature(obj); 135 | 136 | if (userId){ 137 | console.log ("User registered with userId "+userId); 138 | configureForm('logged'); 139 | 140 | login(userId, jwt,"JWT"); 141 | } else { 142 | console.log ("User identified but not registered") 143 | configureForm('notregistered') 144 | } 145 | 146 | } else { 147 | console.log ("Identification failed: "+obj.AuthenticationOperation.error) 148 | infoSignature(obj); 149 | configureForm('identificationFailed'); 150 | } 151 | 152 | 153 | } 154 | 155 | function infoSignature(obj) { 156 | var status = obj.AuthenticationOperation.status; 157 | var error = ""; 158 | var infoSection =""; 159 | var alertClass = ""; 160 | 161 | if (status == "SUCCESS" || status=="UNKNOWN"){ 162 | image = ""; 163 | status = "ID successful"; 164 | alertClass = "alert alert-success well-sm"; 165 | }else if (status == "FAIL"){ 166 | image = ""; 167 | status = "ID fail "+obj.AuthenticationOperation.error; 168 | alertClass = "alert alert-danger well-sm"; 169 | } 170 | status = status +" ("+obj.AuthenticationOperation.mode+") perfomed at "+obj.AuthenticationOperation.date; 171 | 172 | var nameInfo = "Name: "+obj.AuthenticationOperation.name; 173 | if (obj.AuthenticationOperation.phone){ 174 | nameInfo = nameInfo + " Phone: "+obj.AuthenticationOperation.phone; 175 | } 176 | if (obj.AuthenticationOperation.email){ 177 | nameInfo = nameInfo +" Email: "+obj.AuthenticationOperation.email ; 178 | } 179 | if (obj.AuthenticationOperation.nif){ 180 | idInfo = obj.AuthenticationOperation.nif; 181 | } else if (obj.AuthenticationOperation.eIdentifier){ 182 | idInfo = obj.AuthenticationOperation.eIdentifier; 183 | } else if (obj.AuthenticationOperation.eidentifier){ 184 | idInfo = obj.AuthenticationOperation.eidentifier; 185 | } else { 186 | idInfo = ""; 187 | } 188 | 189 | jwtInfo = "JWT: "+obj.AuthenticationOperation.jwt; 190 | infoSection = 191 | "
    " 192 | +"
  • ID: "+idInfo+"
  • " 193 | +"
  • "+nameInfo+"
  • " 194 | +"
  • "+jwtInfo+"
  • " 195 | +"
"; 196 | 197 | var section = "
" 198 | +"
" 199 | +" "+image+"" 200 | +"
" 201 | +"
" 202 | +"

"+status+"

" 203 | + infoSection 204 | + "
" 205 | + "
"; 206 | 207 | var text = $("
"+section+"
"); 208 | $('#identificationInfo').replaceWith(text); 209 | } 210 | 211 | 212 | 213 | 214 | function login (username,password,scheme){ 215 | 216 | sslsUser = new SSLSignature(config.apiUrl,username,password,scheme); 217 | 218 | sslsUser.getUser().then (function(us){ 219 | 220 | userConnected = us.User; 221 | userId = us.User.id; 222 | $("#pageTitle").html("Welcome to CryptoKeys, "+us.User.name+"!"); 223 | 224 | console.log ("log user: "+userId); 225 | if (scheme != 'JWT'){ 226 | 227 | //Autenticación basic, procedente de registro. Guardar token en SSO 228 | console.log(" Obtain JWT and store in SSO localStorage"); 229 | sslsUser.issueJWT(userId).then(function(jwtResponse){ 230 | jwt = jwtResponse.JWT.data; 231 | console.log("Issued JWT token by server: "+jwt); 232 | //Guardar token en SSO 233 | sslssso.login(jwt); 234 | //Chequear claves 235 | openCryptoKeyStore(); 236 | }).catch (function (err){ 237 | console.log(err); 238 | callFailed(err); 239 | }); 240 | 241 | } else { 242 | //Chequear claves 243 | openCryptoKeyStore(); 244 | } 245 | 246 | return sslsUser.issueJWT(userId); 247 | }).then (function (jwtResponse){ 248 | jwt = jwtResponse.JWT.data; 249 | console.log("Issued JWT token by server: "+jwt); 250 | }).catch (function (err){ 251 | console.log(err); 252 | callFailed(err); 253 | }); 254 | 255 | } 256 | 257 | function openCryptoKeyStore(){ 258 | keyStore = new KeyStore(); 259 | keyStore.open("CBKeyStore").then(function() { 260 | console.log ("KeyStore opened"); 261 | //Buscamos si en el navegador hay una key asociada a la cuenta de usuario 262 | return keyStore.getKey("name",userId); 263 | }).then (function (pkcs12Entry){ 264 | console.log("Key exists. Validate with server signing and example text"); 265 | validateCurrentKeyAndRequestIfNotValid(pkcs12Entry); 266 | 267 | }).catch (function (err){ 268 | console.log(err); 269 | console.log("Key does not exists. Enable button so user can request one"); 270 | configureNewKeyForm(); 271 | //requestAKey(); 272 | }); 273 | } 274 | 275 | 276 | 277 | function keyExists(pkcs12Entry){ 278 | currentKey = pkcs12Entry; 279 | listDevices(userId); 280 | configureForm('registeredDevice'); 281 | window.location="#userAuthentication"; 282 | } 283 | 284 | function requestAKey(){ 285 | configureForm('logged'); 286 | ssls.keyRequest(userConnected.id).then (function (kr){ 287 | console.log ("key requested"); 288 | keyRequest = kr; 289 | 290 | }).catch (function (err){ 291 | console.log(err); 292 | var error = "No se ha podido solicitar una nueva clave privada"; 293 | if (err && err.responseJSON ){ 294 | error = error + ": "+err.responseJSON.error; 295 | } else if (err) { 296 | error = error + ": "+err.status+ "-"+err.statusText; 297 | } 298 | error = error + "\nCon este usuario no va a poder realizar operaciones. ¿Desea borrarlo y volver a registrarse?"; 299 | 300 | if (confirm(error)) { 301 | ssls.deleteUser(userConnected.id).then (function (){ 302 | console.log("User "+userConnected.id+" deleted"); 303 | location.reload(); 304 | }).catch (function (err){ 305 | console.log("Error deleting user"+userConnected.id); 306 | location.reload(); 307 | }); 308 | 309 | } 310 | }); 311 | } 312 | 313 | function keyCreated(pkcs12Entry){ 314 | currentKey = pkcs12Entry; 315 | configureForm('registeredDevice'); 316 | listDevices(userId); 317 | } 318 | 319 | function handleLogoutClick(){ 320 | sslssso.logout(); 321 | } 322 | function handleEnrollClick () { 323 | console.log("proceed to enroll "); 324 | //Genera un par de claves privada y pública 325 | var keys = forge.pki.rsa.generateKeyPair(1024); 326 | 327 | // convierte de Forge public key a formatos PEM y DER para enviar a servidor. Esta parte sobraría con el envío de pkcs10, pero desde aquí es más fácil extraer cosas que en servidor. 328 | var publicKeyPem = forge.pki.publicKeyToPem(keys.publicKey); 329 | var subjectPublicKeyInfo = forge.pki.publicKeyToAsn1(keys.publicKey); 330 | var publicKeyInfoDer = forge.asn1.toDer(subjectPublicKeyInfo).getBytes(); 331 | var publicKeyb64 = forge.util.encode64(publicKeyInfoDer); 332 | 333 | //Crea una solicitud de certificado PKCS10 334 | var csr = createCSR(keys,"ES",userConnected.name,userConnected.id); 335 | //Pasa a PEM format 336 | var csrPem = forge.pki.certificationRequestToPem(csr); 337 | 338 | //Resto de datos del registro de clave. Incluye la clave pública y datos del dispositivo 339 | keyRequest.KeyRequest.csrPem = csrPem; 340 | keyRequest.KeyRequest.deviceId = deviceId; 341 | keyRequest.KeyRequest.deviceDescription = deviceDescription; 342 | keyRequest.KeyRequest.deviceCharacteristics = deviceCharacteristics; 343 | keyRequest.KeyRequest.engine = "WEBCRYPTO"; 344 | keyRequest.KeyRequest.otp = $('#otp').val(); 345 | keyRequest.KeyRequest.publicKey = publicKeyb64; 346 | 347 | 348 | //Envía petición a servidor, ID de operación, OTP respondido y CSR con la clave pública 349 | ssls.keyRegister(keyRequest.KeyRequest.userId,keyRequest.KeyRequest.id,keyRequest).then (function (csrResponse){ 350 | console.log("CSR response from server"); 351 | console.log(csrResponse); 352 | var pkcsEntry = new PKCS12Entry(); 353 | pkcsEntry.fromCsrP7b(keys.privateKey,csrResponse.DeviceKey.certificatep7b); 354 | pkcsEntry.name = userConnected.id; 355 | pkcsEntry.keyId = csrResponse.DeviceKey.id; 356 | pkcsEntry.keyName = userConnected.name; 357 | return keyStore.importCertificate(pkcsEntry,false); 358 | }).then(function(pkcs12Entry) { 359 | console.log ("Imported CSR key, generated local, signed on server: "+pkcs12Entry.name); 360 | keyCreated(pkcs12Entry); 361 | }).catch (function (err){ 362 | console.log(err); 363 | enrollFailed(err); 364 | }); 365 | } 366 | 367 | function enrollFailed(result){ 368 | $('#newDeviceSend').hide(); 369 | $('#newDeviceErrorMessage').text("La identificación no ha sido correcta: "+result.status+"-"+result.responseText); 370 | $('#newDeviceErrorMessage').show(); 371 | $('#newDeviceError').show(); 372 | 373 | } 374 | 375 | function configureNewKeyForm(){ 376 | $('#otp').val(null); 377 | $('#newDeviceSend').hide(); 378 | $('#newDeviceErrorMessage').text(""); 379 | $('#newDeviceErrorMessage').hide(); 380 | $('#resendOtp').text(" Habilitar CryptoKeys "); 381 | $('#newDeviceError').show(); 382 | 383 | //requestAKey(); 384 | } 385 | function configureBadKeyForm(){ 386 | $('#otp').val(null); 387 | $('#newDeviceSend').hide(); 388 | $('#newDeviceErrorMessage').text("La clave existe pero no es válida"); 389 | $('#newDeviceErrorMessage').show(); 390 | $('#resendOtp').text(" Solicitar nueva clave "); 391 | $('#newDeviceError').show(); 392 | 393 | //requestAKey(); 394 | } 395 | 396 | function handleResendClick(){ 397 | $('#otp').val(null); 398 | $('#newDeviceError').hide(); 399 | $('#newDeviceErrorMessage').text(""); 400 | $('#resendOtp').text(" Reintentar "); 401 | $('#newDeviceSend').show(); 402 | requestAKey(); 403 | } 404 | 405 | function handleExecuteSignedTransactionClick(){ 406 | 407 | if (!currentKey){ 408 | showCheckResultMessage("No dispone de clave de firma. Por favor, validese primero.", "alert-warning"); 409 | return; 410 | } 411 | 412 | //La clave privada solo se puede usar con pin? 413 | if (currentKey.pin){ 414 | password_prompt("La clave de identificación requiere PIN para habilitar el uso. Introdúzcalo a continuación","Aceptar",320,300,executeSignedTransactionImpl); 415 | } else { 416 | executeSignedTransactionImpl(); 417 | } 418 | } 419 | function executeSignedTransactionImpl(pin){ 420 | var textToSign = "Authorization request text to sign"; 421 | var message = "1. Signing challenge with a private key
"; 422 | 423 | var st = new SignatureToken(); 424 | st.webcryptosign(textToSign,currentKey,pin).then (function (signature){ 425 | message = message + "2. Sending signature to server
"; 426 | var signatureB64 = forge.util.encode64(arrayBufferToString(signature)); 427 | console.log ("signedData: "+signatureB64); 428 | var dataB64 = forge.util.encode64(textToSign); 429 | var check ={KeyCheck:{data:dataB64,signature:signatureB64}}; 430 | 431 | return ssls.userKeyCheck(userId,check); 432 | }).then (function(){ 433 | message = message +"3. Transaction validated"; 434 | showCheckResultMessage(message, "alert-success"); 435 | }).catch (function (err){ 436 | console.log(err); 437 | message = message + "Signature not validated. Transaction can not be performed" 438 | var motivo = null; 439 | if (err && err.responseJSON) 440 | message = message +": " + err.responseJSON.error; 441 | else if (err) 442 | message = message +": " + err; 443 | showCheckResultMessage( message, "alert-danger"); 444 | }); 445 | } 446 | 447 | function validateCurrentKeyAndRequestIfNotValid(pkcs12Entry){ 448 | //La clave privada solo se puede usar con pin?. En ese caso se da por buena y ya la validaremos con la primera transacción 449 | if (pkcs12Entry.pin) 450 | return true; 451 | 452 | var textToSign = "Validating key"; 453 | var pin = null; 454 | 455 | var st = new SignatureToken(); 456 | st.webcryptosign(textToSign,pkcs12Entry,pin).then (function (signature){ 457 | var signatureB64 = forge.util.encode64(arrayBufferToString(signature)); 458 | var dataB64 = forge.util.encode64(textToSign); 459 | var check ={KeyCheck:{data:dataB64,signature:signatureB64}}; 460 | return ssls.userKeyCheck(userId,check); 461 | }).then (function(){ 462 | console.log("The key is valid"); 463 | keyExists(pkcs12Entry); 464 | }).catch (function (err){ 465 | console.log(err); 466 | console.log("The key is not valid. Deleting key for user: "+userId); 467 | keyStore.deleteKey(null,userId).then (function(){ 468 | console.log("Invalid key deleted"); 469 | currentKey = null; 470 | //requestAKey(); 471 | configureBadKeyForm(); 472 | }); 473 | }); 474 | } 475 | 476 | 477 | 478 | 479 | 480 | 481 | function doDeleteKey(){ 482 | 483 | 484 | keyStore.deleteKey(null,userId).then(function (){ 485 | console.log ("key deleted from keystore for user: "+userId); 486 | 487 | var currentKeyToRevoke = currentKey; 488 | if (currentKeyToRevoke && currentKeyToRevoke.keyId && !currentKeyToRevoke.revoked){ 489 | ssls.keyRevoke(userId,currentKeyToRevoke.keyId).then(function(){ 490 | console.log("Key revoked in server "+currentKeyToRevoke.keyId); 491 | listDevices(userId); 492 | }).catch (function (err){ 493 | console.log (err); 494 | console.log("Error revoking key in server "+currentKeyToRevoke.keyId); 495 | listDevices(userId); 496 | }); 497 | } else{ 498 | listDevices(userId); 499 | } 500 | $("#userId").val(null); 501 | currentKey = null; 502 | 503 | }).catch (function (err){ 504 | console.log(err); 505 | }); 506 | 507 | return 508 | } 509 | 510 | 511 | function showCheckResultMessage(mensaje, alertType){ 512 | if (!alertType){ 513 | alertType = "alert-info" 514 | } 515 | 516 | var text = ""; 517 | $('#checkResultMessage').replaceWith(text); 518 | } 519 | 520 | function callFailed(result) { 521 | console.log(result); 522 | alert('Service call failed: ' + result.status + ' - ' + result.statusText + ' - ' +result.responseText); 523 | //showResponse ('Service call failed: ' + result.status + ' - ' + result.statusText + ' - ' +result.responseText); 524 | } 525 | 526 | 527 | function generateCSR(userConnected,keys){ 528 | var CN = null; 529 | if (userConnected.nif) 530 | CN = userConnected.nif; 531 | else if (userConnected.email) 532 | CN = userConnected.email; 533 | var C = "ES"; 534 | var SERIALNUMBER = userConnected.id; 535 | var extractable = false; 536 | 537 | //generate PKCS10 request 538 | var csr = createCSR(keys,C,CN,SERIALNUMBER); 539 | //Pasa a PEM format 540 | var csrPem = forge.pki.certificationRequestToPem(csr); 541 | 542 | return csrPem; 543 | } 544 | 545 | 546 | function createCSR(keys, C,CN,SERIALNUMBER){ 547 | // create a certification request (CSR) 548 | var csr = forge.pki.createCertificationRequest(); 549 | csr.publicKey = keys.publicKey; 550 | csr.setSubject([{ 551 | name: 'commonName', 552 | value: CN 553 | }, { 554 | name: 'countryName', 555 | value: C 556 | }, { 557 | name: 'serialName', 558 | value: SERIALNUMBER 559 | }]); 560 | // set (optional) attributes 561 | /* 562 | csr.setAttributes([{ 563 | name: 'challengePassword', 564 | value: 'password' 565 | }, { 566 | name: 'unstructuredName', 567 | value: 'SSL certificate, Inc.' 568 | }, { 569 | name: 'extensionRequest', 570 | extensions: [{ 571 | name: 'subjectAltName', 572 | altNames: [{ 573 | // 2 is DNS type 574 | type: 2, 575 | value: 'test.domain.com' 576 | }, { 577 | type: 2, 578 | value: 'other.domain.com', 579 | }, { 580 | type: 2, 581 | value: 'www.domain.net' 582 | }] 583 | }] 584 | }]); 585 | */ 586 | // sign certification request 587 | csr.sign(keys.privateKey); 588 | 589 | // verify certification request 590 | var verified = csr.verify(); 591 | return csr; 592 | } 593 | 594 | 595 | 596 | function listDevices(userId){ 597 | console.log("listing keys"); 598 | ssls.keyList(userId).then(function(list) { 599 | console.log(list.DeviceKey); 600 | $("#theDeviceList > tbody").empty(); 601 | for (var i=0; i" 644 | +" " 645 | + ""; 646 | 647 | if (key.revoked){ 648 | keyActions = ""; 649 | } 650 | 651 | 652 | var tableElement = "" 653 | // + "" 654 | + ""+name+"" 655 | + ""+actual+"" 656 | + ""+keyEngine+"" 657 | + ""+keyStatus+"" 658 | + ""+keyActions+"" 659 | +""; 660 | 661 | if (!showOnlyActive || !key.revoked) 662 | $('#theDeviceList').append(tableElement); 663 | } 664 | 665 | function doRevokeKey(selectedKeyId){ 666 | //var selectedKeyId =$('input:radio[name=key]:checked').val(); 667 | console.log ("Revoking key "+selectedKeyId); 668 | if (selectedKeyId){ 669 | ssls.keyRevoke(userId,selectedKeyId).then(function(){ 670 | listDevices(userId); 671 | }).catch(function(err) { 672 | alert("Could not delete key : " + err); 673 | }); 674 | 675 | } 676 | } 677 | 678 | function handleRegisterDeviceClick(){ 679 | var message = "Click to start mobile linking process"; 680 | if (isMobile ){ 681 | var link = makeRegisterLink(userId); 682 | var section = ""; 686 | $('#checkRegisterMessage').replaceWith(section); 687 | 688 | } else { 689 | var qrLink = config.apiUrl+"/account/"+userId+"/qr?userId="+userId+ "&jwt="+jwt; 690 | $('#qrdevice').attr("src",qrLink); 691 | $('#registerDeviceDialog').modal('show') 692 | } 693 | 694 | } 695 | 696 | function handleRefreshDevicesClick(){ 697 | listDevices(userId); 698 | } 699 | 700 | 701 | function handleExecuteSignedTransactionDoubleFactorClick(){ 702 | var textToSign = "Double factor transaction"; 703 | var request = { Authorization : { userId : userId, appKey: config.cryptobankingAppKey,channel:'PUSH',mode:'DIGITAL_SIGNATURE',message: textToSign }}; 704 | 705 | ssls.postAuthorization(request).then (function(obj){ 706 | authorizationResponse(obj); 707 | initTimer(); 708 | }).catch (function (err){ 709 | callFailed(err); 710 | }); 711 | 712 | } 713 | 714 | function checkCallStatus(){ 715 | ssls.getAuthorization (authorizationId).then (function (obj){ 716 | var status = obj.Authorization.status; 717 | 718 | if (isAuthorizationFinished(status)) 719 | finishAuthorization(obj.Authorization); 720 | }).catch (function (result){ 721 | callFailed(result); 722 | }); 723 | } 724 | 725 | 726 | 727 | function authorizationResponse(obj) { 728 | authorizationId = obj.Authorization.id; 729 | console.log("authorization Id : "+authorizationId); 730 | 731 | $('#abortButton').show(); 732 | $('#sendTransactionDoubleFactor').hide(); 733 | $('#textToSignDoubleFactor').hide(); 734 | 735 | var message = "Requesting authorization to your linked device..."; 736 | if (isMobile ){ 737 | var link = makeAuthorizationLink(obj.Authorization); 738 | var section = ""; 742 | $('#checkResultMessage').replaceWith(section); 743 | } else { 744 | showCheckResultMessage(message); 745 | } 746 | } 747 | 748 | 749 | function handleDownloadAppClick(){ 750 | if (!isMobile){ 751 | $('#qrimage').attr("src",config.cryptobankingAppImage); 752 | $('#downloadAndroidDialog').modal('show') 753 | } else { 754 | window.open(cryptobankingApp) 755 | } 756 | } 757 | 758 | function makeAuthorizationLink(authorization){ 759 | var protocol = "cb"; 760 | var appUrl = "com.aralink.cryptobanking.authorization"; 761 | var p1 = "id="+authorization.id; 762 | //var p2 = "web="+webHost; 763 | var p2 = "web="+config.apiUrl; 764 | var p3 = "data="+authorization.dataToSign; 765 | 766 | var link = protocol + "://" + appUrl+ "?"+p1+"&"+p2+"&"+p3; 767 | console.log(link) 768 | return link; 769 | } 770 | 771 | function makeRegisterLink(userId){ 772 | var protocol = "cb"; 773 | var appUrl = "com.aralink.cryptobanking.register"; 774 | var p1 = "userId="+userId; 775 | var p2 = "web="+config.apiUrl; 776 | var p3 = "jwt="+jwt; 777 | //p2 = "web=https://10.5.3.9:444/sslsignature"; 778 | 779 | var link = protocol + "://" + appUrl+ "?"+p1+"&"+p2+"&"+p3; 780 | console.log(link) 781 | return link; 782 | } 783 | 784 | 785 | function isAuthorizationFinished(status) { 786 | return (status == "CANCEL" || status=="SUCCESS" || status =="FAIL") 787 | } 788 | function finishAuthorization(authorization) { 789 | cancelTimer(); 790 | var mode = authorization.mode; 791 | var status = authorization.status; 792 | console.log ("Authorization status ="+status); 793 | 794 | var image; 795 | var alertType; 796 | if (status == "CANCEL"){ 797 | image = ""; 798 | alertType = "alert-warning"; 799 | }else if (status == "SUCCESS"){ 800 | image = ""; 801 | alertType = "alert-success"; 802 | }else if (status == "FAIL"){ 803 | image = ""; 804 | alertType = "alert-danger"; 805 | }else{ 806 | image = ""; 807 | alertType = "alert-info"; 808 | } 809 | 810 | var section = ""; 114 | return keyElement; 115 | 116 | } 117 | 118 | 119 | function listCryptoKeyStore(){ 120 | cbKeyStore.listKeys().then(function(list) { 121 | $( "#cryptoKeyList" ).empty(); 122 | for (var i=0; i" + 139 | ""+ 143 | ""; 144 | return keyElement; 145 | 146 | } 147 | 148 | function escapeHTML(s) { 149 | return s.toString().replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); 150 | } 151 | 152 | 153 | 154 | function handleDeleteClick(){ 155 | var selectedKeyId = parseInt($('input:radio[name=key]:checked').val()); 156 | console.log ("Deleting key "+selectedKeyId); 157 | if (selectedKeyId){ 158 | keyStore.deleteKey(selectedKeyId).then(function(){ 159 | listKeyStore(); 160 | }).catch(function(err) { 161 | alert("Could not delete key : " + err); 162 | }); 163 | 164 | } 165 | } 166 | function handleDeleteCryptoKeyClick(){ 167 | var selectedKeyId = parseInt($('input:radio[name=cryptokey]:checked').val()); 168 | console.log ("Deleting key "+selectedKeyId); 169 | if (selectedKeyId){ 170 | cbKeyStore.deleteKey(selectedKeyId).then(function(){ 171 | listCryptoKeyStore(); 172 | }).catch(function(err) { 173 | alert("Could not delete key : " + err); 174 | }); 175 | 176 | } 177 | } 178 | 179 | function handleImportPkcs12Click(){ 180 | 181 | var file = document.getElementById('pkcs12File').files[0]; 182 | var password = $("#password").val(); 183 | var extractable = $('#extractable').is(':checked'); 184 | 185 | importPkcs12(file, password,extractable); 186 | } 187 | 188 | function handleExportClick(){ 189 | var selectedKeyId = parseInt($('input:radio[name=key]:checked').val()); 190 | var selectedKeyName; 191 | console.log ("Exporting key "+selectedKeyId); 192 | 193 | 194 | keyStore.getKey("id",selectedKeyId). 195 | then (function (pkcs12Entry){ 196 | selectedKeyName = pkcs12Entry.name; 197 | console.log("exportKey:"+ selectedKeyName); 198 | var password = window.prompt("Insert password for .p12",""); 199 | return keyStore.exportKey (selectedKeyId,password); 200 | }).then(function(p12b64){ 201 | if (isIE()) 202 | downloadAsBlob(p12b64,selectedKeyName); 203 | else { 204 | var downloadLink = 'data:application/x-pkcs12;base64,' + p12b64; 205 | window.location = downloadLink; 206 | } 207 | }).catch (function( err){ 208 | alert("Error exporting key: "+err); 209 | }); 210 | 211 | } 212 | 213 | function downloadAsBlob(p12b64,selectedKeyName){ 214 | var blob = b64toBlob(p12b64,'application/x-pkcs12'); 215 | var name = selectedKeyName+ ".p12"; 216 | if (window.saveAs) { 217 | window.saveAs(blob, name); 218 | } else { 219 | navigator.saveBlob = navigator.saveBlob || navigator.msSaveBlob || navigator.mozSaveBlob || navigator.webkitSaveBlob; 220 | navigator.saveBlob(blob, name); 221 | } 222 | } 223 | 224 | 225 | -------------------------------------------------------------------------------- /test/web/hosted/js/login.js: -------------------------------------------------------------------------------- 1 | 2 | var uAg = navigator.userAgent.toLowerCase(); 3 | var isMobile = !!uAg.match(/android|iphone|ipad|ipod|blackberry|symbianos/i); 4 | 5 | var config; 6 | 7 | var webcrypto = true; 8 | var webcryptoError; 9 | 10 | var keyStore; 11 | var keyStoreList; 12 | 13 | var cbKeyStore; 14 | var cbKeyStoreList; 15 | 16 | 17 | 18 | 19 | 20 | $(function () { 21 | $("[data-toggle='tooltip']").tooltip(); 22 | }); 23 | 24 | function start(conf){ 25 | config = conf; 26 | ssls = new SSLSignature(config.apiUrl, config.accountId, config.apiKey,config.tokenType); 27 | } 28 | 29 | $(document).ready(function(){ 30 | configureForm(); 31 | 32 | if (isWebCryptoEnabled()){ 33 | checkWebCrypto(); 34 | openWebCryptoKeyStore(); 35 | } 36 | if (isCryptoKeysEnabled()){ 37 | checkCryptoKeys(); 38 | openCryptoKeysKeyStore(); 39 | } 40 | }); 41 | 42 | function configureForm(){ 43 | $("#webcryptoOff").hide(); 44 | $("#cryptokeysOff").hide(); 45 | 46 | if (!isCertificateEnabled()){ 47 | $("#idByCert").hide(); 48 | } 49 | if (!isClaveEnabled()){ 50 | $("#idByClave").hide(); 51 | } 52 | if (!isWebCryptoEnabled()){ 53 | $("#webcryptoListOn").hide(); 54 | $("#webcryptoOff").hide(); 55 | } 56 | if (!isCryptoKeysEnabled()){ 57 | $("#cryptokeysListOn").hide(); 58 | $("#cryptokeysOff").hide(); 59 | } 60 | if (!isPasswordEnabled()){ 61 | $("#idByPassword").hide(); 62 | } 63 | 64 | if (config.siteTitle){ 65 | $("#siteTitle").text(config.siteTitle); 66 | } 67 | if (config.siteDescription){ 68 | $("#siteDescription").text(config.siteDescription); 69 | } 70 | } 71 | 72 | function isWebCryptoEnabled(){ 73 | return !(config.signInOptions && config.signInOptions.indexOf("WEBCRYPTO") == -1); 74 | } 75 | function isCryptoKeysEnabled(){ 76 | return !(config.signInOptions && config.signInOptions.indexOf("CRYPTOKEYS") == -1); 77 | } 78 | function isCertificateEnabled(){ 79 | return !(config.signInOptions && config.signInOptions.indexOf("CERTIFICATE") == -1); 80 | } 81 | function isClaveEnabled(){ 82 | return !(config.signInOptions && config.signInOptions.indexOf("CLAVE") == -1); 83 | } 84 | function isPasswordEnabled(){ 85 | return !(config.signInOptions && config.signInOptions.indexOf("PASSWORD") == -1); 86 | } 87 | 88 | function checkWebCrypto(){ 89 | if (!window.crypto || !window.crypto.subtle) { 90 | disableWebCrypto("Web Cryptographi API no soportada!"); 91 | } 92 | 93 | if (!window.indexedDB) { 94 | disableWebCrypto("IndexedDB no soportada!"); 95 | } 96 | } 97 | function checkCryptoKeys(){ 98 | if (!window.crypto || !window.crypto.subtle) { 99 | disableCryptoKeys("Web Cryptographi API no soportada!"); 100 | } 101 | 102 | if (!window.indexedDB) { 103 | disableCryptoKeys("IndexedDB no soportada!"); 104 | } 105 | } 106 | 107 | function disableWebCrypto(message){ 108 | webcrypto = false; 109 | webcryptoError = message; 110 | 111 | $("#webcryptoOff").attr('title', message).tooltip('fixTitle').tooltip('show'); 112 | $("#webcryptoOff").show(); 113 | 114 | $("#webcryptoListOn").hide(); 115 | } 116 | 117 | function disableCryptoKeys(message){ 118 | webcrypto = false; 119 | webcryptoError = message; 120 | 121 | $("#cryptokeysOff").attr('title', message).tooltip('fixTitle').tooltip('show'); 122 | $("#cryptokeysOff").show(); 123 | 124 | $("#cryptokeysOn").hide(); 125 | $("#cryptokeysListOn").hide(); 126 | } 127 | 128 | function enableWebCrypto(list){ 129 | keyStoreList = list; 130 | $('#webcryptoList').empty(); 131 | for (var i=0; i"+name+""); 136 | } 137 | $('#webcryptoListOn').show(); 138 | } 139 | 140 | function enableCryptoKeys(list){ 141 | cbKeyStoreList = list; 142 | if (list.length == 1 ){ 143 | console.log("key "+0+ " id:"+list[0].id + " userId: "+list[0].value.name+ " keyId: "+list[0].value.keyId+ " keyName: "+list[0].value.keyName); 144 | userId = list[0].value.name; 145 | keyName = list[0].value.keyName; 146 | $("#cryptokeysOn").attr("onclick","javascript:loginByCryptoId(\""+userId+"\")"); 147 | $('#cryptokeysOn').show(); 148 | $('#cryptokeysListOn').hide(); 149 | } else { 150 | $('#cryptokeysList').empty(); 151 | for (var i=0; i"+keyName+""); 156 | } 157 | $('#cryptokeysListOn').show(); 158 | $('#cryptokeysOn').hide(); 159 | } 160 | } 161 | 162 | function openWebCryptoKeyStore(){ 163 | if (webcrypto){ 164 | console.log("1. Init WebCrypto KeyStore"); 165 | keyStore = new KeyStore(); 166 | keyStore.open().then(function() { 167 | console.log (" WebCrypto KeyStore opened"); 168 | return keyStore.listKeys(); 169 | }).then(function(list) { 170 | console.log("Existen WebCrypto claves: "+list.length); 171 | if (list.length == 0){ 172 | disableWebCrypto("No hay certificados disponibles"); 173 | } else { 174 | enableWebCrypto(list); 175 | 176 | } 177 | 178 | }).catch(function(err) { 179 | disableWebCrypto("Could not open key store: "+err); 180 | }); 181 | } 182 | } 183 | 184 | 185 | function openCryptoKeysKeyStore(){ 186 | if (webcrypto){ 187 | console.log("2. Init CryptoKeys KeyStore"); 188 | cbKeyStore = new KeyStore(); 189 | cbKeyStore.open("CBKeyStore").then(function() { 190 | console.log (" CryptoKeys KeyStore opened"); 191 | return cbKeyStore.listKeys(); 192 | }).then(function(list) { 193 | console.log("Existen CryptoKeys claves: "+list.length); 194 | if (list.length == 0){ 195 | disableCryptoKeys("No hay claves disponibles"); 196 | } else { 197 | enableCryptoKeys(list); 198 | } 199 | }).catch(function(err) { 200 | disableCryptoKeys("Could not open key store: "+err); 201 | }); 202 | } 203 | } 204 | 205 | 206 | function loginByCert () { 207 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idByCert?p=1' + buildRedirect(); 208 | doRedirect(loginUrl); 209 | } 210 | 211 | function loginByClave () { 212 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idByClave?p=1' + buildRedirect(); 213 | //doRedirect(loginUrl); 214 | window.location.href = loginUrl; 215 | } 216 | 217 | function loginByWebCrypto () { 218 | console.log("loginByWebCrypto"); 219 | console.log(Date.now()); 220 | var textToSign = "Solicitud de autorizacion"; 221 | var pin; 222 | 223 | //Box y Document a firmar. Por defecto XML 224 | 225 | var content = ""; 226 | var filename = "login.xml"; 227 | var name = "login"; 228 | var mimetype = "application/xml"; 229 | var contentB64 = forge.util.encode64( content); 230 | 231 | //TODO: Usar firma b�sica enviando el X509-->Solo una llamada a servidor 232 | // O bien optimizar teniendo el fichero b�sico ya en servidor con un ID--> solo se utiliza 233 | 234 | 235 | var boxRequest = { EvidenceBox: { name: "Login" } }; 236 | ssls.postBox(boxRequest).then (function (box){ 237 | boxId = box.EvidenceBox.id; 238 | console.log("Box creada: "+boxId); 239 | var documentRequest = { Evidence:{name: name,filename: filename, mimetype: mimetype, type: "DOCUMENT", content:contentB64}}; 240 | return ssls.postDocument(boxId, null,documentRequest); 241 | }).then(function (document){ 242 | documentId = document.Evidence.id; 243 | console.log("Documento creado: "+documentId); 244 | var params ={}; 245 | params.showKeystore = function(){window.location = "keystore.html" }; 246 | return keyStore.selectClientCertificate(); 247 | }).then (function (currentKey){ 248 | console.log ("Selected certificate to sign: "+currentKey.name) 249 | var signatureParams = { signatureLevel: 'XAdES_BASELINE_B', signaturePackaging: 'ENVELOPED',digestAlgorithm : 'SHA256'}; 250 | var token = new SignatureToken (ssls); 251 | return token.sign(documentId,currentKey, signatureParams); 252 | }).then(function(signature) { 253 | var signatureId = signature.Evidence.id; 254 | console.log ("signature performed: "+signature.Evidence.id); 255 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idBySignature?signatureId='+signatureId+buildRedirect(); 256 | 257 | doRedirect(loginUrl); 258 | //window.location.href = loginUrl; 259 | }).catch (function (result){ 260 | console.log(result); 261 | showMessage("Error en la identificación: "+result.message); 262 | }); 263 | 264 | } 265 | 266 | function loginByWebCryptoId (keyId) { 267 | console.log("loginByWebCryptoID "+keyId); 268 | var textToSign = "Solicitud de autorizaci�n"; 269 | var pin; 270 | 271 | //Box y Document a firmar. Por defecto XML 272 | 273 | var content = ""; 274 | var filename = "login.xml"; 275 | var name = "login"; 276 | var mimetype = "application/xml"; 277 | var contentB64 = forge.util.encode64( content); 278 | 279 | //TODO: Usar firma b�sica enviando el X509-->Solo una llamada a servidor 280 | // O bien optimizar teniendo el fichero b�sico ya en servidor con un ID--> solo se utiliza 281 | 282 | 283 | var boxRequest = { EvidenceBox: { name: "Login" } }; 284 | ssls.postBox(boxRequest).then (function (box){ 285 | boxId = box.EvidenceBox.id; 286 | console.log("Box creada: "+boxId); 287 | var documentRequest = { Evidence:{name: name,filename: filename, mimetype: mimetype, type: "DOCUMENT", content:contentB64}}; 288 | return ssls.postDocument(boxId, null,documentRequest); 289 | }).then(function (document){ 290 | documentId = document.Evidence.id; 291 | console.log("Documento creado: "+documentId); 292 | return keyStore.getKey("id",keyId); 293 | }).then (function (currentKey){ 294 | console.log ("Selected certificate to sign: "+currentKey.name) 295 | var signatureParams = { signatureLevel: 'XAdES_BASELINE_B', signaturePackaging: 'ENVELOPED',digestAlgorithm : 'SHA256'}; 296 | var token = new SignatureToken (ssls); 297 | return token.sign(documentId,currentKey, signatureParams); 298 | }).then(function(signature) { 299 | var signatureId = signature.Evidence.id; 300 | console.log ("signature performed: "+signature.Evidence.id); 301 | 302 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idBySignature?signatureId='+signatureId+buildRedirect(); 303 | doRedirect(loginUrl); 304 | 305 | //window.location.href = loginUrl; 306 | }).catch (function (result){ 307 | console.log(result); 308 | showMessage("Error en la identificación: "+result.message); 309 | }); 310 | 311 | } 312 | 313 | function loginByCryptoId(userId){ 314 | console.log(userId); 315 | 316 | console.log ("Iniciando cryptoId con userId: "+userId); 317 | cbKeyStore.getKey("name",userId).then (function (currentKey){ 318 | var jwtHeader = {"alg":"RS256"}; 319 | var jwtPayload = {"sub":userId, "exp":(Date.now()/1000 + 60)}; 320 | var pin; 321 | 322 | return JWT.sign(jwtHeader,jwtPayload,currentKey,pin); 323 | }).then (function (token){ 324 | console.log("JWT: "+token); 325 | 326 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idByCryptoKey?userId='+userId+'&jwt='+token+buildRedirect(); 327 | doRedirect(loginUrl); 328 | /* 329 | var sslsUser = new SSLSignature(apiUrl,userId,token,"CJWT"); 330 | 331 | return sslsUser.getUser(); 332 | }).then(function (us){ 333 | var userConnected = us.User; 334 | console.log (userConnected);*/ 335 | }).catch (function (result){ 336 | console.log(result); 337 | showMessage("Error en la identificación: "+result.message); 338 | }); 339 | } 340 | 341 | function loginByUserPwd(){ 342 | var username = $('#username').val(); 343 | var password = $('#password').val(); 344 | 345 | if ( !username){ 346 | alert('Please, insert your user name'); 347 | return; 348 | } 349 | 350 | if ( !password){ 351 | alert('Please, insert your password'); 352 | return; 353 | } 354 | 355 | var sslsUser = new SSLSignature(config.apiUrl,username,password); 356 | 357 | sslsUser.getUser().then (function(us){ 358 | userId = us.User.id; 359 | console.log ("login user: "+userId); 360 | return sslsUser.issueJWT(userId); 361 | }).then (function (jwtResponse){ 362 | jwt = jwtResponse.JWT.data; 363 | console.log("Issued JWT token by server: "+jwt); 364 | 365 | var loginUrl = config.apiUrl + '/sso/'+config.accountId+'/idByJWT?userId='+userId+'&jwt='+jwt+buildRedirect(); 366 | doRedirect(loginUrl); 367 | //window.location.href = loginUrl; 368 | 369 | 370 | }).catch (function (result){ 371 | console.log(result); 372 | showMessage("Error en la identificación "+result.status + ' - ' + result.statusText + ' - ' +result.responseText) 373 | }); 374 | } 375 | 376 | function doRedirect(url){ 377 | 378 | console.log("redirecting to: "+url); 379 | //window.location.href = url; 380 | 381 | var iframe = document.createElement('iframe'); 382 | iframe.style.display = "none"; 383 | iframe.src = url; 384 | iframe.id = 'ssls.login.iframe'; 385 | document.body.appendChild(iframe); 386 | } 387 | 388 | function buildRedirect(){ 389 | if (config && config.signInSuccessUrl){ 390 | return '&redirect.url=' + config.signInSuccessUrl; 391 | } else { 392 | return ''; 393 | } 394 | 395 | 396 | } 397 | 398 | function onIdentification(operation){ 399 | var userId = operation.userId; 400 | if (userId){ 401 | console.log ("[PAGE SSO] User logged with userId "+userId); 402 | } else { 403 | console.log ("[PAGE SSO] User logged but not registered"); 404 | } 405 | console.log("[PAGE] eidentifier: "+ operation.eIdentifier); 406 | console.log("[PAGE] name: "+ operation.name); 407 | console.log("[PAGE] jwt: "+ operation.jwt); 408 | } 409 | function onLoad(){ 410 | console.log ("[PAGE SSO] Loaded"); 411 | } 412 | function onLogout(){ 413 | console.log("[PAGE SSO] logout"); 414 | } 415 | 416 | function showMessage(message){ 417 | alert(message); 418 | } 419 | 420 | -------------------------------------------------------------------------------- /test/web/hosted/js/register.js: -------------------------------------------------------------------------------- 1 |  2 | var config = { 3 | apiUrl: 'https://produccion.sslsignature.com/sslsignature', 4 | accountId: '5995a3c9-678b-4338-a674-362af68b9ef9' 5 | }; 6 | var ssls = null; 7 | 8 | function start(conf){ 9 | config = conf; 10 | ssls = new SSLSignature(config.apiUrl, config.accountId, config.apiKey,config.tokenType); 11 | } 12 | 13 | 14 | 15 | function onIdentification(operation){ 16 | console.log("SSO PAGE onIdentification"); 17 | authenticationPerformed(operation); 18 | } 19 | function onLoad(){ 20 | console.log("SSO PAGE onLoad"); 21 | } 22 | function onLogout(){ 23 | console.log("SSO PAGE onLogout"); 24 | } 25 | 26 | 27 | function showRegisterMessage(message,alertClass){ 28 | if (!alertClass){ 29 | alertClass = "alert alert-info well-sm"; 30 | } 31 | 32 | $('#identifiedUser').show(); 33 | $('#identifiedUser').text(message); 34 | $('#identifiedUser').attr("class",alertClass); 35 | } 36 | 37 | 38 | function handleRegisterUserClick(){ 39 | var username = $('#usernameSignup').val(); 40 | var nif = $('#nifSignup').val(); // Solo cryptokeys 41 | var email = $('#emailSignup').val(); 42 | var phone = $('#phoneSignup').val(); 43 | var password = $('#passwordSignup').val(); 44 | var password2 = $('#passwordSignup2').val(); 45 | 46 | if ( !username){ 47 | showRegisterMessage("Insert username","alert alert-warning well-sm"); 48 | return; 49 | } 50 | if ( !phone){ 51 | showRegisterMessage("Insert a phone number","alert alert-warning well-sm"); 52 | return; 53 | } 54 | if ( !email ){ 55 | showRegisterMessage("Insert an email","alert alert-warning well-sm"); 56 | return; 57 | } 58 | if ( !password){ 59 | showRegisterMessage("Insert password","alert alert-warning well-sm"); 60 | return; 61 | } 62 | if ( password != password2){ 63 | showRegisterMessage("Passwords do not match","alert alert-warning well-sm"); 64 | return; 65 | } 66 | 67 | var userToRegister = {User:{ 68 | phone:phone, 69 | name:username, 70 | email:email, 71 | nif:nif, 72 | password:password 73 | }}; 74 | 75 | proceedToRegister(userToRegister); 76 | } 77 | 78 | function proceedToRegister(userToRegister){ 79 | //Register user on SSLSignature server 80 | ssls.registerUser(userToRegister).then (function(createdUser){ 81 | userId = createdUser.User.id; 82 | console.log ("User created: "+userId); 83 | //Issue JWT Id token for created user 84 | return ssls.issueJWT(userId); 85 | }).then (function (jwtResponse){ 86 | jwt = jwtResponse.JWT.data; 87 | console.log("Issued JWT token by server: "+jwt); 88 | 89 | //Store JWT in browser sSO 90 | sslssso.login(jwt); 91 | alert ("User registered with ID "+userId); 92 | if (config.registerSuccessUrl){ 93 | window.location.href = config.registerSuccessUrl; 94 | } 95 | }).catch (function (err){ 96 | showRegisterError(err); 97 | }); 98 | } 99 | 100 | function showRegisterError(err){ 101 | console.log(err); 102 | var error = "No se ha podido registrar el usuario"; 103 | if (err && err.responseJSON ){ 104 | error = error + ": "+err.responseJSON.error; 105 | } else if (err) { 106 | error = error + ": "+err.status+ "-"+err.statusText; 107 | } 108 | alert (error); 109 | } 110 | 111 | 112 | function authenticationPerformed(operation){ 113 | var userId = operation.userId; 114 | var jwt = operation.jwt; 115 | if (userId){ 116 | console.log ("User registered with userId "+userId); 117 | showRegisterMessage ("User registere"); 118 | } else { 119 | console.log ("User is not registered"); 120 | var name = operation.name; 121 | var email = operation.email; 122 | var nif = operation.eIdentifier; 123 | if (operation.nif){ 124 | nif = operation.nif; 125 | } 126 | console.log ("name: "+name + " nif:"+nif) 127 | $('#usernameSignup').val(name); 128 | $('#nifSignup').val(nif); 129 | $('#emailSignup').val(email); 130 | } 131 | 132 | 133 | } 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /test/web/hosted/jwtcreator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SSLSignature - JWT Creator 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 |

JWT creator

25 |

Set the fields, issue a new token, store in browser 26 |

27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 |
35 | 36 | 37 | 38 |
39 | 40 | 41 |
42 |
43 | 44 | 45 |
46 |
47 | @ 48 | 49 |
50 |
51 | 52 | 53 |
54 |
55 | @ 56 | 57 |
58 |
59 | 60 | 61 |
62 | 63 | 64 | Create JWT token 65 |
66 |
67 | 68 |
69 |
70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 131 | 132 | -------------------------------------------------------------------------------- /test/web/hosted/keystore.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aralink/ssojwt/e47856e5594f38b96bd118f4c2fe50b565e3c41c/test/web/hosted/keystore.html -------------------------------------------------------------------------------- /test/web/hosted/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSO SSLSignature 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |

SSO ID FORM

25 |

Select ID method

26 |
27 |
28 |
29 |
30 | 31 | 32 | 33 | 34 |
35 | 36 | 40 | 42 |
43 | 54 | 55 | 60 | 61 | 62 | 63 | 67 |
68 | 71 | 73 |
74 | 75 | 76 | 81 | 82 | 83 | 84 | 85 |
86 | Register 87 | Manage Key Store 88 |
89 | 90 |
91 |
92 | 93 | 127 | 128 | 129 | 130 | 131 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /test/web/hosted/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SSLSignature - Cryptokeys 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 |
22 |

CryptoKeys Register

23 |
24 |
25 | 26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 | 34 |
35 | 36 | 37 |
38 |
39 | 40 | 41 |
42 |
43 | @ 44 | 45 |
46 |
47 | 48 | 49 |
50 |
51 | 52 | 53 |
54 |
55 | 56 | 57 |
58 | 59 | Register 60 |
61 | ¿Ya registrado? Identify 62 |
63 |
64 | 65 |
66 |
67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | -------------------------------------------------------------------------------- /test/web/hosted/sso.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSLSignature Demo SSO 5 | 6 | 7 | 8 | 9 | 10 | 11 | 31 | 32 | 33 | 34 |
35 |
36 |

SSLSignature SingleSignOn Demo

37 |

Multidomain Single Sign On with Json Web Token (JWT)

38 |
39 |
40 | 41 |
42 |
43 |

Welcome!!

44 |

No identification token (JWT) available

45 | 46 | 47 |
48 | JWT creator 49 | Identify 50 | 51 |
52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /test/web/standalone/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SSLSignature - JWT Creator 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 |

JWT creator

22 |

Set the fields, issue a new token, store in browser 23 |

24 |
25 | 26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | @ 45 | 46 |
47 |
48 | 49 | 50 |
51 |
52 | @ 53 | 54 |
55 |
56 | 57 | 58 |
59 | 60 | 61 | Create JWT token 62 |
63 |
64 | 65 |
66 |
67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 108 | 109 | -------------------------------------------------------------------------------- /test/web/standalone/sso.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SSLSignature Demo SSO 5 | 6 | 7 | 8 | 9 | 10 | 11 | 35 | 36 | 37 | 38 |
39 |
40 |

SSLSignature SingleSignOn Demo

41 |

Multidomain Single Sign On with Json Web Token (JWT)

42 |
43 |
44 | 45 |
46 |
47 |

Welcome!!

48 |

No identification token (JWT) available

49 | 50 | 51 |
52 | Identify 53 | 54 |
55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | --------------------------------------------------------------------------------