List of usage examples for org.apache.wicket.authorization Action equals
@Override public boolean equals(final Object obj)
From source file:com.userweave.application.UserWeaveAuthorizationStrategy.java
License:Open Source License
public boolean isActionAuthorized(Component component, Action action) { if (action.equals(Component.RENDER)) { Class<? extends Component> c = component.getClass(); AdminOnly adminOnly = c.getAnnotation(AdminOnly.class); if (adminOnly != null) { return UserWeaveSession.get().isAdmin(); }/*from w w w .ja v a 2 s.c om*/ /** * To set the state of an AuthOnlyTextComponent * may be stupid here, but there is currently * no other option. */ if (component instanceof IAuthOnly) { IAuthOnly comp = (IAuthOnly) component; User user = UserWeaveSession.get().getUser(); AuthorizeAction authAction = comp.getClass().getAnnotation(AuthorizeAction.class); boolean auth = false; if (authAction == null) { // if no annotation is given, admins and participants // have access auth = user.hasRole(Role.PROJECT_ADMIN) || user.hasRole(Role.PROJECT_PARTICIPANT); } else { // evaluate annotation roles auth = user.hasAnyRole(new Roles(authAction.roles())); } comp.setIsAuthorized(auth || user.isAdmin()); return true; } } if (action.equals(Component.ENABLE)) { AuthorizeAction authAction = component.getClass().getAnnotation(AuthorizeAction.class); if (authAction != null) { User user = UserWeaveSession.get().getUser(); boolean isEnabled = user.hasAnyRole(new Roles(authAction.roles())); if (!isEnabled) { if (component instanceof IToolTipComponent) { ((IToolTipComponent) component).setToolTipType(ToolTipType.RIGHTS); } } return isEnabled && component.isEnabled(); } return true; } return true; }
From source file:com.visural.wicket.security.AuthorizationStrategy.java
License:Apache License
public boolean isActionAuthorized(Component com, Action action) { if (action.equals(Component.ENABLE) && ISecureEnableInstance.class.isAssignableFrom(com.getClass())) { if (!((ISecureEnableInstance) com).getEnablePrivilege() .isGrantedToClient(clientProvider.getCurrentClient())) { return false; }/*from w ww. j a v a 2 s . co m*/ } if (action.equals(Component.RENDER) && ISecureRenderInstance.class.isAssignableFrom(com.getClass())) { if (!((ISecureRenderInstance) com).getRenderPrivilege() .isGrantedToClient(clientProvider.getCurrentClient())) { return false; } } return true; }
From source file:rzd.vivc.ideax.wicket.autorization.XAutorisationStrategy.java
@Override public boolean isActionAuthorized(Component cmpnt, Action action) { //? ?. /* w w w.ja va 2 s . c o m*/ if (action.equals(Component.RENDER)) { Class<? extends Component> c = cmpnt.getClass(); DirectorOnly directorOnly = c.getAnnotation(DirectorOnly.class); if (directorOnly != null) { UserSession sess = UserSession.get(); return sess.isAuthenticated() && sess.getUser().isDirector(); } } return true; }