Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

External Authentication

Avatar

Level 2

Hi

This may be going over old ground, but i would really appreciate any help regarding trying to generate an authentication token. After a week or so of trying, insanity is not far off .  Basically I just can't get the authToken to be created, due to a 'Connection error: Error #1088: The markup in the document following the root element must be well-formed. caused by the PHP code regarding 'new AFCSAccount' shown in red below.

I have a Flex 3 project that connects to a mySQL database and I want to externally authenticate the users when they use the chat room/webcam area. I am using the WAMP environment to test things out, with PHP 5.2.9. This is part of the code:

<mx:ViewStack

id = "mainStack" x="20" width="97%" y="180" height="100%" cornerRadius="10" selectedIndex="0">

<mx:Canvas... code of other stack elements not shown here for clarity

<!-- selectedIndex=3 -->

<rtc:ConnectSessionContainer

authenticator="{auth}" id="cSession" width = "100%" height = "100%" autoLogin="false" roomURL = "{roomURL}" >

code of webcam/chat not shown here for clarity

</rtc:ConnectSessionContainer>

</mx:ViewStack>

<rtc:AdobeHSAuthenticator

id="auth" authenticationKey = "{authToken}" protocol="rtmfp" />

My PHP login code is based around the code that Flex Builder creates when using a datagrid with a database, and the fact that I don't completely know what I am doing is I think where the problem lies, and apologise in advance for anything blindingly obvious that I am doing wrong.  The code in red always causes a 'Mark-up' error and so the token variable is not being returned. If I take away this code, all other variables are returned fine, including the roomURL, but obviously not the authToken value.:

function userLogin() {
global $conn;
$username = GetSQLValueString($_REQUEST["Username"], "text");
$password = GetSQLValueString($_REQUEST["Password"], "text");

$devuser = "****";
$devpass = "******";
$user = $username;
$pass = $password;
$account = "*******";
$room    = "*******";
$secret  = "*******";
$host  = "http://connectnow.acrobat.com";
$accountURL = "{$host}/{$account}";
$roomURL = "{$accountURL}/{$room}";


//Query the database to see if the given username/password combination is valid.
$query = "SELECT * FROM users WHERE Username = $username AND password = $password";
$toret = mysql_fetch_array(mysql_query($query, $conn));

                             


$am = new AFCSAccount($accountURL);
    $am->login($devuser, $devpass);
      $session = $am->getSession($room);
$token = $session->getAuthenticationToken($secret, $user, $user, 50);


if(!$toret)
{
// an update error, return it
   $toret = array(
    "data" => array("error" => mysql_error()),
    "metadata" => array()
   );
}
else {

$toret = array(
  "data" => $toret,
  "metadata" => array (
  "Username" => $username,
  "Password" => $password,
  "roomURL" => $roomURL,
  "authToken" => $token
  )
);
  
  }

return $toret;

}

Again, any help or guidance really would be much appreciated. My PHP skills are not great but getting better although I am aware that this is probably the root cause of my current pain!

Thanks in Advance

10 Replies

Avatar

Level 3

Oddly enough this error usually happens due to malformed XML. this can happen for example if a function returns an empty string when it is suppose to return a proper XML statement or by not closing an XML statement correctly... forgettting the slash to close a statement for example.  I would check your function calls around that area to verify the values that you send and receive.  The problem doesn't seem to be where you are connecting to the afcs servers.

Avatar

Level 2

thanks for your reply.  Two weeks later and I'm still tearing my hair out trying to solve this. What ever I try, it always comes back to the aforementioned error when this line : '$am = new AFCSAccount($accountURL)' is put in the code.  Everthing else is working fine - values are being returned from my php file, and if I put a test value of "12345678" for $token then that also is returned fine.  The roomURL is returned no problem.

It's as though the functions and classes in the 'afcs.php' file are just not recognised.

So does that infer that there is something fundamentally wrong with the way I am setting about things?

Avatar

Employee

What version of PHP are you using ? The afcs.php module is written for PHP5 and will not work with PHP4.

Did you try the php example that comes with the SDK ? Does that work for you ?

Avatar

Level 2

Hi Raff, ta for the quick reply.

PHP version is 5.2.9.

Well I have used the sample code and tried to implement it into my own app, and so within a login function. This was one of the many variants I have tried to the previously pasted code, so basically this was the crux of it:

session_start();

    if (isset($_SESSION["XSESSION"])) {
      $session = $_SESSION["XSESSION"];
    } else {
      $am = new AFCSAccount($accountURL);
      $am->login($devuser, $devpass);
      $session = $am->getSession($room);
   
      $_SESSION["XSESSION"] = $session;
    }

    $token = $session->getAuthenticationToken($secret, $user, $user, $role);

but maybe that's where the problem lies.  I'll try and use the sample app on it's own and see what happens. ..

Avatar

Level 2

Ok Raff, in a roundabout way, you have saved me from pulling all my hair out and the world seems a better place now

I tried the SDK example on it's own and it threw an error regarding SSL.  Now I thought I had enabled this in my php.ini file but it seems I hadn't. So I did this, back to my own app and lo and behold the token was returned - I never thought I'd be so happy to see such a long and beautiful number.

I am now back on track - almost.

I now have all variables in order but, kind of crucially, when I click on a button to start the videochat/whiteboard section of my site, none of the components appear.  It is part of a viewstack. Now I have checked that the viewstack index is shown when aforementioned button is clicked (by adding a temp panel)  so that is not the problem.

I think the problem lies in where I have the 'adobeHSAuthenticator' line of code. If I try and put it within the viewstack code, I get this error:

'Component declarations are not allowed here. (Note: visual children must implement mx.core.IUIComponent)'

So I put it outside of the viewstack code which gets rid of the error, but I can't help thinking is not then letting me use or view any of the components.

Thanks again in advance for any guidance....

Avatar

Level 3

well, maybe try something like this... where you enclose it in a box for example...

<viewstack>

     <hbox id='view1'>

          <other stuff>

          </other stuff>

     </hbox>

     <hbox id='view2'>

          <auth id='blah' pass='blah' />

          <webcam />

          <audio />

     </hbox>

</viewstack>

If I were you I would enclose the webcam and the audio into a ConnectSessionContainer, for example...

<rtc:ConnectSessionContainer id="sess" authenticator="{auth}" autoLogin="false" width="100%" height="100%" roomURL="{_roomURL}">

      <rtc:WebCamera id="camera" width="100%" height="100%" creationComplete="initCamera"/>     

</ConnectSessionContainer>
then put your <adobeHSAuthenticato id=auth> anywhere in the file

Avatar

Level 2

Thanks for the reply.  Although my code is already within a ConnectSessionContainer tag.  When I view it(or at least the blank screen) in Firefox it gives a bit of extra information in the bottom left-hand corner of the screen: 'Waiting for na2.connectnow.acrobat.com'.

So something isn't quite clicking yet. This is the output:

FCS Beta Build # : 1.01

requestInfo http://connectnow.acrobat.com/****/*****?exx=*****=&mode=xml&x=******

Warning: Ignoring 'secure' attribute in policy file from http://connectnow.acrobat.com/crossdomain.xml. The 'secure' attribute is only permitted in HTTPS and socket policy files. See http://www.adobe.com/go/strict_policy_files for details.

Warning: Domain connectnow.acrobat.com does not specify a meta-policy. Applying default meta-policy 'master-only'. This configuration is deprecated. See http://www.adobe.com/go/strict_policy_files to fix this problem.

Getting FMS at https://na2.connectnow.acrobat.com/fms?ticket=*****&proto=rtmfp, attempt #1/3

result: <fms>

<origin>fms7.acrobat.com</origin>

<proto_ports>rtmfp:1935,rtmps:443</proto_ports>

<retry_attempts>2</retry_attempts>

</fms>

#FMSConnector# Thu Nov 19 14:24:59 GMT+0000 2009 protocols: [object ProtocolPortPair],[object ProtocolPortPair]

#FMSConnector# Thu Nov 19 14:24:59 GMT+0000 2009 [attempt 1 of 2] Connecting to 0/1: rtmfp://fms7.acrobat.com/cocomo/na2-sdk-**********/******* #startProtosConnect#

#FMSConnector# Thu Nov 19 14:24:59 GMT+0000 2009 tempNetStatusHandler 0/2,NetConnection.Connect.Success

#FMSConnector# Thu Nov 19 14:24:59 GMT+0000 2009 isTunneling? false

#FMSConnector# Thu Nov 19 14:24:59 GMT+0000 2009 is using RTMPS? false

RECEIVED LOGIN AT SESSION

.user descriptor from server [object]

\\

.affiliation [number]= 100

.role [number]= 100

.userID [string]= EXT-****-"*****"

.displayName [string]= "andy"

RECEIVENODES UserManager

receiveAllSynchData UserManager

RECEIVENODES FileManager

receiveAllSynchData FileManager

checkManagerSync:[object FileManager]

RECEIVENODES AVManager

receiveAllSynchData AVManager

checkManagerSync:[object StreamManager]

RECEIVENODES RoomManager

receiveAllSynchData RoomManager

checkManagerSync:[object RoomManager]

checkManagerSync:[object UserManager]

RECEIVENODES default_SimpleChat

receiveAllSynchData default_SimpleChat

RECEIVENODES default_WB

receiveAllSynchData default_WB

RECEIVENODES webcamShare2

receiveAllSynchData webcamShare2

Avatar

Former Community Member

Hi Shed08,

If you run with the debug player, what kind of output do you see?

nigel

Avatar

Former Community Member

Whoops, for some reason, they don't send me a new email when you edit your post - I see your output now.

Based on the output, you're fully synched up - the user has successfully entered the room. My guess is that somehow the viewstack isn't allowing the new components to be shown? If you take the ConnectSessionContainer outside the ViewStack, do things improve?

nigel

Avatar

Level 2

Success. I followed your lead, and basically started to strip out everything except for the afcs components.  When I took out the viewstack, there was no change, however my site was also made up of three different states and this is where the problem was.  I can't fully explain why but it just didn't seem to like it when the connectsessioncontainer was added as a child of the specific state.

I was never that comfortable with using states anyway, don't ask me why, so it has given me the excuse to redsign it using two viewstacks.  I now can see all afcs components, the user details and everything works fine.  I'm sure there's a way to make it work with states but I have to get on with other things now!

Now if you can just tell me that echo cancellation is round the corner, then I'll be a happy man...

Thanks for the team's guidance, much appeciated.

Cheers