Skip to content

Configuring XDI messaging containers

Markus Sabadello edited this page Feb 6, 2017 · 3 revisions

The xdi2-server component uses its configuration files to configure XDI messaging containers.

Spring Beans

The Java Spring Framework and its Inversion of Control principles are used to configure the messaging containers.

Every Spring bean in the applicationContext.xml configuration file whose name starts with a slash ('/') is expected to be a messaging container. The bean name becomes the relative path at which the messaging container is "mounted" and exposed as an XDI endpoint that can receive and process incoming XDI messages.

Many important classes of the XDI2 library are compatible with the Spring bean mechanism, for example implementations of the GraphFactory and Graph interfaces of the xdi2-core component.

A Simple XDI Endpoint

The simplest way to set up an XDI endpoint is as follows:

  1. Instantiate an implementation of the GraphFactory interface as a Spring bean.
  2. Use the openGraph() method of the GraphFactory bean to instantiate an implementation of the Graph interface.
  3. Instantiate the GraphMessagingContainer class and set its "graph" property to the Graph bean.

The following configuration sets up a simple XDI endpoint backed by an in-memory graph at the relative path /mem-graph.

<bean id="graphfactory1" class="xdi2.core.impl.memory.MemoryGraphFactory">
</bean>

<bean id="graph1" factory-bean="graphfactory1" factory-method="openGraph" />

<bean name="/mem-graph" class="xdi2.messaging.container.impl.graph.GraphMessagingContainer">
	<property name="graph" ref="graph1" />
</bean>

A More Complex XDI Endpoint

Messaging containers can be assigned interceptors and contributors in order to add specific functionality.

<bean id="graphfactory4" class="xdi2.core.impl.memory.MemoryGraphFactory">
</bean>

<bean id="graph4" factory-bean="graphfactory4" factory-method="openGraph">
	<constructor-arg><value>(=!:uuid:1111)</value></constructor-arg>
</bean>

<bean name="/=alice" class="xdi2.messaging.container.impl.graph.GraphMessagingContainer">
	<property name="graph" ref="graph4" />
	<property name="interceptors">
		<util:list>
			<bean class="xdi2.messaging.container.interceptor.impl.BootstrapInterceptor">
				<property name="bootstrapOwner" value="=!:uuid:1111" />
				<property name="bootstrapOwnerSynonyms">
					<util:list>
						<value>=alice</value>
					</util:list>
				</property>
				<property name="bootstrapRootLinkContract" value="true" />
				<property name="bootstrapPublicLinkContract" value="true" />
				<property name="bootstrapTimestamp" value="true" />
				<property name="bootstrapGraph">
					<value>
						({$self}/$public)$do/$get/{$self}$msg$encrypt$keypair&lt;$public&gt;&lt;$key&gt;
						({$self}/$public)($do/$get){$self}$msg$encrypt$keypair/$is#/{}
						({$self}/$public)$do/$get/{$self}$msg$sig$keypair&lt;$public&gt;&lt;$key&gt;
						({$self}/$public)($do/$get){$self}$msg$sig$keypair/$is#/{}
					</value>
				</property>
				<property name="bootstrapMessageEnvelope">
					<value>
						($anon[$msg]*!1$do/$do$keypair){$self}$msg$encrypt$keypair/$is#/$rsa$2048
						($anon[$msg]*!1$do/$do$keypair){$self}$msg$sig$keypair/$is#/$rsa$2048
					</value>
				</property>
			</bean>
			<bean class="xdi2.messaging.container.interceptor.impl.RefInterceptor" />
			<bean class="xdi2.messaging.container.interceptor.impl.ToInterceptor" />
			<bean class="xdi2.messaging.container.interceptor.impl.authentication.secrettoken.AuthenticationSecretTokenInterceptor">
				<property name="secretTokenAuthenticator">
					<bean class="xdi2.messaging.container.interceptor.impl.authentication.secrettoken.StaticSecretTokenAuthenticator">
						<property name="globalSalt" value="00000000-0000-0000-0000-000000000000" />
						<property name="localSaltAndDigestSecretTokens">
							<util:map>
								<entry key="=!:uuid:1111" value="xdi2-digest:ec136367-5969-4e69-9c8a-483e330c317f:8a447e411ad21477b67b8793e5be16749416b996c61a40476c17231be4d9390a8e703b87cf8750b66fb541f208799d3b564ee6ed33cae8f9f84ce39c1527e62e" />
							</util:map>
						</property>
					</bean>
				</property>
			</bean>
			<bean class="xdi2.messaging.container.interceptor.impl.linkcontract.LinkContractInterceptor" />
		</util:list>
	</property>
	<property name="contributors">
		<util:list>
			<bean class="xdi2.messaging.container.contributor.impl.digest.GenerateDigestSecretTokenContributor">
				<property name="globalSalt" value="00000000-0000-0000-0000-000000000000" />
			</bean>
			<bean class="xdi2.messaging.container.contributor.impl.keygen.GenerateKeyContributor" />
		</util:list>
	</property>
</bean>
Clone this wiki locally