Architecture

Application Controller

TROIKA.ASP framework uses Application Controller pattern for command management. This involves:

  • Authentication and security
  • RequestContext validation and Error handling
  • Locating and executing Command for specific request

Application Controller is implemented by AppController class.

Figure 9: Application Controller class diagram
Figure 9: Application Controller class diagram

Authentication and security

FrontController delegates incoming request to Application Controller (AppController) together with RequestContext. AppController reads Security Constraints from Config class if defined. It then checks to see if user attempts to access protected resource by matching XML generated by RequestContext with the xpath pattern defined in url-pattern tag:



<security-constraints>
  <constraint>
    <login-form-path>/troika.asp?cmd=login</login-form-path>
    <url-patterns>
      <url-pattern request-ctx-xpath="//action">
        <match-pattern>secretAction</match-pattern>
        <return-path>/troika.asp?cmd=secretAction</return-path>
      </url-pattern>
    </url-patterns>
    <authenticate>
      <role>admin</role>
      <role>member</role>
    </authenticate>
  </constraint>
</security-constraints>

If it matches AppController saves current URI to come back to and then redirects user to login form. Once user successfully logs in ASP session variable security.role will store the name of the current security role. The default role will be guest.

If user’s role is on the list of all authenticated roles (see admin, member in the above XML definition) then AppController proceeds looking up the specific CommandMap object using Config class.

RequestContext validation and error handling

If CommandMap property validate set to true the AppController calls validate() method on RequestContext and if there are any errors returned by the method it forwards the request to URL specified by input path:


<cmd-map action="helloworld" validate="true">
  <name>helloForm</name>
  <type>HelloAction</type>
  <input redirect="false" path="/views/error.xsl" />
  <forwards>
    <forward name="action-error" redirect="false"
      path="/views/error.xsl" />
    <forward name="success" redirect="false"
      path="/views/hello.xsl" />
  </forwards>
</cmd-map>

Locating and executing Command for specific request

If the validation passes the AppController creates an instance of Command object (HelloAction in the example). It calls init() method on the Command and executes it.

Figure 10: Application Controller sequence diagram
Figure 10: Application Controller sequence diagram

Search

Architecture

FAQ

Bookmarks

AddThis Social Bookmark Button

Support This Project