Java Code Examples for org.wso2.carbon.CarbonConstants#REGISTRY_SYSTEM_USERNAME

The following examples show how to use org.wso2.carbon.CarbonConstants#REGISTRY_SYSTEM_USERNAME . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowImplAuditLogger.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Trigger after deleting a BPS package
 *
 * @param workflow
 * @throws WorkflowImplException
 */
@Override
public void doPostRemoveBPSPackage(Workflow workflow) throws WorkflowImplException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Workflow Name" + "\" : \"" + workflow.getWorkflowName()
            + "\",\"" + "Template ID" + "\" : \"" + workflow.getTemplateId()
            + "\",\"" + "Workflow Description" + "\" : \"" + workflow.getWorkflowDescription()
            + "\",\"" + "Workflow ID" + "\" : \"" + workflow.getWorkflowId()
            + "\",\"" + "Workflow Impl ID" + "\" : \"" + workflow.getWorkflowImplId()
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Remove BPS Package",
            "Workflow Impl Admin Service", auditData, AUDIT_SUCCESS));
}
 
Example 2
Source File: WorkflowAuditLogger.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 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 tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    loggedInUser = UserCoreUtil.addTenantDomainToEntry(loggedInUser, tenantDomain);

    String auditData = "\"" + "Association ID" + "\" : \"" + associationId + "\",\""
            + "Resulting State" + "\" : \"" + isEnable + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Change Association State", auditData,
            AUDIT_SUCCESS));
}
 
Example 3
Source File: WorkflowExecutorAuditLogger.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Trigger after executing a workflow request
 *
 * @param workFlowRequest
 * @throws WorkflowException
 */
@Override
public void doPostExecuteWorkflow(WorkflowRequest workFlowRequest, WorkflowExecutorResult result) 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 = "\"" + "Operation Type" + "\" : \"" + workFlowRequest.getEventType()
            + "\",\"" + "Request parameters" + "\" : \"" + workFlowRequest.getRequestParameterAsString()
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Initiate Workflow", auditData,
            AUDIT_SUCCESS));
}
 
Example 4
Source File: WorkflowAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 5
Source File: InMemoryDeliveryManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void publish(Message message, String topicName, int deliveryMode) throws EventBrokerException {

        String resoucePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
        try {
            UserRealm userRealm =
                    EventBrokerHolder.getInstance().getRealmService().getTenantUserRealm
                            (CarbonContext.getThreadLocalCarbonContext().getTenantId());
            String userName = CarbonContext.getThreadLocalCarbonContext().getUsername();
            
            if (userName == null){
                userName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
            }
            if (userName.equals(CarbonConstants.REGISTRY_SYSTEM_USERNAME) ||
                    userRealm.getAuthorizationManager().isUserAuthorized(
                        userName,
                        resoucePath,
                        EventBrokerConstants.EB_PERMISSION_PUBLISH)) {
                List<Subscription> subscriptions = this.matchingManager.getMatchingSubscriptions(topicName);
                for (Subscription subscription : subscriptions) {
                    this.executor.submit(new Worker(this.notificationManager, message, subscription));
                }
            } else {
                throw new EventBrokerException("User " + CarbonContext.getThreadLocalCarbonContext().getUsername()
                        + " is not allowed to publish to " + topicName);
            }
        } catch (UserStoreException e) {
            throw new EventBrokerException("Can not access the user store manager");
        }
    }
 
Example 6
Source File: WorkflowAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after adding a workflow
 *
 * @param workflowDTO
 * @param parameterList
 * @param tenantId
 * @throws WorkflowException
 */
@Override
public void doPostAddWorkflow(Workflow workflowDTO, List<Parameter> parameterList, int tenantId) throws
        WorkflowException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Workflow Name" + "\" : \"" + workflowDTO.getWorkflowName() + "\",\""
            + "Workflow  Impl ID" + "\" : \"" + workflowDTO.getWorkflowImplId() + "\",\""
            + "Workflow ID" + "\" : \"" + workflowDTO.getWorkflowId() + "\",\""
            + "Workflow Description" + "\" : \"" + workflowDTO.getWorkflowDescription() + "\",\""
            + "Template ID" + "\" : \"" + workflowDTO.getTemplateId() + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Add Workflow", auditData, AUDIT_SUCCESS));
}
 
Example 7
Source File: WorkflowImplAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after adding new BPS profile
 *
 * @param bpsProfileDTO
 * @param tenantId
 * @throws WorkflowImplException
 */
@Override
public void doPostAddBPSProfile(BPSProfile bpsProfileDTO, int tenantId) throws WorkflowImplException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Profile Name" + "\" : \"" + bpsProfileDTO.getProfileName()
            + "\",\"" + "Manager Host URL" + "\" : \"" + bpsProfileDTO.getManagerHostURL()
            + "\",\"" + "Worker Host URL" + "\" : \"" + bpsProfileDTO.getWorkerHostURL()
            + "\",\"" + "User" + "\" : \"" + bpsProfileDTO.getUsername()
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Add BPS Profile", auditData, AUDIT_SUCCESS));
}
 
Example 8
Source File: WorkflowAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 9
Source File: IDPMgtAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private String getUser() {
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (user != null) {
        user = user + "@" + CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    } else {
        user = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    return user;
}
 
Example 10
Source File: UserMgtAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private String getUser() {
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (user != null) {
        user = user + "@" + CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    } else {
        user = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    return user;
}
 
Example 11
Source File: WorkflowExecutorAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after executing a workflow request
 *
 * @param workFlowRequest
 * @throws WorkflowException
 */
@Override
public void doPostExecuteWorkflow(WorkflowRequest workFlowRequest, WorkflowExecutorResult result) throws
        WorkflowException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Operation Type" + "\" : \"" + workFlowRequest.getEventType()
            + "\",\"" + "Request parameters" + "\" : \"" + workFlowRequest.getRequestParameterAsString()
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Initiate Workflow", auditData,
            AUDIT_SUCCESS));
}
 
Example 12
Source File: WorkflowImplAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after updating a BPS profile
 *
 * @param bpsProfileDTO
 * @param tenantId
 * @throws WorkflowImplException
 */
@Override
public void doPostUpdateBPSProfile(BPSProfile bpsProfileDTO, int tenantId) throws WorkflowImplException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Profile Name" + "\" : \"" + bpsProfileDTO.getProfileName()
            + "\",\"" + "Manager Host URL" + "\" : \"" + bpsProfileDTO.getManagerHostURL()
            + "\",\"" + "Worker Host URL" + "\" : \"" + bpsProfileDTO.getWorkerHostURL()
            + "\",\"" + "User" + "\" : \"" + bpsProfileDTO.getUsername()
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Update BPS Profile", auditData, AUDIT_SUCCESS));
}
 
Example 13
Source File: WorkflowAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 14
Source File: WorkflowExecutorAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after handling a callback
 *
 * @param uuid
 * @param status
 * @param additionalParams
 * @throws WorkflowException
 */
@Override
public void doPostHandleCallback(String uuid, String status, Map<String, Object> additionalParams) throws WorkflowException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Request ID" + "\" : \"" + uuid
            + "\",\"" + "Callback Status" + "\" : \"" + status
            + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Callback for Workflow Request", auditData,
            AUDIT_SUCCESS));
}
 
Example 15
Source File: WorkflowImplAuditLogger.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger after removing a BPS profile
 *
 * @param profileName
 * @throws WorkflowImplException
 */
@Override
public void doPostRemoveBPSProfile(String profileName) throws WorkflowImplException {
    String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isBlank(loggedInUser)) {
        loggedInUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    String auditData = "\"" + "Profile Name" + "\" : \"" + profileName + "\"";
    AUDIT_LOG.info(String.format(AUDIT_MESSAGE, loggedInUser, "Delete BPS Profile", auditData, AUDIT_SUCCESS));
}
 
Example 16
Source File: WorkflowAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 17
Source File: IDPMgtAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private String getUser() {
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (user != null) {
        user = user + "@" + CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    } else {
        user = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    return user;
}
 
Example 18
Source File: UserClaimsAuditLogger.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get the logged in user's username who is calling the operation
 *
 * @return username
 */
private String getUser() {
    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (user != null) {
        user = user + "@" + CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    } else {
        user = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    return user;
}
 
Example 19
Source File: ListenerUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * To get the current user, who is doing the current task.
 *
 * @return current logged-in user
 */
public static String getUser() {

    String user = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (StringUtils.isNotEmpty(user)) {
        user = UserCoreUtil
                .addTenantDomainToEntry(user, CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
    } else {
        user = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
    }
    return user;
}
 
Example 20
Source File: SharedMemoryDeliveryManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void publish(Message message, String topicName, int deliveryMode) throws EventBrokerException {

        String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
        try {
            UserRealm userRealm =
                    EventBrokerHolder.getInstance().getRealmService().getTenantUserRealm
                            (CarbonContext.getThreadLocalCarbonContext().getTenantId());
            String userName = CarbonContext.getThreadLocalCarbonContext().getUsername();
            
            if (userName == null){
                userName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
            }
            if (userName.equals(CarbonConstants.REGISTRY_SYSTEM_USERNAME) ||
                    userRealm.getAuthorizationManager().isUserAuthorized(
                        userName,
                        resourcePath,
                        EventBrokerConstants.EB_PERMISSION_PUBLISH)) {
                List<Subscription> subscriptions = getMatchingManager().getMatchingSubscriptions(topicName);

                for (Subscription subscription : subscriptions) {
                    String verified = org.wso2.carbon.event.core.sharedmemory.SharedMemorySubscriptionStorage
                    						.getSubscriptionIDTopicNameCache().get(subscription.getId()+"-notVerfied");
                    
                    if(verified != null && "false".equalsIgnoreCase(verified)){
                            subscription.addProperty("notVerfied", "false");
                    }

                    this.executor.submit(new Worker(this.notificationManager, message, subscription));
                }
            } else {
                throw new EventBrokerException("User " + CarbonContext.getThreadLocalCarbonContext().getUsername()
                        + " is not allowed to publish to " + topicName);
            }
        } catch (UserStoreException e) {
            throw new EventBrokerException("Can not access the user store manager",e);
        }
    }