AppRegistrar

Extends \CI_Controller

Manually Developed CI Controller

This controller facilitates the access of table countries

Usage:-

    function index(), default index funtion to list all AIR entries
    function validate_remote_host(), To validate remote host
    function validate_app(), To validate application
    function get_uaacs_feed_by_app_id(), To get uaacs application feed by app id
    function get_calling_app_name(), To get calling app name
    function issueToken(), To issue token
    function generateToken(), To generate token for issuing
    function get_called_app_function_id(), To get called application function id
        function getTimeStamp(), To get time stamp
        function getHostIP(), To get host IP
        function getUserId(), To get user id
        function getRandomString(), To get random string
        function getAppId(), To get app id
        function verify_token(), To verify given token
        function verify_user_access(), To verify user access
    function verify_permission(), To verify permission
    function verify_role(), To verify role
    function view_log(), To view log
    function get_user_ip(), To get user ip
    function get_jason(), To get json
    function get_related_links(), To get related AIR links
    function createDropdown(), To get dropdown listing with AIR linkagse
    function set_called_app_name(), To set caled application name
    function get_called_app_name(), To get caled application name
package

AIR\controllers\Appregistrar

version

V1.2.0

copyright

2015, BizyCorp Internal Systems Development

license

private, All rights reserved

author

MRM Roshan

created

July 2014

uses
see
modified

28/04/2016 by MRM Roshan

modification

1.Added set_called_app_name() and get_called_app_name() to identify called app function 2.Added log entry to identify uses and apps as unkonown if system could not identify them

Methods

__construct()

__construct() 

This is where all models and library files are loaded

Constructor function

createDropdown()

createDropdown(array $data = false) 

createDropdown is the component function. Its main functionality is to produce a dropdown with pre populated table data

Parameter list :-

$data['selectByValue'] => null - preselection of list items by value $data['selectBYText'] => null - preselection of list items by Text $data['filterBy'] => null - filter data set by a field or list $data['outFormat'] => 'html' - Format of the output like HTML,XML Etc $data['isMultiple'] => false - is the drop down with multi select capable $data['sort'] => 'asc' - sort list text Ascending or Descending $data['optionsOnly'] => false - Specify the controller that output only values

Usage :-

1) Format for internal functional call by passing data array

$data = array('selectByValue' => null, 'selectBYText' => null, 'outFormat' => 'html' , 'isMultiple' => false, 'sort' => 'asc', 'optionsOnly' => false, 'filterBy' => array( 'search_field' => 'T.status', 'search_text' => '0', 'query_method'=>'equal', 'order_by' => 'asc' ) )

2) Format of external call by URL

http://.../index.php/task_master/createDropdown/?sbv=null&sbt=null&format=html&multiple=false&sort=asc&filterby=status-0-equal

Description of parameter list,

sbv - selectByValue => null sbt - selectBYText => null format - outFormat => 'html' multiple - isMultiple=> false sort - sort => 'asc' filterby - filterBy => null optionsOnly - options only listing

Arguments

$data

array

data array to create dropdown

generateToken()

generateToken(\boolion $debug = false) : string

This function generats token as per request. The token consists of following values $token = "$calling_app_id-$called_app_id-$hostIp-$userId-$called_app_function_id-$timeStamp" * This then be encripted and sent out

Arguments

$debug

\boolion

  • true / false

Response

string

$enctoken

get_called_app_function_id()

get_called_app_function_id() : \unknown

This function returns called app function id

Response

\unknown

get_called_app_name()

get_called_app_name() 

This function gets called app name from calling app name property

return string calling app name

get_calling_app_name()

get_calling_app_name() 

This function gets calling app name from calling app name property

return string calling app name

get_jason()

get_jason(integer $calling_app_id, integer $called_app_role_id, integer $calling_app_user_id) 

This function echos json string from uaacs feed for given appid,app role,and calling app user id

Arguments

$calling_app_id

integer

$called_app_role_id

integer

$calling_app_user_id

integer

get_uaacs_feed_by_app_id($called_app_id,$app_type,$debug)

get_uaacs_feed_by_app_id(integer $app_id, string $app_type, \boolien $debug = false) 

This function gets UAACS feed for a given app id from UAACS and return for further check ups

Arguments

$app_id

integer

$app_type

string

  • 'calling_app' or 'called_app'

$debug

\boolien

get_user_ip()

get_user_ip() : string

Response

string

user ip

get_user_role_function_data($uaacs_feed,$calling_app_user_id,$debug){

get_user_role_function_data(object $uaacs_feed, integer $calling_app_user_id, boolean $debug = false) : array|boolean

This function processes UAACS feed object and returns user role/assigned function array on success. Otherwise return fals

Arguments

$uaacs_feed

object

$calling_app_user_id

integer

$debug

boolean

Response

array|boolean

getAppId()

getAppId() 

This function returns app id

return int

getHostIP()

getHostIP() : string

This function returns remote address

Response

string

remote address

getRandomString()

getRandomString() 

This function returns a random string

return string

getTimeStamp()

getTimeStamp() : string

This function returns date and only hrs value. It can include minits and seconds. but for the timebeing made available only hrs value along with date

Response

string

date

getUserId()

getUserId() 

This function returns calling app user id

return int calling app user id

issueToken($integration_id,$calling_app_id = 0,$called_app_id = 0,$calling_app_user_id = 0,$calling_app_func_id = 0,$debug = false)

issueToken(integer $integration_id, integer $calling_app_id, integer $called_app_id, integer $calling_app_user_id, integer $calling_app_func_id, boolean $debug = false) : \token

This function accepts above parameters then verify url call and given values. It first performs remote host ip address then performs application id check Based on given values this function then obtains uaacs data feed from UAACS application then store it in local database.Then proceed to generate token process.After obtaining the token then outputs an xml feed.

updated

: Added codes to identify users and applications. If could not do so then to add log as unkonwn user and unkonwn application MRMR

update

on: 28/04/2016

ex: http://localhost/app_registrar/index.php/AppRegistrar/issueToken/109/91/239/241

access

public

since
modified

Jun 17, 2016 by Roshan Ruzaik mrmroshan@yahoo.com

modification

Fixed bug id 21885,21446

Arguments

$integration_id

integer

$calling_app_id

integer

$called_app_id

integer

$calling_app_user_id

integer

$calling_app_func_id

integer

$debug

boolean

Response

\token

prepare_called_app_url($debug=false)

prepare_called_app_url(\boolion $debug = false) : string

This function prepares called app url which was supplied at integrating the app via share_function.xml file

Arguments

$debug

\boolion

  • true / false

Response

string

set_called_app_name($app_feed)

set_called_app_name(object $app_feed) 

This function sets called app name property after xpathing UAACS xml feed

Arguments

$app_feed

object

  • UAACS feed

set_calling_app_name($app_feed)

set_calling_app_name(object $app_feed, integer $app_id = null) 

This function sets calling app name property after xpathing UAACS xml feed

Arguments

$app_feed

object

  • UAACS feed

$app_id

integer

  • application id

validate_app($app_id,$app_type,$debug){

validate_app(integer $app_id, string $app_type, boolean $debug = false) : boolean

This function checks for validity of calling or called applications when a token request or token verification call is made

Arguments

$app_id

integer

$app_type

string

  • 'called_app' or 'calling_app'

$debug

boolean

Response

boolean

validate_remote_host($debug)

validate_remote_host(string $debug = false) : boolean

This function checks validity of remote host when a token is request or token verification call is made

Arguments

$debug

string

Response

boolean

verify_permission()

verify_permission(string $token, string $debug = false) : \number

This function verifies permissions assigned to calling application user.

Arguments

$token

string

  • token value

$debug

string

  • true or fals

Response

\number

verify_role()

verify_role(string $token, integer $user_id, integer $role_id) : \number

This function verifies user role for a given user id.

Arguments

$token

string

  • token value

$user_id

integer

  • user id

$role_id

integer

  • role id

Response

\number

Function verify_token ()

verify_token(string $debug = false) : void
access

public

since
modified

Jun 17, 2016 by Roshan Ruzaik mrmroshan@yahoo.com

modification

Fixed bug id 21527,20497,21455

Arguments

$debug

string

verify_user_access($user_id,$app_id,$app_type,$debug = false)

verify_user_access(integer $user_id, integer $app_id, string $app_type, boolean $debug = false) : integer

This function cross checks with UAACS object for permissions with given user id and application id then return true/false

Arguments

$user_id

integer

$app_id

integer

$app_type

string

$debug

boolean

Response

integer

  • 0 or 1

view_log()

view_log() 

This function is to use as a debug message displayer

Properties

$debug

debug : \boolien
var

Type(s)

\boolien

$progress

progress : string
var

Type(s)

string

$calling_app_id

calling_app_id : integer
var

Type(s)

integer

$calling_app_name

calling_app_name : string
var

Type(s)

string

$called_app_name

called_app_name : string
var

Type(s)

string

$calling_app_user_id

calling_app_user_id : integer
var

Type(s)

integer

$called_app_role_id

called_app_role_id : integer
var

Type(s)

integer

$calling_app_access_key

calling_app_access_key : string
var

Type(s)

string

$calling_app_security_key

calling_app_security_key : string
var

Type(s)

string

$calling_app_host

calling_app_host : string
var

Type(s)

string

$calling_app_func_id

calling_app_func_id : integer
var

Type(s)

integer

$integration_id

integration_id : integer
var

Type(s)

integer

$called_app_id

called_app_id : integer
var

Type(s)

integer

$called_app_access_key

called_app_access_key : string
var

Type(s)

string

$called_app_security_key

called_app_security_key : string
var

Type(s)

string

$appIntRegResult

appIntRegResult : object
var

Type(s)

object

$url

url : string
var

Type(s)

string

$jason_data

jason_data : string
var

Type(s)

string

$tr_host

tr_host : string
var

Type(s)

string

$log_obj

log_obj : object
var

Type(s)

object