public void initialiseExecutionContext() {
final Identity transportIdentity = new EventTransportIdentityImpl(JmsEventTransportImpl.this, transportIdentifier);
if (executionContext == null) {
executionContext = new ExecutionContext() {
@Override
public GeoLocationDetails getLocation() { return null; }
@Override
public IdentityChain getIdentity() {
return new IdentityChain() {
List<Identity> identities= new ArrayList<Identity>(1) {{ add(transportIdentity);}};
@Override
public List<Identity> getIdentities() {
return identities;
}
@Override
public void addIdentity(Identity identity) {
identities.add(identity);
}
@SuppressWarnings({"unchecked"})
@Override
public <T extends Identity> List<T> getIdentities(Class<T> clazz) {
List<T> filteredIdentityList = new ArrayList<T>();
for (Identity identity : identities) {
if (clazz.isAssignableFrom(identity.getClass())) {
filteredIdentityList.add((T)identity);
}
}
return filteredIdentityList;
}
public String toString() {
StringBuffer sb = new StringBuffer("Sonic IdentityChain_");
for (int i=0; i<identities.size(); i++) {
sb.append("Identity:").append(i).append(" ").append(identities.get(i)).append(" ");
}
return sb.toString();
}
};
}
@Override
public RequestUUID getRequestUUID() { return null; }
@Override
public Date getReceivedTime() { return null; }
@Override
public Date getRequestTime() { return null; }
@Override
public boolean traceLoggingEnabled() { return false;}
@Override
public int getTransportSecurityStrengthFactor() {
return 0; // todo: where do we get this from??
}
@Override
public boolean isTransportSecure() {
return getTransportSecurityStrengthFactor() > 1;
}
};
} else {
if (executionContext.getIdentity() != null &&
executionContext.getIdentity().getIdentities(EventTransportIdentity.class).isEmpty()) {
final ExecutionContext delegateExecutionContext = executionContext;
final List<Identity> augmentedIdentityChainList = new ArrayList<Identity>(delegateExecutionContext.getIdentity().getIdentities());
augmentedIdentityChainList.add(transportIdentity);
executionContext = new ExecutionContext() {
@Override
public IdentityChain getIdentity() {
IdentityChain ic = new IdentityChain() {
@Override
public List<Identity> getIdentities() {
return augmentedIdentityChainList;
}
@Override
public void addIdentity(Identity identity) {
augmentedIdentityChainList.add(identity);
}
@Override
public <T extends Identity> List<T> getIdentities(Class<T> clazz) {
List<T> filteredIdentityChain = new ArrayList<T>();
for (Identity identity : augmentedIdentityChainList) {
if (clazz.isAssignableFrom(identity.getClass())) {
filteredIdentityChain.add((T)identity);
}
}
return filteredIdentityChain;
}
public String toString() {
StringBuffer sb = new StringBuffer("Sonic IdentityChain_\n");
for (int i=0; i<augmentedIdentityChainList.size(); i++) {
sb.append("Identity:").append(i).append(" ").append(augmentedIdentityChainList.get(i)).append(" ");
}
return sb.toString();
}
};
return ic;
}
@Override
public RequestUUID getRequestUUID() { return delegateExecutionContext.getRequestUUID(); }
@Override
public Date getReceivedTime() { return delegateExecutionContext.getReceivedTime(); }
@Override
public Date getRequestTime() { return delegateExecutionContext.getRequestTime(); }
@Override
public boolean traceLoggingEnabled() { return delegateExecutionContext.traceLoggingEnabled(); }
@Override
public GeoLocationDetails getLocation() { return delegateExecutionContext.getLocation(); }
@Override
public int getTransportSecurityStrengthFactor() { return delegateExecutionContext.getTransportSecurityStrengthFactor(); }
@Override
public boolean isTransportSecure() { return delegateExecutionContext.isTransportSecure(); }
};
}
}
}