|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
cfhttp and Google Search Appliance
Hey Dave Watts,Kevin Stone 08/20/08 09:26 P > Hey Dave Watts,Dave Watts 08/21/08 01:42 A Thanks Dave,Kevin Stone 08/21/08 12:35 P > You have given me hope. At least I am on a path that isDave Watts 08/21/08 01:05 P Hey Dave,Kevin Stone 08/24/08 08:28 P > I have finished the first version of my CF script that willDave Watts 08/24/08 09:16 P Thanks for your help Dave.Kevin Stone 08/25/08 05:37 P > Thanks for your help Dave.Dave Watts 08/26/08 09:59 A Dave, thanks for your help but I finally got it to work. Just in case you are interested:Kevin Stone 08/28/08 06:25 P Kevin I was trying this exact same thing last week and got the exact same error.Steve Nelson 09/09/08 04:05 P Oh my bad, your example was searching for the word "Google Mini" which isn'tSteve Nelson 09/09/08 04:14 P Hey Dave Watts, Can you use cfhttp to add/delete/update collection configuration in a Google mini? For example when we add a new collection on one of our systems can we use cfhttp to update the other or do we need to do it manually thru the admin console? ----- Excess quoted text cut - see Original Post for more ----- Hey, Kevin! Yes, you can! However, it's a pain. You'll need to capture the cookie from your initial request, then send admin credentials in an HTTP POST, then do the collection submission. Dave Watts, CTO, Fig Leaf Software Thanks Dave, You have given me hope. At least I am on a path that is possible. I have an example done with curl and make but they wont allow curl on our server. Perhaps I can mimic it with cfhttp. Would you suggest any other approach, java, ...? -kevin ----- Excess quoted text cut - see Original Post for more ----- > You have given me hope. At least I am on a path that is > possible. I have an example done with curl and make but they > wont allow curl on our server. Perhaps I can mimic it with > cfhttp. Would you suggest any other approach, java, ...? CF is just as good as any of these for this sort of thing, so if you prefer using CF you should just go ahead. The examples in the GSA Google Group use Python (as do most Google code examples), but they're not very extensive or complete anyway. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! Hey Dave, I have finished the first version of my CF script that will talk with the Google mini Admin console but I am having trouble. Just briefly, I first cfhttp the google and I get a response with a cookie. In the data it sends back I can see it is on the page that requests that you make sure that your browser is set to accept cookies. I store the cookie for future use and then send a "reload" request (should transition the google to the login page) with the cookie stored in the cfhttp header. But, when the google responds it sends a different cookie and there isn't anything that I can see in the response that indicates I am on the login page. Is this what you would expect? I had thought the google would respond with the original cookie since we are in a conversation. thanks -kevin ----- Excess quoted text cut - see Original Post for more ----- ----- Excess quoted text cut - see Original Post for more ----- What's the initial URL you're requesting? I think it should be: https://yourGSA:8443/EnterpriseController/ or http://yourGSA:8000/EnterpriseController/ The fact that you're getting the message about requiring cookies makes me think that you're going through one redirect after your initial request, and aren't sending the cookie along. Presumably, at that point you might get a different cookie. A traffic sniffer or HTTP proxy is your friend here. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! Thanks for your help Dave. Yes, the URL is http://IP:8000/EnterpriseController I don't expect you to do my job for me, but I have included my initial script below. Does anything jump out as being wrong? My code is probably not the best since I am still learning coldfusion. <!---------------------------------------------------------> <!--- Expects URL.command ---> <!--- Export_Config ---> <!--- Import_Config Filename ---> <!--- Add_Collection CollectionID CollectionName? ---> <!--- Delete_Collection CollectionID ---> <!--- Function to check HTTP response for errors and print debug ---> <cffunction name="checkHttpStruct" returnType="boolean"> <cfargument name="httpStruct" type="Struct" required="yes"> <cfargument name="stage" type="String" required="yes"> <cfif LEN(httpStruct.errorDetail) GT 0> <cfdump var="#httpStruct.errorDetail#" label="#stage# Error"><BR> <cfreturn true> </cfif> <cfdump var="#httpStruct#" label="#stage# Response"><BR> <cfreturn false> </cffunction> <!--- Initialize ---> <cfset Variables.error = False> <cfset Variables.googleWelcome = "Google Mini > Home "> <cfset Variables.adminUser = "admin"> <cfset Variables.adminPwd = "blahblah"> <!--- TBD HARDCODE get from db ---> <cfset Variables.googleIP = "192.168.0.22"> <!--- TBD HARDCODE Application.cfm ---> <!--- Set the URL for the google admin console ---> <cfset Variables.url = "http://#Variables.googleIP#:8000/EnterpriseController"> <!--- Send initial request to google. This is just to get a response ---> <cfhttp method="GET" url="#Variables.url#" result="Variables.response"></cfhttp> <cfset Variables.error = checkHttpStruct(Variables.response, "Initial Request")> <cfif NOT Variables.error> <!--- Get the cookie from the response object. This is the cookie that ---> <!--- we are going to echo back in subsequent CFHttp requests. ---> <!--- The google cookie will look like: S=enterprise=XXXXXXXX; PATH=/; ---> <!--- where XXXXXXXX is a unique key ---> <cfset Variables.googleCookie = Variables.response.ResponseHeader["Set-Cookie"]> <!--- We dont care about the PATH so just get the first item from the cookie ---> <!--- (take the string before the first semi-colon) ---> <cfset Variables.NameAndValue = ListGetAt(Variables.googleCookie,1,";")> <!--- The name is everything before the first equal sign (chr(61) ---> <!--- Will be S given the Cookie is S=enterprise=XXXXXXXX ---> <cfset Variables.cName = ListFirst(Variables.NameAndValue, chr(61))> <!--- The value is everything after the first equal sign ---> <!--- Will be enterprise=XXXXXXXX given the Cookie is S=enterprise=XXXXXXXX ---> <cfset Variables.cValue = ListRest(Variables.NameAndValue, chr(61))> <!--- Send a reload request to get past the initial screen ---> <!--- that tells you to enable cookies in your browser ---> <cfhttp method="POST" url="#Variables.url#" result="Variables.response"> <cfhttpparam name="actionType" type="URL" value="reload"> <cfhttpparam name="#Variables.cName#" type="COOKIE" value="#Variables.cValue#"> </cfhttp> <cfset Variables.error = checkHttpStruct(Variables.response, "Reload Request")> </cfif> <cfif NOT Variables.error> <!--- Try to login ---> <cfhttp method="POST" url="#Variables.url#" result="Variables.response"> <cfhttpparam name="actionType" type="URL" value="authenticateUser"> <cfhttpparam name="userName" type="URL" value="#Variables.adminUser#"> <cfhttpparam name="password" type="URL" value="#Variables.adminPwd#"> <cfhttpparam name="#Variables.cName#" type="COOKIE" value="#Variables.cValue#"> </cfhttp> <cfset Variables.error = checkHttpStruct(Variables.response, "Login Request")> </cfif> <cfif NOT Variables.error> <!--- Check if we have a successful login by looking for the google welcome ---> <cfif NOT FindNoCase(Variables.googleWelcome, Variables.response.header)> <cfoutput>Login Failed</cfoutput><BR> <cfset Variables.error = True> </cfif> </cfif> <cfif NOT Variables.error> <cfoutput>Login Success</cfoutput><BR> <cfif URL.command EQ "Export_Config"> <!--- Export Config ---> <cfhttp method="POST" url="#Variables.url#" result="Variables.response"> <cfhttpparam name="actionType" type="URL" value="importExport"> <cfhttpparam name="export" type="URL" value="Export Configuration"> <cfhttpparam name="password1" type="URL" value="#Variables.adminPwd#"> <cfhttpparam name="password2" type="URL" value="#Variables.adminPwd#"> <cfhttpparam name="#Variables.cName#" type="COOKIE" value="#Variables.cValue#"> </cfhttp> <!--- TBD <cfelseif URL.command EQ "Import_Config"> <cfelseif URL.command EQ "Add_Collection"> <cfelseif URL.command EQ "Delete_Collection"> <cfelse> TBD ---> </cfif> <cfset Variables.error = checkHttpStruct(Variables.response, "#URL.command#")> <!--- Log out ---> <cfhttp method="POST" url="#Variables.url#" result="Variables.response"> <cfhttpparam name="actionType" type="URL" value="logout"> </cfhttp> <cfset Variables.error = checkHttpStruct(Variables.response, "Logout Request")> </cfif> ----- Excess quoted text cut - see Original Post for more ----- I don't really see anything that jumps out at me. I'm out of the office until Thursday, and don't have non-SSL access to a Google Search Appliance right now, but will run it against one of our GSAs as soon as I can. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! Dave, thanks for your help but I finally got it to work. Just in case you are interested: <!---------------------------------------------------------> <!--- Expects URL.command ---> <!--- Export_Config ---> <!--- Import_Config Filename ---> <!--- Add_Collection CollectionID CollectionName? ---> <!--- Delete_Collection CollectionID ---> <!--- Function to check HTTP response for errors and print debug ---> <cffunction name="checkHttpStruct" returnType="boolean"> <cfargument name="httpStruct" type="Struct" required="yes"> <cfargument name="stage" type="String" required="yes"> <cfif LEN(httpStruct.errorDetail) GT 0> <cfdump var="#httpStruct.errorDetail#" label="#stage# Error"><BR> <cfreturn true> </cfif> <cfdump var="#httpStruct#" label="#stage# Response"><BR> <cfreturn false> </cffunction> <!--- Initialize ---> <cfset Variables.error = False> <cfset Variables.googleWelcome = "Google Mini > Home"> <cfset Variables.adminUser = "admin"> <cfset Variables.adminPwd = "blahblah"> <!--- TBD HARDCODE get from db ---> <cfset Variables.googleIP = "192.168.0.20"> <!--- TBD HARDCODE Application.cfm ---> <!--- Set the URL for the google admin console ---> <cfset Variables.url = "http://#Variables.googleIP#:8000/EnterpriseController"> <!--- Send initial request to google. This is just to get a response ---> <cfhttp method="GET" url="#Variables.url#" useragent="#CGI.HTTP_USER_AGENT#"></cfhttp> <cfset Variables.error = checkHttpStruct(CFHTTP, "Initial Request")> <cfif NOT Variables.error> <!--- Get the cookie from the response object. This is the cookie that ---> <!--- we are going to echo back in subsequent CFHttp requests. ---> <!--- The google cookie will look like: S=enterprise=XXXXXXXX; ---> <!--- where XXXXXXXX is a unique key ---> <cfset Variables.googleCookie = ListGetAt(CFHTTP.Response.ResponseHeader["Set-Cookie"],1,";")> <!--- Try to login ---> <cfhttp method="POST" url="#Variables.url#" useragent="#CGI.HTTP_USER_AGENT#"> <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" value="#Variables.googleCookie#"> <cfhttpparam name="actionType" type="URL" value="authenticateUser"> <cfhttpparam name="userName" type="URL" value="#Variables.adminUser#"> <cfhttpparam name="password" type="URL" value="#Variables.adminPwd#"> </cfhttp> <cfset Variables.error = checkHttpStruct(CFHTTP, "Login Request")> </cfif> <cfif NOT Variables.error> <!--- Check if we have a successful login by looking for the google welcome on the admin main page ---> <cfif FindNoCase("#Variables.googleWelcome#", CFHTTP.Filecontent) EQ 0> <cfoutput>Login Failed</cfoutput><BR> <cfset Variables.error = True> </cfif> </cfif> <cfif NOT Variables.error> <cfoutput>Login Success</cfoutput><BR> <cfif URL.command EQ "Export_Config"> <!--- Export Config ---> <cfhttp method="POST" url="#Variables.url#" useragent="#CGI.HTTP_USER_AGENT#"> <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" value="#Variables.googleCookie#"> <cfhttpparam name="actionType" type="URL" value="importExport"> <cfhttpparam name="export" type="URL" value="Export Configuration"> <cfhttpparam name="password1" type="URL" value="#Variables.adminPwd#"> <cfhttpparam name="password2" type="URL" value="#Variables.adminPwd#"> </cfhttp> <!--- TBD <cfelseif URL.command EQ "Import_Config"> <cfelseif URL.command EQ "Add_Collection"> <cfelseif URL.command EQ "Delete_Collection"> <cfelse> TBD ---> </cfif> <cfset Variables.error = checkHttpStruct(CFHTTP, "#URL.command#")> <!--- Log out ---> <cfhttp method="POST" url="#Variables.url#" useragent="#CGI.HTTP_USER_AGENT#"> <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" value="#Variables.googleCookie#"> <cfhttpparam name="actionType" type="URL" value="logout"> </cfhttp> <cfset Variables.error = checkHttpStruct(CFHTTP, "Logout Request")> </cfif> Kevin I was trying this exact same thing last week and got the exact same error. I just tried your code and am still unable to login. Can you explain what it is you did to make it work? Steve Nelson ----- Excess quoted text cut - see Original Post for more ----- > <cfargument name="httpStruct" type="Struct" required="yes"> > <cfargument name="stage" type="String" required="yes"> > > <cfif LEN(httpStruct.errorDetail) GT 0> > <cfdump var="#httpStruct.errorDetail#" label="#stage# Error"><BR> > <cfreturn true> > </cfif> > <cfdump var="#httpStruct#" label="#stage# Response"><BR> ----- Excess quoted text cut - see Original Post for more ----- > <!--- Get the cookie from the response object. This is the cookie that > ---> > <!--- we are going to echo back in subsequent CFHttp requests. > ---> > <!--- The google cookie will look like: S=enterprise=XXXXXXXX; > ---> > <!--- where XXXXXXXX is a unique key > ---> > <cfset Variables.googleCookie = > ListGetAt(CFHTTP.Response.ResponseHeader["Set-Cookie"],1,";")> > > <!--- Try to login ---> > <cfhttp method="POST" url="#Variables.url#" useragent="#CGI. > HTTP_USER_AGENT#"> > <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" > value="#Variables.googleCookie#"> > <cfhttpparam name="actionType" type="URL" > value="authenticateUser"> > <cfhttpparam name="userName" type="URL" value="#Variables. > adminUser#"> > <cfhttpparam name="password" type="URL" value="#Variables. > adminPwd#"> > </cfhttp> > <cfset Variables.error = checkHttpStruct(CFHTTP, "Login Request")> > </cfif> > > <cfif NOT Variables.error> > <!--- Check if we have a successful login by looking for the google > welcome on the admin main page ---> > <cfif FindNoCase("#Variables.googleWelcome#", CFHTTP.Filecontent) EQ > 0> > <cfoutput>Login Failed</cfoutput><BR> > <cfset Variables.error = True> > </cfif> > </cfif> > > <cfif NOT Variables.error> > <cfoutput>Login Success</cfoutput><BR> > <cfif URL.command EQ "Export_Config"> > <!--- Export Config ---> > <cfhttp method="POST" url="#Variables.url#" useragent="#CGI. > HTTP_USER_AGENT#"> > <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" > value="#Variables.googleCookie#"> > <cfhttpparam name="actionType" type="URL" value="importExport"> > <cfhttpparam name="export" type="URL" value="Export > Configuration"> > <cfhttpparam name="password1" type="URL" value="#Variables. > adminPwd#"> > <cfhttpparam name="password2" type="URL" value="#Variables. > adminPwd#"> > </cfhttp> > <!--- TBD > <cfelseif URL.command EQ "Import_Config"> > <cfelseif URL.command EQ "Add_Collection"> > <cfelseif URL.command EQ "Delete_Collection"> > <cfelse> > TBD ---> > </cfif> > <cfset Variables.error = checkHttpStruct(CFHTTP, "#URL.command#")> > > <!--- Log out ---> > <cfhttp method="POST" url="#Variables.url#" useragent="#CGI. > HTTP_USER_AGENT#"> > <cfhttpparam name="#Variables.googleCookie#" type="COOKIE" > value="#Variables.googleCookie#"> > <cfhttpparam name="actionType" type="URL" > value="logout"> > </cfhttp> > <cfset Variables.error = checkHttpStruct(CFHTTP, "Logout Request")> > </cfif> Oh my bad, your example was searching for the word "Google Mini" which isn't on the full appliance. Thanks Kevin you've cured my ulcer. Steve
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||