Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<cfsetting showdebugoutput="no">
<cfset factory = createObject( "java", "coldfusion.server.ServiceFactory" )>
<cfset request.security = factory.securityService>
 
<cfset authorized = true>
 
<cfif request.security.RDSSecurityEnabled>
    <cflogin>
            
    
        <cfscript>
            authHeader = 'Authorization-MX' ;
        
            authorized = false ;
            
            httpReq = GetHTTPRequestData() ;
            // check the DW authorization header
            if ( StructKeyExists( httpReq.headers, authHeader ) ) {
            
                authString = ListGetAt( httpReq.headers[authHeader], 2, ' ' ) ;
                authString = ToBinary( authString ) ;        
                
                credentials = createObject( "java", "java.lang.String" ) ;
                credentials.init( authString ) ;
                
                // listLast() bug forces us to do it in this way
                pos = Find( ':', credentials.toString() ) ;
                if ( pos neq 0 )
                    password = RemoveChars( credentials.toString(), 1, pos ) ;
            }
            // check the form password field
            else if ( IsDefined('form.j_password') )
            {
                password = form.j_password ;
            }
            
            if ( IsDefined('password') )
            {
                
                authorized = request.security.checkRDSPassword( password ) ;
                    
                if ( not authorized ) {
                    authorized = request.security.checkAdminPassword( password ) ;
                    invalidPasswordEntered = "thatsright" ;
                }
            }
        </cfscript>
        
        
        
        <cfif authorized>
            <cfloginuser roles="RDSUser" name="#password#" password="#password#">        
        </cfif>
 
        
 
 
    </cflogin>
</cfif>
 
<cfif not authorized>
    <cfinclude template="../common/_logintowizard.cfm">
    <cfabort>
</cfif>