Search in sources :

Example 6 with EntityList

use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.

the class MQTTSession method createRegistryUsage.

private void createRegistryUsage(Subscription subscription) {
    try {
        Entity subUsage = ((EntityList) registryUsage.getEntity("subscriptions")).createEntity();
        subUsage.setName(subscription.getTopicName());
        subscription.fillRegistryUsage(subUsage);
        subUsage.createCommands();
        registryUsage.getEntity("subscriptions").addEntity(subUsage);
    } catch (EntityAddException e) {
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityAddException(com.swiftmq.mgmt.EntityAddException) EntityList(com.swiftmq.mgmt.EntityList)

Example 7 with EntityList

use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.

the class Role method isContextGrantedAndReadOnly.

public boolean isContextGrantedAndReadOnly(String context) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGrantedAndReadOnly, context: " + context);
    boolean granted = false;
    boolean ro = false;
    EntityList filters = (EntityList) roleEntity.getEntity("context-filters");
    if (filters != null) {
        Map map = filters.getEntities();
        if (map != null && map.size() > 0) {
            boolean wasIncludeGranted = false;
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
                Entity filter = (Entity) ((Map.Entry) iter.next()).getValue();
                String predicate = (String) filter.getProperty("cli-context-predicate").getValue();
                String type = (String) filter.getProperty("type").getValue();
                boolean readOnly = (Boolean) filter.getProperty("read-only").getValue();
                if (LikeComparator.compare(context, predicate, '\\')) {
                    if (type.equals("include")) {
                        granted = true;
                        wasIncludeGranted = true;
                        ro = readOnly;
                    } else {
                        granted = false;
                        wasIncludeGranted = false;
                    }
                } else {
                    if (!wasIncludeGranted)
                        granted = false;
                }
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGrantedAndReadOnly, predicate: " + predicate + ", type: " + type + ", readOnly: " + readOnly + ", granted=" + granted);
            }
        }
    }
    return granted && ro;
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map)

Example 8 with EntityList

use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.

the class Role method getGrantedCommands.

public String[] getGrantedCommands(String context) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/getGrantedCommands, context: " + context);
    EntityList filters = (EntityList) roleEntity.getEntity("context-filters");
    if (filters != null) {
        Map map = filters.getEntities();
        if (map != null && map.size() > 0) {
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
                Entity filter = (Entity) ((Map.Entry) iter.next()).getValue();
                String predicate = (String) filter.getProperty("cli-context-predicate").getValue();
                if (LikeComparator.compare(context, predicate, '\\')) {
                    String cmds = (String) filter.getProperty("granted-commands").getValue();
                    if (cmds != null)
                        return SwiftUtilities.tokenize(cmds, " ,");
                }
            }
        }
    }
    return new String[0];
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map)

Example 9 with EntityList

use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.

the class MailServer method connect.

/**
 * Does the actual connect to the mail server.
 *
 * @return MailServer
 * @throws Exception
 */
public MailServer connect() throws Exception {
    boolean smtpAuthEnabled = username != null;
    Properties props = new Properties();
    props.setProperty("mail.smtp.host", host);
    props.setProperty("mail.smtp.auth", String.valueOf(smtpAuthEnabled));
    session = Session.getInstance(props, smtpAuthEnabled ? new SMTPPasswordAuthenticator(username, password) : null);
    session.setDebug(ctx.ctx.traceSpace.enabled);
    transport = session.getTransport("smtp");
    transport.connect();
    try {
        EntityList mailList = (EntityList) ctx.usage.getEntity("mailservers");
        usage = mailList.createEntity();
        usage.setName(host);
        usage.createCommands();
        mailList.addEntity(usage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return this;
}
Also used : EntityList(com.swiftmq.mgmt.EntityList) Properties(java.util.Properties)

Example 10 with EntityList

use of com.swiftmq.mgmt.EntityList in project swiftmq-ce by iitsoftware.

the class Role method isContextGranted.

public boolean isContextGranted(String context, boolean wantChange) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGranted, context: " + context + ", wantChange: " + wantChange);
    if (!((Boolean) adminRolesEnabled.getValue()).booleanValue())
        return true;
    boolean granted = false;
    EntityList filters = (EntityList) roleEntity.getEntity("context-filters");
    if (filters != null) {
        Map map = filters.getEntities();
        if (map != null && map.size() > 0) {
            boolean wasIncludeGranted = false;
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
                Entity filter = (Entity) ((Map.Entry) iter.next()).getValue();
                String predicate = (String) filter.getProperty("cli-context-predicate").getValue();
                String type = (String) filter.getProperty("type").getValue();
                boolean readOnly = (Boolean) filter.getProperty("read-only").getValue();
                if (LikeComparator.compare(context, predicate, '\\')) {
                    if (type.equals("include")) {
                        granted = true;
                        wasIncludeGranted = true;
                        if (wantChange && readOnly)
                            granted = false;
                    } else {
                        granted = false;
                        wasIncludeGranted = false;
                    }
                } else {
                    if (!wasIncludeGranted)
                        granted = false;
                }
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/isContextGranted, context: " + context + ", predicate: " + predicate + ", type: " + type + ", readOnly: " + readOnly + ", granted=" + granted);
            }
        }
    }
    return granted;
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) Iterator(java.util.Iterator) Map(java.util.Map)

Aggregations

EntityList (com.swiftmq.mgmt.EntityList)17 Entity (com.swiftmq.mgmt.Entity)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)8 Iterator (java.util.Iterator)5 Map (java.util.Map)5 EntityAddException (com.swiftmq.mgmt.EntityAddException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JMSException (javax.jms.JMSException)2 JobFactoryAdded (com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded)1 ManagementProcessor (com.swiftmq.impl.streams.processor.ManagementProcessor)1 Property (com.swiftmq.mgmt.Property)1 JobParameter (com.swiftmq.swiftlet.scheduler.JobParameter)1 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 Properties (java.util.Properties)1 XAException (javax.transaction.xa.XAException)1