Search in sources :

Example 1 with JMSSessionHolder

use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.

the class SendMessageThread method lazyInit.

public void lazyInit(ConfigManager cfgMgr) throws ProvisioningException {
    try {
        smtpQueue = "TremoloUnisonSMTPQueue";
        if (cfgMgr.getCfg().getProvisioning() != null && cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
            smtpQueue = cfgMgr.getCfg().getProvisioning().getQueueConfig().getSmtpQueueName();
        }
        this.smtpSendSession = JMSConnectionFactory.getConnectionFactory().getSession(smtpQueue);
        JMSSessionHolder smtpReceieve = JMSConnectionFactory.getConnectionFactory().getSession(smtpQueue);
        smtpReceieve.setMessageListener(this);
    } catch (JMSException e) {
        throw new ProvisioningException("Could not initialize JMS", e);
    }
}
Also used : JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder) JMSException(javax.jms.JMSException)

Example 2 with JMSSessionHolder

use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.

the class SendMessageThread method initLocalBroker.

private void initLocalBroker() throws ProvisioningException {
    if (this.isInternalQueue()) {
        this.broker = BrokerHolder.getInstance(cfgMgr, "local", this);
        this.mpPools = new ArrayList<JMSSessionHolder>();
        String taskQueueName = "unison-tasks";
        if (this.cfgMgr.getCfg().getProvisioning() != null && this.cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
            taskQueueName = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName();
        }
        try {
            JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
            this.mpPools.add(sessionHolder);
        } catch (Throwable t) {
            logger.warn("Could not create internal queue " + taskQueueName);
        }
    } else {
        this.mpPools = new ArrayList<JMSSessionHolder>();
        if (this.cfgMgr.getCfg().getProvisioning().getQueueConfig().isMultiTaskQueues()) {
            for (int j = 1; j <= this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getNumQueues(); j++) {
                String name = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName().replace("{x}", Integer.toString(j));
                JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(name);
                this.mpPools.add(sessionHolder);
            }
        } else {
            this.mpPools = new ArrayList<JMSSessionHolder>();
            JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName());
            this.mpPools.add(sessionHolder);
        }
    }
}
Also used : JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder)

Example 3 with JMSSessionHolder

use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.

the class SendMessageThread method addMessageListener.

@Override
public void addMessageListener(MessageListenerType mlt) throws InstantiationException, IllegalAccessException, ClassNotFoundException, ProvisioningException, JMSException {
    UnisonMessageListener uml = (UnisonMessageListener) Class.forName(mlt.getClassName()).newInstance();
    HashMap<String, Attribute> attrs = new HashMap<String, Attribute>();
    for (ParamType pt : mlt.getParams()) {
        Attribute attr = attrs.get(pt.getName());
        if (attr == null) {
            attr = new Attribute(pt.getName());
            attrs.put(pt.getName(), attr);
        }
        attr.getValues().add(pt.getValue());
    }
    uml.init(this.cfgMgr, attrs);
    JMSSessionHolder session = JMSConnectionFactory.getConnectionFactory().getSession(mlt.getQueueName());
    session.setMessageListener(uml);
    this.listenerSessions.put(mlt.getQueueName(), session);
}
Also used : Attribute(com.tremolosecurity.saml.Attribute) LDAPAttribute(com.novell.ldap.LDAPAttribute) HashMap(java.util.HashMap) JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder) ParamType(com.tremolosecurity.config.xml.ParamType)

Example 4 with JMSSessionHolder

use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.

the class SendMessageThread method initMessageConsumers.

@Override
public void initMessageConsumers() throws ProvisioningException {
    try {
        if (cfgMgr.getCfg().getProvisioning() == null) {
            return;
        }
        String taskQueueName = "TremoloUnisonTaskQueue";
        if (this.cfgMgr.getCfg().getProvisioning() != null && this.cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
            taskQueueName = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName();
        }
        if (this.isInternalQueue()) {
            TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
            JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
            sessionHolder.setMessageListener(taskConsumer);
        } else {
            if (this.cfgMgr.getCfg().getProvisioning().getQueueConfig().isMultiTaskQueues()) {
                for (int j = 1; j <= this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getNumQueues(); j++) {
                    String name = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName().replace("{x}", Integer.toString(j));
                    for (int i = 0; i < this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getMaxConsumers(); i++) {
                        TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
                        JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(name);
                        sessionHolder.setMessageListener(taskConsumer);
                    }
                }
            } else {
                for (int i = 0; i < this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getMaxConsumers(); i++) {
                    TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
                    JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
                    sessionHolder.setMessageListener(taskConsumer);
                }
            }
        }
    } catch (JMSException e) {
        throw new ProvisioningException("Could not initialize task message system", e);
    }
}
Also used : JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder) JMSException(javax.jms.JMSException)

Example 5 with JMSSessionHolder

use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.

the class SendMessageThread method enqueue.

public void enqueue(WorkflowHolder wfHolder) throws ProvisioningException {
    TextMessage bm;
    try {
        JMSSessionHolder session;
        String originalQueue;
        session = this.getTaskMessageProducer();
        bm = session.getSession().createTextMessage();
        originalQueue = session.getQueueName();
        synchronized (session) {
            bm.setStringProperty("OriginalQueue", originalQueue);
            bm.setStringProperty("WorkflowName", wfHolder.getWorkflow().getName());
            bm.setStringProperty("WorkflowSubject", wfHolder.getUser().getUserID());
            bm.setStringProperty("JMSXGroupID", "unison");
            bm.setStringProperty("nonce", UUID.randomUUID().toString());
            TaskHolder holder = wfHolder.getWfStack().peek();
            WorkflowTask task = holder.getParent().get(holder.getPosition());
            bm.setStringProperty("WorkflowCurrentTask", task.getLabel());
            EncryptedMessage encMsg = this.encryptObject(wfHolder);
            String json = JsonWriter.objectToJson(encMsg);
            bm.setText(json);
            session.getMessageProduceer().send(bm);
        }
    } catch (Exception e) {
        throw new ProvisioningException("Could not enqueue message", e);
    }
}
Also used : TaskHolder(com.tremolosecurity.provisioning.util.TaskHolder) JMSSessionHolder(com.tremolosecurity.provisioning.jms.JMSSessionHolder) EncryptedMessage(com.tremolosecurity.provisioning.util.EncryptedMessage) TextMessage(javax.jms.TextMessage) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) LDAPException(com.novell.ldap.LDAPException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SocketException(java.net.SocketException) SQLException(java.sql.SQLException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) MessagingException(javax.mail.MessagingException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) JMSException(javax.jms.JMSException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) BadPaddingException(javax.crypto.BadPaddingException)

Aggregations

JMSSessionHolder (com.tremolosecurity.provisioning.jms.JMSSessionHolder)6 JMSException (javax.jms.JMSException)4 LDAPAttribute (com.novell.ldap.LDAPAttribute)2 LDAPException (com.novell.ldap.LDAPException)2 ParamType (com.tremolosecurity.config.xml.ParamType)2 Attribute (com.tremolosecurity.saml.Attribute)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SocketException (java.net.SocketException)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 InvalidKeyException (java.security.InvalidKeyException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 BadPaddingException (javax.crypto.BadPaddingException)2 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)2 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)2 MessagingException (javax.mail.MessagingException)2