/** * @see io.apiman.manager.api.core.IStorage#createAuditEntry(io.apiman.manager.api.beans.audit.AuditEntryBean) */ @Override public void createAuditEntry(AuditEntryBean entry) throws StorageException { this.delegate.createAuditEntry(entry); }
/** * @see io.apiman.manager.api.exportimport.read.IImportReaderDispatcher#audit(io.apiman.manager.api.beans.audit.AuditEntryBean) */ @Override public void audit(AuditEntryBean entry) { try { logger.info(Messages.i18n.format("StorageImportDispatcher.ImportingAuditEntry") + entry.getId()); //$NON-NLS-1$ entry.setId(null); storage.createAuditEntry(entry); } catch (StorageException e) { error(e); } }
storage.createAuditEntry(AuditUtils.policiesReordered(pvb, PolicyType.Plan, securityContext));
storage.createAuditEntry(AuditUtils.policiesReordered(cvb, PolicyType.Client, securityContext));
storage.createAuditEntry(AuditUtils.policiesReordered(pvb, PolicyType.Plan, securityContext));
/** * Creates a plan version. * @param bean * @param plan * @throws StorageException */ protected PlanVersionBean createPlanVersionInternal(NewPlanVersionBean bean, PlanBean plan) throws StorageException { if (!BeanUtils.isValidVersion(bean.getVersion())) { throw new StorageException("Invalid/illegal plan version: " + bean.getVersion()); //$NON-NLS-1$ } PlanVersionBean newVersion = new PlanVersionBean(); newVersion.setCreatedBy(securityContext.getCurrentUser()); newVersion.setCreatedOn(new Date()); newVersion.setModifiedBy(securityContext.getCurrentUser()); newVersion.setModifiedOn(new Date()); newVersion.setStatus(PlanStatus.Created); newVersion.setPlan(plan); newVersion.setVersion(bean.getVersion()); storage.createPlanVersion(newVersion); storage.createAuditEntry(AuditUtils.planVersionCreated(newVersion, securityContext)); return newVersion; }
/** * Creates a plan version. * @param bean * @param plan * @throws StorageException */ protected PlanVersionBean createPlanVersionInternal(NewPlanVersionBean bean, PlanBean plan) throws StorageException { if (!BeanUtils.isValidVersion(bean.getVersion())) { throw new StorageException("Invalid/illegal plan version: " + bean.getVersion()); //$NON-NLS-1$ } PlanVersionBean newVersion = new PlanVersionBean(); newVersion.setCreatedBy(securityContext.getCurrentUser()); newVersion.setCreatedOn(new Date()); newVersion.setModifiedBy(securityContext.getCurrentUser()); newVersion.setModifiedOn(new Date()); newVersion.setStatus(PlanStatus.Created); newVersion.setPlan(plan); newVersion.setVersion(bean.getVersion()); storage.createPlanVersion(newVersion); storage.createAuditEntry(AuditUtils.planVersionCreated(newVersion, securityContext)); return newVersion; }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#deleteApiDefinition(java.lang.String, java.lang.String, java.lang.String) */ @Override public void deleteApiDefinition(String organizationId, String apiId, String version) throws OrganizationNotFoundException, ApiVersionNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiVersionBean apiVersion = storage.getApiVersion(organizationId, apiId, version); if (apiVersion == null) { throw ExceptionFactory.apiVersionNotFoundException(apiId, version); } apiVersion.setDefinitionType(ApiDefinitionType.None); apiVersion.setModifiedBy(securityContext.getCurrentUser()); apiVersion.setModifiedOn(new Date()); storage.createAuditEntry(AuditUtils.apiDefinitionDeleted(apiVersion, securityContext)); storage.deleteApiDefinition(apiVersion); storage.updateApiVersion(apiVersion); storage.commitTx(); log.debug(String.format("Deleted API %s definition %s", apiId, apiVersion)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
protected void storeApiDefinition(String organizationId, String apiId, String version, ApiDefinitionType definitionType, InputStream data) { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiVersionBean apiVersion = storage.getApiVersion(organizationId, apiId, version); if (apiVersion == null) { throw ExceptionFactory.apiVersionNotFoundException(apiId, version); } if (apiVersion.getDefinitionType() != definitionType) { apiVersion.setDefinitionType(definitionType); storage.updateApiVersion(apiVersion); } storage.createAuditEntry(AuditUtils.apiDefinitionUpdated(apiVersion, securityContext)); storage.updateApiDefinition(apiVersion, data); apiVersion.setModifiedOn(new Date()); apiVersion.setModifiedBy(securityContext.getCurrentUser()); storage.updateApiVersion(apiVersion); storage.commitTx(); log.debug(String.format("Stored API definition %s: %s", apiId, apiVersion)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * Creates a new client version. * @param bean * @param client * @throws StorageException */ protected ClientVersionBean createClientVersionInternal(NewClientVersionBean bean, ClientBean client) throws StorageException { if (!BeanUtils.isValidVersion(bean.getVersion())) { throw new StorageException("Invalid/illegal client version: " + bean.getVersion()); //$NON-NLS-1$ } ClientVersionBean newVersion = new ClientVersionBean(); newVersion.setClient(client); newVersion.setCreatedBy(securityContext.getCurrentUser()); newVersion.setCreatedOn(new Date()); newVersion.setModifiedBy(securityContext.getCurrentUser()); newVersion.setModifiedOn(new Date()); newVersion.setStatus(ClientStatus.Created); newVersion.setVersion(bean.getVersion()); newVersion.setApikey(bean.getApiKey()); if (newVersion.getApikey() == null) { newVersion.setApikey(apiKeyGenerator.generate()); } storage.createClientVersion(newVersion); storage.createAuditEntry(AuditUtils.clientVersionCreated(newVersion, securityContext)); log.debug(String.format("Created new client version %s: %s", newVersion.getClient().getName(), newVersion)); //$NON-NLS-1$ return newVersion; }
protected void storeApiDefinition(String organizationId, String apiId, String version, ApiDefinitionType definitionType, InputStream data) { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiVersionBean apiVersion = storage.getApiVersion(organizationId, apiId, version); if (apiVersion == null) { throw ExceptionFactory.apiVersionNotFoundException(apiId, version); } if (apiVersion.getDefinitionType() != definitionType) { apiVersion.setDefinitionType(definitionType); storage.updateApiVersion(apiVersion); } storage.createAuditEntry(AuditUtils.apiDefinitionUpdated(apiVersion, securityContext)); storage.updateApiDefinition(apiVersion, data); apiVersion.setModifiedOn(new Date()); apiVersion.setModifiedBy(securityContext.getCurrentUser()); storage.updateApiVersion(apiVersion); storage.commitTx(); log.debug(String.format("Stored API definition %s: %s", apiId, apiVersion)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#revoke(java.lang.String, java.lang.String, java.lang.String) */ @Override public void revoke(String organizationId, String roleId, String userId) throws OrganizationNotFoundException, RoleNotFoundException, UserNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.orgAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); get(organizationId); users.get(userId); roles.get(roleId); MembershipData auditData = new MembershipData(); auditData.setUserId(userId); try { storage.beginTx(); storage.deleteMembership(userId, roleId, organizationId); auditData.addRole(roleId); storage.createAuditEntry(AuditUtils.membershipRevoked(organizationId, auditData, securityContext)); storage.commitTx(); log.debug(String.format("Revoked User %s Role %s Org %s", userId, roleId, organizationId)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#revoke(java.lang.String, java.lang.String, java.lang.String) */ @Override public void revoke(String organizationId, String roleId, String userId) throws OrganizationNotFoundException, RoleNotFoundException, UserNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.orgAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); get(organizationId); users.get(userId); roles.get(roleId); MembershipData auditData = new MembershipData(); auditData.setUserId(userId); try { storage.beginTx(); storage.deleteMembership(userId, roleId, organizationId); auditData.addRole(roleId); storage.createAuditEntry(AuditUtils.membershipRevoked(organizationId, auditData, securityContext)); storage.commitTx(); log.debug(String.format("Revoked User %s Role %s Org %s", userId, roleId, organizationId)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
storage.beginTx(); storage.updatePlanVersion(versionBean); storage.createAuditEntry(AuditUtils.planLocked(versionBean, securityContext)); storage.commitTx(); } catch (Exception e) {
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#revokeAll(java.lang.String, java.lang.String) */ @Override public void revokeAll(String organizationId, String userId) throws OrganizationNotFoundException, RoleNotFoundException, UserNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.orgAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); get(organizationId); users.get(userId); MembershipData auditData = new MembershipData(); auditData.setUserId(userId); auditData.addRole("*"); //$NON-NLS-1$ try { storage.beginTx(); storage.deleteMemberships(userId, organizationId); storage.createAuditEntry(AuditUtils.membershipRevoked(organizationId, auditData, securityContext)); storage.commitTx(); } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#revokeAll(java.lang.String, java.lang.String) */ @Override public void revokeAll(String organizationId, String userId) throws OrganizationNotFoundException, RoleNotFoundException, UserNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.orgAdmin, organizationId)) throw ExceptionFactory.notAuthorizedException(); get(organizationId); users.get(userId); MembershipData auditData = new MembershipData(); auditData.setUserId(userId); auditData.addRole("*"); //$NON-NLS-1$ try { storage.beginTx(); storage.deleteMemberships(userId, organizationId); storage.createAuditEntry(AuditUtils.membershipRevoked(organizationId, auditData, securityContext)); storage.commitTx(); } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
storage.createAuditEntry(AuditUtils.planUpdated(planForUpdate, auditData, securityContext)); storage.commitTx(); log.debug(String.format("Updated plan: %s", planForUpdate)); //$NON-NLS-1$
storage.createAuditEntry(AuditUtils.organizationUpdated(orgForUpdate, auditData, securityContext)); storage.commitTx(); log.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate)); //$NON-NLS-1$
storage.createAuditEntry(AuditUtils.clientUpdated(clientForUpdate, auditData, securityContext)); storage.commitTx(); log.debug(String.format("Updated client %s: %s", clientForUpdate.getName(), clientForUpdate)); //$NON-NLS-1$
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#updateApi(java.lang.String, java.lang.String, io.apiman.manager.api.beans.apis.UpdateApiBean) */ @Override public void updateApi(String organizationId, String apiId, UpdateApiBean bean) throws ApiNotFoundException, NotAuthorizedException { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiBean apiForUpdate = storage.getApi(organizationId, apiId); if (apiForUpdate == null) { throw ExceptionFactory.apiNotFoundException(apiId); } EntityUpdatedData auditData = new EntityUpdatedData(); if (AuditUtils.valueChanged(apiForUpdate.getDescription(), bean.getDescription())) { auditData.addChange("description", apiForUpdate.getDescription(), bean.getDescription()); //$NON-NLS-1$ apiForUpdate.setDescription(bean.getDescription()); } storage.updateApi(apiForUpdate); storage.createAuditEntry(AuditUtils.apiUpdated(apiForUpdate, auditData, securityContext)); storage.commitTx(); } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }