public static void init(Object o) throws ShiroException { if (o instanceof Initializable) { init((Initializable) o); } }
/** * Calls {@link #init(Object) init} for each object in the collection. If the collection is {@code null} or empty, * this method returns quietly. * * @param c the collection containing objects to {@link #init init}. * @throws ShiroException if unable to initialize one or more instances. * @since 0.9 */ public static void init(Collection c) throws ShiroException { if (c == null || c.isEmpty()) { return; } for (Object o : c) { init(o); } }
private void addToRealms(Collection<Realm> realms, RealmFactory factory) { LifecycleUtils.init(factory); Collection<Realm> factoryRealms = factory.getRealms(); //SHIRO-238: check factoryRealms (was 'realms'): if (!CollectionUtils.isEmpty(factoryRealms)) { realms.addAll(factoryRealms); } }
LifecycleUtils.init(environment);
@SuppressWarnings({"unchecked"}) public Map<String, ?> buildObjects(Map<String, String> kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { BeanConfigurationProcessor processor = new BeanConfigurationProcessor(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { String lhs = entry.getKey(); String rhs = interpolator.interpolate(entry.getValue()); String beanId = parseBeanId(lhs); if (beanId != null) { //a beanId could be parsed, so the line is a bean instance definition processor.add(new InstantiationStatement(beanId, rhs)); } else { //the line must be a property configuration processor.add(new AssignmentStatement(lhs, rhs)); } } processor.execute(); } //SHIRO-413: init method must be called for constructed objects that are Initializable LifecycleUtils.init(objects.values()); return objects; }
public void execute() { for( Statement statement : statements) { statement.execute(); BeanConfiguration bd = statement.getBeanConfiguration(); if (bd.isExecuted()) { //bean is fully configured, no more statements to execute for it: //bean configured overrides the 'eventBus' bean - replace the existing eventBus with the one configured: if (bd.getBeanName().equals(EVENT_BUS_NAME)) { EventBus eventBus = (EventBus)bd.getBean(); enableEvents(eventBus); } //ignore global 'shiro.' shortcut mechanism: if (!bd.isGlobalConfig()) { BeanEvent event = new ConfiguredBeanEvent(bd.getBeanName(), bd.getBean(), Collections.unmodifiableMap(objects)); eventBus.publish(event); } //initialize the bean if necessary: LifecycleUtils.init(bd.getBean()); //ignore global 'shiro.' shortcut mechanism: if (!bd.isGlobalConfig()) { BeanEvent event = new InitializedBeanEvent(bd.getBeanName(), bd.getBean(), Collections.unmodifiableMap(objects)); eventBus.publish(event); } } } } }
private void addToRealms(Collection<Realm> realms, RealmFactory factory) { LifecycleUtils.init(factory); Collection<Realm> factoryRealms = factory.getRealms(); //SHIRO-238: check factoryRealms (was 'realms'): if (!CollectionUtils.isEmpty(factoryRealms)) { realms.addAll(factoryRealms); } }
public static void init(Object o) throws ShiroException { if (o instanceof Initializable) { init((Initializable) o); } }
public static void init(Object o) throws ShiroException { if (o instanceof Initializable) { init((Initializable) o); } }
/** * Calls {@link #init(Object) init} for each object in the collection. If the collection is {@code null} or empty, * this method returns quietly. * * @param c the collection containing objects to {@link #init init}. * @throws ShiroException if unable to initialize one or more instances. * @since 0.9 */ public static void init(Collection c) throws ShiroException { if (c == null || c.isEmpty()) { return; } for (Object o : c) { init(o); } }
/** * Calls {@link #init(Object) init} for each object in the collection. If the collection is {@code null} or empty, * this method returns quietly. * * @param c the collection containing objects to {@link #init init}. * @throws ShiroException if unable to initialize one or more instances. * @since 0.9 */ public static void init(Collection c) throws ShiroException { if (c == null || c.isEmpty()) { return; } for (Object o : c) { init(o); } }
private void addToRealms(Collection<Realm> realms, RealmFactory factory) { LifecycleUtils.init(factory); Collection<Realm> factoryRealms = factory.getRealms(); if (!CollectionUtils.isEmpty(realms)) { realms.addAll(factoryRealms); } }
protected void configureDelegate(PortofinoRealm security) { applicationContext.getAutowireCapableBeanFactory().autowireBean(security); security.setCacheManager(cacheManager); LifecycleUtils.init(security); }
private void initRealms(SecurityManager securityManager) { Collection<Realm> realms = getRealms(securityManager); if (!CollectionUtils.isEmpty(realms)) { LifecycleUtils.init(realms); } }
protected void configureDelegate(PortofinoRealm security) { Injections.inject( security, servletContext, null); security.setCacheManager(cacheManager); LifecycleUtils.init(security); }
public EmoSecurityManager build() { checkNotNull(_authIdentityReader, "authIdentityManager not set"); checkNotNull(_permissionReader, "permissionManager not set"); if(_cacheManager == null) { // intended for test use _cacheManager = new GuavaCacheManager(null); } ApiKeyRealm realm = new ApiKeyRealm(_realmName, _cacheManager, _authIdentityReader, _permissionReader, _anonymousId); LifecycleUtils.init(realm); return new ApiKeySecurityManager(realm); } }
@Override public void start() { logger.info("Initializing Shiro environment"); WebEnvironment environment = environmentLoader.initEnvironment(servletContext); RealmSecurityManager rsm = (RealmSecurityManager) environment.getWebSecurityManager(); logger.debug("Creating SecurityGroovyRealm"); try { String securityGroovy = new File(groovyClasspath, "Security.groovy").toURI().toString(); logger.debug("Security.groovy URL: {}", securityGroovy); SecurityGroovyRealm realm = new SecurityGroovyRealm(groovyScriptEngine, securityGroovy, servletContext); LifecycleUtils.init(realm); rsm.setRealm(realm); status = ModuleStatus.STARTED; } catch (Exception e) { logger.error("Security.groovy not found or invalid; installing dummy realm", e); SimpleAccountRealm realm = new SimpleAccountRealm(); LifecycleUtils.init(realm); rsm.setRealm(realm); status = ModuleStatus.FAILED; } }
@SuppressWarnings({"unchecked"}) public Map<String, ?> buildObjects(Map<String, String> kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { BeanConfigurationProcessor processor = new BeanConfigurationProcessor(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { String lhs = entry.getKey(); String rhs = interpolator.interpolate(entry.getValue()); String beanId = parseBeanId(lhs); if (beanId != null) { //a beanId could be parsed, so the line is a bean instance definition processor.add(new InstantiationStatement(beanId, rhs)); } else { //the line must be a property configuration processor.add(new AssignmentStatement(lhs, rhs)); } } processor.execute(); } //SHIRO-413: init method must be called for constructed objects that are Initializable LifecycleUtils.init(objects.values()); return objects; }
LifecycleUtils.init(this.objects.values());
public void execute() { for( Statement statement : statements) { statement.execute(); BeanConfiguration bd = statement.getBeanConfiguration(); if (bd.isExecuted()) { //bean is fully configured, no more statements to execute for it: //bean configured overrides the 'eventBus' bean - replace the existing eventBus with the one configured: if (bd.getBeanName().equals(EVENT_BUS_NAME)) { EventBus eventBus = (EventBus)bd.getBean(); enableEvents(eventBus); } //ignore global 'shiro.' shortcut mechanism: if (!bd.isGlobalConfig()) { BeanEvent event = new ConfiguredBeanEvent(bd.getBeanName(), bd.getBean(), Collections.unmodifiableMap(objects)); eventBus.publish(event); } //initialize the bean if necessary: LifecycleUtils.init(bd.getBean()); //ignore global 'shiro.' shortcut mechanism: if (!bd.isGlobalConfig()) { BeanEvent event = new InitializedBeanEvent(bd.getBeanName(), bd.getBean(), Collections.unmodifiableMap(objects)); eventBus.publish(event); } } } } }