Package org.apache.sling.jcr.webdav.impl.helper

# Class SlingSessionProvider

java.lang.Object
org.apache.sling.jcr.webdav.impl.helper.SlingSessionProvider

All Implemented Interfaces:
  `org.apache.jackrabbit.server.SessionProvider`

public class SlingSessionProvider extends Object implements org.apache.jackrabbit.server.SessionProvider
The `SlingSessionProvider` is a Jackrabbit WebDAV server `SessionProvider` which returns the session stored as the `javax.jcr.Session` request attribute. This request attribute is set by the Sling Authenticator when the request is authenticated. If the request is not authenticated, the request attribute is not set and hence no session is returned.

This class expects an authenticated request, which is identified by the request authentication type to not be `null`. Otherwise the `getSession(HttpServletRequest, Repository, String)` method throws a `LoginException` to force authentication.

## Constructor Summary

Constructors
Constructor
Description
`SlingSessionProvider()`

## Method Summary

Modifier and Type
Method
Description
`javax.jcr.Session`
`getSession(javax.servlet.http.HttpServletRequest request, javax.jcr.Repository rep, String workspace)`
Returns the value of the `javax.jcr.Session` request attribute or `null` if the request attribute is not set.
`void`
`releaseSession(javax.jcr.Session session)`
Does nothing as the session is taken from the Sling request and hence the session will be released by Sling.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SlingSessionProvider

public SlingSessionProvider()

## Method Details

### getSession

public javax.jcr.Session getSession(javax.servlet.http.HttpServletRequest request, javax.jcr.Repository rep, String workspace) throws javax.jcr.LoginException
Returns the value of the `javax.jcr.Session` request attribute or `null` if the request attribute is not set. If the request is not authenticated, that is the authentication type is `null`, a `LoginException` is thrown to force authentication.

Specified by:
  `getSession` in interface `org.apache.jackrabbit.server.SessionProvider`
Throws:
  `javax.jcr.LoginException`

### releaseSession

public void releaseSession(javax.jcr.Session session)
Does nothing as the session is taken from the Sling request and hence the session will be released by Sling.

Specified by:
  `releaseSession` in interface `org.apache.jackrabbit.server.SessionProvider`