# Application Development Guide

# Session Manager Web Service

The Session Manager Web Service contains operations for establishing a session with Oracle Communications Services Gatekeeper, changing the application’s password, querying the amount of time remaining in the session, refreshing the session, and terminating the session.

Note: | Not all installations of Oracle Communications Services Gatekeeper require session management. The contents of this chapter apply only to those installations that do.

When an operator requires it, an application must establish a session with Oracle Communications Services Gatekeeper before the application can perform any operations on the Parlay X or Extended Web Services interfaces. When a session is established, a session ID is returned which must be used in each subsequent operation towards Oracle Communications Services Gatekeeper.

## Endpoint

The WSDL for the Session Manager can be found at `http://<host>:<port>/session_manager/SessionManager`

where host and port depend on the Oracle Communications Services Gatekeeper deployment.

## Interface: SessionManager

Operations to establish a session, change a password, get the remaining lifetime of a session, refresh a session and destroy a session.

### Operation: getSession

Establishes a session using Web Services Security. Authentication information must be provided according to WS-Security. See Authentication.

#### Input message: getSession

Part name | Part type | Optional | Description
--- | --- | --- | ---
- | - | - | -

#### Output message: getSessionResponse

Part name | Part type | Optional | Description
--- | --- | --- | ---
getSessionReturn | xsd:String | N | The session ID to use in subsequent requests.

#### Referenced faults

GeneralException

### Operation: changeApplicationPassword

Changes the password for an application.

#### Input message: changeApplicationPassword

Part name | Part type | Optional | Description
--- | --- | --- | ---
sessionId | xsd:string | N | The ID of an established session.
oldPassword | xsd:string | N | The current password.
newPassword | xsd:string | N | The new password.

#### Output message: changeApplicationPasswordResponse

Part name | Part type | Optional | Description
--- | --- | --- | ---
- | - | - | -

#### Referenced faults

-

### Operation: getSessionRemainingLifeTime

Gets the remaining lifetime of an established session. The default lifetime is configured in Oracle Communications Services Gatekeeper.

#### Input message: getSessionRemainingLifeTime

Part name | Part type | Optional | Description
--- | --- | --- | ---
sessionId | xsd:string | N | The ID of an established session.

#### Output message: getSessionRemainingLifeTimeResponse

Part name | Part type | Optional | Description
--- | --- | --- | ---
getSessionRemainingLifeTimeReturn | xsd:string | N | The remaining lifetime of the session. Given in milliseconds.

#### Referenced faults

-

### Operation: refreshSession

Refreshes the lifetime of an session. The session can be refreshed during a time interval after the a session has expired. This time interval is configured in Oracle Communications Services Gatekeeper.

#### Input message: refreshSession

Part name | Part type | Optional | Description
--- | --- | --- | ---
sessionId | xsd:string | N | The ID of an established session.

#### Output message: refreshSessionResponse

Part name | Part type | Optional | Description
--- | --- | --- | ---
refreshSessionReturn | xsd:string | N | The session ID to be used in subsequent requests. The same ID as the original session ID is returned.

#### Referenced faults

-

### Operation: destroySession

Destroys an established session.

#### Input message: destroySession

Part name | Part type | Optional | Description
--- | --- | --- | ---
sessionId | xsd:string | N | The ID of an established session.

#### Output message: destroySessionResponse

Part name | Part type | Optional | Description
--- | --- | --- | ---
destroySessionReturn | xsd:boolean | N | True if the session was destroyed.

#### Referenced faults

-

## Examples

The code below illustrates how to get the Session Manager and how to prepare the generated stub with Web Service security information. The stub is generated from the Session Manager Web Service.

Listing 4-1 Get hold of the Session Manager

    protected ClientSessionManImpl(String sessionManagerURL, PolicyBase pbase) throws Exception {

      SessionManagerService accessservice =

        new SessionManagerService_Impl(sessionManagerURL+"?WSDL");

      port = accessservice.getSessionManager();

      pbase.prepareStub((Stub)port);

      }

Below illustrates how to prepare the Session Manager stub with Username Token information according to WS-Policy.

Listing 4-2 Prepare the Session Manager with Username Token information

    package com.bea.wlcp.wlng.client.access.wspolicy;

    import weblogic.wsee.security.unt.ClientUNTCredentialProvider;

    import weblogic.xml.crypto.wss.WSSecurityContext;

    import javax.xml.rpc.Stub;

    import java.util.ArrayList;

    import java.util.List;

    public class UsernameTokenPolicy implements PolicyBase {

      private String username;

      private String password;

    public UsernameTokenPolicy(String username, String password) {

        this.username = username;

        this.password = password;

      }

      public void prepareStub(Stub stub) throws Exception {

        List<ClientUNTCredentialProvider> credProviders = new ArrayList<ClientUNTCredentialProvider>();

        credProviders.add(new ClientUNTCredentialProvider(username.getBytes(),

                                                          password.getBytes()));

        System.out.println("setting standard wssec");

        stub._setProperty(WSSecurityContext.CREDENTIAL_PROVIDER_LIST,

                          credProviders);

      }

    }