if (implementation.getType() != null && implementation.getType() != implementationTO.getType()) { sce.getElements().add("ImplementationType cannot be changed"); throw sce; implementation.setKey(implementationTO.getKey()); implementation.setEngine(implementationTO.getEngine()); implementation.setType(implementationTO.getType()); implementation.setBody(implementationTO.getBody()); if (implementation.getEngine() == ImplementationEngine.JAVA) { Class<?> base = null; switch (implementation.getType()) { case REPORTLET: base = Reportlet.class; sce.getElements().add("No Java interface found for " + implementation.getType()); throw sce; if (implementation.getType() == ImplementationType.REPORTLET) { ReportletConf reportlet = POJOHelper.deserialize(implementation.getBody(), ReportletConf.class); if (reportlet == null) { sce.getElements().add("Could not deserialize as ReportletConf"); throw sce; } else if (implementation.getType() == ImplementationType.ACCOUNT_RULE || implementation.getType() == ImplementationType.PASSWORD_RULE || implementation.getType() == ImplementationType.PULL_CORRELATION_RULE || implementation.getType() == ImplementationType.PUSH_CORRELATION_RULE) {
@Override public ImplementationTO getImplementationTO(final Implementation implementation) { ImplementationTO implementationTO = new ImplementationTO(); implementationTO.setKey(implementation.getKey()); implementationTO.setEngine(implementation.getEngine()); implementationTO.setType(implementation.getType()); implementationTO.setBody(implementation.getBody()); return implementationTO; } }
@SuppressWarnings("unchecked") private static <T> T buildJava(final Implementation impl) throws ClassNotFoundException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = Class.forName(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
filter(impl -> GroupMemberProvisionTaskJobDelegate.class.getName().equals(impl.getBody())). findFirst().orElseGet(() -> { Implementation caz = entityFactory.newEntity(Implementation.class); caz.setKey(GroupMemberProvisionTaskJobDelegate.class.getSimpleName()); caz.setEngine(ImplementationEngine.JAVA); caz.setType(ImplementationType.TASKJOB_DELEGATE); caz.setBody(GroupMemberProvisionTaskJobDelegate.class.getName()); caz = implementationDAO.save(caz); return caz;
public static Optional<AccountRule> buildAccountRule(final Implementation impl) throws InstantiationException, IllegalAccessException { switch (impl.getEngine()) { case GROOVY: return Optional.of(ImplementationManager.<AccountRule>buildGroovy(impl)); case JAVA: default: AccountRule rule = null; AccountRuleConf ruleConf = POJOHelper.deserialize(impl.getBody(), AccountRuleConf.class); Class<? extends AccountRule> ruleClass = ApplicationContextProvider.getApplicationContext(). getBean(ImplementationLookup.class).getAccountRuleClass(ruleConf.getClass()); if (ruleClass == null) { LOG.warn("Could not find matching account rule for {}", impl.getClass()); } else { // fetch (or create) rule if (ApplicationContextProvider.getBeanFactory().containsSingleton(ruleClass.getName())) { rule = (AccountRule) ApplicationContextProvider.getBeanFactory(). getSingleton(ruleClass.getName()); } else { rule = (AccountRule) ApplicationContextProvider.getBeanFactory(). createBean(ruleClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); ApplicationContextProvider.getBeanFactory(). registerSingleton(ruleClass.getName(), rule); } rule.setConf(ruleConf); } return Optional.ofNullable(rule); } }
@Override public Implementation save(final Implementation implementation) { Implementation merged = entityManager().merge(implementation); ImplementationManager.purge(merged.getKey()); return merged; }
public static <T> T build(final Implementation impl) throws InstantiationException, IllegalAccessException, ClassNotFoundException { switch (impl.getEngine()) { case GROOVY: return ImplementationManager.<T>buildGroovy(impl); case JAVA: default: return ImplementationManager.<T>buildJava(impl); } }
filter(impl -> PushJobDelegate.class.getName().equals(impl.getBody())). findFirst().orElse(null) : implementationDAO.find(pushTaskTO.getJobDelegate()); if (jobDelegate == null) { jobDelegate = entityFactory.newEntity(Implementation.class); jobDelegate.setKey(PushJobDelegate.class.getSimpleName()); jobDelegate.setEngine(ImplementationEngine.JAVA); jobDelegate.setType(ImplementationType.TASKJOB_DELEGATE); jobDelegate.setBody(PushJobDelegate.class.getName()); jobDelegate = implementationDAO.save(jobDelegate); filter(impl -> PullJobDelegate.class.getName().equals(impl.getBody())). findFirst().orElse(null) : implementationDAO.find(pullTaskTO.getJobDelegate()); if (jobDelegate == null) { jobDelegate = entityFactory.newEntity(Implementation.class); jobDelegate.setKey(PullJobDelegate.class.getSimpleName()); jobDelegate.setEngine(ImplementationEngine.JAVA); jobDelegate.setType(ImplementationType.TASKJOB_DELEGATE); jobDelegate.setBody(PullJobDelegate.class.getName()); jobDelegate = implementationDAO.save(jobDelegate); provisioningTask.getActions().removeIf(impl -> !provisioningTaskTO.getActions().contains(impl.getKey()));
public static Optional<Reportlet> buildReportlet(final Implementation impl) throws InstantiationException, IllegalAccessException { switch (impl.getEngine()) { case GROOVY: return Optional.of(ImplementationManager.<Reportlet>buildGroovy(impl)); case JAVA: default: Reportlet reportlet = null; ReportletConf reportletConf = POJOHelper.deserialize(impl.getBody(), ReportletConf.class); Class<? extends Reportlet> reportletClass = ApplicationContextProvider.getApplicationContext(). getBean(ImplementationLookup.class).getReportletClass(reportletConf.getClass()); if (reportletClass == null) { LOG.warn("Could not find matching reportlet for {}", reportletConf.getClass()); } else { // fetch (or create) reportlet if (ApplicationContextProvider.getBeanFactory().containsSingleton(reportletClass.getName())) { reportlet = (Reportlet) ApplicationContextProvider.getBeanFactory(). getSingleton(reportletClass.getName()); } else { reportlet = (Reportlet) ApplicationContextProvider.getBeanFactory(). createBean(reportletClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); ApplicationContextProvider.getBeanFactory(). registerSingleton(reportletClass.getName(), reportlet); } reportlet.setConf(reportletConf); } return Optional.ofNullable(reportlet); } }
@SuppressWarnings("unchecked") private static <T> T buildJava(final Implementation impl) throws ClassNotFoundException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = Class.forName(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
@Override public boolean isValid(final Implementation resource, final ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (resource.getKey() == null || !KEY_PATTERN.matcher(resource.getKey()).matches()) { context.buildConstraintViolationWithTemplate( getTemplate(EntityViolationType.InvalidKey, "Invalid implementation key")). addPropertyNode("key").addConstraintViolation(); return false; } return true; } }
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_READ + "')") @Transactional(readOnly = true) public ImplementationTO read(final ImplementationType type, final String key) { Implementation implementation = implementationDAO.find(key); if (implementation == null) { LOG.error("Could not find implementation '" + key + "'"); throw new NotFoundException(key); } if (implementation.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + implementation.getType()); throw sce; } return binder.getImplementationTO(implementation); }
public static <T> T build(final Implementation impl) throws InstantiationException, IllegalAccessException, ClassNotFoundException { switch (impl.getEngine()) { case GROOVY: return ImplementationManager.<T>buildGroovy(impl); case JAVA: default: return ImplementationManager.<T>buildJava(impl); } }
public static Optional<PullCorrelationRule> buildPullCorrelationRule(final Implementation impl) throws InstantiationException, IllegalAccessException { switch (impl.getEngine()) { case GROOVY: return Optional.of(ImplementationManager.<PullCorrelationRule>buildGroovy(impl)); case JAVA: default: PullCorrelationRule rule = null; PullCorrelationRuleConf ruleConf = POJOHelper.deserialize(impl.getBody(), PullCorrelationRuleConf.class); Class<? extends PullCorrelationRule> ruleClass = ApplicationContextProvider.getApplicationContext(). getBean(ImplementationLookup.class).getPullCorrelationRuleClass(ruleConf.getClass()); if (ruleClass == null) { LOG.warn("Could not find matching pull correlation rule for {}", impl.getClass()); } else { // fetch (or create) rule if (ApplicationContextProvider.getBeanFactory().containsSingleton(ruleClass.getName())) { rule = (PullCorrelationRule) ApplicationContextProvider.getBeanFactory(). getSingleton(ruleClass.getName()); } else { rule = (PullCorrelationRule) ApplicationContextProvider.getBeanFactory(). createBean(ruleClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); ApplicationContextProvider.getBeanFactory(). registerSingleton(ruleClass.getName(), rule); } rule.setConf(ruleConf); } return Optional.ofNullable(rule); } }
@SuppressWarnings("unchecked") private static <T> T buildGroovy(final Implementation impl) throws InstantiationException, IllegalAccessException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = GROOVY_CLASSLOADER.parseClass(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
if (reportlet.isPresent()) { try { status.set("Invoking reportlet " + report.getReportlets().get(i).getKey()); reportlet.get().extract(handler, status); } catch (Throwable t) {
if (implementation.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + implementation.getType()); throw sce; switch (implementation.getType()) { case REPORTLET: inUse = !reportDAO.findByReportlet(implementation).isEmpty();
public static Optional<PasswordRule> buildPasswordRule(final Implementation impl) throws InstantiationException, IllegalAccessException { switch (impl.getEngine()) { case GROOVY: return Optional.of(ImplementationManager.<PasswordRule>buildGroovy(impl)); case JAVA: default: PasswordRule rule = null; PasswordRuleConf ruleConf = POJOHelper.deserialize(impl.getBody(), PasswordRuleConf.class); Class<? extends PasswordRule> ruleClass = ApplicationContextProvider.getApplicationContext(). getBean(ImplementationLookup.class).getPasswordRuleClass(ruleConf.getClass()); if (ruleClass == null) { LOG.warn("Could not find matching password rule for {}", impl.getClass()); } else { // fetch (or create) rule if (ApplicationContextProvider.getBeanFactory().containsSingleton(ruleClass.getName())) { rule = (PasswordRule) ApplicationContextProvider.getBeanFactory(). getSingleton(ruleClass.getName()); } else { rule = (PasswordRule) ApplicationContextProvider.getBeanFactory(). createBean(ruleClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); ApplicationContextProvider.getBeanFactory(). registerSingleton(ruleClass.getName(), rule); } rule.setConf(ruleConf); } return Optional.ofNullable(rule); } }
@SuppressWarnings("unchecked") private static <T> T buildGroovy(final Implementation impl) throws InstantiationException, IllegalAccessException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = GROOVY_CLASSLOADER.parseClass(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }