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) {
}
}
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;
}
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];
}
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;
}
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;
}
Aggregations