Package org.structr.core.entity

Examples of org.structr.core.entity.ResourceAccess


    final long initialFlagsValue             = 0;

    final App app = StructrApp.getInstance();
    try {

      ResourceAccess grant = app.nodeQuery(ResourceAccess.class).and(ResourceAccess.signature, signature).getFirst();
      if (grant == null) {

        // create new grant
        grants.add(app.create(DynamicResourceAccess.class,
          new NodeAttribute(DynamicResourceAccess.signature, signature),
View Full Code Here


  @Override
  public void checkResourceAccess(final HttpServletRequest request, final String rawResourceSignature, final String propertyView)
    throws FrameworkException {

    ResourceAccess resourceAccess = ResourceAccess.findGrant(rawResourceSignature);

    Method method       = methods.get(request.getMethod());

    Principal user = getUser(request, true);
    boolean validUser = (user != null);

    // super user is always authenticated
    if (validUser && (user instanceof SuperUser || user.getProperty(Principal.isAdmin))) {
      return;
    }

    // no grants => no access rights
    if (resourceAccess == null) {

      throw new UnauthorizedException("Forbidden");

    } else {

      switch (method) {

        case GET :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_GET)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_GET)) {

            return;

          }

          break;

        case PUT :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_PUT)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_PUT)) {

            return;

          }

          break;

        case POST :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_POST)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_POST)) {

            return;

          }

          break;

        case DELETE :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_DELETE)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_DELETE)) {

            return;

          }

          break;

        case OPTIONS :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_OPTIONS)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_OPTIONS)) {

            return;

          }

          break;

        case HEAD :

          if (!validUser && resourceAccess.hasFlag(NON_AUTH_USER_HEAD)) {

            return;

          }

          if (validUser && resourceAccess.hasFlag(AUTH_USER_HEAD)) {

            return;

          }
View Full Code Here

TOP

Related Classes of org.structr.core.entity.ResourceAccess

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.