| 470 | | String authPage = authConstraint.getAuthPage(); |
| 471 | | if (authPage != null && !authPage.equals(lastAuthPage)) { |
| 472 | | if (authPages.contains(authPage)) { |
| 473 | | StringBuilder sb = new StringBuilder(); |
| 474 | | for (String s : authPages) |
| 475 | | sb.append(s + " -> "); |
| 476 | | sb.append(authPage); |
| 477 | | throw new Exception("Circular authconstraint@authpage reference: " + sb.toString()); |
| 478 | | } |
| 479 | | PageRequestConfigImpl cfg = getPageRequestConfig(authPage); |
| 480 | | if (cfg != null) { |
| 481 | | AuthConstraint ac = cfg.getAuthConstraint(); |
| 482 | | if (ac == null) ac = getDefaultAuthConstraint(); |
| 483 | | if (ac != null) { |
| 484 | | authPages.add(authPage); |
| 485 | | checkAuthConstraint(ac, authPages, authPage); |
| | 471 | for (String authPage : traverseAuthPages(authConstraint)) { |
| | 472 | if (authPage != null && !authPage.equals(lastAuthPage)) { |
| | 473 | if (authPages.contains(authPage)) { |
| | 474 | StringBuilder sb = new StringBuilder(); |
| | 475 | for (String s : authPages) |
| | 476 | sb.append(s + " -> "); |
| | 477 | sb.append(authPage); |
| | 478 | throw new Exception("Circular authconstraint@authpage reference: " + sb.toString()); |
| 487 | | } else throw new Exception("Authpage not configured: " + authPage); |
| 488 | | } |
| 489 | | } |
| 490 | | |
| | 480 | PageRequestConfigImpl cfg = getPageRequestConfig(authPage); |
| | 481 | if (cfg != null) { |
| | 482 | AuthConstraint ac = cfg.getAuthConstraint(); |
| | 483 | if (ac == null) ac = getDefaultAuthConstraint(); |
| | 484 | if (ac != null) { |
| | 485 | authPages.add(authPage); |
| | 486 | checkAuthConstraint(ac, authPages, authPage); |
| | 487 | } |
| | 488 | } else throw new Exception("Authpage not configured: " + authPage); |
| | 489 | } |
| | 490 | } |
| | 491 | } |
| | 492 | |
| | 493 | private Iterable<String> traverseAuthPages(final AuthConstraint authConstraint) { |
| | 494 | return new Iterable<String>() { |
| | 495 | @Override |
| | 496 | public Iterator<String> iterator() { |
| | 497 | return new Iterator<String>() { |
| | 498 | |
| | 499 | private Iterator<NavigationCase> navCases = |
| | 500 | authConstraint.getNavigation().iterator(); |
| | 501 | |
| | 502 | private boolean visitedDefaultAuthPage; |
| | 503 | |
| | 504 | private boolean isDefaultPageVisitable() { |
| | 505 | return !visitedDefaultAuthPage && authConstraint.getDefaultAuthPage() != null; |
| | 506 | } |
| | 507 | |
| | 508 | @Override |
| | 509 | public boolean hasNext() { |
| | 510 | return isDefaultPageVisitable() || |
| | 511 | navCases.hasNext(); |
| | 512 | } |
| | 513 | |
| | 514 | @Override |
| | 515 | public String next() { |
| | 516 | if (isDefaultPageVisitable()) { |
| | 517 | String result = authConstraint.getDefaultAuthPage(); |
| | 518 | visitedDefaultAuthPage = true; |
| | 519 | return result; |
| | 520 | } |
| | 521 | return navCases.next().getPage(); |
| | 522 | } |
| | 523 | |
| | 524 | @Override |
| | 525 | public void remove() { |
| | 526 | throw new UnsupportedOperationException(); |
| | 527 | } |
| | 528 | }; |
| | 529 | } |
| | 530 | }; |
| | 531 | } |
| | 532 | |