You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Igor Vaynberg <ig...@gmail.com> on 2010/10/22 21:09:42 UTC

Re: svn commit: r1026443 - in /wicket/trunk: wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/ wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/ wicket-examples/src/ma

i think only the isinstantiationauthorized should use class<? extends
irequestablecomponent>

everything else - that gets a concrete instance - should get
Component. reason being auth strategy often accesses metadata on
component to figure out allowed roles, etc. so either we add metadata
to irequestablecomponent - which is weird since there is nothing
requestable about it, or we change it back to use concrete Component.
im in favor of the latter.

-igor

On Fri, Oct 22, 2010 at 11:46 AM,  <mg...@apache.org> wrote:
> Author: mgrigorov
> Date: Fri Oct 22 18:46:27 2010
> New Revision: 1026443
>
> URL: http://svn.apache.org/viewvc?rev=1026443&view=rev
> Log:
> IAuthorizationStrategy should use IRequestableComponent instead of just Component
>
> Modified:
>    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java
>    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java
>    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java
>    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication1/SignInApplication.java
>    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication2/SignIn2Application.java
>    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
>    wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/IAuthorizationStrategy.java
>    wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/CompoundAuthorizationStrategy.java
>    wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/ActionAuthorizationStrategy.java
>    wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/IActionAuthorizer.java
>    wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/page/AbstractPageAuthorizationStrategy.java
>    wicket/trunk/wicket/src/test/java/org/apache/wicket/AuthorizationTest.java
>    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java
>    wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
>    wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java
>
> Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/AnnotationsRoleAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -16,11 +16,11 @@
>  */
>  package org.apache.wicket.authorization.strategies.role.annotations;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.authorization.Action;
>  import org.apache.wicket.authorization.strategies.role.AbstractRoleAuthorizationStrategy;
>  import org.apache.wicket.authorization.strategies.role.IRoleCheckingStrategy;
>  import org.apache.wicket.authorization.strategies.role.Roles;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -46,7 +46,8 @@ public class AnnotationsRoleAuthorizatio
>        /**
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>         */
> -       public <T extends Component> boolean isInstantiationAuthorized(final Class<T> componentClass)
> +       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +               final Class<T> componentClass)
>        {
>                // We are authorized unless we are found not to be
>                boolean authorized = true;
> @@ -77,7 +78,7 @@ public class AnnotationsRoleAuthorizatio
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>         *      org.apache.wicket.authorization.Action)
>         */
> -       public boolean isActionAuthorized(final Component component, final Action action)
> +       public boolean isActionAuthorized(final IRequestableComponent component, final Action action)
>        {
>                // Get component's class
>                final Class<?> componentClass = component.getClass();
>
> Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java (original)
> +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/InstantiationPermissions.java Fri Oct 22 18:46:27 2010
> @@ -22,6 +22,7 @@ import java.util.Map;
>  import org.apache.wicket.Component;
>  import org.apache.wicket.IClusterable;
>  import org.apache.wicket.authorization.strategies.role.Roles;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -100,7 +101,7 @@ public class InstantiationPermissions im
>         * @return the roles that have a binding with the given component class, or null if no entries
>         *         are found
>         */
> -       public <T extends Component> Roles authorizedRoles(final Class<T> componentClass)
> +       public <T extends IRequestableComponent> Roles authorizedRoles(final Class<T> componentClass)
>        {
>                if (componentClass == null)
>                {
>
> Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/MetaDataRoleAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -23,13 +23,14 @@ import org.apache.wicket.authorization.A
>  import org.apache.wicket.authorization.strategies.role.AbstractRoleAuthorizationStrategy;
>  import org.apache.wicket.authorization.strategies.role.IRoleCheckingStrategy;
>  import org.apache.wicket.authorization.strategies.role.Roles;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
>  * Strategy that uses the Wicket metadata facility to check authorization. The static
> - * <code>authorize</code> methods are for authorizing component actions and component
> - * instantiation by role. This class is the main entry point for users wanting to use the
> - * roles-based authorization of the wicket-auth-roles package based on wicket metadata.
> + * <code>authorize</code> methods are for authorizing component actions and component instantiation
> + * by role. This class is the main entry point for users wanting to use the roles-based
> + * authorization of the wicket-auth-roles package based on wicket metadata.
>  *
>  * For instance, use like:
>  *
> @@ -253,7 +254,7 @@ public class MetaDataRoleAuthorizationSt
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>         *      org.apache.wicket.authorization.Action)
>         */
> -       public boolean isActionAuthorized(final Component component, final Action action)
> +       public boolean isActionAuthorized(final IRequestableComponent component, final Action action)
>        {
>                if (component == null)
>                {
> @@ -277,7 +278,8 @@ public class MetaDataRoleAuthorizationSt
>         *
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>         */
> -       public <T extends Component> boolean isInstantiationAuthorized(final Class<T> componentClass)
> +       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +               final Class<T> componentClass)
>        {
>                if (componentClass == null)
>                {
> @@ -309,7 +311,7 @@ public class MetaDataRoleAuthorizationSt
>         * @return the roles that are authorized for creation of the componentClass, or null if no
>         *         specific authorization was configured
>         */
> -       private static <T extends Component> Roles rolesAuthorizedToInstantiate(
> +       private static <T extends IRequestableComponent> Roles rolesAuthorizedToInstantiate(
>                final Class<T> componentClass)
>        {
>                final InstantiationPermissions permissions = Application.get().getMetaData(
> @@ -330,10 +332,11 @@ public class MetaDataRoleAuthorizationSt
>         *            the action
>         * @return the roles for the action as defined with the given component
>         */
> -       private static Roles rolesAuthorizedToPerformAction(final Component component,
> +       private static Roles rolesAuthorizedToPerformAction(final IRequestableComponent component,
>                final Action action)
>        {
> -               final ActionPermissions permissions = component.getMetaData(ACTION_PERMISSIONS);
> +               // XXX WICKET-NG this cast doesn't look nice
> +               final ActionPermissions permissions = ((Component)component).getMetaData(ACTION_PERMISSIONS);
>                if (permissions != null)
>                {
>                        return permissions.rolesFor(action);
>
> Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication1/SignInApplication.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication1/SignInApplication.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication1/SignInApplication.java (original)
> +++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication1/SignInApplication.java Fri Oct 22 18:46:27 2010
> @@ -16,7 +16,6 @@
>  */
>  package org.apache.wicket.examples.authentication1;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.Page;
>  import org.apache.wicket.RestartResponseAtInterceptPageException;
>  import org.apache.wicket.Session;
> @@ -25,6 +24,7 @@ import org.apache.wicket.authorization.I
>  import org.apache.wicket.examples.WicketExampleApplication;
>  import org.apache.wicket.request.Request;
>  import org.apache.wicket.request.Response;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>  /**
>  * Forms example.
> @@ -69,13 +69,14 @@ public final class SignInApplication ext
>                // Register the authorization strategy
>                getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy()
>                {
> -                       public boolean isActionAuthorized(Component component, Action action)
> +                       public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                        {
>                                // authorize everything
>                                return true;
>                        }
>
> -                       public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +                       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +                               Class<T> componentClass)
>                        {
>                                // Check if the new Page requires authentication (implements the marker interface)
>                                if (AuthenticatedWebPage.class.isAssignableFrom(componentClass))
>
> Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication2/SignIn2Application.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication2/SignIn2Application.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication2/SignIn2Application.java (original)
> +++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication2/SignIn2Application.java Fri Oct 22 18:46:27 2010
> @@ -16,7 +16,6 @@
>  */
>  package org.apache.wicket.examples.authentication2;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.Page;
>  import org.apache.wicket.RestartResponseAtInterceptPageException;
>  import org.apache.wicket.Session;
> @@ -25,6 +24,7 @@ import org.apache.wicket.authorization.I
>  import org.apache.wicket.examples.WicketExampleApplication;
>  import org.apache.wicket.request.Request;
>  import org.apache.wicket.request.Response;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -71,13 +71,14 @@ public final class SignIn2Application ex
>                // Register the authorization strategy
>                getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy()
>                {
> -                       public boolean isActionAuthorized(Component component, Action action)
> +                       public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                        {
>                                // authorize everything
>                                return true;
>                        }
>
> -                       public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +                       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +                               Class<T> componentClass)
>                        {
>                                // Check if the new Page requires authentication (implements the marker interface)
>                                if (AuthenticatedWebPage.class.isAssignableFrom(componentClass))
>
> Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java (original)
> +++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java Fri Oct 22 18:46:27 2010
> @@ -27,11 +27,10 @@ import org.apache.wicket.request.Url;
>  import org.apache.wicket.request.handler.PageProvider;
>  import org.apache.wicket.request.handler.RenderPageRequestHandler;
>  import org.apache.wicket.request.mapper.AbstractComponentMapper;
> -import org.apache.wicket.request.mapper.HomePageMapper;
>
>  /**
> - * An {@link IRequestMapper} that overrides the behavior of {@link HomePageMapper} and appends the
> - * string representation of the current session locale in the url
> + * An {@link IRequestMapper} that handles requests to the home page ('/') and appends the string
> + * representation of the current session locale in the URL
>  *
>  * <p>
>  * I.e. a request to http://example.com/app will end up in http://example.com/app/en_US
>
> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/IAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/IAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/IAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/IAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -17,6 +17,7 @@
>  package org.apache.wicket.authorization;
>
>  import org.apache.wicket.Component;
> +import org.apache.wicket.request.component.IRequestableComponent;
>  import org.apache.wicket.settings.ISecuritySettings;
>
>  /**
> @@ -40,7 +41,7 @@ public interface IAuthorizationStrategy
>                /**
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>                 */
> -               public <T extends Component> boolean isInstantiationAuthorized(final Class<T> c)
> +               public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> c)
>                {
>                        return true;
>                }
> @@ -49,7 +50,7 @@ public interface IAuthorizationStrategy
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                 *      org.apache.wicket.authorization.Action)
>                 */
> -               public boolean isActionAuthorized(Component c, Action action)
> +               public boolean isActionAuthorized(IRequestableComponent c, Action action)
>                {
>                        return true;
>                }
> @@ -72,7 +73,7 @@ public interface IAuthorizationStrategy
>         *            The component class to check
>         * @return Whether the given component may be created
>         */
> -       <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass);
> +       <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass);
>
>        /**
>         * Gets whether the given action is permitted. If it is, this method should return true. If it
> @@ -90,5 +91,5 @@ public interface IAuthorizationStrategy
>         * @see Component#ENABLE
>         * @see Component#RENDER
>         */
> -       boolean isActionAuthorized(Component component, Action action);
> +       boolean isActionAuthorized(IRequestableComponent component, Action action);
>  }
>
> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/CompoundAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/CompoundAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/CompoundAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/CompoundAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -19,9 +19,9 @@ package org.apache.wicket.authorization.
>  import java.util.ArrayList;
>  import java.util.List;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.authorization.Action;
>  import org.apache.wicket.authorization.IAuthorizationStrategy;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -53,7 +53,8 @@ public class CompoundAuthorizationStrate
>        /**
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>         */
> -       public final <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +       public final <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +               Class<T> componentClass)
>        {
>                int size = strategies.size();
>                for (int i = 0; i < size; i++)
> @@ -71,7 +72,7 @@ public class CompoundAuthorizationStrate
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>         *      org.apache.wicket.authorization.Action)
>         */
> -       public final boolean isActionAuthorized(Component component, Action action)
> +       public final boolean isActionAuthorized(IRequestableComponent component, Action action)
>        {
>                int size = strategies.size();
>                for (int i = 0; i < size; i++)
>
> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/ActionAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/ActionAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/ActionAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/ActionAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -19,9 +19,9 @@ package org.apache.wicket.authorization.
>  import java.util.HashMap;
>  import java.util.Map;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.authorization.Action;
>  import org.apache.wicket.authorization.IAuthorizationStrategy;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -50,7 +50,8 @@ public class ActionAuthorizationStrategy
>        /**
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>         */
> -       public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +               Class<T> componentClass)
>        {
>                return true;
>        }
> @@ -59,7 +60,7 @@ public class ActionAuthorizationStrategy
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>         *      org.apache.wicket.authorization.Action)
>         */
> -       public boolean isActionAuthorized(Component component, Action action)
> +       public boolean isActionAuthorized(IRequestableComponent component, Action action)
>        {
>                IActionAuthorizer authorizer = actionAuthorizerForAction.get(action);
>                if (authorizer != null)
>
> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/IActionAuthorizer.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/IActionAuthorizer.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/IActionAuthorizer.java (original)
> +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/action/IActionAuthorizer.java Fri Oct 22 18:46:27 2010
> @@ -16,9 +16,9 @@
>  */
>  package org.apache.wicket.authorization.strategies.action;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.IClusterable;
>  import org.apache.wicket.authorization.Action;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>  /**
>  * A way to provide authorization for a specific component action.
> @@ -42,5 +42,5 @@ public interface IActionAuthorizer exten
>         *            The component to authorize this action on
>         * @return True if this action is authorized
>         */
> -       boolean authorizeAction(Component component);
> +       boolean authorizeAction(IRequestableComponent component);
>  }
>
> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/page/AbstractPageAuthorizationStrategy.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/page/AbstractPageAuthorizationStrategy.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/page/AbstractPageAuthorizationStrategy.java (original)
> +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/authorization/strategies/page/AbstractPageAuthorizationStrategy.java Fri Oct 22 18:46:27 2010
> @@ -16,10 +16,10 @@
>  */
>  package org.apache.wicket.authorization.strategies.page;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.Page;
>  import org.apache.wicket.authorization.Action;
>  import org.apache.wicket.authorization.IAuthorizationStrategy;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>  /**
>  * An abstract base class for implementing simple authorization of Pages. Users should override
> @@ -35,7 +35,7 @@ public abstract class AbstractPageAuthor
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>         *      org.apache.wicket.authorization.Action)
>         */
> -       public boolean isActionAuthorized(final Component component, final Action action)
> +       public boolean isActionAuthorized(final IRequestableComponent component, final Action action)
>        {
>                return true;
>        }
> @@ -44,7 +44,7 @@ public abstract class AbstractPageAuthor
>         * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>         */
>        @SuppressWarnings("unchecked")
> -       public final <T extends Component> boolean isInstantiationAuthorized(
> +       public final <T extends IRequestableComponent> boolean isInstantiationAuthorized(
>                final Class<T> componentClass)
>        {
>                if (instanceOf(componentClass, Page.class))
>
> Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/AuthorizationTest.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/AuthorizationTest.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/test/java/org/apache/wicket/AuthorizationTest.java (original)
> +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/AuthorizationTest.java Fri Oct 22 18:46:27 2010
> @@ -27,6 +27,7 @@ import org.apache.wicket.markup.html.bas
>  import org.apache.wicket.markup.html.form.Form;
>  import org.apache.wicket.markup.html.form.TextField;
>  import org.apache.wicket.model.CompoundPropertyModel;
> +import org.apache.wicket.request.component.IRequestableComponent;
>
>
>  /**
> @@ -53,11 +54,12 @@ public class AuthorizationTest extends W
>         */
>        public void testCreateDisallowedComponent() throws Exception
>        {
> -               tester.getApplication().getSecuritySettings().setAuthorizationStrategy(
> -                       new DummyAuthorizationStrategy()
> +               tester.getApplication()
> +                       .getSecuritySettings()
> +                       .setAuthorizationStrategy(new DummyAuthorizationStrategy()
>                        {
>                                @Override
> -                               public <T extends Component> boolean isInstantiationAuthorized(
> +                               public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
>                                        Class<T> componentClass)
>                                {
>                                        return false;
> @@ -82,8 +84,9 @@ public class AuthorizationTest extends W
>         */
>        public void testRenderAllowedComponent() throws Exception
>        {
> -               tester.getApplication().getSecuritySettings().setAuthorizationStrategy(
> -                       new DummyAuthorizationStrategy());
> +               tester.getApplication()
> +                       .getSecuritySettings()
> +                       .setAuthorizationStrategy(new DummyAuthorizationStrategy());
>
>                tester.startPage(AuthTestPage1.class);
>                tester.assertRenderedPage(AuthTestPage1.class);
> @@ -97,15 +100,16 @@ public class AuthorizationTest extends W
>         */
>        public void testRenderDisallowedComponent() throws Exception
>        {
> -               tester.getApplication().getSecuritySettings().setAuthorizationStrategy(
> -                       new DummyAuthorizationStrategy()
> +               tester.getApplication()
> +                       .getSecuritySettings()
> +                       .setAuthorizationStrategy(new DummyAuthorizationStrategy()
>                        {
>                                /**
>                                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                                 *      org.apache.wicket.authorization.Action)
>                                 */
>                                @Override
> -                               public boolean isActionAuthorized(Component component, Action action)
> +                               public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                                {
>                                        if (action == Component.RENDER && component instanceof Label)
>                                        {
> @@ -126,8 +130,9 @@ public class AuthorizationTest extends W
>         */
>        public void testEnabledAllowedComponent() throws Exception
>        {
> -               tester.getApplication().getSecuritySettings().setAuthorizationStrategy(
> -                       new DummyAuthorizationStrategy());
> +               tester.getApplication()
> +                       .getSecuritySettings()
> +                       .setAuthorizationStrategy(new DummyAuthorizationStrategy());
>
>                tester.startPage(AuthTestPage1.class);
>                tester.assertRenderedPage(AuthTestPage1.class);
> @@ -148,15 +153,16 @@ public class AuthorizationTest extends W
>         */
>        public void testEnabledDisallowedComponent() throws Exception
>        {
> -               tester.getApplication().getSecuritySettings().setAuthorizationStrategy(
> -                       new DummyAuthorizationStrategy()
> +               tester.getApplication()
> +                       .getSecuritySettings()
> +                       .setAuthorizationStrategy(new DummyAuthorizationStrategy()
>                        {
>                                /**
>                                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                                 *      org.apache.wicket.authorization.Action)
>                                 */
>                                @Override
> -                               public boolean isActionAuthorized(Component c, Action action)
> +                               public boolean isActionAuthorized(IRequestableComponent c, Action action)
>                                {
>                                        if (action == Component.ENABLE && c instanceof TextField &&
>                                                c.getId().equals("stringInput"))
> @@ -168,9 +174,7 @@ public class AuthorizationTest extends W
>                        });
>                tester.startPage(AuthTestPage1.class);
>                tester.assertRenderedPage(AuthTestPage1.class);
> -               tester.getRequest()
> -                       .getPostParameters()
> -                       .setParameterValue("form:stringInput", "test");
> +               tester.getRequest().getPostParameters().setParameterValue("form:stringInput", "test");
>                try
>                {
>                        tester.submitForm("form");
> @@ -191,7 +195,8 @@ public class AuthorizationTest extends W
>                /**
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>                 */
> -               public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +               public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +                       Class<T> componentClass)
>                {
>                        return true;
>                }
> @@ -200,7 +205,7 @@ public class AuthorizationTest extends W
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                 *      org.apache.wicket.authorization.Action)
>                 */
> -               public boolean isActionAuthorized(Component c, Action action)
> +               public boolean isActionAuthorized(IRequestableComponent c, Action action)
>                {
>                        return true;
>                }
>
> Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java (original)
> +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabledTest.java Fri Oct 22 18:46:27 2010
> @@ -25,6 +25,7 @@ import org.apache.wicket.mock.MockApplic
>  import org.apache.wicket.protocol.http.WebSession;
>  import org.apache.wicket.request.Request;
>  import org.apache.wicket.request.Response;
> +import org.apache.wicket.request.component.IRequestableComponent;
>  import org.apache.wicket.util.tester.WicketTester;
>
>  /**
> @@ -44,7 +45,7 @@ public class AjaxBehaviorEnabledTest ext
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                 *      org.apache.wicket.authorization.Action)
>                 */
> -               public boolean isActionAuthorized(Component component, Action action)
> +               public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                {
>                        if (action == Component.ENABLE && component.getId().endsWith("disabled"))
>                        {
> @@ -57,7 +58,8 @@ public class AjaxBehaviorEnabledTest ext
>                 *
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>                 */
> -               public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass)
> +               public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +                       Class<T> componentClass)
>                {
>                        return true;
>                }
> @@ -113,8 +115,8 @@ public class AjaxBehaviorEnabledTest ext
>                tester.assertVisible("enabled");
>                tester.assertVisible("disabled");
>                assertTrue(tester.getTagByWicketId("enabled").hasAttribute("onclick"));
> -               assertFalse("disabled behaviors should not generate onclick", tester.getTagByWicketId(
> -                       "disabled").hasAttribute("onclick"));
> +               assertFalse("disabled behaviors should not generate onclick",
> +                       tester.getTagByWicketId("disabled").hasAttribute("onclick"));
>
>        }
>
>
> Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java (original)
> +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/login/InterceptTest.java Fri Oct 22 18:46:27 2010
> @@ -18,7 +18,6 @@ package org.apache.wicket.markup.html.fo
>
>  import junit.framework.TestCase;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.Page;
>  import org.apache.wicket.RestartResponseAtInterceptPageException;
>  import org.apache.wicket.Session;
> @@ -28,6 +27,7 @@ import org.apache.wicket.mock.MockApplic
>  import org.apache.wicket.protocol.http.WebSession;
>  import org.apache.wicket.request.Request;
>  import org.apache.wicket.request.Response;
> +import org.apache.wicket.request.component.IRequestableComponent;
>  import org.apache.wicket.util.string.Strings;
>  import org.apache.wicket.util.tester.FormTester;
>  import org.apache.wicket.util.tester.WicketTester;
> @@ -208,7 +208,8 @@ public class InterceptTest extends TestC
>                /**
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
>                 */
> -               public boolean isInstantiationAuthorized(Class componentClass)
> +               public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
> +                       Class<T> componentClass)
>                {
>                        if (MockHomePage.class.equals(componentClass) &&
>                                !((MySession)Session.get()).isLoggedIn())
> @@ -222,7 +223,7 @@ public class InterceptTest extends TestC
>                 * @see org.apache.wicket.authorization.IAuthorizationStrategy#isActionAuthorized(org.apache.wicket.Component,
>                 *      org.apache.wicket.authorization.Action)
>                 */
> -               public boolean isActionAuthorized(Component component, Action action)
> +               public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                {
>                        return true;
>                }
>
> Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java
> URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java?rev=1026443&r1=1026442&r2=1026443&view=diff
> ==============================================================================
> --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java (original)
> +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/intercept/InterceptTest.java Fri Oct 22 18:46:27 2010
> @@ -16,13 +16,13 @@
>  */
>  package org.apache.wicket.redirect.intercept;
>
> -import org.apache.wicket.Component;
>  import org.apache.wicket.Page;
>  import org.apache.wicket.RestartResponseAtInterceptPageException;
>  import org.apache.wicket.WicketTestCase;
>  import org.apache.wicket.authorization.Action;
>  import org.apache.wicket.authorization.IAuthorizationStrategy;
>  import org.apache.wicket.mock.MockApplication;
> +import org.apache.wicket.request.component.IRequestableComponent;
>  import org.apache.wicket.util.tester.WicketTester;
>
>  /**
> @@ -50,12 +50,12 @@ public class InterceptTest extends Wicke
>
>                                        private boolean block = true;
>
> -                                       public boolean isActionAuthorized(Component component, Action action)
> +                                       public boolean isActionAuthorized(IRequestableComponent component, Action action)
>                                        {
>                                                return true;
>                                        }
>
> -                                       public <T extends Component> boolean isInstantiationAuthorized(
> +                                       public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
>                                                Class<T> componentClass)
>                                        {
>                                                if (block &&
>
>
>

Re: svn commit: r1026443 - in /wicket/trunk: wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/ wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/ wicket-examples/src/ma

Posted by Martin Grigorov <mg...@apache.org>.
done
r1026462

On Fri, Oct 22, 2010 at 9:22 PM, Martin Grigorov <mg...@apache.org>wrote:

> ok, I'll revert that part of the change
> thanks for reviewing!
>
>
> On Fri, Oct 22, 2010 at 9:12 PM, Jeremy Thomerson <
> jeremy@wickettraining.com> wrote:
>
>> On Fri, Oct 22, 2010 at 2:09 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>> >wrote:
>>
>> > i think only the isinstantiationauthorized should use class<? extends
>> > irequestablecomponent>
>> >
>> > everything else - that gets a concrete instance - should get
>> > Component. reason being auth strategy often accesses metadata on
>> > component to figure out allowed roles, etc. so either we add metadata
>> > to irequestablecomponent - which is weird since there is nothing
>> > requestable about it, or we change it back to use concrete Component.
>> > im in favor of the latter.
>> >
>> > -igor
>> >
>>
>> I agree with Igor.  I actually just replied to this commit as well, but
>> only
>> to the commits@ list, which bounced.
>>
>> --
>> Jeremy Thomerson
>> http://wickettraining.com
>> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>>
>
>

Re: svn commit: r1026443 - in /wicket/trunk: wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/ wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/ wicket-examples/src/ma

Posted by Martin Grigorov <mg...@apache.org>.
ok, I'll revert that part of the change
thanks for reviewing!

On Fri, Oct 22, 2010 at 9:12 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> On Fri, Oct 22, 2010 at 2:09 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
>
> > i think only the isinstantiationauthorized should use class<? extends
> > irequestablecomponent>
> >
> > everything else - that gets a concrete instance - should get
> > Component. reason being auth strategy often accesses metadata on
> > component to figure out allowed roles, etc. so either we add metadata
> > to irequestablecomponent - which is weird since there is nothing
> > requestable about it, or we change it back to use concrete Component.
> > im in favor of the latter.
> >
> > -igor
> >
>
> I agree with Igor.  I actually just replied to this commit as well, but
> only
> to the commits@ list, which bounced.
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>

Re: svn commit: r1026443 - in /wicket/trunk: wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/annotations/ wicket-auth-roles/src/main/java/org/apache/wicket/authorization/strategies/role/metadata/ wicket-examples/src/ma

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Fri, Oct 22, 2010 at 2:09 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> i think only the isinstantiationauthorized should use class<? extends
> irequestablecomponent>
>
> everything else - that gets a concrete instance - should get
> Component. reason being auth strategy often accesses metadata on
> component to figure out allowed roles, etc. so either we add metadata
> to irequestablecomponent - which is weird since there is nothing
> requestable about it, or we change it back to use concrete Component.
> im in favor of the latter.
>
> -igor
>

I agree with Igor.  I actually just replied to this commit as well, but only
to the commits@ list, which bounced.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*