Custom Server Implementation

It is possible to use wsag4j only as webservice engine and replace the default WS-Agreement engine with a custom implementation. By doing that, mechanisms for e.g. validating agreement offers, are not available.

To configure a new wsag4j implementation you have to unzip the distribution war file, add your implementation jar to the webapp/WEB-INF/lib directory and change the wsag4j.properties file in the webapp/WEB-INF/classes folder in order to use your implementation.

  • change the org.ogf.graap.wsag.api.AgreementFactory property to your WS-Agreement server implementation class.

The easiest way to implement a new AgreementFactory or Agreement is to inherit from one of the following classes:

  • org.ogf.graap.wsag.server.simple.SimpleAgreementFactory
  • org.ogf.graap.wsag.server.simple.SimpleAgreement

Server implementation

The following samples provide an overview how a server implementation could look like.

This sample shows how to get informations about state

    @Override
    public GuaranteeTermStateType[] getGuaranteeTermStates()
    {
        GuaranteeTermStateType[] state = new GuaranteeTermStateType[2];

        state[0] = GuaranteeTermStateType.Factory.newInstance();
        state[1] = GuaranteeTermStateType.Factory.newInstance();

        state[0].setState( GuaranteeTermStateDefinition.NOT_DETERMINED );
        state[0].setTermName( "term_0" );

        state[1].setState( GuaranteeTermStateDefinition.FULFILLED );
        state[1].setTermName( "term_1" );

        return state;
    }

Accessing security properties

Real world implementations need to access the credentials clients used to authenticate at a service. A common example is a wsag4j based service, that allows or denies the creation service level agreements based on the clients access rights. In wsag4j the client credentials can be retrieved via the org.ogf.graap.wsag.api.engine.WsagMessageContext class.

The message context stores a set of parameters, which can be used by implementations to access functionalities of the basic frameworks. The most important parameters are listed below:

  • org.ogf.graap.wsag.api.engine.WsagMessageContext.AXIS_MESSAGE_CONTEXT Returns the Axis 2 message context for the current thread.
  • org.ogf.graap.wsag.security.core.SecurityConstants.X509_CLIENT_CERTIFICATE Returns the client certificate that was used for signing the message.
  • org.ogf.graap.wsag.security.core.SecurityConstants.X509_CLIENT_CERTIFICATE_CHAIN Returns the client certificate chain that was used for signing the message.