Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.coherence.rest.server
Class AbstractHttpServer

java.lang.Object
  extended by com.tangosol.coherence.rest.server.AbstractHttpServer

All Implemented Interfaces:
HttpServer
Direct Known Subclasses:
DefaultHttpServer, GrizzlyHttpServer, SimpleHttpServer

public abstract class AbstractHttpServer
extends java.lang.Object
implements HttpServer

Abstract base class for HttpServer implementations.

Author:
as 2011.06.16

Nested Class Summary
protected static class AbstractHttpServer.SimpleSecurityContext
          Simple implementation of the SecurityContext interface.

 

Field Summary
static java.lang.String ATTR_SUBJECT
          Attribute name that should be used to store Subject for the request.
static java.lang.String AUTH_BASIC
          HTTP basic authentication.
static java.lang.String AUTH_CERT
          Certificate authentication.
static java.lang.String AUTH_CERT_BASIC
          Certificate authentication.
static java.lang.String AUTH_NONE
          No authentication.
static java.lang.String DEFAULT_ADDRESS
          Default HTTP server address.
static IdentityAsserter DEFAULT_IDENTITY_ASSERTER
          Default identity asserter.
static int DEFAULT_PORT
          Default HTTP server port.
static java.lang.String HEADER_AUTHORIZATION
          Authorization header.
protected static java.lang.String HEADER_WWW_AUTHENTICATE
          WWW-Authenticate header.
static java.lang.String HTTP_BASIC_REALM
          Realm for HTTP basic authentication.
protected  ConfigurableCacheFactory m_cacheFactory
          Cache factory.
protected  boolean m_fStarted
          Flag specifying whether the server is already started.
protected  IdentityAsserter m_identityAsserter
          Identity asserter to use with HTTP basic authentication.
protected  java.util.Map m_mapResourceConfig
          Map of context names to Jersey resource configurations.
protected  int m_nPort
          Port number server should listen on.
protected  java.lang.String m_sAddr
          Address server should listen on.
protected  java.lang.String m_sAuthMethod
          Authentication method.
protected  Service m_serviceParent
          Parent service.
protected  com.oracle.common.net.SocketProvider m_socketProvider
          SocketProvider used by the server.

 

Constructor Summary
AbstractHttpServer()
           

 

Method Summary
protected  javax.security.auth.Subject authenticate(java.lang.String sAuth)
          Perform HTTP Basic authentication and return authenticated Subject.
protected  java.lang.Object createContainer(com.sun.jersey.api.core.ResourceConfig resourceConfig)
          Create and configure a Jersey container that will process HTTP requests.
 IdentityAsserter getIdentityAsserter()
          Return identity asserter to use for HTTP basic authentication.
 java.lang.String getLocalAddress()
          Return the address the server should listen on.
 int getLocalPort()
          Return the port number the server should listen on.
 Service getParentService()
          Return the service that is embedding this server.
 java.util.Map getResourceConfig()
          Return map of context names to Jersey resource configurations.
 com.oracle.common.net.SocketProvider getSocketProvider()
          Return the SocketProvider to use.
 javax.net.ssl.SSLContext getSSLContext()
          Return the SSLContext to use.
 javax.net.ssl.SSLParameters getSSLParameters()
          Return the SSLParameters to use.
protected  javax.security.auth.Subject getSubjectFromSession(javax.net.ssl.SSLSession session)
          Creates Subject instance using principal and credentials from the SSL session.
protected  void handleRequest(com.sun.jersey.spi.container.WebApplication app, com.sun.jersey.spi.container.ContainerRequest request, com.sun.jersey.spi.container.ContainerResponseWriter responseWriter, javax.security.auth.Subject subject)
          Handle HTTP(S) request.
protected abstract  java.lang.Object instantiateContainer(com.sun.jersey.spi.container.WebApplication application, com.sun.jersey.api.core.ResourceConfig config)
          Factory method for Jersey container instances.
protected  boolean isAuthMethodBasic()
          Return true if this server should use HTTP basic authentication.
protected  boolean isAuthMethodCert()
          Return true if this server should use client certificates for authentication.
protected  boolean isAuthMethodNone()
          Return true if this server should not require client authentication.
protected  boolean isSecure()
          Return true if this server uses SSL to secure communication.
 void setAuthMethod(java.lang.String sMethod)
          Set the client authentication method to use.
 void setCacheFactory(ConfigurableCacheFactory cacheFactory)
          Set ConfigurableCacheFactory to use.
protected  void setIdentityAsserter(IdentityAsserter asserter)
          Configure the identity asserter to use for HTTP basic authentication.
 void setLocalAddress(java.lang.String sAddr)
          Set the address server should listen on.
 void setLocalPort(int nPort)
          Set the port number server should listen on.
 void setParentService(Service service)
          Set the Service that is embedding this HttpServer.
 void setResourceConfig(java.util.Map mapConfig)
          Set the map of Jersey ResourceConfig to use.
 void setResourceConfig(com.sun.jersey.api.core.ResourceConfig config)
          Set the Jersey ResourceConfig to use.
 void setSocketProvider(com.oracle.common.net.SocketProvider provider)
          Set the SocketProvider to use.
 void start()
          Start the server.
protected abstract  void startInternal()
          Start the server.
 void stop()
          Stop the server.
protected abstract  void stopInternal()
          Stop the server.
 java.lang.String toString()
          

 

Field Detail

m_sAuthMethod

protected java.lang.String m_sAuthMethod
Authentication method. Valid values are 'basic', 'cert', 'cert+basic', and 'none'.

m_cacheFactory

protected ConfigurableCacheFactory m_cacheFactory
Cache factory.

m_sAddr

protected java.lang.String m_sAddr
Address server should listen on.

m_nPort

protected int m_nPort
Port number server should listen on.

m_serviceParent

protected Service m_serviceParent
Parent service.

m_mapResourceConfig

protected java.util.Map m_mapResourceConfig
Map of context names to Jersey resource configurations.

m_socketProvider

protected com.oracle.common.net.SocketProvider m_socketProvider
SocketProvider used by the server.

m_identityAsserter

protected IdentityAsserter m_identityAsserter
Identity asserter to use with HTTP basic authentication.

m_fStarted

protected boolean m_fStarted
Flag specifying whether the server is already started.

DEFAULT_ADDRESS

public static final java.lang.String DEFAULT_ADDRESS
Default HTTP server address.
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Default HTTP server port.
See Also:
Constant Field Values

DEFAULT_IDENTITY_ASSERTER

public static final IdentityAsserter DEFAULT_IDENTITY_ASSERTER
Default identity asserter.

AUTH_BASIC

public static final java.lang.String AUTH_BASIC
HTTP basic authentication.
See Also:
Constant Field Values

AUTH_CERT

public static final java.lang.String AUTH_CERT
Certificate authentication.
See Also:
Constant Field Values

AUTH_CERT_BASIC

public static final java.lang.String AUTH_CERT_BASIC
Certificate authentication.
See Also:
Constant Field Values

AUTH_NONE

public static final java.lang.String AUTH_NONE
No authentication.
See Also:
Constant Field Values

HTTP_BASIC_REALM

public static final java.lang.String HTTP_BASIC_REALM
Realm for HTTP basic authentication.
See Also:
Constant Field Values

ATTR_SUBJECT

public static final java.lang.String ATTR_SUBJECT
Attribute name that should be used to store Subject for the request.
See Also:
Constant Field Values

HEADER_AUTHORIZATION

public static final java.lang.String HEADER_AUTHORIZATION
Authorization header.
See Also:
Constant Field Values

HEADER_WWW_AUTHENTICATE

protected static final java.lang.String HEADER_WWW_AUTHENTICATE
WWW-Authenticate header.
See Also:
Constant Field Values

Constructor Detail

AbstractHttpServer

public AbstractHttpServer()

Method Detail

setAuthMethod

public void setAuthMethod(java.lang.String sMethod)
Set the client authentication method to use.

Valid values basic for HTTP basic authentication, cert for client certificate authentication, cert+basic for both client certificate and HTTP basic authentication, and none for no authentication.

Specified by:
setAuthMethod in interface HttpServer
Parameters:
sMethod - the authentication method to use

setCacheFactory

public void setCacheFactory(ConfigurableCacheFactory cacheFactory)
Set ConfigurableCacheFactory to use.
Specified by:
setCacheFactory in interface HttpServer
Parameters:
cacheFactory - the cache factory

setLocalAddress

public void setLocalAddress(java.lang.String sAddr)
Set the address server should listen on.
Specified by:
setLocalAddress in interface HttpServer
Parameters:
sAddr - the address

setLocalPort

public void setLocalPort(int nPort)
Set the port number server should listen on.
Specified by:
setLocalPort in interface HttpServer
Parameters:
nPort - the port number

setParentService

public void setParentService(Service service)
Set the Service that is embedding this HttpServer.
Specified by:
setParentService in interface HttpServer
Parameters:
service - the parent service

setResourceConfig

public void setResourceConfig(com.sun.jersey.api.core.ResourceConfig config)
Set the Jersey ResourceConfig to use.

This method will register specified application under the root context, which is equivalent to: setResourceConfig(Collections.singletonMap("/", config));

Specified by:
setResourceConfig in interface HttpServer
Parameters:
config - the resource config for a Jersey web application

setResourceConfig

public void setResourceConfig(java.util.Map mapConfig)
Set the map of Jersey ResourceConfig to use.
Specified by:
setResourceConfig in interface HttpServer
Parameters:
mapConfig - the map of context names to corresponding Jersey resource configs to use

setSocketProvider

public void setSocketProvider(com.oracle.common.net.SocketProvider provider)
Set the SocketProvider to use.
Specified by:
setSocketProvider in interface HttpServer
Parameters:
provider - the SocketProvider

start

public void start()
           throws java.io.IOException
Start the server.
Specified by:
start in interface HttpServer
Throws:
java.io.IOException - if an error occurs

stop

public void stop()
          throws java.io.IOException
Stop the server.
Specified by:
stop in interface HttpServer
Throws:
java.io.IOException - if an error occurs

startInternal

protected abstract void startInternal()
                               throws java.io.IOException
Start the server.
Throws:
java.io.IOException - if an error occurs

stopInternal

protected abstract void stopInternal()
                              throws java.io.IOException
Stop the server.
Throws:
java.io.IOException - if an error occurs

instantiateContainer

protected abstract java.lang.Object instantiateContainer(com.sun.jersey.spi.container.WebApplication application,
                                                         com.sun.jersey.api.core.ResourceConfig config)
Factory method for Jersey container instances.
Parameters:
application - the web application the container delegates to for the handling of HTTP requests
config - the resource configuration
Returns:
container instance

createContainer

protected java.lang.Object createContainer(com.sun.jersey.api.core.ResourceConfig resourceConfig)
Create and configure a Jersey container that will process HTTP requests.
Parameters:
resourceConfig - resource configuration
Returns:
the container

authenticate

protected javax.security.auth.Subject authenticate(java.lang.String sAuth)
Perform HTTP Basic authentication and return authenticated Subject.
Parameters:
sAuth - the value of Authorization header from the request
Returns:
authenticated Subject if successful, null otherwise

getSubjectFromSession

protected javax.security.auth.Subject getSubjectFromSession(javax.net.ssl.SSLSession session)
                                                     throws javax.net.ssl.SSLPeerUnverifiedException
Creates Subject instance using principal and credentials from the SSL session.
Parameters:
session - SSL session
Returns:
Subject for the client
Throws:
javax.net.ssl.SSLPeerUnverifiedException - if the client is not authenticated

handleRequest

protected void handleRequest(com.sun.jersey.spi.container.WebApplication app,
                             com.sun.jersey.spi.container.ContainerRequest request,
                             com.sun.jersey.spi.container.ContainerResponseWriter responseWriter,
                             javax.security.auth.Subject subject)
                      throws java.io.IOException
Handle HTTP(S) request.
Parameters:
app - web application that should handle request
request - the request
responseWriter - the response writer
subject - the subject, can be null
Throws:
java.io.IOException - if an error occurs

getLocalAddress

public java.lang.String getLocalAddress()
Return the address the server should listen on.
Returns:
the address

getLocalPort

public int getLocalPort()
Return the port number the server should listen on.
Returns:
the port number

getParentService

public Service getParentService()
Return the service that is embedding this server.
Returns:
the parent service

getSocketProvider

public com.oracle.common.net.SocketProvider getSocketProvider()
Return the SocketProvider to use.
Returns:
the SocketProvider

getSSLContext

public javax.net.ssl.SSLContext getSSLContext()
Return the SSLContext to use.
Returns:
the SSLContext

getSSLParameters

public javax.net.ssl.SSLParameters getSSLParameters()
Return the SSLParameters to use.
Returns:
the SSLParameters

getResourceConfig

public java.util.Map getResourceConfig()
Return map of context names to Jersey resource configurations.
Returns:
map of context names to Jersey resource configurations

getIdentityAsserter

public IdentityAsserter getIdentityAsserter()
Return identity asserter to use for HTTP basic authentication.
Returns:
the identity asserter to use

setIdentityAsserter

protected void setIdentityAsserter(IdentityAsserter asserter)
Configure the identity asserter to use for HTTP basic authentication.
Parameters:
asserter - the identity asserter to use

isAuthMethodBasic

protected boolean isAuthMethodBasic()
Return true if this server should use HTTP basic authentication.
Returns:
true if HTTP basic authentication should be used

isAuthMethodCert

protected boolean isAuthMethodCert()
Return true if this server should use client certificates for authentication.
Returns:
true if client certificates should be used for authentication

isAuthMethodNone

protected boolean isAuthMethodNone()
Return true if this server should not require client authentication.
Returns:
true if client authentication is not required

isSecure

protected boolean isSecure()
Return true if this server uses SSL to secure communication.
Returns:
true if this server uses SSL

toString

public java.lang.String toString()

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.