Doing the security check in onBeforeRender() in the Panel fixed it. I
did not have a Page yet.
Warren
I am trying to do a security check on a component that is on a panel
like this:
if(SecureComponentHelper.isAuthenticated(myComponent) &&
SecureComponentHelper.isActionAuthorized(myComponent, "enable")) {
// Do Something }
I have also tried this:
if(myComponent.isAuthenticated() &&
!myComponent.isActionAuthorized("enable")) { // Do Something }
Basically the same thing. myComponent implements ISecureComponent.
setSecurityCheck(new ComponentSecurityCheck(this)) is called in the
constructors of myComponent.
This works fine if myComponent is on a page, but does not work if
myComponent is on a panel. I get the following exception:
Caused by: org.apache.wicket.security.strategies.SecurityException:
Unable to create alias for component: [MarkupContainer [Component id
= myComponent]] at
org.apache.wicket.security.components.SecureComponentHelper.alias(SecureComponentHelper.java:263)
at
org.apache.wicket.security.hive.authorization.permissions.ComponentPermission.<init>(ComponentPermission.java:54)
at
org.apache.wicket.security.swarm.strategies.SwarmStrategy.isComponentAuthorized(SwarmStrategy.java:228)
at
org.apache.wicket.security.checks.ComponentSecurityCheck.isActionAuthorized(ComponentSecurityCheck.java:127)
at
org.apache.wicket.security.components.SecureComponentHelper.isActionAuthorized(SecureComponentHelper.java:177)
at
com.scanman.panels.menus.MainMenuHandHeldPanel.<init>(MainMenuHandHeldPanel.java:123)
at com.scanman.pages.menus.MainMenu$2.<init>(MainMenu.java:157) at
com.scanman.pages.menus.MainMenu.<init>(MainMenu.java:157) ... 28
more Caused by: java.lang.IllegalStateException: No Page found for
component [MarkupContainer [Component id = resetButtonContainer]] at
org.apache.wicket.Component.getPage(Component.java:1729) at
org.apache.wicket.security.components.SecureComponentHelper.alias(SecureComponentHelper.java:259)
... 35 more
How do you do a security check on a component that is on a panel?
Thanks,
Warren