/** * Adds context items to this set. * * @param contextItems Context items to add. */ public void addItems(ContextItems contextItems) { addItems(contextItems.items); }
/** * Adds context items to this set. * * @param contextItems Context items to add. */ public void addItems(ContextItems contextItems) { addItems(contextItems.items); }
/** * Returns the marshaled context representing the state of all shared contexts. * * @return A ContextItems object representing the current state of all shared contexts. */ public ContextItems getMarshaledContext() { ContextItems marshaledContext = new ContextItems(); for (IManagedContext<?> managedContext : managedContexts) { marshaledContext.addItems(managedContext.getContextItems(false)); } return marshaledContext; }
/** * Returns the marshaled context representing the state of all shared contexts. * * @return A ContextItems object representing the current state of all shared contexts. */ public ContextItems getMarshaledContext() { ContextItems marshaledContext = new ContextItems(); for (IManagedContext managedContext : managedContexts) { marshaledContext.addItems(managedContext.getContextItems(false)); } return marshaledContext; }
/** * Initializes one or all managed contexts to their default state. * * @param item Managed context to initialize or, if null, initializes all managed contexts. * @param callback Callback to report subscriber responses. */ public void init(IManagedContext<?> item, ISurveyCallback callback) { contextItems.clear(); if (ccowIsActive()) { contextItems.addItems(ccowContextManager.getCCOWContext()); } if (item != null) { initItem(item, callback); } else { SurveyResponse response = new SurveyResponse(); initItem(managedContexts.iterator(), response, callback); } }
/** * Unmarshals the marshaled context. Performs digital signature verification, then returns the * unmarshaled context items. * * @param marshaledContext Marshaled context * @param authSignature If set, the digital signature is verified. * @return The unmarshaled context. * @throws Exception Unspecified exception. */ public ContextItems unmarshal(String marshaledContext, String authSignature) throws Exception { ContextItems contextItems = new ContextItems(); contextItems.addItems(marshaledContext); String whichKey = contextItems.getItem(PROPNAME_KEY); String timestamp = contextItems.getItem(PROPNAME_TIME); if (authSignature != null && !signer.verify(authSignature, marshaledContext, timestamp, whichKey)) { throw new MarshalException("Invalid digital signature"); } return contextItems; } }
/** * Unmarshals the marshaled context. Performs digital signature verification, then returns the * unmarshaled context items. * * @param marshaledContext Marshaled context * @param authSignature If set, the digital signature is verified. * @return The unmarshaled context. * @throws Exception Unspecified exception. */ public ContextItems unmarshal(String marshaledContext, String authSignature) throws Exception { ContextItems contextItems = new ContextItems(); contextItems.addItems(marshaledContext); String whichKey = contextItems.getItem(PROPNAME_KEY); String timestamp = contextItems.getItem(PROPNAME_TIME); if (authSignature != null && !signer.verify(authSignature, marshaledContext, timestamp, whichKey)) { throw new MarshalException("Invalid digital signature"); } return contextItems; } }
/** * Initializes one or all managed contexts to their default state. * * @param item Managed context to initialize or, if null, initializes all managed contexts. * @return True if the operation was successful. */ public boolean init(IManagedContext item) { contextItems.clear(); boolean result = true; if (ccowIsActive()) { contextItems.addItems(ccowContextManager.getCCOWContext()); } if (item != null) { result = initItem(item); } else { for (IManagedContext managedContext : managedContexts) { result &= initItem(managedContext); } } return result; }