public static String getLoggedInUserName(){ return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); } }
/** * Method returns username of the logged in user * @return username of logged in user */ private static String getLoggedInUserName(){ return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); }
public static String getLoggedInUserName(){ return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); }
private String getLoggedInUserName() { return PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); }
/** * Trigger after removing an association. * * @param associationId * @throws WorkflowException */ @Override public void doPostRemoveAssociation(int associationId) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String auditData = "\"" + "Association ID" + "\" : \"" + associationId + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove Association", auditData, AUDIT_SUCCESS)); }
/** * Trigger after changing state of an association * * @param associationId * @param isEnable * @throws WorkflowException */ @Override public void doPostChangeAssociationState(String associationId, boolean isEnable) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String auditData = "\"" + "Association ID" + "\" : \"" + associationId + "\",\"" + "Resulting State" + "\" : \"" + isEnable + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Change Association State", auditData, AUDIT_SUCCESS)); } }
/** * Trigger after delete the workflow * * @param workflow * @throws WorkflowException */ @Override public void doPostDeleteWorkflow(Workflow workflow) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String auditData = "\"" + "Workflow ID" + "\" : \"" + workflow.getWorkflowId() + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove workflow", auditData, AUDIT_SUCCESS)); }
private boolean validateDomainsForDelete(String[] domains) { String userDomain = IdentityUtil.extractDomainFromName(PrivilegedCarbonContext.getThreadLocalCarbonContext() .getUsername()); for (String domain : domains) { if (domain.equalsIgnoreCase(userDomain)) { //Trying to delete own domain return false; } } return true; }
/** * Trigger after deleting the request * * @param workflowRequest * @throws WorkflowException */ @Override public void doPostDeleteWorkflowRequest(WorkflowRequest workflowRequest) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String auditData = "\"" + "Request ID" + "\" : \"" + workflowRequest.getRequestId() + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove workflow request", auditData, AUDIT_SUCCESS)); }
private boolean validateDomainsForDelete(String[] domains) { String userDomain = IdentityUtil.extractDomainFromName(PrivilegedCarbonContext.getThreadLocalCarbonContext() .getUsername()); for (String domain : domains) { if (domain.equalsIgnoreCase(userDomain)) { //Trying to delete own domain return false; } } return true; }
private void validateAuthorizationForListReceipts(String piiPrincipalId) throws ConsentManagementException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (isBlank(loggedInUser)) { throw handleClientException(ERROR_CODE_NO_USER_FOUND, LIST_RECEIPT); } int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); if (isNotBlank(piiPrincipalId) && piiPrincipalId.equalsIgnoreCase(loggedInUser)) { if (log.isDebugEnabled()) { log.debug("User: " + piiPrincipalId + " is authorized to perform a search on own consent receipts."); } //Returns here since same user is trying to search own receipts. return; } handleAuthorization(LIST_RECEIPT, loggedInUser, tenantId); }
/** * Trigger after removing an association. * * @param associationId * @throws WorkflowException */ @Override public void doPostRemoveAssociation(int associationId) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain); String auditData = "\"" + "Association ID" + "\" : \"" + associationId + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove Association", auditData, AUDIT_SUCCESS)); }
/** * Trigger after removing an association. * * @param associationId * @throws WorkflowException */ @Override public void doPostRemoveAssociation(int associationId) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain); String auditData = "\"" + "Association ID" + "\" : \"" + associationId + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove Association", auditData, AUDIT_SUCCESS)); }
public static String getUserConsumerId() { //String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String currentTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); String consumerId = userName + "@" + currentTenantDomain; return consumerId; }
/** * Trigger after delete the workflow * * @param workflow * @throws WorkflowException */ @Override public void doPostDeleteWorkflow(Workflow workflow) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain); String auditData = "\"" + "Workflow ID" + "\" : \"" + workflow.getWorkflowId() + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove workflow", auditData, AUDIT_SUCCESS)); }
/** * Trigger after deleting the request * * @param workflowRequest * @throws WorkflowException */ @Override public void doPostDeleteWorkflowRequest(WorkflowRequest workflowRequest) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain); String auditData = "\"" + "Request ID" + "\" : \"" + workflowRequest.getRequestId() + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove workflow request", auditData, AUDIT_SUCCESS)); }
/** * Trigger after deleting the request * * @param workflowRequest * @throws WorkflowException */ @Override public void doPostDeleteWorkflowRequest(WorkflowRequest workflowRequest) throws WorkflowException { String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (StringUtils.isBlank(loggedInUser)) { loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; } String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain); String auditData = "\"" + "Request ID" + "\" : \"" + workflowRequest.getRequestId() + "\""; AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove workflow request", auditData, AUDIT_SUCCESS)); }
public static String getUserConsumerId() { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String currentTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); return UserCoreUtil.addTenantDomainToEntry(userName, currentTenantDomain); }
public void scheduleReport(ReportConfigurationBean configuration) throws Exception { HashMap<String, String> propertyMap = new HashMap<String, String>( CommonUtil.attributeArrayToMap(configuration.getAttributes())); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); propertyMap.put("reporting.registry.username", username); propertyMap.put("reporting.registry.tenantId", String.valueOf(tenantId)); propertyMap.put("reporting.type", configuration.getType()); propertyMap.put("reporting.class", configuration.getReportClass()); propertyMap.put("reporting.template", configuration.getTemplate()); propertyMap.put("reporting.resource.path", configuration.getResourcePath()); String clazz = ReportingTask.class.getName(); TaskManager taskManager = ReportingServiceComponent.getTaskManager(tenantId); taskManager.registerTask(new TaskInfo(configuration.getName(), clazz, propertyMap, new TaskInfo.TriggerInfo(configuration.getCronExpression()))); taskManager.rescheduleTask(configuration.getName()); // Re-adding full configuration properties to report path -REGISTRY-1017 saveReport(configuration); }
/** * Delete OAuth2/OIDC application with client_id * @param clientId * @throws DCRMException */ public void deleteApplication(String clientId) throws DCRMException { OAuthConsumerAppDTO appDTO = getApplicationById(clientId); String applicationOwner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); deleteServiceProvider(appDTO.getApplicationName(), tenantDomain, applicationOwner); }