index.html 65.2 KB
Newer Older
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557
<!DOCTYPE html>



<html lang="en">
<head>

    


    


<title>
        Seed manual - Web    
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta name="robots" content="noindex,nofollow">



<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,700,300,400" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Bitter:700" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/unify/css/style.css">
<link rel="stylesheet" href="/assets/unify/plugins/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/css/style.css">



<script type="application/ld+json">
{
  "@context" : "http://schema.org",
  "@type" : "SoftwareApplication",
  "name" : "SeedStack",
  "image" : "http://www.seedstack.org/img/logos/seedstack-logo-round.svg",
  "publisher" : {
    "@type" : "Organization",
    "name" : "Open-Source Software"
  },
  "applicationCategory" : "development stack"
}
</script>



<link rel="search" type="application/opensearchdescription+xml" href="http://beta.seedstack.org/opensearch.xml" title="SeedStack" />



<link rel="apple-touch-icon" sizes="57x57" href="/img/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/img/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/img/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/img/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/img/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/img/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/img/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/img/favicons/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/img/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/img/favicons/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="/img/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/img/favicons/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/img/favicons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/img/favicons/manifest.json">
<meta name="apple-mobile-web-app-title" content="SeedStack">
<meta name="application-name" content="SeedStack">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="msapplication-TileImage" content="/img/favicons/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">



<script type="text/javascript">
    window.seedstack = {
        state: {}
    };
</script>


</head>
<body class="homepage">
    
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5R5FP9"
                  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5R5FP9');</script>


    <div id="header">
        <div class="header">
    <div class="container">
        <a class="logo" href="/">SeedStack</a>
        <div class="topbar hidden-xs hidden-sm">
            <ul class="loginbar pull-right">
                <li><i class="fa fa-github"></i> <a target="_blank" href="https://github.com/seedstack">GitHub</a></li>
                <li class="topbar-devider"></li>
                <li><i class="fa fa-keyboard-o"></i> <a style="cursor: pointer;" onclick="seedstack.ui.openHelp();">Shortcuts</a></li>
            </ul>
        </div>
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="fa fa-bars"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse navbar-responsive-collapse" data-role="navigation" style="pointer-events: none;">
        <div class="container">
            <ul class="nav navbar-nav" style="pointer-events: auto;">
                <li>
                    <a href="/getting-started">Getting started</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
                        Documentation
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="/docs/seed">Java framework</a></li>
                        <li><a href="/docs/w20">Web framework</a></li>
                        <li><a href="/docs/business">Business framework</a></li>
                        <li><a href="/guides">Guides</a></li>
                    </ul>
                </li>
                <li>
                    <a href="/addons">Add-ons</a>
                </li>
                <li>
                    <a href="/posts">Blog</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
                        More
                    </a>
                    <ul class="dropdown-menu">
                        <li><a target="_blank" href="https://github.com/seedstack/samples">Samples <i style="margin-top: 3px" class="pull-right fa fa-github"></i></a></li>
                        <li><a href="/project">Project</a></li>
                        <li><a href="/glossary">Glossary</a></li>
                        <li><a href="/tags">Tags</a></li>
                    </ul>
                </li>
                <li>
                    <i class="search fa fa-search search-btn"></i>
                    <div class="search-open">
                        <form method="GET" action="/search">
                            <div class="input-group animated fadeInDown">
                                <input id="search-field" type="text" class="form-control" placeholder="Search" name="q">
                                <span class="input-group-btn">
                                    <button class="btn-u" type="submit">Go</button>
                                </span>
                            </div>
                        </form>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>

<div class="channel-marker beta">
    <div class="container">
        <span><strong>BETA documentation.</strong> <small>You may want go to the <a href="http://seedstack.org">stable documentation</a> instead.</small></span>
    </div>
</div>


        
<div class="title-header small">
    <div class="container">
        <div class="row">
            <div class="col-md-9 col-sm-12">
                <h2>Java framework</h2>
                <p class="hidden-xs">Also known as Seed, the Java framework provides support for a large range of technologies and standards from the Java world.</p>
            </div>
            <div class="col-md-3 hidden-sm hidden-xs">
                <div class="header-image-wrapper">
                    <img class="header-image" src="/img/logos/seed-logo.svg">
                </div>
            </div>
        </div>
    </div>
</div>
<div class="title-subheader">
    <div class="container">
        <ul>
            <li><h3 class=''><i class="fa fa-play-circle"></i> <a href="/docs/seed">Introduction</a></h3></li>
            <li><h3 class='active'><i class="fa fa-book"></i> <a href="/docs/seed/manual">Manual</a></h3></li>
            <li><h3 class=''><i class="fa fa-cogs"></i> <a href="/docs/seed/maven-plugin">Maven plugin</a></h3></li>
            <li><h3><i class="fa fa-info-circle"></i> <a href="/javadoc" target="_blank">Javadoc</a></h3></li>
            <li><h3><i class="fa fa-tag"></i> <a href="https://github.com/seedstack/seed/releases" target="_blank">Releases</a></h3></li>
            <li><h3><i class="fa fa-github"></i> <a href="https://github.com/seedstack/seed" target="_blank">Source</a></h3></li>
        </ul>
    </div>
</div>

    </div>
    <div id="content" class="container">
        <div class="row">
    <div class="col-md-9">
        <div class="content-wrapper">
            <div class="doc-content">
                

<p>Seed has great support for Web applications whether by using its lightweight embedded Web server or in more classical
environments, when using an external Web application server. Seed provides tight integration with the Java Servlet
specification along with support for HTTP security, WebSockets, Cross-Origin Resource Sharing (CORS), or advanced
static-resources serving. To enable Web support in your project, add the <code>seed-web-core</code> module to your classpath.</p>






    
        
            
        
    

<div class="tab-v2">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab-org-seedstack-seed-seed-web-core-maven" data-toggle="tab" aria-expanded="true">Maven</a></li>
        <li class=""><a href="#tab-org-seedstack-seed-seed-web-core-gradle" data-toggle="tab" aria-expanded="true">Gradle</a></li>
    </ul>
    <span class="tabs-icon fa-2x fa fa-cubes pull-right"></span>
    <div class="clear-both"></div>
    <div class="tab-content">
        <div class="tab-pane in active" id="tab-org-seedstack-seed-seed-web-core-maven">
            <pre style="margin-top: 0;"><code class="xml">&lt;dependency&gt;
    &lt;groupId&gt;org.seedstack.seed&lt;/groupId&gt;
    &lt;artifactId&gt;seed-web-core&lt;/artifactId&gt;<span id="org-seedstack-seed-seed-web-core-version" style="display: none;">
    &lt;version&gt;2.2.0&lt;/version&gt;</span>
&lt;/dependency&gt;</code></pre>
            <small class="pull-right" style="color: #aaa; margin-top: -20px; margin-right: 5px;">
                <span id="org-seedstack-seed-seed-web-core-warn" style="display: none;"><i class="fa fa-warning" style="color: orange;"></i> Specifying versions manually is error-prone, use the <a href="/getting-started/distribution">distribution</a> instead.</span>
                <a style="cursor: pointer;" id="org-seedstack-seed-seed-web-core-show" onclick="$('#org-seedstack-seed-seed-web-core-version, #org-seedstack-seed-seed-web-core-warn').show(); $('#org-seedstack-seed-seed-web-core-show').hide();">Show version</a>
            </small>
        </div>
        <div class="tab-pane in" id="tab-org-seedstack-seed-seed-web-core-gradle">
            <pre style="margin-bottom: 0;"><code class="java">dependencies {
    compile("org.seedstack.seed:seed-web-core:2.2.0")
}</code></pre>
        </div>
    </div>
</div>


<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>When deploying a Seed application in a standalone Web container, the required minimum Servlet compliance level is 2.5
though some features require a Servlet 3.0 compliance level. All the features are available with the embedded Web server.</p>

        </div>
    </div>
</div>

<h1 id="security:fbd9d552fff6e255f698507e4f0e8ccc">Security</h1>

<p>When running in a Servlet environment (Web), you might want to secure access to the application URLs by specifying
filtering patterns. To enable this feature, add the <code>seed-web-security</code> module to your project.</p>






    
        
            
        
    

<div class="tab-v2">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab-org-seedstack-seed-seed-web-security-maven" data-toggle="tab" aria-expanded="true">Maven</a></li>
        <li class=""><a href="#tab-org-seedstack-seed-seed-web-security-gradle" data-toggle="tab" aria-expanded="true">Gradle</a></li>
    </ul>
    <span class="tabs-icon fa-2x fa fa-cubes pull-right"></span>
    <div class="clear-both"></div>
    <div class="tab-content">
        <div class="tab-pane in active" id="tab-org-seedstack-seed-seed-web-security-maven">
            <pre style="margin-top: 0;"><code class="xml">&lt;dependency&gt;
    &lt;groupId&gt;org.seedstack.seed&lt;/groupId&gt;
    &lt;artifactId&gt;seed-web-security&lt;/artifactId&gt;<span id="org-seedstack-seed-seed-web-security-version" style="display: none;">
    &lt;version&gt;2.2.0&lt;/version&gt;</span>
&lt;/dependency&gt;</code></pre>
            <small class="pull-right" style="color: #aaa; margin-top: -20px; margin-right: 5px;">
                <span id="org-seedstack-seed-seed-web-security-warn" style="display: none;"><i class="fa fa-warning" style="color: orange;"></i> Specifying versions manually is error-prone, use the <a href="/getting-started/distribution">distribution</a> instead.</span>
                <a style="cursor: pointer;" id="org-seedstack-seed-seed-web-security-show" onclick="$('#org-seedstack-seed-seed-web-security-version, #org-seedstack-seed-seed-web-security-warn').show(); $('#org-seedstack-seed-seed-web-security-show').hide();">Show version</a>
            </small>
        </div>
        <div class="tab-pane in" id="tab-org-seedstack-seed-seed-web-security-gradle">
            <pre style="margin-bottom: 0;"><code class="java">dependencies {
    compile("org.seedstack.seed:seed-web-security:2.2.0")
}</code></pre>
        </div>
    </div>
</div>


<p>This module depends upon the <code>seed-security-core</code> module. A servlet filter is automatically added on <code>/*</code> and, as such,
has the ability to intercept all application URLs. You can then define its interception behavior by specifying a list or
URL patterns with their associated chains of security filters.</p>

<h2 id="url-patterns:fbd9d552fff6e255f698507e4f0e8ccc">URL patterns</h2>

<p>Declaring URL patterns for security interception is done in configuration, by prefixing patterns with
<code>org.seedstack.seed.security.urls</code>. This can be easily done in a Props file by defining a section:</p>

<pre><code>[org.seedstack.seed.security.urls]
/some/path/specific = filter1, filter2
/some/path/** = filter3, filter4, filter5
/other/path/* = filter6
/** = fallbackFilter
</code></pre>

<p>The patterns (at the left of the equal sign) are <a href="https://ant.apache.org/manual/dirtasks.html#patterns">Ant-style path expressions</a>
relative to your Web application&rsquo;s context root. The order matters as the first pattern to match the incoming request is
applied and subsequent patterns are ignored. This allows to define a catch-all default pattern at the end that will apply
if no above filters matched. When a pattern is matched, the filters (at the right of the equal sign) are applied in sequence.</p>

<h2 id="filters:fbd9d552fff6e255f698507e4f0e8ccc">Filters</h2>

<p>Filters can be used for various task such as:</p>

<ul>
<li>Authentication (form, basic),</li>
<li>Authorization (verify some permission, role),</li>
<li>Other security checks or tasks.</li>
</ul>

<p>You can directly use built-in filters or define custom ones.</p>

<h3 id="built-in-filters:fbd9d552fff6e255f698507e4f0e8ccc">Built-in filters</h3>

<p>Various built-in filters are directly available by specifying their names (and eventual parameters) in the filter chain:</p>

<ul>
<li><code>anon</code>: immediately allows access to the path without performing security checks of any kind (unless you add other
filters after it in the chain).</li>
<li><code>authc</code>: authentifies the subject using the request params (<code>username</code> and <code>password</code>). This can be used for form
authentication.</li>
<li><code>authcBasic</code>: triggers and checks a Basic authentication.</li>
<li><code>cert</code>: extracts the certificates found by the JEE server and provides them to a <code>X509CertificateRealm</code>. You can specify
the <code>optional</code> parameter to allow the request even if certificate authentication fails: <code>cert[optional]</code>.</li>
<li><code>logout</code>: logouts the current Subject. Note that it will clear the subject session and will invalidate the corresponding
security caches. Note that basic authentication credentials are kept by user-agents (like browsers), meaning that
authentication will automatically happen again during the next request.</li>
<li><code>noSessionCreation</code>: will prevent the creation of a security session.</li>
<li><code>perms</code>: checks for the permission specified as a parameter. Only allows access if the current subject has the
specified permission. Multiple permissions can be specified with commas: <code>perms[users:delete, cache:invalidate]</code> for
instance.</li>
<li><code>port</code>: requires the request to be on the specified port: <code>port[8080]</code> for instance.</li>
<li><code>rest</code>: similar to the <code>perms</code> filter but appends a CRUD verb derived from the HTTP method to the specified permission(s).
For instance, <code>rest[users]</code> will check the following permissions depending on the HTTP verb:

<ul>
<li>DELETE checks for the <code>users:delete</code> permission,</li>
<li>GET checks for the <code>users:read</code> permission,</li>
<li>HEAD checks for the <code>users:read</code> permission,</li>
<li>OPTIONS checks for the <code>users:read</code> permission,</li>
<li>POST checks for the <code>users:create</code> permission,</li>
<li>PUT checks for the <code>users:update</code> permission,</li>
<li>TRACE checks for the <code>users:read</code> permission.</li>
</ul></li>
<li><code>roles</code>: checks that the subject has the specified role(s). Only allows access if current subject has <strong>all</strong> the
specified roles. Multiple roles can be specified with commas: <code>roles[manager, admin]</code> for instance.</li>
<li><code>ssl</code>: Only allows access if the request is on port 443 and <code>ServletRequest.isSecure()</code> returns true.</li>
<li><code>user</code>: Only allows access if the user is identified.</li>
</ul>

<h3 id="custom-filters:fbd9d552fff6e255f698507e4f0e8ccc">Custom filters</h3>

<p>You can define you own custom security filters by creating a class implementing <code><span data-toggle="tooltip" data-html="true" title='javax.&amp;#8203;servlet.&amp;#8203;Filter'>Filter</span></code> and
annotating it with <code><a data-toggle="tooltip" data-html="true" title='org.&amp;#8203;seedstack.&amp;#8203;seed.&amp;#8203;web.&amp;#8203;security.&amp;#8203;SecurityFilter' href='http://seedstack.org/javadoc/org/seedstack/seed/web/security/SecurityFilter.html'>@SecurityFilter</a></code>. The annotation value will define
the name of the filter that can be used in filter chains.</p>

<p>As an example, consider a filter that always returns HTTP response code 418:</p>

<pre><code>@SecurityFilter(&quot;teapot&quot;)
public class TeapotFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, 
                         ServletResponse response, 
                         FilterChain chain) throws IOException, ServletException {
        ((HttpServletResponse)response).sendError(418);
    }

    @Override
    public void destroy() {
    }

}
</code></pre>

<p>You can use it in filter chains like this:</p>

<pre><code class="language-ini">[org.seedstack.seed.security.urls]
/teapot = teapot
</code></pre>

<p>When a subject access the <code>/teapot</code> URL, an HTTP response code 418 will be returned. To create advanced security filters,
you can extend existing Shiro security filters, or use them as models.</p>

<h2 id="example:fbd9d552fff6e255f698507e4f0e8ccc">Example</h2>

<p>Consider the following example:</p>

<pre><code class="language-ini">[org.seedstack.seed.security.urls]
/resources/** = anon
/rest/users = ssl, authcBasic, rest[users]
/rest/** = authcBasic, roles[normal]
/** = authcBasic
</code></pre>

<p>Note that:</p>

<ul>
<li>Anything served under <code>/resource/**</code> can be accessed anonymously.</li>
<li>The <code>/rest/users</code> resource can only be accessed by authenticated subjects in HTTPS with the <code>users:action</code> permission,
where action is dependent upon the HTTP method used (see the <code>rest</code> filter definition for details).</li>
<li>Anything served under <code>/rest/**</code> can only be accessed by authenticated subjects with the <code>normal</code> application-role.</li>
<li>All others URLs can only be accessed by authenticated subjects.</li>
<li>In this example, authentication is handled with the Basic Authentication scheme.</li>
</ul>

<h1 id="servlets-and-filters:fbd9d552fff6e255f698507e4f0e8ccc">Servlets and Filters</h1>

<p>You can register a servlet and its mappings automatically by annotating your servlet class with <code><a data-toggle="tooltip" data-html="true" title='org.&amp;#8203;seedstack.&amp;#8203;seed.&amp;#8203;web.&amp;#8203;WebServlet' href='http://seedstack.org/javadoc/org/seedstack/seed/web/WebServlet.html'>WebServlet</a></code>:</p>

<pre><code>@WebServlet(
    value = &quot;/myservlet/*&quot;, 
    initParams = { @WebInitParam(name = &quot;param&quot;, value = &quot;value&quot;) }, 
    name = &quot;my-servlet&quot;)
public class MyServlet extends HttpServlet {
    ...
}
</code></pre>

<p>Similarly, you can register a filter and its mappings automatically by annotating your servlet class with <code><a data-toggle="tooltip" data-html="true" title='org.&amp;#8203;seedstack.&amp;#8203;seed.&amp;#8203;web.&amp;#8203;WebFilter' href='http://seedstack.org/javadoc/org/seedstack/seed/web/WebFilter.html'>WebFilter</a></code>:</p>

<pre><code>@WebFilter(
    value = &quot;/myfilter/*&quot;, 
    initParams = { @WebInitParam(name = &quot;param&quot;, value = &quot;value&quot;) }, 
    name = &quot;my-filter&quot;)
public class MyFilter extends HttpFilter {
    ...
}
</code></pre>

<h1 id="static-resources:fbd9d552fff6e255f698507e4f0e8ccc">Static resources</h1>

<p>Seed provides automatic static resource serving from the classpath and the document root with some benefits over the container
default resource serving:</p>

<ul>
<li>Automatic serving of pre-minified and/or pre-gzipped versions of resources,</li>
<li>On-the-fly gzipping of resources,</li>
<li>Cache friendly,</li>
<li>Emulation of servlet 3.0 serving from classpath when not available.</li>
</ul>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Static resource serving is enabled by default. It has a low priority
Docroot resources always have precedence over classpath resources. If a file under document root leads to the same resulting
path as in classpath, then the document root file have priority (like robots.txt in above example).</p>

        </div>
    </div>
</div>

<h2 id="default-behavior:fbd9d552fff6e255f698507e4f0e8ccc">Default behavior</h2>

<p>The default behavior is to serve resources located under the document root folder and, if not found, under the
<code>META-INF/resources</code> classpath location on the <code>/*</code> path. For example, consider the following folder tree:</p>

<pre><code>docroot/
    index.html
    robots.txt

META-INF/
    resources/
        robots.txt
        lib/
            jquery.js
            jquery.min.js
            jquery.min.js.gz
</code></pre>

<p>The default behavior is to serve index.html, robots.txt and jquery.js on the following paths:</p>

<pre><code>/robots.txt
/index.html
/lib/jquery.js
</code></pre>

<p>The jquery.js file will be served as a minified and gzipped version (without the overhead of on-the-fly gzipping since
a pre-gzipped version is already available).</p>

<div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Docroot resources always have precedence over classpath resources. If a file under document root leads to the same resulting
path as in classpath, then the document root file have priority (like robots.txt in above example).</p>

        </div>
    </div>
</div>

<h2 id="configuration:fbd9d552fff6e255f698507e4f0e8ccc">Configuration</h2>

<p>Resources are always served on <code>/*</code> with a low priority</p>

<p>The default serving path can be altered. For example:</p>

<pre><code>org.seedstack.seed.web.resources.path = /my-custom-resource-path
</code></pre>

<p>The serving paths then are updated by appending <code>/my-custom-resource-path</code> to the document root base path and the
<code>META-INF/resources</code> classpath location thus serving from respective following paths:</p>

<ul>
<li><code>docroot/my-custom-resource-path</code> for document root based resources</li>
<li><code>META-INF/resources/my-custom-resource-path</code> for classpath based resources</li>
</ul>

<p>Note that specifying an empty resource path would mean that resources are served directly under the application context root.
In that case the webapp must be dedicated to serving web resources since it will not be able to register additional
servlets (<code>/*</code> will be reserved for web resources).</p>

<h2 id="minification-and-gzip-support:fbd9d552fff6e255f698507e4f0e8ccc">Minification and gzip support</h2>

<p>The file extension is determined from the requested URL as the characters&rsquo; sequence after the last dot <code>.</code> of the
hierarchical part. For instance <code>js</code> extension would be retrieved from:</p>

<pre><code class="language-plain">http://myapplication/resources/lib/jquery.js
</code></pre>

<p>If minification support is enabled and a file with a <code>min.</code> prefixed extension is found, then it is used instead of the
originally requested file In below example, the last file would be served:</p>

<pre><code class="language-plain">/resources/lib/jquery.js
/resources/lib/jquery.min.js
</code></pre>

<p>If gzip support is enabled and the browser accepts gzip encoding and a file with a <code>.gzip</code> suffixed extension is found,
then it is used instead of the originally requested file (or instead of the minified file determined in the previous step):</p>

<p>For instance, in below example, the last file would be served:</p>

<pre><code class="language-plain">/resources/lib/jquery.js
/resources/lib/jquery.min.js
/resources/lib/jquery.js.gzip
</code></pre>

<p>If no gzipped version has been found but on-the-fly gzip support is enabled, the resource will be gzipped in-memory for
serving. To control the minification and gzip behavior, use the following properties:</p>

<pre><code>org.seedstack.seed.web.resources.minification-support = true | false
org.seedstack.seed.web.resources.gzip-support = true | false
org.seedstack.seed.web.resources.gzip-on-the-fly = true | false
</code></pre>

<h2 id="mime-types:fbd9d552fff6e255f698507e4f0e8ccc">MIME types</h2>

<p>The following MIME types are automatically derived from extensions:</p>

<table class="table table-striped">
<tr><th>Mime type</th><th>Extensions</th></tr>
<tr><td>text/html</td><td>html htm HTML HTM</td></tr>
<tr><td>text/plain</td><td>txt text TXT TEXT</td></tr>
<tr><td>text/javascript</td><td>js JS</td></tr>
<tr><td>text/css</td><td>css less CSS LESS</td></tr>
<tr><td>image/gif</td><td>gif GIF</td></tr>
<tr><td>image/jpeg</td><td>jpeg jpg jpe JPEG JPG JPE</td></tr>
<tr><td>image/png</td><td>png PNG</td></tr>
<tr><td>image/vnd.microsoft.icon</td><td>ico ICO</td></tr>
<tr><td>application/pdf</td><td>pdf PDF</td></tr>
<tr><td>application/json</td><td>json JSON</td></tr>
<tr><td>application/font-woff</td><td>woff WOFF</td></tr>
<tr><td>application/vnd.ms-fontobject</td><td>eot EOT</td></tr>
<tr><td>font/truetype</td><td>ttf TTF</td></tr>
<tr><td>font/opentype</td><td>otf OTF</td></tr>
</table>

<h2 id="caching:fbd9d552fff6e255f698507e4f0e8ccc">Caching</h2>

<p>Resource information is determined by calls to classloader <code>getResource()</code> for classpath locations and by calls to
<code>File.canRead()</code> for docroot locations. The number of these calls per resource lookup can increase when:</p>

<ul>
<li>Using multiple locations (classpath or docroot based), in which case the lookup logic is invoked for each location.</li>
<li>Using minification and gzip support, in which case the lookup logic itself is more costly trying to find
the resource in the following order :<br />

<ul>
<li>gzipped minified version</li>
<li>gzipped version</li>
<li>minified version</li>
<li>normal version<br /></li>
</ul></li>
</ul>

<p>A built-in cache is used to improve the lookup performance of resources that were served at least one time. You can
alter the cache properties as follows (below example with default values):</p>

<pre><code class="language-ini">org.seedstack.seed.web.resources.cache.max-size = 8192
org.seedstack.seed.web.resources.cache.concurrency = 32
org.seedstack.seed.web.resources.cache.initial-size = 2048
</code></pre>

<p>If you don&rsquo;t specify the initial-size configuration property, it will be set at <code>max-size / 4</code>.</p>

<h1 id="cors:fbd9d552fff6e255f698507e4f0e8ccc">CORS</h1>

<p>Cross-Origin Resource Sharing (CORS) is supported through a Java filter and can be enabled in any Seed application.</p>

<p><div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Seed integrates the CORS filter from <a href="http://software.dzhuvinov.com/cors-filter.html">dzhuvinov software</a>. There is no
need to install and configure the filter manually, it is automatically registered by Seed. All filter options can be
specified through configuration properties.</p>

        </div>
    </div>
</div></p>

<h2 id="configuration-1:fbd9d552fff6e255f698507e4f0e8ccc">Configuration</h2>

<p>To enable CORS support just add the following configuration to your application:</p>

<pre><code class="language-ini">org.seedstack.seed.web.cors.enabled = true
</code></pre>

<h2 id="filter-properties:fbd9d552fff6e255f698507e4f0e8ccc">Filter properties</h2>

<p>The CORS filter allows to alter its default behavior with various parameters. The filter documentation enumerates all
configuration parameters. Seed can transform any configuration property prefixed with <code>org.seedstack.seed.web.cors.property</code>
to the corresponding filter parameter. For instance, to specify the recognized verbs, you can use the following configuration:</p>

<pre><code class="language-ini">[org.seedstack.seed.web.cors.property]
supportedMethods= GET\\, POST\\, HEAD\\, OPTIONS\\, PUT\\, DELETE
</code></pre>

<p>This configuration property is automatically translated to the <code>cors.supportedMethods</code> filter parameter found in the
documentation. Note that the escaping of the commas is required to inhibit Seed from parsing this value as a list.</p>

<p><div class="callout callout-info">
    <div style="display:table; width: 100%">
        <div style="display:table-cell; width: 50px; vertical-align: middle;">
            
            
                <i class="fa fa-info-circle icon-2x" style="line-height: 30px;"></i>
            
            
            
        </div>
        <div style="display:table-cell; vertical-align: middle;">
            <p>Please refer to this page of the <a href="http://software.dzhuvinov.com/cors-filter-configuration.html">filter documentation</a>
for a complete list of configuration parameters.</p>

        </div>
    </div>
</div></p>

<h1 id="websockets:fbd9d552fff6e255f698507e4f0e8ccc">WebSockets</h1>

<p>Seed also integrates the Java API for WebSocket (JSR 356), allowing server and client endpoints to be injected. WebSocket
support requires Java 7 to work.</p>

<p>




    
        
            
        
    

<div class="tab-v2">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab-org-seedstack-seed-seed-web-websocket-maven" data-toggle="tab" aria-expanded="true">Maven</a></li>
        <li class=""><a href="#tab-org-seedstack-seed-seed-web-websocket-gradle" data-toggle="tab" aria-expanded="true">Gradle</a></li>
    </ul>
    <span class="tabs-icon fa-2x fa fa-cubes pull-right"></span>
    <div class="clear-both"></div>
    <div class="tab-content">
        <div class="tab-pane in active" id="tab-org-seedstack-seed-seed-web-websocket-maven">
            <pre style="margin-top: 0;"><code class="xml">&lt;dependency&gt;
    &lt;groupId&gt;org.seedstack.seed&lt;/groupId&gt;
    &lt;artifactId&gt;seed-web-websocket&lt;/artifactId&gt;<span id="org-seedstack-seed-seed-web-websocket-version" style="display: none;">
    &lt;version&gt;2.2.0&lt;/version&gt;</span>
&lt;/dependency&gt;</code></pre>
            <small class="pull-right" style="color: #aaa; margin-top: -20px; margin-right: 5px;">
                <span id="org-seedstack-seed-seed-web-websocket-warn" style="display: none;"><i class="fa fa-warning" style="color: orange;"></i> Specifying versions manually is error-prone, use the <a href="/getting-started/distribution">distribution</a> instead.</span>
                <a style="cursor: pointer;" id="org-seedstack-seed-seed-web-websocket-show" onclick="$('#org-seedstack-seed-seed-web-websocket-version, #org-seedstack-seed-seed-web-websocket-warn').show(); $('#org-seedstack-seed-seed-web-websocket-show').hide();">Show version</a>
            </small>
        </div>
        <div class="tab-pane in" id="tab-org-seedstack-seed-seed-web-websocket-gradle">
            <pre style="margin-bottom: 0;"><code class="java">dependencies {
    compile("org.seedstack.seed:seed-web-websocket:2.2.0")
}</code></pre>
        </div>
    </div>
</div>
</p>

<h2 id="server-endpoints:fbd9d552fff6e255f698507e4f0e8ccc">Server endpoints</h2>

<p>No specific configuration is required for server endpoint. Just declare a standard JSR 356 endpoint:</p>

<pre><code>@ServerEndpoint(value = &quot;/chat&quot;)
public class ChatEndpoint {

    @Logging
    private Logger logger;

    @Inject
    EchoService echoService;

    @OnOpen
    public void onOpen(Session session) {
        logger.info(&quot;Connected ... &quot; + session.getId());
    }

    @OnMessage
    public void message(String message, 
                        Session client) throws IOException, EncodeException {
        for (Session peer : client.getOpenSessions()) {
            peer.getBasicRemote().sendText(echoService.echo(message));
        }
    }

    @OnClose
    public void onClose(Session session, CloseReason closeReason) {
        logger.info(String.format(&quot;Session %s close because of %s&quot;, 
            session.getId(), closeReason));
    }

    @OnError
    public void onError(Session session, Throwable t) {
        logger.error(t.getMessage, t);
    }

}
</code></pre>

<p>In this example, the endpoint receives a message and then broadcast it to all clients.</p>

<h2 id="client-endpoints:fbd9d552fff6e255f698507e4f0e8ccc">Client endpoints</h2>

<p>Unlike server endpoints, client endpoints have to explicitly specify a <code>SeedClientEndpointConfigurator</code> in order to be
managed by Seed.</p>

<pre><code>@ClientEndpoint(configurator = SeedClientEndpointConfigurator.class)
public class ChatClientEndpoint1 {
    public static final String TEXT = &quot;Client1 joins&quot;;
    public static CountDownLatch latch;
    public static String response;

    @OnOpen
    public void onOpen(Session session) {
        try {
            session.getBasicRemote().sendText(TEXT);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    @OnMessage
    public void processMessage(String message) {
        response = message;
        latch.countDown();
    }
}
</code></pre>

<h2 id="testing:fbd9d552fff6e255f698507e4f0e8ccc">Testing</h2>

<p>You can test WebSocket endpoints with <a href="../testing">Seed Web integration testing</a>. Here is an example which tests two
client endpoints:</p>

<pre><code>public class WebSocketIT extends AbstractSeedWebIT {

    @Logging
    private Logger logger;

    @Inject
    ChatClientEndpoint1 chatClientEndpoint1;

    @Inject
    ChatClientEndpoint2 chatClientEndpoint2;

    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(WebArchive.class).setWebXML(&quot;WEB-INF/web.xml&quot;);
    }

    @Test
    @RunAsClient
    public void communication_is_working(@ArquillianResource URL baseUrl) throws Exception {
        ChatClientEndpoint1.latch = new CountDownLatch(1);

        final Session session1 = connectToServer(baseUrl, chatClientEndpoint1);
        assertNotNull(session1);

        assertTrue(ChatClientEndpoint1.latch.await(2, TimeUnit.SECONDS));
        assertEquals(&quot;echo: &quot; + ChatClientEndpoint1.TEXT, ChatClientEndpoint1.response);

        ChatClientEndpoint1.latch = new CountDownLatch(1);
        ChatClientEndpoint2.latch = new CountDownLatch(1);

        final Session session2 = connectToServer(baseUrl, chatClientEndpoint2);
        assertNotNull(session2);

        assertTrue(ChatClientEndpoint1.latch.await(2, TimeUnit.SECONDS));
        assertTrue(ChatClientEndpoint2.latch.await(2, TimeUnit.SECONDS));
        assertEquals(&quot;echo: &quot; + ChatClientEndpoint2.TEXT, ChatClientEndpoint1.response);
        assertEquals(&quot;echo: &quot; + ChatClientEndpoint2.TEXT, ChatClientEndpoint2.response);
    }

    private Session connectToServer(URL baseUrl, Object endpoint) {
        try {
        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        URI uri = new URI(&quot;ws://&quot; + baseUrl.getHost() + &quot;:&quot; + baseUrl.getPort()
            + baseUrl.getPath() + &quot;chat&quot;);
        return container.connectToServer(endpoint, uri);
        } catch(Exception e) {
            logger.error(e.getMessage(), e);
            fail();
        }
    }

}
</code></pre>

            </div>
        </div>
    </div>
    <div class="col-md-3">
        
<div class="side-menu">
    
        
        <div class="list-group">
            <ul class="nav">
                
                
                
                    
                    <li>
                        <a href="/docs/seed/manual/" class="list-group-item ">
                            Basics
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/testing/" class="list-group-item ">
                            Testing
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/security/" class="list-group-item ">
                            Security
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/crypto/" class="list-group-item ">
                            Cryptography
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/web/" class="list-group-item  active ">
                            Web
                        </a>
                        
                        
                            <nav id="TableOfContents">
<ul>
<li><a href="#security:fbd9d552fff6e255f698507e4f0e8ccc">Security</a>
<ul>
<li><a href="#url-patterns:fbd9d552fff6e255f698507e4f0e8ccc">URL patterns</a></li>
<li><a href="#filters:fbd9d552fff6e255f698507e4f0e8ccc">Filters</a>
<ul>
<li><a href="#built-in-filters:fbd9d552fff6e255f698507e4f0e8ccc">Built-in filters</a></li>
<li><a href="#custom-filters:fbd9d552fff6e255f698507e4f0e8ccc">Custom filters</a></li>
</ul></li>
<li><a href="#example:fbd9d552fff6e255f698507e4f0e8ccc">Example</a></li>
</ul></li>
<li><a href="#servlets-and-filters:fbd9d552fff6e255f698507e4f0e8ccc">Servlets and Filters</a></li>
<li><a href="#static-resources:fbd9d552fff6e255f698507e4f0e8ccc">Static resources</a>
<ul>
<li><a href="#default-behavior:fbd9d552fff6e255f698507e4f0e8ccc">Default behavior</a></li>
<li><a href="#configuration:fbd9d552fff6e255f698507e4f0e8ccc">Configuration</a></li>
<li><a href="#minification-and-gzip-support:fbd9d552fff6e255f698507e4f0e8ccc">Minification and gzip support</a></li>
<li><a href="#mime-types:fbd9d552fff6e255f698507e4f0e8ccc">MIME types</a></li>
<li><a href="#caching:fbd9d552fff6e255f698507e4f0e8ccc">Caching</a></li>
</ul></li>
<li><a href="#cors:fbd9d552fff6e255f698507e4f0e8ccc">CORS</a>
<ul>
<li><a href="#configuration-1:fbd9d552fff6e255f698507e4f0e8ccc">Configuration</a></li>
<li><a href="#filter-properties:fbd9d552fff6e255f698507e4f0e8ccc">Filter properties</a></li>
</ul></li>
<li><a href="#websockets:fbd9d552fff6e255f698507e4f0e8ccc">WebSockets</a>
<ul>
<li><a href="#server-endpoints:fbd9d552fff6e255f698507e4f0e8ccc">Server endpoints</a></li>
<li><a href="#client-endpoints:fbd9d552fff6e255f698507e4f0e8ccc">Client endpoints</a></li>
<li><a href="#testing:fbd9d552fff6e255f698507e4f0e8ccc">Testing</a></li>
</ul></li>
</ul>
</nav>
                            <script>
                                seedstack.state.previousPage = '\/docs\/seed\/manual\/crypto\/';
                            </script>
                            
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/rest/" class="list-group-item ">
                            REST
                        </a>
                        
                            <script>
                                seedstack.state.nextPage = '\/docs\/seed\/manual\/rest\/';
                            </script>
                            
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/operations/" class="list-group-item ">
                            Operations
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/transactions/" class="list-group-item ">
                            Transactions
                        </a>
                        
                        
                    </li>
                    
                
                    
                    <li>
                        <a href="/docs/seed/manual/more/" class="list-group-item ">
                            More
                        </a>
                        
                        
                    </li>
                    
                
            </ul>
        </div>
        
    
    
    <div class="list-group">
        <ul class="nav">
            <li class="list-group-item"><div style="margin-bottom: 10px;"><i class="fa fa-tag"></i> Tags</div>
                <div class="tags">
                    
                    <a class="label label-default" href="/tags/servlet">Servlet</a>
                    
                    <a class="label label-default" href="/tags/security">Security</a>
                    
                    <a class="label label-default" href="/tags/url">Url</a>
                    
                    <a class="label label-default" href="/tags/filter">Filter</a>
                    
                    <a class="label label-default" href="/tags/static">Static</a>
                    
                    <a class="label label-default" href="/tags/resource">Resource</a>
                    
                    <a class="label label-default" href="/tags/mime">Mime</a>
                    
                    <a class="label label-default" href="/tags/cors">Cors</a>
                    
                    <a class="label label-default" href="/tags/websocket">Websocket</a>
                    
                </div>
            </li>
        </ul>
    </div>
    
    <div class="list-group">
        <ul class="nav">
            
                <li><a class="list-group-item" href="https://github.com/seedstack/website/edit/beta/content/docs/seed/manual/web.md" target="_blank"><i class="fa fa-edit"></i> Contribute to this BETA page</a></li>
            
        </ul>
    </div>
</div>

    </div>
</div>

    </div>
    <div id="footer">
        <div class="footer-v3">
    <div class="footer">
        <div class="container">
            <div class="row">
                <div class="col-md-4 md-margin-bottom-40">
                    <div class="headline"><h2>About</h2></div>
                    <p class="margin-bottom-25 md-margin-bottom-40">SeedStack is an Open-Source enterprise-class development stack for building modern and robust applications.</p>
                </div>

                <div class="col-md-4 md-margin-bottom-40">
                    <div class="posts">
                        <div class="headline"><h2>License</h2></div>
                        <p>
                            Code licensed under the <a href="https://www.mozilla.org/MPL/2.0" target="_blank">Mozilla Public License 2.0</a>.
                            <br/>
                            Documentation licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.
                        </p>
                    </div>
                </div>

                <div class="col-md-4 map-img">
                    <div class="headline"><h2>Contact us</h2></div>
                    <address>
                        <p>
                            IRC channel <a href="irc://chat.freenode.net/seedstack">#seedstack on Freenode community</a>
                            <br/>
                            Google group <a href="https://groups.google.com/forum/#!forum/seedstack">seedstack@googlegroups.com</a>
                        </p>
                    </address>

                    <div class="headline"><h2>Stay in touch</h2></div>
                    <div style="margin-bottom: 20px;">
                        <a class="twitter-follow-button"
                           href="https://twitter.com/seedstack"
                           data-show-count="true"
                           data-lang="en">
                            Follow @seedstack
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    </div>
    <div id="hotkeys-modal" class="modal">
    <div class="modal-dialog" style="min-width: 960px !important;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">Keyboard shortcuts <a id="show-all-shortcuts" style="cursor: pointer;" onclick="seedstack.ui.showAllShortcuts();">(Show all)</a></h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-4">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Global shortcuts</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>?</kbd>
                                </td>
                                <td>Show this help dialog</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>/</kbd>
                                </td>
                                <td>Focus the search field</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>alt</kbd> <kbd></kbd>
                                </td>
                                <td>Go to previous menu item</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>alt</kbd> <kbd></kbd>
                                </td>
                                <td>Go to next menu item</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>S</kbd>
                                </td>
                                <td>Go to Seed framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>W</kbd>
                                </td>
                                <td>Go to W20 framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>B</kbd>
                                </td>
                                <td>Go to Business framework</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>A</kbd>
                                </td>
                                <td>Go to add-ons</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>G</kbd>
                                </td>
                                <td>Go to guides</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Seed framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>t</kbd>
                                </td>
                                <td>Go to testing</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>s</kbd>
                                </td>
                                <td>Go to security</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>c</kbd>
                                </td>
                                <td>Go to cryptography</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>w</kbd>
                                </td>
                                <td>Go to Web</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>r</kbd>
                                </td>
                                <td>Go to REST</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>o</kbd>
                                </td>
                                <td>Go to operations</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>s</kbd> <kbd>T</kbd>
                                </td>
                                <td>Go to transactions</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>Business framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>m</kbd>
                                </td>
                                <td>Go to model</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>l</kbd>
                                </td>
                                <td>Go to lifecycle</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>e</kbd>
                                </td>
                                <td>Go to events</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>p</kbd>
                                </td>
                                <td>Go to policies</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>a</kbd>
                                </td>
                                <td>Go to assemblers</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>f</kbd>
                                </td>
                                <td>Go to finders</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>b</kbd> <kbd>P</kbd>
                                </td>
                                <td>Go to pagination</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4 hidden-shortcuts" style="display: none;">
                        <table class="keyboard-mappings">
                            <tbody>
                            <tr>
                                <th></th>
                                <th>W20 framework</th>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>b</kbd>
                                </td>
                                <td>Go to basics</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>s</kbd>
                                </td>
                                <td>Go to security</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>c</kbd>
                                </td>
                                <td>Go to culture</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>h</kbd>
                                </td>
                                <td>Go to hypermedia</td>
                            </tr>
                            <tr>
                                <td class="keys">
                                    <kbd>g</kbd> <kbd>w</kbd> <kbd>u</kbd>
                                </td>
                                <td>Go to UI</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="versions-modal" class="modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 id="versions-title" class="modal-title">Fetching components...</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <table id="versions-table" class="table table-striped table-hover table-bordered">
                            <tr>
                                <th>Component</th>
                                <th>Version</th>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/github.min.css">

    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lunr.js/0.5.9/lunr.min.js"></script>
<script src="/assets/unify/plugins/smoothScroll.js"></script>
<script src="/js/xml2json.js"></script>
<script src="/js/jquery.highlight.js"></script>
<script src="/js/seedstack.js"></script>
<script>
    $(document).ready(function () {
        var $search = $('.search-btn');

        $('.search').click(function () {
            if ($search.hasClass('fa-search')) {
                seedstack.ui.openSearch();
            } else {
                seedstack.ui.closeSearch();
            }
        });

        $('pre code').each(function (i, block) {
            hljs.highlightBlock(block);
        });

        $('.side-menu').affix({
            offset: {
                top: $('#header').height() + 20,
                bottom: $('#footer').height() + 40
            }
        });

        Mousetrap.bind('/', function () {
            seedstack.ui.openSearch();
            return false;
        });

        Mousetrap.bind('alt+up', function () {
            if (seedstack.state.previousPage) {
                window.location = seedstack.state.previousPage;
            }
            return false;
        });

        Mousetrap.bind('alt+down', function () {
            if (seedstack.state.nextPage) {
                window.location = seedstack.state.nextPage;
            }
            return false;
        });

        Mousetrap.bind('?', function () {
            seedstack.ui.openHelp();
            return false;
        });

        Mousetrap.bind('esc', function () {
            seedstack.ui.closeHelp();
            seedstack.ui.closeSearch();
            return false;
        });

        var originalCallback = Mousetrap.stopCallback;
        Mousetrap.stopCallback = function (e, element, combo) {
            if (combo === 'esc') {
                return false;
            }

            return originalCallback(e, element, combo);
        };

        function bindShortcuts(value) {
            $.each(value, function (sequence, item) {
                if (typeof item === 'string') {
                    Mousetrap.bind("g " + sequence, function () {
                        window.location = item;
                        return false;
                    });
                } else if (typeof item === 'object') {
                    Mousetrap.bind("g " + sequence, function () {
                        window.location = item.path;
                        return false;
                    });
                    if (item.shortcuts && location.pathname.indexOf(item.path) === 0) {
                        bindShortcuts(item.shortcuts);
                    }
                }
            });
        }

        function resolveVersions() {
            var $versionsTitle = $('#versions-title');
            if (!seedstack.versions) {
                $.ajax({
                    dataType: 'text',
                    url: '/distribution.pom.xml'
                }).done(function (data) {
                    var pom = new X2JS().xml_str2json(data);

                    if (pom.project && pom.project.properties && pom.project.version) {
                        var $versions = $('#versions-table');
                        var versions = {};

                        $versionsTitle.text("SeedStack " + pom.project.version);

                        $.each(pom.project.properties, function (name, value) {
                            if (/\.version$/.test(name)) {
                                versions[name.substr(0, name.indexOf('.version'))] = value;

                                $versions.append(
                                        '<tr>' +
                                        '<td>' +
                                        name.substr(0, 1).toUpperCase() + name.substr(1, name.indexOf('.version') - 1).replace(/-/g, ' ') +
                                        '</td>' +
                                        '<td>' + value + '</td>' +
                                        '</tr>');
                            }
                        });

                        $('.loginbar').prepend(
                                '<li class="hidden-xs hidden-sm"><i class="fa fa-tag"></i> <a style="cursor: pointer;" onclick="seedstack.ui.openVersions();">Version ' + pom.project.version + '</a></li>' +
                                '<li class="topbar-devider"></li>'
                        );

                        seedstack.versions = versions;
                    }
                }).error(function () {
                    console.error("SeedStack version could not be resolved");
                });
            }
        }

        bindShortcuts(seedstack.ui.shortcuts);

        resolveVersions();

        $('[data-toggle="tooltip"]').tooltip();

        $('#hotkeys-modal, #versions-modal').bind('hidden.bs.modal', function () {
            $("html").css("margin-right", "0px");
        }).bind('show.bs.modal', function () {
            $("html").css("margin-right", "-15px");
        });

        var query = seedstack.strings.parseQueryString(location);
        if (query.h && query.h.length > 0) {
            $('.doc-content').highlight(query.h);
            if (query.scroll) {
                $('html, body').animate({
                    scrollTop: $('span[class=highlight]:first').offset().top - 20
                }, 250);
            }
        }
    });
</script>
<script>window.twttr = (function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {};
    if (d.getElementById(id))return t;
    js = d.createElement(s);
    js.id = id;
    js.src = "https://platform.twitter.com/widgets.js";
    fjs.parentNode.insertBefore(js, fjs);
    t._e = [];
    t.ready = function (f) {
        t._e.push(f);
    };
    return t;
}(document, "script", "twitter-wjs"));</script>

</body>
</html>