Package org.jboss.errai.security.shared.api.annotation

Examples of org.jboss.errai.security.shared.api.annotation.RestrictedAccess


  @Override
  public List<? extends Statement> generateDecorator(InjectableInstance<Page> ctx) {
    final List<Statement> stmts = new ArrayList<Statement>();

    if (ctx.getInjector().getInjectedType().isAnnotationPresent(RestrictedAccess.class)) {
      final RestrictedAccess annotation = ctx.getAnnotation(RestrictedAccess.class);
      final String roleListenerVar = ctx.getInjector().getInstanceVarName() + "_roleListener";
      ctx.getTargetInjector().addStatementToEndOfInjector(
              Stmt.declareFinalVariable(
                      roleListenerVar,
                      MetaClassFactory.parameterizedAs(LifecycleListener.class,
View Full Code Here


            && Arrays.equals(searchMethod.getParameterTypes(), method.getParameterTypes());
  }

  private void addRestrictedAccessIfPresent(final AnnotatedElement annotated,
          final Collection<RestrictedAccess> annotations) {
    final RestrictedAccess annotation = annotated.getAnnotation(RestrictedAccess.class);
    if (annotation != null) {
      annotations.add(annotation);
    }
  }
View Full Code Here

  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final RestrictedAccess annotation = getRestrictedAccessAnnotation(context.getTarget().getClass(), context.getMethod());
    if (user == null) {
      throw new UnauthenticatedException();
    }
    else if (!hasAllRoles(user.getRoles(), annotation.roles())) {
      throw new UnauthorizedException();
    } else {
      return context.proceed();
    }
  }
View Full Code Here

      return context.proceed();
    }
  }

  private RestrictedAccess getRestrictedAccessAnnotation(Class<?> aClass, Method method) {
    RestrictedAccess annotation = getRestrictedAccessAnnotation(method.getAnnotations());
    if (annotation != null) {
      return annotation;
    }

    Class<?>[] interfaces = aClass.getInterfaces();
View Full Code Here

    return annotation;
  }

  private RestrictedAccess getRestrictedAccess(Class<?> aClass, Method searchMethod) {
    for (Method method : aClass.getMethods()) {
      final RestrictedAccess annotation = getRestrictAccess(searchMethod, method);
      if (annotation != null) {
        return annotation;
      }
    }
View Full Code Here

    return null;
  }

  private RestrictedAccess getRestrictAccess(Method searchMethod, Method method) {
    RestrictedAccess requiredRoles = null;

    if (searchMethod.getName().equals(method.getName())
            && Arrays.equals(searchMethod.getParameterTypes(), method.getParameterTypes())) {
      requiredRoles = getRestrictedAccessAnnotation(method.getAnnotations());
    }
View Full Code Here

  @Override
  public List<? extends Statement> generateDecorator(InjectableInstance<Page> ctx) {
    final List<Statement> stmts = new ArrayList<Statement>();

    if (ctx.getInjector().getInjectedType().isAnnotationPresent(RestrictedAccess.class)) {
      final RestrictedAccess annotation = ctx.getAnnotation(RestrictedAccess.class);
      final String roleListenerVar = ctx.getInjector().getInstanceVarName() + "_roleListener";
      ctx.getTargetInjector().addStatementToEndOfInjector(
              Stmt.declareFinalVariable(
                      roleListenerVar,
                      MetaClassFactory.parameterizedAs(LifecycleListener.class,
View Full Code Here

  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final RestrictedAccess annotation = getRestrictedAccessAnnotation(context.getTarget().getClass(),
            context.getMethod());
    if (User.ANONYMOUS.equals(user)) {
      throw new UnauthenticatedException();
    }
    else if (!user.hasAllRoles(annotation.roles())) {
      throw new UnauthorizedException();
    }
    else {
      return context.proceed();
    }
View Full Code Here

      return context.proceed();
    }
  }

  private RestrictedAccess getRestrictedAccessAnnotation(Class<?> aClass, Method method) {
    RestrictedAccess annotation = method.getAnnotation(RestrictedAccess.class);
    if (annotation != null) {
      return annotation;
    }

    annotation = method.getDeclaringClass().getAnnotation(RestrictedAccess.class);
View Full Code Here

    return annotation;
  }

  private RestrictedAccess getRestrictedAccess(Class<?> aClass, Method searchMethod) {
    for (Method method : aClass.getMethods()) {
      final RestrictedAccess annotation = getRestrictAccess(searchMethod, method);
      if (annotation != null) {
        return annotation;
      }
    }
View Full Code Here

TOP

Related Classes of org.jboss.errai.security.shared.api.annotation.RestrictedAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.