com.wewebu.ow.server.ecmimpl.opencmis.alfresco
Class OwCMISAlfrescoOAuthInterceptor

java.lang.Object
  extended by com.wewebu.ow.server.ecmimpl.opencmis.alfresco.OwCMISAlfrescoOAuthInterceptor
All Implemented Interfaces:
OwCMISAuthenticationInterceptor

public class OwCMISAlfrescoOAuthInterceptor
extends Object
implements OwCMISAuthenticationInterceptor

Implementation of AuthProviderFactory for OAuth handling.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
static String EL_ACCESS_URL
          Configuration node of URL where to get AccessToken
static String EL_CALLBACK_URL
          Configuration node for Client redirect/callback URL
static String EL_CLIENT_ID
          Configuration node for CLIENT ID
static String EL_CLIENT_SECRETE
          Configuration node for client secrete
static String EL_GRANT_URL
          Configuration node of URL where to redirect to get GRANT from User
static String EL_REFRESH_URL
          Configuration Node for refresh URL
static String EL_URL_ENCODING
          (optional) Configuration node to define the value encoding URL-parameter, by default UTF-8
static String PARAM_CLIENT_ID
           
static String PARAM_CODE
           
static String PARAM_REDIRECT_URI
           
static String PARAM_RESPONSE_TYPE
           
static String PARAM_SCOPE
           
 
Constructor Summary
OwCMISAlfrescoOAuthInterceptor()
           
 
Method Summary
protected  void appendParameter(StringBuilder url, String paramName, String paramVal)
          Helper method for creation of URL, will attach the parameter name and value to it and escape the value using UTF-8 base.
 org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider createAuthenticationProvider(Map<String,?> information)
          Called to create a new Authentication provider which should be used in communication between CMIS client and server.
protected  String getConfigValue(String configName)
           
protected  String getConfigValue(String configName, String defaultValue)
           
protected  String getGrantToken()
          Get the grant token which is used for access token retrieval.
 void init(com.wewebu.ow.server.util.OwXMLUtil configNode)
          Initialization of AuthProviderFactory instance with corresponding configuration.
 boolean onRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Called before login page is rendered, can be used for redirect or preparation of this instance.
protected  boolean stageOne(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Stage one of OAuth is to redirect to grant URL and wait for user grant token.
protected  boolean stageTwo(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Stage two is to retrieve access token if needed.
We will use the AuthenticationProvider factory method of Alfresco extension, so that the refresh token handling will be done through the created AuthenticationProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EL_CLIENT_ID

public static final String EL_CLIENT_ID
Configuration node for CLIENT ID

See Also:
Constant Field Values

EL_CLIENT_SECRETE

public static final String EL_CLIENT_SECRETE
Configuration node for client secrete

See Also:
Constant Field Values

EL_CALLBACK_URL

public static final String EL_CALLBACK_URL
Configuration node for Client redirect/callback URL

See Also:
Constant Field Values

EL_GRANT_URL

public static final String EL_GRANT_URL
Configuration node of URL where to redirect to get GRANT from User

See Also:
Constant Field Values

EL_ACCESS_URL

public static final String EL_ACCESS_URL
Configuration node of URL where to get AccessToken

See Also:
Constant Field Values

EL_REFRESH_URL

public static final String EL_REFRESH_URL
Configuration Node for refresh URL

See Also:
Constant Field Values

EL_URL_ENCODING

public static final String EL_URL_ENCODING
(optional) Configuration node to define the value encoding URL-parameter, by default UTF-8

See Also:
Constant Field Values

PARAM_CODE

public static final String PARAM_CODE
See Also:
Constant Field Values

PARAM_REDIRECT_URI

public static final String PARAM_REDIRECT_URI
See Also:
Constant Field Values

PARAM_SCOPE

public static final String PARAM_SCOPE
See Also:
Constant Field Values

PARAM_RESPONSE_TYPE

public static final String PARAM_RESPONSE_TYPE
See Also:
Constant Field Values

PARAM_CLIENT_ID

public static final String PARAM_CLIENT_ID
See Also:
Constant Field Values
Constructor Detail

OwCMISAlfrescoOAuthInterceptor

public OwCMISAlfrescoOAuthInterceptor()
Method Detail

init

public void init(com.wewebu.ow.server.util.OwXMLUtil configNode)
          throws com.wewebu.ow.server.exceptions.OwException
Description copied from interface: OwCMISAuthenticationInterceptor
Initialization of AuthProviderFactory instance with corresponding configuration.

Specified by:
init in interface OwCMISAuthenticationInterceptor
Parameters:
configNode - OwXMLUtil node which represents AuthProviderFactory configuration
Throws:
com.wewebu.ow.server.exceptions.OwException

createAuthenticationProvider

public org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider createAuthenticationProvider(Map<String,?> information)
                                                                                              throws com.wewebu.ow.server.exceptions.OwException
Description copied from interface: OwCMISAuthenticationInterceptor
Called to create a new Authentication provider which should be used in communication between CMIS client and server.

Specified by:
createAuthenticationProvider in interface OwCMISAuthenticationInterceptor
Parameters:
information - Map current available informations for OpenCMIS Session creation
Returns:
AuthenticationProvider which should be used for session creation
Throws:
com.wewebu.ow.server.exceptions.OwException

onRequest

public boolean onRequest(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse resp)
                  throws com.wewebu.ow.server.exceptions.OwException,
                         IOException
Description copied from interface: OwCMISAuthenticationInterceptor
Called before login page is rendered, can be used for redirect or preparation of this instance. The return value defines if the process sequence should be processed as defined, or if it should stop because the response was created by this instance.

If true is returned, by default a login is processed through network. The login will call the OwCMISAuthenticationInterceptor.createAuthenticationProvider(Map) and verify against back-end if login was successful.

Specified by:
onRequest in interface OwCMISAuthenticationInterceptor
Parameters:
req - HttpServletRequest
resp - HttpServletResponse
Returns:
boolean true process sequence as defined, false stop processing
Throws:
com.wewebu.ow.server.exceptions.OwException
IOException

stageOne

protected boolean stageOne(javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse resp)
                    throws com.wewebu.ow.server.exceptions.OwException,
                           IOException
Stage one of OAuth is to redirect to grant URL and wait for user grant token.

Parameters:
req - HttpServletRequest
resp - HttpServletResponse
Returns:
boolean true
Throws:
com.wewebu.ow.server.exceptions.OwException
IOException

stageTwo

protected boolean stageTwo(javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse resp)
                    throws com.wewebu.ow.server.exceptions.OwException
Stage two is to retrieve access token if needed.
We will use the AuthenticationProvider factory method of Alfresco extension, so that the refresh token handling will be done through the created AuthenticationProvider.

Parameters:
req - HttpServletRequest
resp - HttpServletResponse
Returns:
boolean true process further sequence, false interrupt sequence and return
Throws:
com.wewebu.ow.server.exceptions.OwException

getConfigValue

protected String getConfigValue(String configName)

getConfigValue

protected String getConfigValue(String configName,
                                String defaultValue)

appendParameter

protected void appendParameter(StringBuilder url,
                               String paramName,
                               String paramVal)
                        throws UnsupportedEncodingException
Helper method for creation of URL, will attach the parameter name and value to it and escape the value using UTF-8 base.

Parameters:
url - StringBuilder URL
paramName - String
paramVal - String
Throws:
UnsupportedEncodingException

getGrantToken

protected String getGrantToken()
Get the grant token which is used for access token retrieval.

Returns:
String


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.