本文整理汇总了Java中org.apache.wicket.request.component.IRequestableComponent类的典型用法代码示例。如果您正苦于以下问题:Java IRequestableComponent类的具体用法?Java IRequestableComponent怎么用?Java IRequestableComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IRequestableComponent类属于org.apache.wicket.request.component包,在下文中一共展示了IRequestableComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
if (componentClass == CmsPage.class) {
RequestCycle requestCycle = RequestCycle.get();
String pageId = requestCycle.getRequest().getQueryParameters().getParameterValue("pageId").toString("");
PageRoleTable pageRoleTable = Tables.PAGE_ROLE.as("pageRoleTable");
RoleTable roleTable = Tables.ROLE.as("roleTable");
DSLContext context = Spring.getBean(DSLContext.class);
List<String> roles = context.select(roleTable.NAME).from(roleTable).innerJoin(pageRoleTable).on(roleTable.ROLE_ID.eq(pageRoleTable.ROLE_ID)).where(pageRoleTable.PAGE_ID.eq(pageId)).fetchInto(String.class);
Roles r = new Roles();
if (roles != null && !roles.isEmpty()) {
r.addAll(roles);
}
return hasAny(r);
} else {
return super.isInstantiationAuthorized(componentClass);
}
}
示例2: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
final AuthorizeInstantiationIfPermission authorizeInstantiationAnnotation =
componentClass.getAnnotation(AuthorizeInstantiationIfPermission.class);
if (authorizeInstantiationAnnotation != null) {
String[] permissionNames = authorizeInstantiationAnnotation.permissions();
for (String permissionName : permissionNames) {
Permission permission = permissionFactory.buildFromName(permissionName);
if (authenticationService.hasPermission(permission)) {
return true;
}
}
return false;
}
return true;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:18,代码来源:AnnotationsPermissionAuthorizationStrategy.java
示例3: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
// if it's not a wicket page --> allow
if (!Page.class.isAssignableFrom(componentClass)) {
return true;
}
// if it's a page that does not require authentication --> allow
for (Class<? extends WebPage> clazz : PAGES_WO_AUTH_REQ) {
if (clazz.isAssignableFrom(componentClass)) {
return true;
}
}
// if it's any other wicket page and user is not logged in -->
// redirect to login page
if (!((UQSession) Session.get()).isAuthenticated()) {
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
return true;
}
示例4: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
*/
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
// We are authorized unless we are found not to be
boolean authorized = true;
// Check class annotation first because it is more specific than package
// annotation
final AuthorizeInstantiation classAnnotation = componentClass.getAnnotation(AuthorizeInstantiation.class);
if (classAnnotation != null) {
authorized = hasAny(classAnnotation.value());
} else {
// Check package annotation if there is no one on the the class
final Package componentPackage = componentClass.getPackage();
if (componentPackage != null) {
final AuthorizeInstantiation packageAnnotation = componentPackage.getAnnotation(AuthorizeInstantiation.class);
if (packageAnnotation != null) {
authorized = hasAny(packageAnnotation.value());
}
}
}
return authorized;
}
示例5: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* Uses application level meta data to match levels for component
* instantiation.
*
* @see
* org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
*/
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
if (componentClass == null) {
throw new IllegalArgumentException("argument componentClass cannot be null");
}
// as long as the interface does not use generics, we should check this
if (!Component.class.isAssignableFrom(componentClass)) {
throw new IllegalArgumentException("argument componentClass must be of type " + Component.class.getName());
}
final EnumSet<Role> roles = rolesAuthorizedToInstantiate(componentClass);
if (roles != null) {
return hasAny(roles);
}
return true;
}
示例6: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* Uses application level meta data to match roles for component
* instantiation.
*
* @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
*/
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
if (componentClass == null) {
throw new IllegalArgumentException("argument componentClass cannot be null");
}
// as long as the interface does not use generics, we should check this
if (!Component.class.isAssignableFrom(componentClass)) {
throw new IllegalArgumentException("argument componentClass must be of type " + Component.class.getName());
}
final Roles roles = rolesAuthorizedToInstantiate(componentClass);
if (roles != null) {
return hasAny(roles);
}
return true;
}
示例7: onRequestHandlerResolved
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public void onRequestHandlerResolved(final RequestCycle cycle,
final IRequestHandler handler) {
if (cycle.getMetaData(FIRST_HANDLER)) {
cycle.setMetaData(FIRST_HANDLER, false);
final StringBuilder s = new StringBuilder();
if (handler instanceof IComponentRequestHandler) {
final IRequestableComponent c = ((IComponentRequestHandler) handler).getComponent();
s.append('/');
s.append(pageClassToPath(c.getPage().getClass()));
s.append('/');
s.append(componentToPath(c));
} else if (handler instanceof IPageClassRequestHandler) {
s.append('/');
s.append(pageClassToPath(((IPageClassRequestHandler) handler).getPageClass()));
} else {
NewRelic.ignoreTransaction();
return;
}
NewRelic.setTransactionName(null, s.toString());
}
}
示例8: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
Class<T> componentClass) {
if(!Page.class.isAssignableFrom(componentClass)){
return true;
}
if(RegisterPage.class.isAssignableFrom(componentClass)){
return true;
}
if(LogoutPage.class.isAssignableFrom(componentClass)){
return true;
}
if(LoginPage.class.isAssignableFrom(componentClass)){
return true;
}
@SuppressWarnings("rawtypes")
UserSession session = (UserSession)Session.get();
if(session.getUser().isAnonymous){
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
return true;
}
示例9: setAuthorizationStrategy
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* Initializes the authorization strategy for the web application. Pages,
* which implement the {@link AuthenticatedWebPage} interface, are only
* accessible for authenticated users.
*/
private void setAuthorizationStrategy() {
this.getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() {
@Override
public boolean isActionAuthorized(final Component component, final Action action) {
// authorize everything
return true;
}
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass) {
// Check if the new Page requires authentication
// (implements the marker interface)
if (AuthenticatedWebPage.class.isAssignableFrom(componentClass)) {
// Is user signed in?
if (((AuthenticatedSession) Session.get()).isSignedIn()) {
// okay to proceed
return true;
}
// Intercept the request, but remember the target
// for later.
// Invoke Component.continueToOriginalDestination()
// after successful logon to
// continue with the target remembered.
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
// okay to proceed
return true;
}
});
}
示例10: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
Class<T> componentClass) {
if(Page.class.isAssignableFrom(componentClass))
{
RequiredOrientResource[] resources = getRequiredOrientResources(componentClass);
return resources!=null?checkResources(resources, Component.RENDER):true;
}
else
{
return true;
}
}
示例11: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
if (!hasSpringSecuredAnnotation(componentClass)) {
return true;
}
boolean authorized = isAuthorized(componentClass);
if (Page.class.isAssignableFrom(componentClass) && !authorized) {
String missingPermissions = ArrayUtils.toString(componentClass.getAnnotation(Secured.class).value());
Session.get().error("Zugriff verweigert fehlende Berechtigung(en): " + missingPermissions);
throw new RestartResponseAtInterceptPageException(LoginPage.class);
}
return authorized;
}
示例12: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
final RolesAllowed classAnnotation = componentClass.getAnnotation(RolesAllowed.class);
boolean authorized = true;
if (classAnnotation != null) {
authorized = securityService.hasAnyRole(classAnnotation.value());
}
return authorized;
}
示例13: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* @see org.apache.wicket.authorization.IAuthorizationStrategy#isInstantiationAuthorized(java.lang.Class)
*/
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(final Class<T> componentClass)
{ if (WebPage.class.isAssignableFrom(componentClass) == true) {
if (MySession.get().isAuthenticated() == true) {
return true;
}
if (AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true
|| AbstractSecuredBasePage.class.isAssignableFrom(componentClass) == true
|| AbstractSecuredMobilePage.class.isAssignableFrom(componentClass) == true) {
return false;
}
}
return true;
}
示例14: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
final Class<T> componentClass)
{
if (!Page.class.isAssignableFrom(componentClass))
{
return true;
}
return onInstantiationAuthorized(componentClass);
}
开发者ID:astrapi69,项目名称:wicket.component.authorization.strategy,代码行数:14,代码来源:ComponentAuthorizationStrategy.java
示例15: isInstantiationAuthorized
import org.apache.wicket.request.component.IRequestableComponent; //导入依赖的package包/类
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
return true;
}