Added SE launch condition logic
authorWoowon <woowon.park@samsung.com>
Thu, 12 Sep 2013 02:12:59 +0000 (11:12 +0900)
committerWoowon <woowon.park@samsung.com>
Thu, 12 Sep 2013 03:14:22 +0000 (12:14 +0900)
Change-Id: I51267bbfd510416ca8ddd57b716c796223851824
Signed-off-by: Woowon <woowon.park@samsung.com>
plugins/nfc-condition-handler/NfcConditionHandler.cpp

index 6094bdd..4a9f9a7 100644 (file)
@@ -253,7 +253,8 @@ private:
        {
                //-------------------------------------------------------------------------
                // The BNF format of the OSP NFC condition is as follows:
-               //    <condition>   ::= <tnf_field>"&"<type_field>["&"<code_field>]
+               //    <condition>   ::= <rw_condition> | <card_condition>
+               //    <rw_condition>   ::= <tnf_field>"&"<type_field>["&"<code_field>]
                //    <tnf_field>   ::= "tnf="<tnf_value>
                //    <tnf_value>   ::= "rtd"|"mime"|"uri"|"ext"
                //    <type_field>  ::= "type="<type_string>
@@ -261,6 +262,10 @@ private:
                //    <code_field>  ::= "code="<uri_code>
                //    <uri_code>          ::= "0x"<hexa_digit><hexa_digit>
                //    <hexa_digit>  ::= "0".."9"|"A".."F"
+               //    <card_condition> :: = <se_field> ["&" <aid_field>]
+               //    <se_field>       :: = "se=" <se_name>
+               //    <se_name>        :: = "SIM" <slot_number> | "eSE"
+               //    <aid_field>      :: = "aid=" <applet_id>
                //
                // AUL translation rules according to <tnf_field> are as follows:
                //    "tnf=rtd" --> "http://tizen.org/appcontrol/operation/nfc/wellknown|"{<uri_scheme>|"*"}"|"<type_string>"/"{<uri_code>|"*"}
@@ -277,16 +282,23 @@ private:
                //    tnf=ext&type=Bordeaux_Wine:1996
                //    tnf=uri&type=http://www.tizen.org
                //    tnf=mime&type=text/x-vcard
+               //    se=SIM1&aid=123456789
+               //    se=eSE
                //  Target(AUL):
                //    http://tizen.org/appcontrol/operation/nfc/wellknown|NULL|T/*
                //    http://tizen.org/appcontrol/operation/nfc/wellknown|http|U/0x03
                //    http://tizen.org/appcontrol/operation/nfc/external|Bordeaux_Wine:1996|NULL
                //    http://tizen.org/appcontrol/operation/nfc/uri|http://www.tizen.org|NULL
                //    http://tizen.org/appcontrol/operation/nfc/mime|NULL|text/x-vcard
+               //    nfc://secure/SIM1/aid/123456789
+               //    nfc://secure/eSE/aid/*
                //-------------------------------------------------------------------------
 
                String tnfValue;        // <tnf_value>
                String typeString;      // <type_string>
+               String seName;          // <se_name>
+               String aidField;        // <aid_field>
+               String appletId;        // <applet_id>
                String uriCode(L'*');   // <uri_code>
                String uriScheme(L"NULL");
                int delimiterIndex = -1;
@@ -300,100 +312,139 @@ private:
 
 
                // Check whether the condition includes the tnf field.
-               isOk = originalCondition.StartsWith(L"tnf=", 0);
-               _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls) - No tnf field.", originalCondition.GetPointer() );
-
-               // Search the index of the type field.
-               r = originalCondition.IndexOf(L'&', 0, delimiterIndex);
-               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Illegal format (%ls)- No type field.", originalCondition.GetPointer() );
+               if (originalCondition.StartsWith(L"tnf=", 0))
+               {
+                       // Search the index of the type field.
+                       r = originalCondition.IndexOf(L'&', 0, delimiterIndex);
+                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Illegal format (%ls)- No type field.", originalCondition.GetPointer() );
 
-               // Read <tnf_value>.
-               // The length of <tnf_value> is (delimiterIndex - 4).
-               r = originalCondition.SubString(4, delimiterIndex - 4, tnfValue);
-               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+                       // Read <tnf_value>.
+                       // The length of <tnf_value> is (delimiterIndex - 4).
+                       r = originalCondition.SubString(4, delimiterIndex - 4, tnfValue);
+                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
 
-               // Check whether the condition includes the type field.
-               isOk = originalCondition.StartsWith(L"type=", delimiterIndex + 1);
-               _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls)- No type field.", originalCondition.GetPointer() );
+                       // Check whether the condition includes the type field.
+                       isOk = originalCondition.StartsWith(L"type=", delimiterIndex + 1);
+                       _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls)- No type field.", originalCondition.GetPointer() );
 
-               // Read <type_string>.
-               r = originalCondition.SubString(delimiterIndex + 6, typeString);
-               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+                       // Read <type_string>.
+                       r = originalCondition.SubString(delimiterIndex + 6, typeString);
+                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
 
-               if (tnfValue.CompareTo(L"rtd") == 0)
-               {
-                       // Search the index of the code field.
-                       // The code field is optional.
-                       r = typeString.IndexOf(L'&', 0, delimiterIndex);
-                       if (!IsFailed(r))
+                       if (tnfValue.CompareTo(L"rtd") == 0)
                        {
-                               String fullTypeString(typeString);
+                               // Search the index of the code field.
+                               // The code field is optional.
+                               r = typeString.IndexOf(L'&', 0, delimiterIndex);
+                               if (!IsFailed(r))
+                               {
+                                       String fullTypeString(typeString);
 
-                               r = fullTypeString.SubString(0, delimiterIndex, typeString);
-                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+                                       r = fullTypeString.SubString(0, delimiterIndex, typeString);
+                                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
 
-                               if (typeString.CompareTo(L"U") == 0)
+                                       if (typeString.CompareTo(L"U") == 0)
+                                       {
+                                               uriScheme.Clear();
+                                               uriScheme.Append(L"*");
+                                               // Check whether the condition includes the type field.
+                                               isOk = fullTypeString.StartsWith(L"code=", delimiterIndex + 1);
+                                               _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls)- No code field after the second '&'.", originalCondition.GetPointer() );
+
+                                               // Read <uri_code>.
+                                               r = fullTypeString.SubString(delimiterIndex + 6, uriCode);
+                                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+
+                                               //      Get <uri_scheme> from matching table of <uri_code> and <uri_scheme>.
+                                               r = uriSchemeMap.ContainsKey(uriCode, isOk);
+                                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Invalid URI code.");
+
+                                               r = uriSchemeMap.GetValue(uriCode, uriScheme);
+                                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Failed to get URI scheme from URI code.");
+                                       }
+                               }
+                               else if (typeString.CompareTo(L"U") == 0)
                                {
                                        uriScheme.Clear();
                                        uriScheme.Append(L"*");
-                                       // Check whether the condition includes the type field.
-                                       isOk = fullTypeString.StartsWith(L"code=", delimiterIndex + 1);
-                                       _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls)- No code field after the second '&'.", originalCondition.GetPointer() );
+                               }
 
-                                       // Read <uri_code>.
-                                       r = fullTypeString.SubString(delimiterIndex + 6, uriCode);
-                                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+                               aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/wellknown|";
+                               aulFormatCondition.Append(uriScheme);
+                               aulFormatCondition.Append(L'|');
+                               aulFormatCondition.Append(typeString);
+                               aulFormatCondition.Append(L'/');
+                               aulFormatCondition.Append(uriCode);             // The default value of 'uriCode' is '*'
+                        }
+                        else if ((tnfValue.CompareTo(L"ext") == 0)  || (tnfValue.CompareTo(L"uri") == 0))
+                        {
+                               if (tnfValue.CompareTo(L"ext") == 0)
+                               {
+                                       aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/external|";
+                                       // Convert all the letters to lower case.
+                                       typeString.ToLowerCase();
+                               }
+                               else
+                               {
+                                       aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/uri|";
+                               }
 
-                                       //      Get <uri_scheme> from matching table of <uri_code> and <uri_scheme>.
-                                       r = uriSchemeMap.ContainsKey(uriCode, isOk);
-                                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Invalid URI code.");
+                               aulFormatCondition.Append(typeString);
+                               aulFormatCondition.Append(L"|NULL");
+                       }
+                       else if (tnfValue.CompareTo(L"mime") == 0)
+                       {
+                               typeString.ToLowerCase();
 
-                                       r = uriSchemeMap.GetValue(uriCode, uriScheme);
-                                       _NfcSysTryLogReturn(r == E_SUCCESS, null, "Failed to get URI scheme from URI code.");
-                               }
+                               aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/mime|NULL|";
+                               aulFormatCondition.Append(typeString);
                        }
-                       else if (typeString.CompareTo(L"U") == 0)
+                       else
                        {
-                               uriScheme.Clear();
-                               uriScheme.Append(L"*");
+                               SysLog(NID_APP, "Illegal format (%ls) - Invalid TNF value", originalCondition.GetPointer() );
+                               return null;
                        }
-
-                       aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/wellknown|";
-                       aulFormatCondition.Append(uriScheme);
-                       aulFormatCondition.Append(L'|');
-                       aulFormatCondition.Append(typeString);
-                       aulFormatCondition.Append(L'/');
-                       aulFormatCondition.Append(uriCode);             // The default value of 'uriCode' is '*'
-                }
-                else if ((tnfValue.CompareTo(L"ext") == 0)  || (tnfValue.CompareTo(L"uri") == 0))
-                {
-                       if (tnfValue.CompareTo(L"ext") == 0)
+               }
+               // Check whether the condition includes the se field.
+               else if (originalCondition.StartsWith(L"se=", 0))
+               {
+                       //check whether the condition includes aid field
+                       if (originalCondition.IndexOf(L'&', 0, delimiterIndex) == E_SUCCESS)
                        {
-                               aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/external|";
-                               // Convert all the letters to lower case.
-                               typeString.ToLowerCase();
+                               r = originalCondition.SubString(3, delimiterIndex - 3, seName);
+                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+
+                               r = originalCondition.SubString(delimiterIndex + 1, aidField);
+                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+
+                               isOk = aidField.StartsWith(L"aid=", 0);
+                               _NfcSysTryLogReturn(isOk == true, null, "Illegal format (%ls)- No aid field.", originalCondition.GetPointer() );
+
+                               r = aidField.SubString(4, appletId);
+                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", aidField.GetPointer() );
                        }
+
                        else
                        {
-                               aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/uri|";
+                               r = originalCondition.SubString(3, seName);
+                               _NfcSysTryLogReturn(r == E_SUCCESS, null, "Parsing error. (%ls)", originalCondition.GetPointer() );
+
+                               appletId.Append(L"*");
                        }
 
-                       aulFormatCondition.Append(typeString);
-                       aulFormatCondition.Append(L"|NULL");
+                       aulFormatCondition = L"nfc://secure/";
+                       aulFormatCondition.Append(seName);
+                       aulFormatCondition.Append(L"/aid/");
+                       aulFormatCondition.Append(appletId);
                }
-               else if (tnfValue.CompareTo(L"mime") == 0)
-               {
-                       typeString.ToLowerCase();
 
-                       aulFormatCondition = L"http://tizen.org/appcontrol/operation/nfc/mime|NULL|";
-                       aulFormatCondition.Append(typeString);
-               }
                else
                {
-                       SysLog(NID_APP, "Illegal format (%ls) - Invalid TNF value", originalCondition.GetPointer() );
+                       SysLog(NID_APP, "Illegal format (%ls) - No condition field.", originalCondition.GetPointer());
                        return null;
                }
 
+               SysLog(NID_APP, "AulFormatCondition : (%ls)", aulFormatCondition.GetPointer());
                return aulFormatCondition;
        }