Search in sources :

Example 1 with FailApproval

use of com.tremolosecurity.provisioning.scheduler.jobs.util.FailApproval in project OpenUnison by TremoloSecurity.

the class AutoFailApprovalListener method onMessage.

@Override
public void onMessage(ConfigManager cfg, Object payload, Message msg) throws ProvisioningException {
    FailApproval fa = (FailApproval) payload;
    GlobalEntries.getGlobalEntries().getConfigManager().getProvisioningEngine().doApproval(fa.getApprovalID(), fa.getApprover(), false, fa.getMsg());
}
Also used : FailApproval(com.tremolosecurity.provisioning.scheduler.jobs.util.FailApproval)

Example 2 with FailApproval

use of com.tremolosecurity.provisioning.scheduler.jobs.util.FailApproval in project OpenUnison by TremoloSecurity.

the class AutoFail method execute.

@Override
public void execute(ConfigManager configManager, JobExecutionContext context) throws ProvisioningException {
    if (configManager == null || configManager.getProvisioningEngine() == null) {
        logger.warn("System not fully initialized");
        return;
    }
    String queueName = context.getJobDetail().getJobDataMap().getString("queueName");
    String approver = context.getJobDetail().getJobDataMap().getString("approver");
    String msg = context.getJobDetail().getJobDataMap().getString("message");
    ApprovalSummaries summaries = ServiceActions.listOpenApprovals(approver, "", configManager);
    try {
        this.createConnections(configManager, queueName);
        Gson gson = new Gson();
        for (ApprovalSummary sum : summaries.getApprovals()) {
            FailApproval fa = new FailApproval();
            fa.setApprovalID(sum.getApproval());
            fa.setApprover(approver);
            fa.setMsg(msg);
            EncryptedMessage em = configManager.getProvisioningEngine().encryptObject(fa);
            synchronized (sessionHolder) {
                TextMessage tmsg = sessionHolder.getSession().createTextMessage(gson.toJson(em));
                tmsg.setStringProperty("JMSXGroupID", "unison-autofail");
                sessionHolder.getMessageProduceer().send(tmsg);
            }
        }
    } catch (Throwable t) {
        throw new ProvisioningException("Could not process open approvals", t);
    }
}
Also used : ApprovalSummaries(com.tremolosecurity.provisioning.service.util.ApprovalSummaries) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) EncryptedMessage(com.tremolosecurity.provisioning.util.EncryptedMessage) Gson(com.google.gson.Gson) FailApproval(com.tremolosecurity.provisioning.scheduler.jobs.util.FailApproval) ApprovalSummary(com.tremolosecurity.provisioning.service.util.ApprovalSummary)

Aggregations

FailApproval (com.tremolosecurity.provisioning.scheduler.jobs.util.FailApproval)2 Gson (com.google.gson.Gson)1 ProvisioningException (com.tremolosecurity.provisioning.core.ProvisioningException)1 ApprovalSummaries (com.tremolosecurity.provisioning.service.util.ApprovalSummaries)1 ApprovalSummary (com.tremolosecurity.provisioning.service.util.ApprovalSummary)1 EncryptedMessage (com.tremolosecurity.provisioning.util.EncryptedMessage)1