Package org.jboss.errai.bus.server.security.auth.rules

Examples of org.jboss.errai.bus.server.security.auth.rules.RolesRequiredRule


                                    }

                                    // Subscribe the service to the bus.
                                    bus.subscribe(svcName, (MessageCallback) svc);

                                    RolesRequiredRule rule = null;
                                    if (clazz.isAnnotationPresent(RequireRoles.class)) {
                                        rule = new RolesRequiredRule(clazz.getAnnotation(RequireRoles.class).value(), bus);
                                    }
                                    else if (clazz.isAnnotationPresent(RequireAuthentication.class)) {
                                        rule = new RolesRequiredRule(new HashSet<Object>(), bus);
                                    }
                                    if (rule != null) {
                                        bus.addRule(svcName, rule);
                                    }
                                }

                                if (svc == null) {
                                    svc = Guice.createInjector(new AbstractModule() {
                                        @Override
                                        protected void configure() {
                                            bind(MessageBus.class).toInstance(bus);
                                            bind(RequestDispatcher.class).toInstance(dispatcher);

                                            // Add any extension bindings.
                                            for (Map.Entry<Class, Provider> entry : extensionBindings.entrySet()) {
                                                bind(entry.getKey()).toProvider(entry.getValue());
                                            }
                                        }
                                    }).getInstance(loadClass);
                                }

                                Map<String, MessageCallback> epts = new HashMap<String, MessageCallback>();


                                // we scan for endpoints
                                for (final Method method : loadClass.getDeclaredMethods()) {
                                    if (method.isAnnotationPresent(Endpoint.class)) {
                                        epts.put(method.getName(), method.getReturnType() == Void.class ?
                                                new EndpointCallback(svc, method) :
                                                new ConversationalEndpointCallback(svc, method, bus));
                                    }
                                }

                                if (!epts.isEmpty()) {
                                    bus.subscribe(loadClass.getSimpleName() + ":RPC", new RemoteServiceCallback(epts));
                                }

                            }
                            else if (loadClass.isAnnotationPresent(ExposeEntity.class)) {
                                log.info("Marked " + loadClass + " as serializable.");
                                loadedComponents.add(loadClass.getName());
                                serializableTypes.add(loadClass);
                            }
                        }
                    }
            );
        }
        else {
            log.info("auto-scan disabled.");
        }

        String requireAuthenticationForAll = "errai.require_authentication_for_all";

        if (hasProperty(requireAuthenticationForAll) && "true".equals(getProperty(requireAuthenticationForAll))) {
            log.info("authentication for all requests required, adding rule ... ");
            bus.addRule("AuthorizationService", new RolesRequiredRule(new HashSet<Object>(), bus));
        }

        ConfigUtil.cleanupStartupTempFiles();

        log.info("running deferred configuration tasks ...");
View Full Code Here


                                    }

                                    // Subscribe the service to the bus.
                                    bus.subscribe(svcName, (MessageCallback) svc);

                                    RolesRequiredRule rule = null;
                                    if (clazz.isAnnotationPresent(RequireRoles.class)) {
                                        rule = new RolesRequiredRule(clazz.getAnnotation(RequireRoles.class).value(), bus);
                                    }
                                    else if (clazz.isAnnotationPresent(RequireAuthentication.class)) {
                                        rule = new RolesRequiredRule(new HashSet<Object>(), bus);
                                    }
                                    if (rule != null) {
                                        bus.addRule(svcName, rule);
                                    }
                                }

                                if (svc == null) {
                                    svc = Guice.createInjector(new AbstractModule() {
                                        @Override
                                        protected void configure() {
                                            bind(MessageBus.class).toInstance(bus);
                                            bind(RequestDispatcher.class).toInstance(dispatcher);

                                            // Add any extension bindings.
                                            for (Map.Entry<Class, Provider> entry : extensionBindings.entrySet()) {
                                                bind(entry.getKey()).toProvider(entry.getValue());
                                            }
                                        }
                                    }).getInstance(loadClass);
                                }

                                Map<String, MessageCallback> epts = new HashMap<String, MessageCallback>();


                                // we scan for endpoints
                                for (final Method method : loadClass.getDeclaredMethods()) {
                                    if (method.isAnnotationPresent(Endpoint.class)) {
                                        epts.put(method.getName(), method.getReturnType() == Void.class ?
                                                new EndpointCallback(svc, method) :
                                                new ConversationalEndpointCallback(svc, method, bus));
                                    }
                                }

                                if (!epts.isEmpty()) {
                                    bus.subscribe(loadClass.getSimpleName() + ":RPC", new RemoteServiceCallback(epts));
                                }

                            }
                            else if (loadClass.isAnnotationPresent(ExposeEntity.class)) {
                                log.info("Marked " + loadClass + " as serializable.");
                                loadedComponents.add(loadClass.getName());
                                serializableTypes.add(loadClass);
                            }
                        }
                    }
            );
        }
        else {
            log.info("auto-scan disabled.");
        }

        String requireAuthenticationForAll = "errai.require_authentication_for_all";

        if (hasProperty(requireAuthenticationForAll) && "true".equals(getProperty(requireAuthenticationForAll))) {
            log.info("authentication for all requests required, adding rule ... ");
            bus.addRule("AuthorizationService", new RolesRequiredRule(new HashSet<Object>(), bus));
        }

        ConfigUtil.cleanupStartupTempFiles();

        log.info("running deferred configuration tasks ...");
View Full Code Here

                    RuleDelegateMessageCallback ruleDelegate = (RuleDelegateMessageCallback) mc;
                    DefaultMutableTreeNode securityNode =
                            new DefaultMutableTreeNode("Security");

                    if (ruleDelegate.getRoutingRule() instanceof RolesRequiredRule) {
                        RolesRequiredRule rule = (RolesRequiredRule) ruleDelegate.getRoutingRule();

                        DefaultMutableTreeNode rolesNode =
                                new DefaultMutableTreeNode(rule.getRoles().isEmpty() ? "Requires Authentication" : "Roles Required");

                        for (Object o : rule.getRoles()) {
                            //     DefaultMutableTreeNode roleNode = new DefaultMutableTreeNode(String.valueOf(o));

                            rolesNode.add(createIconEntry("key.png", String.valueOf(o)));
                        }
View Full Code Here

          RuleDelegateMessageCallback ruleDelegate = (RuleDelegateMessageCallback) mc;
          DefaultMutableTreeNode securityNode =
              new DefaultMutableTreeNode("Security");

          if (ruleDelegate.getRoutingRule() instanceof RolesRequiredRule) {
            RolesRequiredRule rule = (RolesRequiredRule) ruleDelegate.getRoutingRule();

            DefaultMutableTreeNode rolesNode =
                new DefaultMutableTreeNode(rule.getRoles().isEmpty() ? "Requires Authentication" : "Roles Required");

            for (Object o : rule.getRoles()) {
              //     DefaultMutableTreeNode roleNode = new DefaultMutableTreeNode(String.valueOf(o));

              rolesNode.add(UiHelper.createIconEntry("key.png", valueOf(o)));
            }
View Full Code Here

    final ErraiServiceConfigurator config = context.getConfig();

    if (config.hasProperty(requireAuthenticationForAll) && "true".equals(config.getProperty(requireAuthenticationForAll))) {
      log.debug("authentication for all requests required, adding rule ... ");
      context.getBus().addRule("AuthorizationService", new RolesRequiredRule(new HashSet<Object>(), context.getBus()));
    }
  }
View Full Code Here

            }
          }
        }).getInstance(loadClass);
      }

      RolesRequiredRule rule = null;
      if (loadClass.isAnnotationPresent(RequireRoles.class)) {
        rule = new RolesRequiredRule(loadClass.getAnnotation(RequireRoles.class).value(), context.getBus());
      }
      else if (loadClass.isAnnotationPresent(RequireAuthentication.class)) {
        rule = new RolesRequiredRule(new HashSet<Object>(), context.getBus());
      }

      if (!commandPoints.isEmpty()) {
        if (local) {
          context.getBus().subscribeLocal(svcName, new CommandBindingsCallback(commandPoints, svc, context.getBus()));
View Full Code Here

          RuleDelegateMessageCallback ruleDelegate = (RuleDelegateMessageCallback) mc;
          DefaultMutableTreeNode securityNode =
                  new DefaultMutableTreeNode("Security");

          if (ruleDelegate.getRoutingRule() instanceof RolesRequiredRule) {
            RolesRequiredRule rule = (RolesRequiredRule) ruleDelegate.getRoutingRule();

            DefaultMutableTreeNode rolesNode =
                    new DefaultMutableTreeNode(rule.getRoles().isEmpty() ? "Requires Authentication" : "Roles Required");

            for (Object o : rule.getRoles()) {
              //     DefaultMutableTreeNode roleNode = new DefaultMutableTreeNode(String.valueOf(o));

              rolesNode.add(UiHelper.createIconEntry("key.png", valueOf(o)));
            }
View Full Code Here

    if (svc == null) {
      svc = createServiceInjector(loadClass, context, config, false);
    }

    RolesRequiredRule rule = null;
   
    // Will never return true for service methods
    if (svcParser.hasRule()) {
      rule = new RolesRequiredRule(loadClass.getAnnotation(RequireRoles.class).value(), context.getBus());
    }
    else if (svcParser.hasAuthentication()) {
      rule = new RolesRequiredRule(new HashSet<Object>(), context.getBus());
    }

    // If we have created an injector, get a callback and register it
    if (svc != null) {
      MessageCallback callback = svcParser.getCallback(svc, context.getBus());
View Full Code Here

                if (commandPoints.isEmpty()) {
                    // Subscribe the service to the bus.
                    context.getBus().subscribe(svcName, (MessageCallback) svc);
                }

                RolesRequiredRule rule = null;
                if (clazz.isAnnotationPresent(RequireRoles.class)) {
                    rule = new RolesRequiredRule(clazz.getAnnotation(RequireRoles.class).value(), context.getBus());
                } else if (clazz.isAnnotationPresent(RequireAuthentication.class)) {
                    rule = new RolesRequiredRule(new HashSet<Object>(), context.getBus());
                }
                if (rule != null) {
                    context.getBus().addRule(svcName, rule);
                }
            }
View Full Code Here

                  }

                  // Subscribe the service to the bus.
                  context.getBus().subscribe(svcName, (MessageCallback) svc);

                  RolesRequiredRule rule = null;
                  if (clazz.isAnnotationPresent(RequireRoles.class)) {
                    rule = new RolesRequiredRule(clazz.getAnnotation(RequireRoles.class).value(), context.getBus());
                  } else if (clazz.isAnnotationPresent(RequireAuthentication.class)) {
                    rule = new RolesRequiredRule(new HashSet<Object>(), context.getBus());
                  }
                  if (rule != null) {
                    context.getBus().addRule(svcName, rule);
                  }
                }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.server.security.auth.rules.RolesRequiredRule

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.