Engines and Servers

Engines and Servers

Engines

jWebSocket.xml engine configuration.

<!-- jWebSocket engine configuration -->
<engines>   
  <engine>     
    <name>org.jwebsocket.tcp.engines.TCPEngine</name>     
    <id>tcp0</id>     
    <jar>jWebSocketTCPEngine-<version>.jar</jar>
    <port>8787</port>
	<!-- these domains are accepted by the engine listening on the above mentioned port -->
    <domains>       
      <domain>jwebsocket.org</domain>       
      <domain>jwebsocket.com</domain>     
    </domains>     
    <timeout>120000</timeout>   
  </engine>   
  <engine>     
    <name>org.jwebsocket.netty.engines.NettyEngine</name>     
    <id>netty0</id>     
    <jar>jWebSocketNettyEngine-
      <version>.jar</version>
    </jar>     
    <port>8788</port>
	<!-- these domains are accepted by the engine listening on the above mentioned port -->    
    <domains>       
      <domain>javawebsocket.org</domain>       
      <domain>javawebsocket.com</domain>     
    </domains>     
    <timeout>120000</timeout>   
  </engine> 
</engines>

<Engines> section in the jWebSocket.xml

Servers

jWebSocket.xml server configuration.

<!-- server types to be instantiated for jWebSocket -->
<servers>   
  <server>     
    <name>org.jwebsocket.server.TokenServer</name>     
    <id>ts0</id>     
    <jar>jWebSocketTokenServer-<version>.jar</jar>   
  </server>   
  <server>     
    <name>org.jwebsocket.server.CustomServer</name>     
    <id>cs0</id>     
    <jar>jWebSocketCustomServer-<version>.jar</jar>   
  </server> 
</servers>

<Servers> section in the jWebSocket.xml

Plug-Ins and Filters

Plug-Ins

jWebSocket.xml plug-in configuration.

<!-- plug-ins to be instantiated for jWebSocket -->
<plugins>   
  <plugin>     
    <name>org.jwebsocket.plugins.system.SystemPlugIn</name>     
    <ns>org.jWebSocket.plugins.system</ns>     
    <id>jws.system</id>     
    <jar>jWebSocketPlugins-<version>.jar</jar>
    <!-- plug-in specific settings -->     
    <settings>       <!-- specify whether open,close,login,logout event should be broadcasted -->       
      <setting key="broadcastOpenEvent">true</setting>       
      <setting key="broadcastCloseEvent">true</setting>       
      <setting key="broadcastLoginEvent">true</setting>       
      <setting key="broadcastLogoutEvent">true</setting>     
    </settings>     
    <server-assignments>       
      <server-assignment>ts0</server-assignment>     
    </server-assignments>   
  </plugin>   :   
  <plugin>     
    <name>org.jwebsocket.plugins.flashbridge.FlashBridgePlugIn</name>     
    <id>jws.flashbridge</id>     
    <ns>org.jWebSocket.plugins.flashbridge</ns>     
    <jar>jWebSocketPlugins-<version>.jar</jar>     
    <server-assignments>       
      <server-assignment>ts0</server-assignment>     
    </server-assignments>   
  </plugin> 
</plugins>

<Plugins> section in the jWebSocket.xml

Filters

jWebSocket.xml filter configuration.

<!-- filters to be instantiated for jWebSocket -->
<filters>   
  <filter>     
    <name>org.jwebsocket.filters.system.SystemFilter</name>     
    <ns>org.jWebSocket.filters.system</ns>     
    <id>systemFilter</id>     
    <jar>jWebSocketPlugins-<version>.jar</jar>
    <!-- plug-in specific settings -->     
    <settings>
      <!-- specify whether open,close,login,logout event should be broadcasted -->       
      <setting key="key">value</setting>
    </settings>     
    <server-assignments>       
      <server-assignment>ts0</server-assignment>     
    </server-assignments>   
  </filter>   
  <filter>     
    <name>org.jwebsocket.filters.custom.CustomTokenFilter</name>     
    <id>userFilter</id>     
    <ns>org.jWebSocket.filters.custom</ns>     
    <jar>jWebSocketPlugins-<version>.jar</jar>     
    <server-assignments>       
      <server-assignment>ts0</server-assignment>     
    </server-assignments>   
  </filter> 
</filters>

<Filters> section in the jWebSocket.xml

Rights and Roles

The access to certain resources or functions of the jWebSocket server is controlled by roles and rights. Both rights and roles are specified in the jWebSocket.xml. A user is always assigned to one or more roles and each role covers one or more rights. Thus the user's effective rights are calculated by all rights of those roles the user is assigned to.

Rights

Rights are specified by an id, a namespace and a description in a section of the jWebSocket.xml config file. Rights are not directly assigned to a certain user but only to roles (see below).

<!-- jWebSocket global rights -->
<rights>   <!-- configuration of chat plug-in specific rights -->  
<!-- list of rights for "User" role (ns + . + id) -->   
  <right>     
    <ns>org.jWebSocket.plugins.chat</ns>     
    <id>broadcast</id>     
    <description>Broadcast message to all other clients.</description>   
  </right>    <!-- configuration of rpc plug-in specific rights -->   
  <right>     
    <ns>org.jWebSocket.plugins.rpc</ns>     
    <id>rpc</id>     
    <description>Allow Remote Procedure Calls (RPC) to server</description>   
  </right> 
</rights>

<Rights> section in the jWebSocket.xml

Rights can either be global or plug-in specific. Hence there can be multiple sections in a config file, one global one and optionally one per plug-in if the plug-in needs a authorization mechanism. Because plug-ins already have a namespace the namespace for the plug-in specific right can be inherited and does not explicitely be specified. If it is specified it overwrites the inherited value. Internally all effective rights of a use are maintained in a single map with. Acting as the key and the Right class as value.

Roles

Like the Rights, roles are also specified by an id, a namespace and a description in a section of the jWebSocket.xml config file. A user is assigned to one or more roles. His effective rights are calculated by all rights of the roles he is assigned to.

<!-- jWebSocket roles -->
<roles>   
  <role>     
    <id>Administrator</id>     
    <description>Administrators</description>     
    <rights>       <!-- list of rights for "Administrator" role (ns + . + id) -->       
      <right>org.jWebSocket.plugins.chat.broadcast</right>       
      <right>org.jWebSocket.plugins.rpc.rpc</right>       
      <right>org.jWebSocket.plugins.rpc.rrpc</right>     
    </rights>   
  </role>   
  <role>     
    <id>Guest</id>     
    <description>Anonymous users (not registered)</description>     
    <rights>       <!-- list of rights for "Guest" role (ns + . + id) -->       
      <right>org.jWebSocket.plugins.chat.broadcast</right>     
    </rights>   
  </role> 
</roles>

<Roles> section in the jWebSocket.xml

Unlike the rights, the roles do not have a namespace but a list of rights. The section within a role specifies which rights a user obtains when he is assigned to that role.

Users

In the users sections of the jWebSocket.xml all users that may login at the jWebSocket server are listed. A user is specified by its loginname, firstname, lastname and a description. The status field allows or blocks a user. In the roles section it is specified to which roles a user is assigned to.

<!-- jWebSocket users -->
<users>   
  <user>     
    <loginname>aschulze</loginname>     
    <firstname>Alexander</firstname>     
    <lastname>Schulze</lastname>     
    <password>t0p-s3cr3t</password>     
    <description>jWebSocket Founder</description>     <!-- 0=blocked 1=allowed ... future states pending -->     
    <status>1</status>     
    <roles>       <!-- the rights of all roles are merged -->       
      <role>Administrator</role>       
      <role>User</role>       
      <role>Guest</role>     
    </roles>   
  </user>   
  <user>     
    <loginname>guest</loginname>     
    <firstname>Mr./Mrs.</firstname>     
    <lastname>Guest</lastname><!-- no password means that the user does not need a password -->     
    <password></password>     
    <description>jWebSocket Guest</description>     
    <status>1</status>     
    <roles>       
      <role>Guest</role>     
    </roles>   
  </user> 
</users>

<Users> section in the jWebSocket.xml

Please notice that the password field is stored in plain text here, so take care that the jWebSocket.xml file is not accessible by unauthorized people on the network.

Publications

Learn more about WebSockets in general, get background information and gain deeper insight!

Join jWebSocket

Wether developer, designer or translator – join the jWebSocket team and grow together with our success!

Contact

jWebSocket Headquarter

Innotrade GmbH

An Vieslapp 29

52134 Herzogenrath

Germany

Copyright © 2013 Innotrade GmbH. All rights reserved.