@Override public AnyType getType() { return ApplicationContextProvider.getBeanFactory().getBean(AnyTypeDAO.class).findUser(); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_READ + "')") @Transactional(readOnly = true) public AnyTypeTO read(final String key) { AnyType anyType = anyTypeDAO.find(key); if (anyType == null) { LOG.error("Could not find anyType '" + key + "'"); throw new NotFoundException(key); } return binder.getAnyTypeTO(anyType); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_UPDATE + "')") public AnyTypeTO update(final AnyTypeTO anyTypeTO) { AnyType anyType = anyTypeDAO.find(anyTypeTO.getKey()); if (anyType == null) { LOG.error("Could not find anyType '" + anyTypeTO.getKey() + "'"); throw new NotFoundException(anyTypeTO.getKey()); } binder.update(anyType, anyTypeTO); anyType = anyTypeDAO.save(anyType); return binder.getAnyTypeTO(anyTypeDAO.save(anyType)); }
protected Pair<TO, List<LogicActions>> beforeCreate(final TO input) { Realm realm = realmDAO.findByFullPath(input.getRealm()); if (realm == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm); sce.getElements().add(input.getRealm()); throw sce; } AnyType anyType = input instanceof UserTO ? anyTypeDAO.findUser() : input instanceof GroupTO ? anyTypeDAO.findGroup() : anyTypeDAO.find(input.getType()); if (anyType == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType); sce.getElements().add(input.getType()); throw sce; } TO any = input; templateUtils.apply(any, realm.getTemplate(anyType)); List<LogicActions> actions = getActions(realm); for (LogicActions action : actions) { any = action.beforeCreate(any); } LOG.debug("Input: {}\nOutput: {}\n", input, any); return ImmutablePair.of(any, actions); }
setDynMembership(group, anyTypeDAO.findUser(), groupTO.getUDynMembershipCond()); AnyType anyType = anyTypeDAO.find(type); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), type); AnyType anyType = anyTypeDAO.find(typeExtTO.getAnyType()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), typeExtTO.getAnyType());
@Override public AnyType getType() { return ApplicationContextProvider.getBeanFactory().getBean(AnyTypeDAO.class).findGroup(); }
@Override public AnyTypeClassTO getAnyTypeClassTO(final AnyTypeClass anyTypeClass) { AnyTypeClassTO anyTypeClassTO = new AnyTypeClassTO(); anyTypeClassTO.setKey(anyTypeClass.getKey()); anyTypeClassTO.getInUseByTypes().addAll( anyTypeDAO.findByTypeClass(anyTypeClass).stream().map(Entity::getKey).collect(Collectors.toList())); anyTypeClassTO.getPlainSchemas().addAll( anyTypeClass.getPlainSchemas().stream().map(Entity::getKey).collect(Collectors.toList())); anyTypeClassTO.getDerSchemas().addAll( anyTypeClass.getDerSchemas().stream().map(Entity::getKey).collect(Collectors.toList())); anyTypeClassTO.getVirSchemas().addAll( anyTypeClass.getVirSchemas().stream().map(Entity::getKey).collect(Collectors.toList())); return anyTypeClassTO; }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_LIST + "')") @Transactional(readOnly = true) public List<AnyTypeTO> list() { return anyTypeDAO.findAll().stream().map(binder::getAnyTypeTO).collect(Collectors.toList()); }
@Override public AnyTypeTO delete(final AnyType anyType) { AnyTypeTO deleted = getAnyTypeTO(anyType); anyTypeDAO.delete(anyType.getKey()); final Set<String> removed = EntitlementsHolder.getInstance().removeFor(deleted.getKey()); if (!adminUser.equals(AuthContextUtils.getUsername())) { AccessToken accessToken = accessTokenDAO.findByOwner(AuthContextUtils.getUsername()); try { Set<SyncopeGrantedAuthority> authorities = new HashSet<>(POJOHelper.deserialize( ENCRYPTOR.decode(new String(accessToken.getAuthorities()), CipherAlgorithm.AES), new TypeReference<Set<SyncopeGrantedAuthority>>() { })); authorities.removeAll(authorities.stream(). filter(authority -> removed.contains(authority.getAuthority())).collect(Collectors.toList())); accessToken.setAuthorities(ENCRYPTOR.encode( POJOHelper.serialize(authorities), CipherAlgorithm.AES). getBytes()); accessTokenDAO.save(accessToken); } catch (Exception e) { LOG.error("Could not fetch or store authorities", e); } } return deleted; }
AnyType anyType = anyTypeDAO.find(provResult.getAnyType()); boolean includeUser = resource.getProvision(anyTypeDAO.findUser()) != null; boolean includeGroup = resource.getProvision(anyTypeDAO.findGroup()) != null; boolean includeAnyObject = resource.getProvisions().stream().anyMatch( provision -> provision.getAnyType().getKind() == AnyTypeKind.ANY_OBJECT);
setDynMembership(group, anyTypeDAO.findUser(), groupPatch.getUDynMembershipCond()); AnyType anyType = anyTypeDAO.find(entry.getKey()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), entry.getKey()); AnyType anyType = anyTypeDAO.find(typeExtTO.getAnyType()); if (anyType == null) { LOG.warn("Ignoring invalid {}: {}", AnyType.class.getSimpleName(), typeExtTO.getAnyType());
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_CREATE + "')") public AnyTypeTO create(final AnyTypeTO anyTypeTO) { if (StringUtils.isBlank(anyTypeTO.getKey())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add(AnyType.class.getSimpleName() + " key"); throw sce; } if (anyTypeDAO.find(anyTypeTO.getKey()) != null) { throw new DuplicateException(anyTypeTO.getKey()); } return binder.getAnyTypeTO(anyTypeDAO.save(binder.create(anyTypeTO))); }
@Transactional(readOnly = true) @Override public void before(final PropagationTask task, final ConnectorObject beforeObj) { Optional<? extends Provision> provision = task.getResource().getProvision(anyTypeDAO.findGroup()); if (AnyTypeKind.USER == task.getAnyTypeKind() && provision.isPresent() && provision.get().getMapping() != null
@Override public void delete(final String key) { AnyTypeClass anyTypeClass = find(key); if (anyTypeClass == null) { return; } for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) { schema.setAnyTypeClass(null); } for (DerSchema schema : derSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) { schema.setAnyTypeClass(null); } for (VirSchema schema : virSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) { schema.setAnyTypeClass(null); } for (AnyType type : anyTypeDAO.findByTypeClass(anyTypeClass)) { type.getClasses().remove(anyTypeClass); } for (TypeExtension typeExt : groupDAO.findTypeExtensions(anyTypeClass)) { typeExt.getAuxClasses().remove(anyTypeClass); if (typeExt.getAuxClasses().isEmpty()) { typeExt.getGroup().getTypeExtensions().remove(typeExt); typeExt.setGroup(null); } } for (Provision provision : resourceDAO.findProvisionsByAuxClass(anyTypeClass)) { provision.getAuxClasses().remove(anyTypeClass); } entityManager().remove(anyTypeClass); }
final AnyType anyType = anyTypeDAO.find(intAttrName.getRelationshipAnyType()); if (relationshipType == null || groupableRelatable.getRelationships(relationshipType).isEmpty()) { LOG.warn("No relationship for type {} in {}, ignoring", Mapping uMapping = provision.getAnyType().equals(anyTypeDAO.findUser()) ? provision.getMapping() : null; Mapping gMapping = provision.getAnyType().equals(anyTypeDAO.findGroup()) ? provision.getMapping() : null;
private boolean isPasswordMapped(final ExternalResource resource) { boolean result = false; Optional<? extends Provision> provision = resource.getProvision(anyTypeDAO.findUser()); if (provision.isPresent() && provision.get().getMapping() != null) { result = provision.get().getMapping().getItems().stream().anyMatch(item -> item.isPassword()); } return result; }