Security Code Auto Registration

Security Code Auto Registration is a way to register your application automatically for authorization. Administrator is the only user granted for access at this auto registration.

Using this feature, you will not must entered manually to database to configure user access right to application. LightArmy first will create a unique or supplied identity for your application and register it to LightArmy registry.

Now, you can configure user access right using web-based applications provided. LightArmy provides you two ways of: you can configure per user (user-based) or you can configure per application (application-based).

If you think to whom users application will be given access, you use application-based. If you thing what accesses you will give to a user, you use user-based.

User-based access right management:


Application-based access right management:


Analogy:
You place your file on operating system (i.e. Linux, Windows , etc) at any folder and then you can configure access right of that application.

Note:
You can create hierarchy of security code as you wish as you create file system hierarchy.

How to cache your page?

You create your page as any other pages. To cache your page, you just only add an attribute 'Cache' with value of 'true' for page xml element of your page configuration (*.pageconf file). For more custom cache, utilize two other attributes: CacheLifetime, and CacheKeys.

CacheLifetime attribute defines for how long time (in minutes), page cache is valid. CacheKeys attribute defines in what parameters (key), separate cache will be made for the same page. As for example, you have page to deliver user information that not change for a user but different from user to user, you can use user id for CacheKeys.

Here is for your example:



<?xml version="1.0" encoding="UTF-8"?>
<page name="HelpFile" id="HelpFile" Cache="true" CacheLifetime="0" CacheKeys="fn::GetParam('context_id')" >
<processor PageSecurityCode="Page|HelpFile" HelpContext="LIGHTARMY-Applications.HelpFile"
sOnlyTemplateFileName="HelpFile.html" CanPublic="true" Authenticate="false"
ValidateSystemConfiguration="false" >

<PageSecurityCode>
<Name>Help File</Name>
<Description></Description>
<HelpContext>LIGHTARMY-Applications.HelpFile</HelpContext>
</PageSecurityCode>

<TemplateProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Show();
]]></TemplateProcessingScript>

<ResponseProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Print();
]]></ResponseProcessingScript>

<IncludeFile>PageClass/HelpFile.php</IncludeFile>

</processor>
</page>

How to use dynamic value inside page configuration?

You can assign dynamic value to any parameters inside page configuration (*.pageconf file). You define your dynamic value using prefix 'fn::' for parameter value. As for example: fn::GetParam('context_id'). Any statement after prefix must can be evaluated and resulting a simple value.

Here is for your example:



<?xml version="1.0" encoding="UTF-8"?>
<page name="HelpFile" id="HelpFile" Cache="true" CacheLifetime="0" CacheKeys="fn::GetParam('context_id')" >
<processor PageSecurityCode="Page|HelpFile" HelpContext="LIGHTARMY-Applications.HelpFile"
sOnlyTemplateFileName="HelpFile.html" CanPublic="true" Authenticate="false"
ValidateSystemConfiguration="false" >

<PageSecurityCode>
<Name>Help File</Name>
<Description></Description>
<HelpContext>LIGHTARMY-Applications.HelpFile</HelpContext>
</PageSecurityCode>

<TemplateProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Show();
]]></TemplateProcessingScript>

<ResponseProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Print();
]]></ResponseProcessingScript>

<IncludeFile>PageClass/HelpFile.php</IncludeFile>

</processor>
</page>

How to create static page?

You create your page as any other pages. To change your page as static page, you just only add an attribute 'Static' with value of 'true' for page xml element of your page configuration (*.pageconf file).

If you want to use parameter for your static page, you can utilize cache inside page configuration. There are some attributes related to cached page: Cache, CacheLifetime, and CacheKeys.

Here is for your example:



<?xml version="1.0" encoding="UTF-8"?>
<page name="HelpFile" id="HelpFile" Cache="true" CacheLifetime="0" CacheKeys="fn::GetParam('context_id')" >
<processor PageSecurityCode="Page|HelpFile" HelpContext="LIGHTARMY-Applications.HelpFile"
sOnlyTemplateFileName="HelpFile.html" CanPublic="true" Authenticate="false"
ValidateSystemConfiguration="false" >

<PageSecurityCode>
<Name>Help File</Name>
<Description></Description>
<HelpContext>LIGHTARMY-Applications.HelpFile</HelpContext>
</PageSecurityCode>

<TemplateProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Show();
]]></TemplateProcessingScript>

<ResponseProcessingScript><![CDATA[
CIISONLINE_HelpFile::HelpFile_Print();
]]></ResponseProcessingScript>

<IncludeFile>PageClass/HelpFile.php</IncludeFile>

</processor>
</page>

How to link help context-sensitive with application?

You do link help context-sensitive with application inside of its configuration (*.pageconf file). Inside 'page' xml root will present a 'processor' xml element. For static security code, you define a HelpContext attribute to do. Other, you create HelpContext element inside PageSecurityCode element under 'processor' xml element.

See below for your example:



<?xml version="1.0" encoding="UTF-8"?>
<page name="NestMaint" id="NestMaint" >
<processor PageSecurityCode="Page|NestMaint" HelpContext="LIGHTARMY-Applications.NestConfig" sOnlyTemplateFileName="NestMaint.html" CanPublic="false">

<PageSecurityCode>
<Name>Nest Maintenance</Name>
<Description></Description>
<HelpContext>LIGHTARMY-Applications.NestConfig</HelpContext>
</PageSecurityCode>

<PageActionSelectionScript><![CDATA[
switch ((string)GetCurrentPageConfig('sForm')) {
case 'NestMaint':
CIISONLINE_NestMaint::NestMaintAction(GetCurrentPageConfig('sAction'));
}
]]></PageActionSelectionScript>
<TemplateProcessingScript><![CDATA[
CIISONLINE_Header::Menu_Show();
CIISONLINE_Footer::FooterForm_Show();
CIISONLINE_NestMaint::MenuPath_Show();
CIISONLINE_NestMaint::NestMaint_Show();
]]></TemplateProcessingScript>
<ResponseProcessingScript><![CDATA[
ResponseWrite (PrintVar('main'));
]]></ResponseProcessingScript>
<IncludeFile>PageClass/Header.php</IncludeFile>
<IncludeFile>PageClass/Footer.php</IncludeFile>
<IncludeFile>PageClass/NestMaint.php</IncludeFile>

<TemplateSpaceHolder name="Header">Header.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Footer">Footer.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space01">Space01.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space02">Space02.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space03">Space03.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space04">Space04.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space05">Space05.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space06">Space06.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space07">Space07.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space08">Space08.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space09">Space09.html</TemplateSpaceHolder>
<TemplateSpaceHolder name="Space10">Space10.html</TemplateSpaceHolder>

</processor>
</page>

How to use Remote Queue?

First you need to define a queue box with the type of Remote. Fill the queue server uri, username and password.

Now you can access queue as any other type of queue and completely transparent. You can put message, get message, delete message, and list messages using common way.

Here is an example of queue configuration using remote queue:



<?xml version="1.0" encoding="UTF-8"?>
<configuration id="administration">
<section name="queue">
<config name="boxes">
<config name="subscriber">
<config name="buffer">
<config name="storage">
<config name="type">FileSystem</config>
<config name="directory">buffer</config>
</config>
</config>
<config name="handled">
<config name="storage">
<config name="type">FileSystem</config>
<config name="directory">handled</config>
</config>
</config>


<config name="storage">
<config name="type">Remote</config>
<config name="authkeyfilter">CIISONLINE_FEP_STREAMWRAPPER::AuthKeyFilter</config>
<config name="server">http://localhost/knowledge/Queue.php</config>
<config name="user">steve</config>
<config name="password">password</config>
<config name="secure">1</config>
</config>
</config>
</config>
</section>
</configuration>

Steps for delivering SMS application

You need kannel SMS/WAP gateway to deliver SMS application using LightArmy. Here are your steps:

  • Install and configure Kannel SMS/WAP gateway. See Kannel documentation. You can use this for many services. Kannel website: http://www.kannel.org/

  • Create Kannel interface for LightArmy and configure the settings. You can use this for many services.
    Here is for an example:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration id="kannel">
    <section name="core">
    <!--Gateway Configuration -->
    <config name="description">KANNEL MBUNI SMS/MMS Service</config>
    <config name="handler"></config>
    <config name="serviceresponse"></config>

    <config name="auth">
    <config name="username">kannel</config>
    <config name="password">lennak</config>
    </config>

    <config name="path">
    <config name="bearerbox">bearerbox</config>
    <config name="smsbox">smsbox</config>
    <config name="wapbox">wapbox</config>
    <config name="mmsbox">mmsbox</config>
    <config name="mmsrelay">mmsrelay</config>
    <config name="mmsproxy">mmsproxy</config>
    <config name="mmsfromemail">mmsfromemail</config>
    </config>

    <config name="interface">
    <config name="smsposturl"><![CDATA[http://localhost/admin/Restricted/kannel.php?processstage=incoming&message-mime=sms]]></config>
    <config name="smsgeturl"><![CDATA[http://localhost/admin/Restricted/kannel.php?processstage=incoming&message-mime=sms]]></config>
    <config name="smsxmlurl"></config>
    <config name="smsexec"><![CDATA[/System/Kannel/kannel.php processstage=incoming\&message-mime=sms]]></config>
    <config name="smssend"><![CDATA[http://localhost:13013/cgi-bin/sendsms]]></config>
    <config name="smsdlr"><![CDATA[http://localhost/admin/Restricted/kannel.php?processstage=delivery&message-mime=sms]]></config>

    <config name="mmsposturl"><![CDATA[http://localhost/admin/Restricted/kannel.php?processstage=incoming&message-mime=mms]]></config>
    <config name="mmsdlr"><![CDATA[http://localhost/admin/Restricted/kannel.php?processstage=delivery&message-mime=sms]]></config>
    <config name="mmssend"><![CDATA[http://localhost:13014/cgi-bin/sendmms]]></config>
    </config>

    </section>
    </configuration>



  • Create manifest of kannel handler you what (direct reply, stomp, or queue)
    If you choose stomp you need ActiveMQ queue server. ActiveMQ website: http://activemq.apache.org/
    If you choose queue you need queue.
    Here is for an example:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration id="queue_handler">
    <section name="core">
    <!-- Service Handler Configuration-->
    <config name="handler">
    <config name="type">queue_handler</config>
    <config name="name"><![CDATA[SMSPasswordService]]></config>
    <config name="description"><![CDATA[SMS Password Service]]></config>
    <config name="start"></config>
    <config name="end"></config>

    <config name="disableincoming">0</config>
    <config name="disableoutgoing">0</config>
    <config name="disabledelivery">1</config>
    </config>

    <!-- Queue Storage -->
    <config name="connections">
    <config name="mainqueue">
    <config name="type">QUEUE</config>
    <config name="storages">
    <config name="smsincoming">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:inbox</config>
    </config>
    <config name="smsoutgoing">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:outbox</config>
    </config>
    <config name="smsdelivery">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:delivery</config>
    </config>
    <config name="mmsincoming">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:inbox</config>
    </config>
    <config name="mmsoutgoing">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:outbox</config>
    </config>
    <config name="mmsdelivery">
    <config name="ref">QUEUEBOX:QUEUE:SMSPasswordService:delivery</config>
    </config>
    </config>
    </config>
    </config>

    <!-- Database Connection -->
    <config name="connections">
    <config name="kanneldb">
    <config name="type">DATABASE</config>
    <config name="dbtype">mysql</config>
    <config name="host">172.16.250.129</config>
    <config name="username">ciisonline</config>
    <config name="password"></config>
    <config name="dbname">ciisonline</config>
    </config>
    </config>

    <!-- Database Tables -->
    <config name="connections">
    <config name="kanneldb">
    <config name="tables">
    <config name="smsincoming">sms_inbox</config>
    <config name="smsoutgoing">sms_oubox</config>
    <config name="mmsincoming">sms_inbox</config>
    <config name="mmsoutgoing">sms_oubox</config>
    </config>
    </config>
    </config>

    </section>
    </configuration>



  • Create manifest of Kannel Service as appropriate. Use kannel_stompservice for stomp handler. Use kannel_queueservice for queue.
    Here is for an example:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration id="kannel_queueservice">
    <section name="core">
    <!-- Process Configuration-->
    <config name="process">
    <config name="type">kannel_queueservice</config>
    <config name="name">KANNEL_QUEUESERVICE_PASSWORD</config>
    <config name="start"></config>
    <config name="end"></config>
    </config>

    <!--Service Configuration-->
    <config name="service">
    <config name="responder">
    <config name="name">Password</config>
    <config name="directory">Application/SMS/Responder/</config>
    </config>
    <config name="log">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    </config>
    <config name="queue">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    <config name="delivery">smsdelivery</config>
    </config>
    </config>

    <!--Kannel Configuration-->
    <config name="kannel">
    <config name="validate">1</config>
    <config name="name"></config>
    <config name="service">Password</config>
    <config name="auth">
    <config name="username">kannel</config>
    <config name="password">lennak</config>
    </config>
    </config>

    </section>
    </configuration>



  • Create database for logging messages as you need.

  • Create manifest of Kannel Sender as appropriate. Use kannel_stompsender for stomp handler. Use kannel_queuesender for queue.
    Here is for an example:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration id="kannel_queuesender">
    <section name="core">
    <!-- Process Configuration-->
    <config name="process">
    <config name="type">kannel_queuesender</config>
    <config name="name">KANNEL_QUEUESENDER_PASSWORD</config>
    <config name="start"></config>
    <config name="end"></config>
    </config>

    <!--Sender Configuration-->
    <config name="sender">
    <config name="updatestatus">1</config>
    </config>

    <!--Delivery Configuration-->
    <config name="delivery">
    <config name="disable">0</config>
    <config name="interface"></config>
    </config>

    <!--Service Configuration-->
    <config name="service">
    <config name="log">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    </config>
    <config name="queue">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    <config name="delivery">smsdelivery</config>
    </config>
    </config>

    <!--Kannel Configuration-->
    <config name="kannel">
    <config name="validate">1</config>
    <config name="name"></config>
    <config name="service">Password</config>
    <config name="auth">
    <config name="username">kannel</config>
    <config name="password">lennak</config>
    </config>
    </config>

    </section>
    </configuration>



  • If you want to know the status of delivery, create manifest of Kannel delivery status as appropriate. Use kannel_stompdeliverystatus for stomp handler. Use kannel_queuedeliverystatus for queue.
    Here is for an example:


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration id="kannel_queuedeliverystatus">
    <section name="core">
    <!-- Process Configuration-->
    <config name="process">
    <config name="type">kannel_queuedeliverystatus</config>
    <config name="name">KANNEL_QUEUEDELIVERYSTATUS_PASSWORD</config>
    <config name="start"></config>
    <config name="end"></config>
    </config>

    <!--Service Configuration-->
    <config name="service">
    <config name="log">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    </config>
    <config name="queue">
    <config name="incoming">smsincoming</config>
    <config name="outgoing">smsoutgoing</config>
    <config name="delivery">smsdelivery</config>
    </config>
    </config>

    <!--Kannel Configuration-->
    <config name="kannel">
    <config name="validate">1</config>
    <config name="name"></config>
    <config name="service">Password</config>
    <config name="auth">
    <config name="username">kannel</config>
    <config name="password">lennak</config>
    </config>
    </config>

    </section>
    </configuration>



  • Create your responder for your service. Responder is the only program (code) you need to create for your specific purpose. You can use any available responder if appropriate.
    Here is for an example:


    <?php

    class Password {

    static function handle($headers,$body,$addheaders=null) {
    $statement = $body;
    while (strpos($statement,' ')!==false) {
    $statement = str_replace(' ',' ',$statement);
    }

    $words = explode(' ',$statement);
    if (isset($headers['from']) && count($words)==3 && strtolower($words[0])=='password' && false!==($pos=strpos($words[1],'@'))) {
    $from = $headers['from'];
    $email = $words[1];
    $password = $words[2];
    return 'test only..';
    // check for sender and email and response if successful only
    }

    return 'another';
    }
    }

    ?>





After all of that, you just start all of that manifests.
Now SMS service is available for serving.

If you want to change your service you may only change the last step and make/change code as appropriate or even no programming needed.

Note:
You can integrate SMS application with any other applications easily. You can shutting down computer using SMS as for example. Another example is sending you an SMS if a process is terminated. You can also sending SMS by email and so on.
CommentLuv Enabled

Followers