Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to implement a token based security scheme with Geoserver.

What we need to do is send the client a license key when they log into our primary application. This license key is generated by another application and is stored in a MySql Database along with the User name and password, Ip Address form login, etc.

We would like to be able to pass this License key as part of the WMS Request to ensure that only logged in and validated users obtain access to the data.

Has anyone implemented anything similar before, any help, suggestions or code would be appreciated.

Edit ..

I Think I may have answered my own question, we use Classic ASP Still (Dinasour) and something like the following from here might do the trick.

<% 
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
strURL = Request("url")" 
objHttp.open "GET", strURL, False 
objHttp.Send
If objHttp.status = 200 Then 
Response.Expires = 90 
Response.ContentType = Request("mimeType") 
Response.BinaryWrite objHttp.responseBody 
set objHttp = Nothing 
End If %>
share|improve this question
add comment

2 Answers 2

Ok, we ended up with a proxy to forward the tiles, something like this:

<% 
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
strURL = Request("url")" 
objHttp.open "GET", strURL, False 
objHttp.Send
If objHttp.status = 200 Then 
Response.Expires = 90 
Response.ContentType = Request("mimeType") 
Response.BinaryWrite objHttp.responseBody 
set objHttp = Nothing 
End If %>
share|improve this answer
    
Did you forget to add some more information? –  Paul Aug 21 '13 at 2:53
    
Ok, I wrapped it in code formatting. The code was there, just hidden from the final post because it was wrapped in <> I think. –  Paul Aug 21 '13 at 22:47
    
Paul, I posted the wrong code anyway. Not enough coffee. Answered again with the correct code and figured out how to format it properly. –  Mark C Aug 21 '13 at 23:03
add comment
up vote 0 down vote accepted

Ok, I messed up the code in the comment. Here is the final Code. Thanks for pointing it out Paul.

        <%
    Session.Timeout=10 ' ten minute timeout, question is, will same session remain open or not?? Should timeout be longer so sessions will be reused???

    ServerName=trim(ucase(Request.ServerVariables("SERVER_NAME")))
    MapUrl=urldecode(trim(Request.querystring))

    If ServerName <> "MAPS.XXXXX.NET" AND ServerName <> "MAPS1.XXXXX.NET" AND ServerName <> "MAPS2.XXXXX.NET" AND ServerName <> "MAPS3.XXXXX.NET" AND ServerName <> "MAPS4.XXXXX.NET" AND ServerName <> "MAPS5.XXXXX.NET" Then
        response.clear
        response.end
    end if


    If Servername="MAPS.XXXXX.NET" Then

        newurl="http://java2:8080/geoserver/web"

    else

        If ServerName = "MAPS1.XXXXX.NET" Or ServerName <> "MAPS3.XXXXX.NET" Then

            'newurl="http://java2:8080/geoserver/a_ph/gwc/service/wms?" & MapUrl
            'newurl="http://java2:8080/geoserver/a_ph/wms?" & MapUrl
            newurl="http://java2:8080/geoserver/wms?" & MapUrl
            'newurl="http://java2:8080/geoserver/gwc/service/wms?" & MapUrl

        Else

            'newurl="http://java1:8080/geoserver/a_ph/gwc/service/wms?" & MapUrl
            'newurl="http://java1:8080/geoserver/a_ph/wms?" & MapUrl
            newurl="http://java1:8080/geoserver/wms?" & MapUrl
            'newurl="http://java1:8080/geoserver/gwc/service/wms?" & MapUrl

        End If

    end if




    set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")



    objHttp.open "GET", newURL, False
    objHttp.Send

    If objHttp.status = 200 Then
        Response.Expires = 90
        Response.ContentType = Request("mimeType")
        Response.BinaryWrite objHttp.responseBody
        set objHttp = Nothing

    else

    Response.Write objHttp.responseBody

    'response.clear
    'response.end

    End If

    '======================================================================================


    Function URLDecode(str)
            Dim re
            Set re = new RegExp
            str = Replace(str, "+", " ")
            re.Pattern = "%([0-9a-fA-F]{2})"
            re.Global = True
            URLDecode = re.Replace(str, GetRef("URLDecodeHex"))
    end function

    ' Replacement function for the above
    Function URLDecodeHex(match, hex_digits, pos, source)
        URLDecodeHex = chr("&H" & hex_digits)
    End Function

    Function URLDecode1(sConvert)

            sDecoded = sConvert
            Set oRegExpr = Server.CreateObject("VBScript.RegExp")
            oRegExpr.Pattern = "%[0-9,A-F]{2}"
            oRegExpr.Global = True
            Set oMatchCollection = oRegExpr.Execute(sConvert)
            For Each oMatch In oMatchCollection
                sDecoded = Replace(sDecoded,oMatch.value,Chr(CInt("&H" & Right(oMatch.Value,2))))
            Next
            URLDecode = sDecoded

    end function

    Function URLDecode2(sConvert)
        Dim aSplit
        Dim sOutput
        Dim I
        If IsNull(sConvert) Then
           URLDecode = ""
           Exit Function
        End If

        ' convert all pluses to spaces
        sOutput = REPLACE(sConvert, "+", " ")

        ' next convert %hexdigits to the character
        aSplit = Split(sOutput, "%")

        If IsArray(aSplit) Then
          sOutput = aSplit(0)
          For I = 0 to UBound(aSplit) - 1
            sOutput = sOutput & _
              Chr("&H" & Left(aSplit(i + 1), 2)) &_
              Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
          Next
        End If

       URLDecode = sOutput
    End Function


    %>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.