Skip to content

Commit

Permalink
added a measures for secure.softbank.ne.jp (refs #1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kousuke Ebihara committed May 30, 2010
1 parent bafb60d commit 46d8786
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/filter/opExecutionFilter.class.php
Expand Up @@ -101,6 +101,12 @@ protected function handleAction($filterChain, $actionInstance)
{
$moduleName = $actionInstance->getModuleName();
$actionName = $actionInstance->getActionName();
$request = $actionInstance->getRequest();

if ($this->needToRedirectToSoftBankGateway())
{
$this->redirectToSoftBankGateway();
}

$this->handleSSl($actionInstance);

Expand Down
33 changes: 33 additions & 0 deletions lib/request/opWebRequest.class.php
Expand Up @@ -17,6 +17,9 @@
*/
class opWebRequest extends sfWebRequest
{
const SB_GW_COOKIE_NAME = 'is_sb_gw';
const SB_GW_BASE_URL = 'https://secure.softbank.ne.jp/';

protected
$userAgentMobileInstance = null;

Expand Down Expand Up @@ -324,4 +327,34 @@ private function convertEncodingForOutputCallback($value)

return mb_convert_encoding($value, $this->outsideEncoding, 'UTF-8');
}

protected function needToRedirectToSoftBankGateway()
{
$request = $actionInstance->getRequest();

if (
!$request->getMobile()->isSoftBank() // The gateway is usable only for SoftBank mobile phone
|| !sfConfig::get('op_use_ssl', false) // OpenPNE doesn't consider SSL
|| !$request->isSecure() // Non-SSL connection is already passed the gateway
|| $request->getMobile()->getUID() // This UID is granted by the gateway
|| $request->getCookie(self::SB_GW_COOKIE_NAME) // Redirecting has already done
)
{
return false;
}

return true;
}

protected function redirectToSoftBankGateway()
{
$baseUrl = sfConfig::get('op_ssl_base_url');
sfContext::getInstance()->getResponse()->setCookie(self::SB_GW_COOKIE_NAME, '1');

$url = self::SB_GW_BASE_URL
.str_replace(array('https://', 'http://'), '', $baseUrl[sfConfig::get('sf_app')])
.$this->getCurrentUri();

$this->context->getController()->redirect($url);
}
}

0 comments on commit 46d8786

Please sign in to comment.