List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Authorizes the given roles to create component instances of type * componentClass. This authorization is added to any previously authorized * roles.//from w w w. ja v a 2s.c o m * * @param <T> * * @param componentClass The component type that is subject for the * authorization * @param roles The roles that are authorized to create component instances * of type componentClass */ private static <T extends Component> void authorize(final Class<T> componentClass, final Role... roles) { final Application application = Application.get(); InstantiationPermissions permissions = application.getMetaData(INSTANTIATION_PERMISSIONS); if (permissions == null) { permissions = new InstantiationPermissions(); application.setMetaData(INSTANTIATION_PERMISSIONS, permissions); } permissions.authorize(componentClass, roles); }
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Grants permission to all roles to create instances of the given component * class.//from w ww . j a va2 s. c o m * * @param <T> * * @param componentClass The component class */ private static <T extends Component> void authorizeAll(final Class<T> componentClass) { Application application = Application.get(); InstantiationPermissions authorizedLevels = application.getMetaData(INSTANTIATION_PERMISSIONS); if (authorizedLevels != null) { authorizedLevels.authorizeAll(componentClass); } }
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Removes permission for the given roles to create instances of the given * component class. There is no danger in removing authorization by calling * this method. If the last authorization grant is removed for a given * componentClass, the internal level Role.NoRole will automatically be * added, effectively denying access to all roles (if this was not done, all * levels would suddenly have access since no authorization is equivalent to * full access)./* w w w . j a v a2 s . c o m*/ * * @param <T> * * @param componentClass The component type * @param roles The set of roles that are no longer to be authorized to * create instances of type componentClass */ private static <T extends Component> void unauthorize(final Class<T> componentClass, final Role... roles) { final InstantiationPermissions permissions = Application.get().getMetaData(INSTANTIATION_PERMISSIONS); if (permissions != null) { permissions.unauthorize(componentClass, roles); } }
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Gets the roles for creation of the given component class, or null if * none were registered.//from ww w. j av a2s.c o m * * @param <T> * * @param componentClass the component class * @return the roles that are authorized for creation of the * componentClass, or null if no specific authorization was configured */ private static <T extends IRequestableComponent> EnumSet<Role> rolesAuthorizedToInstantiate( final Class<T> componentClass) { final InstantiationPermissions permissions = Application.get().getMetaData(INSTANTIATION_PERMISSIONS); if (permissions != null) { return permissions.authorizedRoles(componentClass); } return null; }
From source file:fi.ilmoeuro.membertrack.ui.MtApplication.java
License:Open Source License
@SuppressWarnings("unchecked") public static MtApplication get() { try {//from w w w . j av a 2 s . co m return (MtApplication) Application.get(); } catch (ClassCastException ex) { String error = "Called get() from wrong app"; log.error(error, ex); throw new RuntimeException(error, ex); } }
From source file:fiftyfive.wicket.js.JavaScriptDependencySettings.java
License:Apache License
/** * Returns the JavaScriptDependencySettings associated with the current * Wicket Application, creating a new default settings object if one does * not yet exist. This method can only be called within a Wicket thread. *///from w w w .ja va 2s . c om public static JavaScriptDependencySettings get() { Application app = Application.get(); if (null == app) { throw new IllegalStateException("No thread-local Wicket Application object was found. " + "JavaScriptDependencySettings.get() can only be called " + "within a Wicket request."); } JavaScriptDependencySettings settings = app.getMetaData(SETTINGS_KEY); if (null == settings) { settings = new JavaScriptDependencySettings(app); app.setMetaData(SETTINGS_KEY, settings); } return settings; }
From source file:fiftyfive.wicket.js.locator.DefaultJavaScriptDependencyLocator.java
License:Apache License
/** * Loads the given ResourceReference as an IResourceStream or returns * {@code null} if the resource could not be found. *//*www .j a v a 2 s . co m*/ private IResourceStream load(ResourceReference ref) { IResourceStreamLocator locator = Application.get().getResourceSettings().getResourceStreamLocator(); Class<?> scope = ref.getScope(); String path = Packages.absolutePath(scope, ref.getName()); return locator.locate(scope, path); }
From source file:fiftyfive.wicket.link.HomeLink.java
License:Apache License
public HomeLink(String id) { super(id, Application.get().getHomePage()); }
From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java
License:Apache License
/** * Returns the {@code ShiroWicketPlugin} instance that has been installed * in the current Wicket application. This is a convenience method that * only works within a Wicket thread, and it assumes that * {@link #install install()} has already been called. * /* ww w. ja va 2 s.c o m*/ * @throws IllegalStateException if there is no Wicket application bound * to the current thread, or if a * {@code ShiroWicketPlugin} has not been * installed. */ public static ShiroWicketPlugin get() { Application app = Application.get(); if (null == app) { throw new IllegalStateException("No wicket application is bound to the current thread."); } ShiroWicketPlugin plugin = app.getMetaData(PLUGIN_KEY); if (null == plugin) { throw new IllegalStateException("A ShiroWicketPlugin has not been installed in this Wicket " + "application. You must call ShiroWicketPlugin.install() in " + "your application init()."); } return plugin; }
From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java
License:Apache License
/** * The page class that was set via {@link #setUnauthorizedPage}; otherwise the * application home page.//ww w . j a va 2 s . c o m */ public Class<? extends Page> getUnauthorizedPage() { return unauthorizedPage != null ? unauthorizedPage : Application.get().getHomePage(); }