/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/


package com.nokia.mj.impl.security.midp.authentication;

import java.util.Hashtable;
import java.util.Vector;
import com.nokia.mj.impl.installer.utils.InstallerMain;
import com.nokia.mj.impl.security.midp.authentication.AuthenticationModule;
import com.nokia.mj.impl.security.midp.authentication.OcspEventListener;
import com.nokia.mj.impl.security.midp.authentication.OcspUserPreferences;
import com.nokia.mj.impl.security.common.InstallerSecurityException;
import com.nokia.mj.impl.security.common.RuntimeSecurityException;
import com.nokia.mj.impl.security.common.Certificate;
import com.nokia.mj.impl.security.midp.common.SigningCertificate;
import com.nokia.mj.impl.security.midp.common.SigningInfo;
import com.nokia.mj.impl.security.midp.common.SecurityAttributes;
import com.nokia.mj.impl.security.midp.common.AuthenticationCredentials;
import com.nokia.mj.impl.security.midp.common.AuthenticationAttribute;
import com.nokia.mj.impl.security.midp.common.ProtectionDomain;
import com.nokia.mj.impl.utils.Uid;
import com.nokia.mj.impl.storage.*;
import com.nokia.mj.impl.security.midp.storage.SecurityStorage;
import com.nokia.mj.impl.security.midp.storage.AuthenticationStorageData;
import com.nokia.mj.impl.utils.InstallerErrorMessage;
import com.nokia.mj.impl.utils.InstallerDetailedErrorMessage;
import com.nokia.mj.impl.utils.OtaStatusCode;
import com.nokia.mj.impl.utils.Attribute;
import com.nokia.mj.impl.rt.support.ApplicationInfo;
import com.nokia.mj.impl.security.utils.SecurityErrorMessage;
import com.nokia.mj.impl.security.utils.SecurityDetailedErrorMessage;

import j2meunit.framework.Test;
import j2meunit.framework.TestCase;
import j2meunit.framework.TestMethod;
import j2meunit.framework.TestSuite;

/**
 * AuthenticationModule unit tests.
 */
public class AuthenticationModuleTests extends TestCase implements InstallerMain
{

    private static String TEST_DATA_DIR;

    static
    {
        String platform = System.getProperty("os.name");
        if (platform != null && platform.equalsIgnoreCase("linux"))
        {
            TEST_DATA_DIR = System.getProperty("JAVA_BIN_ROOT") + "/securitytestdata/";
        }
        else
        {
            TEST_DATA_DIR = "C:\\java\\securitytestdata\\";
        }
    }

    // class to be tested
    AuthenticationModule authenticationModule;
    StorageSession session;
    SecurityStorage storage;
    Uid appUID;

    /**
     * Hashtable holding all the attributes. Tests populate this hashtable
     * prior to being executed
     */
    protected Hashtable allAttributes;

    // general-purpose constants
    protected static final String MIDP_PROFILE_ATTRIBUTE_NAME = "MicroEdition-Profile";
    protected static final String MIDP3 = "MIDP-3.0";
    protected static final String MIDP2 = "MIDP-2.0";
    private static final String COMMA = ",";

    // references to error messages
    protected InstallerErrorMessage errorMessage = new InstallerErrorMessage();
    protected InstallerDetailedErrorMessage detailedErrorMessage = new InstallerDetailedErrorMessage();
    protected SecurityErrorMessage securityErrorMessage = new SecurityErrorMessage();
    protected SecurityDetailedErrorMessage securityDetailedErrorMessage = new SecurityDetailedErrorMessage();

    protected String INVALID_CERTIFICATE_MSG = "Certificate with invalid value threw InstallerSecurityException with following status code and message: ";
    protected String INVALID_CERTIFICATE_SIGNATURE_MSG = "Certificate with invalid signature threw InstallerSecurityException with following status code and message: ";

    // Begin j2meunit test framework setup
    public void installerMain(String[] args)
    {
        TestSuite suite = new TestSuite(this.getClass().getName());

        suite.addTest(new AuthenticationModuleTests("testAuthentication", new TestMethod()
        {
            public void run(TestCase tc)
            {
                ((AuthenticationModuleTests)tc).testAuthentication();
            }
        }));
        suite.addTest(new AuthenticationModuleTests("testVerifyAuthenticity", new TestMethod()
        {
            public void run(TestCase tc)
            {
                ((AuthenticationModuleTests)tc).testVerifyAuthenticity();
            }
        }));
        suite.addTest(new AuthenticationModuleTests("testOcsp", new TestMethod()
        {
            public void run(TestCase tc)
            {
                ((AuthenticationModuleTests)tc).testOcsp();
            }
        }));

        com.nokia.mj.impl.utils.OmjTestRunner.run(suite);
    }

    public AuthenticationModuleTests()
    {
    }

    public AuthenticationModuleTests(String aTestName, TestMethod aTestMethod)
    {
        super(aTestName, aTestMethod);
    }

    public void assertFalse(String aMsg, boolean aCondition)
    {
        assertTrue(aMsg, !aCondition);
    }

    // End j2meunit test framework setup

    protected void setUp()
    {
        authenticationModule = authenticationModule.getInstance();
        session = StorageFactory.createSession();
        storage = new SecurityStorage();
        session.open();
        appUID = Uid.createUid("myUID");
    }

    protected void tearDown()
    {
        session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
    }

    private void testAuthentication()
    {
        // prepare the storage data
        AuthenticationCredentials[] credentials;
        SigningCertificate[] details;
        String domainCategory;
        StorageEntry midpEntry;
        StorageEntry appPackageEntry;
        allAttributes = new Hashtable();
        SecurityAttributes securityAttributes;
        // 1. get protection domain category
        authenticationModule.removeSecurityData(session, appUID);
        assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID) == null
                   && authenticationModule.getCertificatesDetails(session, appUID) == null);
        authenticationModule.removeSecurityData(session, appUID);
        // 2. unsigned, install from JAR which does not exist
        authenticationModule.removeSecurityData(session, appUID);
        try
        {
            authenticationModule.authenticateJar(session, appUID,null,"somethingWhichDoesNotExist", false);
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue("",
                       e.getOtaStatusCode() == OtaStatusCode.INTERNAL_ERROR
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_UNEXPECTED_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.INTERNAL_ERROR,
                                                        new String[] {"Could not compute hash for somethingWhichDoesNotExist"})));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 3. unsigned, install from JAR
        authenticationModule.removeSecurityData(session, appUID);
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
        assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
                   && authenticationModule.getCertificatesDetails(session, appUID) == null);
        authenticationModule.removeSecurityData(session, appUID);
        // 3.1. unsigned, install from JAR, no session provided to authenticateJar -> no authentication data stored to storage
        authenticationModule.removeSecurityData(session, appUID);
        authenticationModule.authenticateJar(null, appUID,null,TEST_DATA_DIR + "security_tmp"  + System.getProperty("file.separator") + "app.jar", false);
        StorageEntry query = new StorageEntry();
        query.addAttribute(new StorageAttribute(
                               StorageAttribute.ID,
                               appUID.getStringValue()));
        query.addAttribute(new StorageAttribute(
                               StorageNames.SECURITY_DOMAIN,
                               ""));
        query.addAttribute(new StorageAttribute(
                               StorageNames.SECURITY_DOMAIN_CATEGORY,
                               ""));
        query.addAttribute(new StorageAttribute(
                               StorageNames.HASH,
                               ""));
        query.addAttribute(new StorageAttribute(
                               StorageNames.CERT_HASH,
                               ""));
        query.addAttribute(new StorageAttribute(
                               StorageNames.VALID_CERTS,
                               ""));
        StorageEntry[] entries =         session.search(StorageNames.MIDP_PACKAGE_TABLE, query);
        assertTrue(entries == null || entries.length == 0);
        authenticationModule.removeSecurityData(session, appUID);
        // 4. unsigned, install from JAD
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP2));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        credentials = authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(credentials != null && credentials.length == 1 && credentials[0].getProtectionDomainName().equals("UnidentifiedThirdParty")
                   && authenticationModule.getCertificatesDetails(session, appUID) == null);
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp"  +  System.getProperty("file.separator") + "app.jar", false);
        assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN));
        authenticationModule.removeSecurityData(session, appUID);
        // 5. upgrade of authentication storage data
        authenticationModule.removeSecurityData(session, appUID);
        storage.writeAuthenticationStorageData(appUID, new AuthenticationStorageData("UnidentifiedThirdParty", ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN, "jarHash", "rootHash", new Vector()));
        authenticationModule.authenticateJar(session, appUID,appUID,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
        assertTrue(authenticationModule.getProtectionDomainCategory(session, appUID).equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
                   && authenticationModule.getCertificatesDetails(session, appUID) == null);
        authenticationModule.removeSecurityData(session, appUID);
        // 6. cert validation ok (2 certs succesfully validated)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("",
                          "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-1", new Attribute("", "MIICWDCCAcECBEhQwA0wDQYJKoZIhvcNAQEEBQAwczELMAkGA1UEBhMCZmkxEjAQBgNVBAgTCVBpcmthbm1hYTEQMA4GA1UEBxMHVGFtcGVyZTEOMAwGA1UEChMFTm9raWExDTALBgNVBAsTBEphdmExHzAdBgNVBAMMFkpQX0RldmljZV9NYW51ZmFjdHVyZXIwHhcNMDgwNjEyMDYxOTU3WhcNMTgwNjEwMDYxOTU3WjBzMQswCQYDVQQGEwJmaTESMBAGA1UECBMJUGlya2FubWFhMRAwDgYDVQQHEwdUYW1wZXJlMQ4wDAYDVQQKEwVOb2tpYTENMAsGA1UECxMESmF2YTEfMB0GA1UEAwwWSlBfRGV2aWNlX01hbnVmYWN0dXJlcjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApi3ipIPj8O33/rZre1euh7Itd9d6ZVf2mvQ/tLpHEsFJe5XLOsVViMvFskhhKUzmDsRbP4J03L6827/vEDIi/1i8kJGLaoFqJYaLGFWI2Zmxlj6aJV8cfZyOjmQPWJn1IDEe1ZAWbvMSp8xibWRsCLNEGKIkxQvAr/QDK/6iS+kCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCDXt6klAs6yKvdTab3D2wkdoi3Lu4YFsMgLexJOu5HhAUJ/9VYO+Q2+mjd95MRsTa5rWQ2Jjvhn57Z3z/KBOwfHbymmNtMk6Gl14H0vQRoHa31jh3mTuAy5KotDVthaDp30aOizk473NU68wY1WdP4gFk5ZhrpNea9q3st13BxIQ=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" ,new Attribute("", "IcANmLKiOJQF8ABCNDj1PNNH/O8v9jfCVuiGBVm8enXDkM/gLwPjrC65sDKpOCHPqssUlHzjmVN5b9g8aRs4jxUOXNt2b732J7NSIPh97vw/WrP/KHdiooi/1KFUyklMyokK9ZrIv+GW1ttLCfKbuFupT9zmPAmWJQpnuD7J6sE="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        credentials = authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.removeSecurityData(session, appUID);
        assertTrue(credentials != null && credentials.length == 2);
        // 7. cert validation ok (2 certs succesfully validated, but the signature of one failed) and JAR ok
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "Khn165ePip/dPyTN3p61MnjjzPsA1nnGLFhPbQ5Dv7YYVRPz5WrrHWlvIOyDA7MadOURwIO3xB8tfBm7cFtRIRKWB7cDj4a1MbrySDb/g1iCWnOyOYFGbpxj1d2QjAtlNlEt+0IAQlqLrQC5a0aFBoJHj4bvkfzcuRFxpbnQ8wY="));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("",
                          "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        details = (SigningCertificate[])authenticationModule.getCertificatesDetails(session, appUID);
        authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        // this empties the cache as well
        authenticationModule.removeSecurityData(session, appUID);
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        assertTrue((domainCategory.equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN)
                    || domainCategory.equals(ApplicationInfo.MANUFACTURER_DOMAIN)
                    || domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN)
                    || domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN)));
        // put manually the DB data back, so that we can test the certificates details
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.NAME,
                                         "MIDlet-Certificate-1-1"));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.VALUE,
                                         "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        midpEntry = new StorageEntry();
        midpEntry.addAttribute(new StorageAttribute(
                                   StorageAttribute.ID,
                                   appUID.getStringValue()));
        midpEntry.addAttribute(new StorageAttribute(
                                   StorageAttribute.VALID_CERTS,
                                   "1"));
        session.write(StorageNames.MIDP_PACKAGE_TABLE, midpEntry);
        details = (SigningCertificate[])authenticationModule.getCertificatesDetails(session, appUID);
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        authenticationModule.removeSecurityData(session, appUID);
        assertTrue(details != null);
        // play with invalid values for certificate -> see it does not return anything
        // delete from StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE
        midpEntry = new StorageEntry();
        midpEntry.addAttribute(new StorageAttribute(
                                   StorageAttribute.ID,
                                   appUID.getStringValue()));
        midpEntry.addAttribute(new StorageAttribute(
                                   StorageAttribute.VALID_CERTS,
                                   "1"));
        session.write(StorageNames.MIDP_PACKAGE_TABLE, midpEntry);
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.NAME,
                                         "MIDlet-Certificate-1-1"));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.VALUE,
                                         "INVALID"));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        details = (SigningCertificate[])authenticationModule.getCertificatesDetails(session, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        assertTrue(details == null);
        // 8. cert validation ok (2 certs succesfully validated, but the signature of one failed) and JAR nok
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "Khn165ePip/dPyTN3p61MnjjzPsA1nnGLFhPbQ5Dv7YYVRPz5WrrHWlvIOyDA7MadOURwIO3xB8tfBm7cFtRIRKWB7cDj4a1MbrySDb/g1iCWnOyOYFGbpxj1d2QjAtlNlEt+0IAQlqLrQC5a0aFBoJHj4bvkfzcuRFxpbnQ8wY="));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "2-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "2" , new Attribute("",
                          "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        try
        {
            authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" + System.getProperty("file.separator") + "modified_app.jar", false);
            assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHORIZATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED,
                                                        new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME})));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 9. cert validation nok (none of the certs were validated ok due to cert errors)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("","cert11"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("","signature1"));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        try
        {
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(INVALID_CERTIFICATE_MSG, false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 10. cert validation nok (none of the certs were validated ok due to signing certs being expired)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICczCCAdygAwIBAgIJAJT/0kM9aoDeMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTA4MTIwMTExMTI0M1oXDTA4MTIwMjExMTI0M1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqqHuJXLGMi7XBbM+8t4z6BMA3KTjXIe9Q6GhnqdQ6+SrUKQlty+zfuD2w+NqQDAkQjEs/flMbDk90rNl1orV11kTgUt8mqwQ8k2HWbNP3Lh+vx172E0SmGQdqVM6ElLck+KdJBPAW7KVqtBRN9NethTU8kLydpoDiUZxVUgDYW0CAwEAAaMrMCkwDgYDVR0PAQH/BAQDAgeAMBcGA1UdJQQQMA4GDCsGAQQBXgExAQICAzANBgkqhkiG9w0BAQUFAAOBgQCPZR3E5BGuQtnpo8lmftM5czJrSyXUZqm8unjSJRcV/vst9c08utSX1s3KQsA18ghaHbiP9mlHdZWvMLJQUVZ1JScl6BayG3GZXqJnZjdb3jumXAA4lOSZCDfaApRB/SCuT4qAH93wOi8PWaajFfELLlldGyFWxE0W9CDyXWFqUA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "MRjh1zZ3rRPOD/jUx/Nhf/v3cXyt7IlurT4VEWJ4tDUmaBdZitKAznrJPwwnhRi9fWhcN6JNbjl7TUuZ+lut3Ut43yDLVjXn7uT3xsHmBu8LOjXdbP4vQ+WwxP7UjTQtp2gyXF7STf+8T514OKvWU0tnCbJaxBP8Xcow1MVJgXw="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        try
        {
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 11. cert validation nok (none of the certs were validated ok due to having the root inside the chain)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICBzCCAXACCQCyjGn678eCCjANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQGEwJGSTEQMA4GA1UEBxMHVGFtcGVyZTEnMCUGA1UEAxQeUzYwX1JuRF9DZXJ0aWZpY2F0ZV9TZXJ2aWNlX0NBMB4XDTA3MTAwMzA4NDMxOVoXDTA4MTAwMjA4NDMxOVowSDELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxJzAlBgNVBAMUHlM2MF9SbkRfQ2VydGlmaWNhdGVfU2VydmljZV9DQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvQ+LJvaMlX9XMkrqJoczOi54w10MiolWX6cKH6GvpDwXBhoMtvTKXQPeNqoXBmNa2/1YFnfosan83GXZP7+GOL1g5qW/i3I9ZngU/HCiB1UJSbx1hHblV3g5jZ8wUPnATC5dOUgJeEkkr9pU1GK8Z33P29DMlF0JGnJhJ/80Vq0CAwEAATANBgkqhkiG9w0BAQUFAAOBgQCNwkvEW2shElVGL065k1o45HzFq4+EbinhjGLUmFrII65JiHysjkdCHbJamVwoOgvLJxhULlQDLJ+iHJevPMfuNcFTBvsIKlleV8X2X04SLAfXi09JkcdsMOKK6BNLjEZPrzOomLV/aniZ1sW3mEqGvMVgwhWQBhN/nCzxXWbqUw=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "sT72Uw6P2uSn3euuQxJ6ybkfckFLVFR9jtpUhltMdxwJFsnoIJJaQ1eiVyalygpqxUSs3GRV/1bIi3zDmT6JwE+MGpBFA3O15QJF9o0xZIjYedy7ZKzXw4XgG74jeufiP/CjasH2ZTwOc0NiDuhAuxc78eoqH7/pClouTyEyjCk="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        try
        {
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 12. cert validation nok (none of the certs were validated ok due to not having the root)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICJjCCAY+gAwIBAgIJAIipukKWgXc+MA0GCSqGSIb3DQEBBQUAMEgxCzAJBgNVBAYTAkZJMRAwDgYDVQQHEwdUYW1wZXJlMScwJQYDVQQDFB5TNjBfUm5EX0NlcnRpZmljYXRlX1NlcnZpY2VfQ0EwHhcNMDgxMjAxMTAzNjA3WhcNMDkxMjAxMTAzNjA3WjA1MQswCQYDVQQGEwJGSTEQMA4GA1UEBxMHVGFtcGVyZTEUMBIGA1UEAxMLSmF2YURldkNlcnQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANtT1AD8t4IAUt2pyzX8FyoEzrQj9RCR3R29u8EAvlRF0azkKJ/5IO/R/fQJBaAArt5QsxEcN6eQoZ0gEiR/EwHdYG2NmDLDqdTEJOXeKP5QWpondlCqawJUurQXnScOjcxyJ8Lmva5m08IXj9xsZir3WyyMNNr7ulKecTkfAjH1AgMBAAGjKzApMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwDQYJKoZIhvcNAQEFBQADgYEAc2QsDrLJY0ZsoLLiT971696XWRdAOtysUQjxicObbiD6TVu8UKwMRO4fFTktCq7biPAhPLEA3rHPTK+FMSiOS1YIwycmxKXRavFKmfCk/GzB2duq1bum9BlWojMbHpl5XRVCZrcyIfbHJ6RyTB+2xlvc9fXF7ScSMr3eVke85n8="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "gf60j7s2VDHCiluDxOikBUeHlxK1mAdQTcu1VZTr9E0SGWY+lOpsnueg7RKW/lxQoNC6VGlmEJei7Hu7TJKKmzZBQPEJyhs+bD42dRelewDv4UWhBoza0Lgwr4GI290mvMxRP5+qf65aTaGTu+6+vraR8MpMbjc79WsmGoHX8Bc="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        try
        {
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 14. cert validation nok (signature verification fails)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1",new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "Khn165ePip/dPyTN3p61MnjjzPsA1nnGLFhPbQ5Dv7YYVRPz5WrrHWlvIOyDA7MadOURwIO3xB8tfBm7cFtRIRKWB7cDj4a1MbrySDb/g1iCWnOyOYFGbpxj1d2QjAtlNlEt+0IAQlqLrQC5a0aFBoJHj4bvkfzcuRFxpbnQ8wY="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        try
        {
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG, false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_SIGNATURE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHORIZATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED,
                                                        new String[] {AuthenticationAttribute.SECOND_LEGACY_ATTRIBUTE_NAME})));
        }
        authenticationModule.removeSecurityData(session, appUID);
        // 15. check parsing of signing certificate info
        // no subject
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICsTCCAhqgAwIBAgIJAKJPf47MYBEgMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMTkzOFoXDTE1MDIwNDEyMTkzOFowPjELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxHTAbBgNVBAoTFE15IE9yZ2FuaXphdGlvbiBOYW1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAopEiJMbNqMH8Y6KRrLIv4cTGTABO8wu2s9MZtD4tncP5OOlRgDDcN3suLNpmict4sDOa6b4G4NQX5GZltijHaEuizHxWBNPj0xahOoz1+kOR9Rt1ktLkBw5M/G4ndUGAbRGaP0WXIqxB3s1djcMd+tlZGCrA4UL46yps9rIQVOvPhRWlzPgoekW+HovBbkbR+QPT/d0hXm5N/KrZQSRJbosPquq9QOS6A8cSkJoxvjRHw+WbHwrKPCwOnXBiRZ/CgLnS8Owb9TH4KatsPsq/hFzd7CFLgskHShwEJwoGJNPCxEo71aMKVT1szOioYvfYR5gfhbW3ap3GE0OcdT2NowIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAEknv3IppfU8kKw5bm4V0XMSb54OHrlcx7P/OP4R5e54UaVLzO4/zsWeHOgmOIt7EDENbnah4rbfwJhTDA6rNR3OGI5RB0PIe2EkvXkzo62onbFx4WWXhK/pZE1mbBvhuYinRiIvGcJkS85rFVS7wH6tn5GkfXAWp/1etY7HU5MD"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "GQE13S11H6pp7KfCmKofG/4L2szDx93jp9vpAjpDuEdJkG+xZZWi2Pt0+E7JyxRrGllxdD7D2iEMBp70z++E8ehTQ0uqb3cW7lj5a0rKSoObnHycplKwkpjo9RhJOcClBoPfbvg2ezXv0yT4W0O5RSTLWySKGl+ScSvVVedXHMcq9d2tiZLFW2X0vaDWq9sWNwdBxSkiGDLqX5yUV9NkA6pAs8BeEQ8Vmg5j3ibrIywHAizAjilcBn3yzkxQVA9NR+Z/67ssztygO1x/pz+ARYq8+qmNCMBbrNkawBFi55eRgdwHFteerRzER10Vsw7M7JLLGYjVtaVy6A9LiGRdeA=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        details = authenticationModule.getCertificatesDetails(session, appUID);
        assertTrue(details != null && details.length == 1 && details[0].getFormattedSubject() != null && details[0].getFormattedSubject().equals("My Organization Name, FI, Tampere"));
        // no organization
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICqzCCAhSgAwIBAgIJALwZDU9Un3bLMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMjgyMVoXDTE1MDIwNDEyMjgyMVowODELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1tsrsmfM//C2kJ3TJ/dDNktYyfFseNeFqiN/z1xb/hb1vRplVXM21Ouc+y05EtBz+5gXErC7dr9k910cM0TQFe9qB78hbNNaKUcGZv1alLZRKjFlEWIexBzyLleOxb7o/wAHzdabTlthYuWmU5WF7B7FCDErBQQxEoLwL/tJV9AKLjqcBtrQ/88/PPbQieexU46HYxnpwoV01lH8PdKknnam3jV8fwHBWoh62lKNe8aXT4HVINrdL4xFjk5RT5wWKs0ceEntO4x3mXa+P9tHTJS1/NQalvg6an+zu/epSjtnp3gID0SHubgmLQtRJE3MgKiXCKvV3GSRtgS/S8vTAwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFEo1+F90QbQ+AFwH3Z3AJaUcuuqNb4/CwtpGhvb3H58aFbhfr4SO2qNjrQVdp5I35jeMbr/QMxTs/SQlY84YvxqzGa80+nDDrK0pdki/go11FoCWQx+o2V/ksZaIubqZ4O2FCiyIaT+jat2367ksbeFeCdlig6kEtPDV7wnsSns"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "nCPnbbo0yOnckgv6wT8N9pH1id3MZvHbQzU6mFleGZiIwvc8c+wITX6NbyFVsrG4wk8OhIkp51aIvLTFMze38gwRwGuYFfqiv5NooAtmBlzDVGfBjJczklROJgrrJjwuFt/Jd1mxYqUdojU0h3JZonDlOqjTc4HCR6KOn77QiCAKgaxtDlEfdKL0vkfJLdkqB5Y3Vj15QVsLGZUDHAEET1qHlPOUzTSBFnvLQ9/20isk35PZUbxHBiA5tC3atfNZOvmcD/IvDqTy0DFgcEapV2o9FRlv4yptr19hIfsKfMmSFYPRbiKWYt8IL0f1zH6ogKdMHGk0lzLyEHy/6CnDAA=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        details = authenticationModule.getCertificatesDetails(session, appUID);
        assertTrue(details != null && details.length == 1 && details[0].getOrganization() == null);
        // all elements present (My Company Name, My Organization Name)
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKmyKIcZTQ3PMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTEyMzA0NloXDTE1MDIwNDEyMzA0NlowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALiEQ8ApumyMFM9L5mIRWf8OyFPwO6lFLOfJvsD4o2TFBSLSo2va02ExbseehLlMFiyOZyf1VDva8oEe/pV2vjEInxpJEfWO734TGr5fX8E0kdZ8mURNQqcl5nBqwT0xnJfatm7rPIm7yvWnJzpEn9MrkNWrxCOnjHSA26AkU+1q9rJt2eQrXOe0J5AfOI9YLhSHyTsETI6PybGHme3lFtpjBVkbraZHGXWhxLWO+E3zkkjbVZjJwHs6MYZk1bLl/6hB9F9EBjVjsYPbXtmFPBMgf1TGIugTbttHqlCNqNyb6juzoqnptE7atoIjBh5ZhA0G4WtAleCVgf/aFYzX5EECAwEAATANBgkqhkiG9w0BAQUFAAOBgQCp4KaxMok1ijm6ywMfvJbwQnbau2vS/8sEjJd1fUV20p0yZem6W492OlyRCLlu3NLoBEyV2bGZBKRWRXURALdboLARJiSLd2NGSL3rTjxWiAylCPlXESo9jv8l3QUCWVfxnyFtmNJ8t1qsPNb48u5sU80YRTJwAQ6P3wfl+5Bb5Q=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "s0wTZDsS3XSM/mb6USV3oD0vE10/L2obQD6Hn/0Vi0Z8hWAdfH2RAcvXVMJ3IhaFd/mPJ6ZOPv3r1IM+j96PajN+cj4THSdjO3JOUl+oWJnr8y3AlgEOhCxVYGrtMqjACZy/tuaCux14OdF2fKUWqTjmMRb6IJh+ub9gTRuoZ18TfE9EffpjnqWAYGujMWGBHubcV3qpPL/MWSZ1hfNq659yDSrlkdMI2tstiRrr/StwuJNdrY17qtFVftbRiBFF0AOKeJgD5jU5DpWg3MFW9jkM8SoNO9dbOM1RC/H9E0xxlPC/rPayJ3b0sFa3ywbNfTaz5JFGmXbgIZynjFrL8Q=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        details = authenticationModule.getCertificatesDetails(session, appUID);
        SigningCertificate cert1 = null;
        SigningCertificate cert2 = new SigningCertificate(null,null,"My Organization Name",null,null, null, null, "98C116D3", "IdentifiedThirdParty","ITPD");
        SigningCertificate cert3 = new SigningCertificate(null,null,null,null,null, null, null, "F91CE143", "manufacturer","MFD");
        SigningCertificate cert4 = new SigningCertificate(null,null,"My Organization Name",null,null, null, null,null, null,"MFD");
        SigningCertificate cert5 = new SigningCertificate(null,null,"My Organization Name",null,null, null, null, "","manufacturer",null);
        SigningCertificate cert6 = new SigningCertificate(null,null,"My Organization Name",null,null, null, null, "6CC300CF","operator","OPD");
        assertTrue(details != null && details.length == 1 && checkCertificateDetails(details)
                   && !details[0].isSameSigner(cert1)
                   && details[0].isSameSigner(cert2)
                   && !details[0].isSameSigner(cert3)
                   && !details[0].isSameSigner(cert4)
                   && !details[0].isSameSigner(cert5)
                   && !details[0].isSameSigner(cert6));
        // 16. Developer Certificates/Manufacturer - sign to trusted third party domain
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIIC7DCCAlWgAwIBAgIJAIjarxZ6zTJ2MA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMzYyNloXDTE1MDIwNDEyMzYyNlowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAs5/XLwdG8ykxn8bq3IhHcoeIKTN9fzrnkbW+Z80expjpG5Fbpsh7hR0vybYtu6kPP6DHV/SsYXeIfCvmYPRUXe9iR4qWb4DoqrCzd01wOPFaln3orRTXZhvlvKEMNmOlIcdjQGAdiKlFSm7aGXcWF7vRfL9x+CW8YjzV3FbBFIMCAwEAAaOBozCBoDApBgNVHSAEIjAgMA4GDCsGAQQBXgExAQEDBDAOBgwrBgEEASoCbgICAgMwDgYDVR0PAQH/BAQDAgeAMBcGA1UdJQQQMA4GDCsGAQQBXgExAQICAzBKBgwrBgEEAV4BMQECAgcBAf8ENzCCADMMDzA3NTMxNjYxNTc4NzUxMQwPODUzMTEwMzg2NjU2NzgyDA8wMDAwMDAwMDAwMDAwMDAwDQYJKoZIhvcNAQEFBQADgYEAK63bD9hyNjvIykCUaMYJENuJy/9kCEtGL4YQPZdHG+TeSQ0zgvUwiQXsWPwFaa/P6xY5TTA1Wf+uQY7hxFdWvnSISHgcDlw7uKk0prENl2el+bGMU1E4kVqcx+QRGPYdFRpFXq3VtL0GR9AC0sJRwjGo8ZIxIwSMrKI6NpkLOO8="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "otIHquw4orxOi5bhejtnZGdWPHyJW+EQPhTgqoGFqQt8zNhAl1MNbBxZCaXBu84IWChcMbTj3ziogyUDeW+CmnP5T85z18/A0GanqAXYj7otaYiba/Si2CiHYQdEBvGgjATuDuVr9wsv/1qWGqmmnPo6+1OqulM38etWnB2/zGQ="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
        // 17. Developer Certificates/Manufacturer - sign to operator party domain
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIIC7DCCAlWgAwIBAgIJAMx3Pmq32sbvMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMzkyN1oXDTE1MDIwNDEyMzkyN1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzcPrO75PU8yU2VyOa/boUeZ7Glvhnq4BgE3gLYLLQgKLAwlO5NfVn0v1JKKP02milDo+ptYxVTdGYnKDd8Bd3GE4IGaQY0PGEXEnZ6Oa/9afxjUkHQh3AgnyCceU9UJ1JVjdrVltiVMoa7fruqq8j6MXaWkctOBbXe0APnfHDpkCAwEAAaOBozCBoDApBgNVHSAEIjAgMA4GDCsGAQQBXgExAQEDBDAOBgwrBgEEASoCbgICAgEwDgYDVR0PAQH/BAQDAgeAMBcGA1UdJQQQMA4GDCsGAQQBXgExAQICAzBKBgwrBgEEAV4BMQECAgcBAf8ENzCCADMMDzA3NTMxNjYxNTc4NzUxMQwPODUzMTEwMzg2NjU2NzgyDA8wMDAwMDAwMDAwMDAwMDAwDQYJKoZIhvcNAQEFBQADgYEACZ4K4DQxzfuL5wVoQElbSi5w2vEQrtq7UvDb9TkBVjp/Ls+1g6yTzvp42sl6fJAl4Ooqxo+9SwiddYaiiB1DG3hP1V88HZOjQBDVuiv+iKU6+1L6yb2k5PkaBkYZG+bkg/iUGYOedzenTlocj3cHKOZtfcECVMoDpVR+YkDfvZ8="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "wXTAM75XDaBaBV89qlb/XnR/hRtQ2y8uVJmUJg/NY0JXD0g8o9mT3M7PGJbDIjUGE1zcdqN+NmWaDQtWo7yUX1G4nn8TEnXvupNo2hWqwhTMDM3wMgs7kgbK1W/lC/OZVuM9CXmbPw+/r8eRJmCspz1ocYonYS08ZQUQ943cRt0="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
        // 18. Developer Certificates/Manufacturer - sign to manufacturer domain
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIIC7DCCAlWgAwIBAgIJALV2Fc/8vZkDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNDAwN1oXDTE1MDIwNDEyNDAwN1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA932ZtgmgBrqP6FN/KsVYOhhHouD0BZ8PIgIgbD14furlOWkUiex2CeWU6uNXosYui28E9d6eAoYh1ri3nH5AjHhDKNtF0jaQJOW9a9ZRf3MXeXGgNR+lb1X0KRvdNK3hukkeLfT98/UCnw3GZiu8kMAEUhvuyPELlmyIQUpSjmkCAwEAAaOBozCBoDApBgNVHSAEIjAgMA4GDCsGAQQBXgExAQEDBDAOBgwrBgEEASoCbgICAgIwDgYDVR0PAQH/BAQDAgeAMBcGA1UdJQQQMA4GDCsGAQQBXgExAQICAzBKBgwrBgEEAV4BMQECAgcBAf8ENzCCADMMDzA3NTMxNjYxNTc4NzUxMQwPODUzMTEwMzg2NjU2NzgyDA8wMDAwMDAwMDAwMDAwMDAwDQYJKoZIhvcNAQEFBQADgYEAZqNEIjA90iRuIPJE+OEnB+LpBlENkamEmNCSX5LtxFS/96BzUVc0gU90it1YP5A1HlqWF2+dK13b+QAU0bW1xfORw3bCCRhAZei1E93/watRQDf0yCjDhRqa3LFU19j7zNd8Ul7YynByAZiZUmXNQZHELmWpUmYruNEWBNORKyk="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "1ggIHsuOMDD+GeLcwZr3W3EnY9HD9g68WH7qe6fXLsCicGc+mEB3jqmvxIsMgv8zvv+fdAQsgQfXDqNWQ5EJ5pf5SKXIowpilwQu9Tvk2iRaqDXqAZIqp0en1ST4CZOEC1xEdBcXBBAaAMvAG2EJQtCeMtkdU27UfpFbdWy1eu4="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.MANUFACTURER_DOMAIN));
        // 19. Developer Certificates/Operator - sign to trusted third party domain
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICxTCCAi6gAwIBAgIJAJBmh9ckN0IqMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMRswGQYDVQQDDBJKUF9PcGVyYXRvcl9Eb21haW4wHhcNMTAwMjA1MTI0MjM4WhcNMTUwMjA0MTI0MjM4WjBXMQswCQYDVQQGEwJGSTEQMA4GA1UEBxMHVGFtcGVyZTEXMBUGA1UEAxMOTXkgQ29tbW9uIE5hbWUxHTAbBgNVBAoTFE15IE9yZ2FuaXphdGlvbiBOYW1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCycnZBBs0xC3qAFELkRzdzldYLO6bWXq9+1uAnifZHtQBnHlTV28ejT+ZwlG5LXqOeQHShw+GRA7jUaeilMax2jCfCnNpIHpgxgp86HN3SLK8Bqwdt8dfSTfXdODlfsB3+Ivm5Ki46RbVJmFnS/qtgljAr/cbinAFWrryXh7oL4QIDAQABo4GAMH4wKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgIDMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwKAYMKwYBBAFeATEBAgIHAQH/BBUwggARDA8qKioqKioqKioqKioqKiowDQYJKoZIhvcNAQEFBQADgYEAd0GNAT5doSHyUNHMvNWpy1rq5O0LNuMHGho3YQBEJ3N4NCSx490hhlCV/6VKGVj4aKkrTfqRGBQ26Oa00srH8EUme7wBTn0SuWj04a2aZ+PwzuG39kqmZag1jPmB+t5/+j5p+DW3YhDGn2297pKR7h0/uCT15NAq9xPMYopqHQA="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "mQ5yJoXJK1Uc4KXGm8Gue+Yi8LzzFEaRSfYyUiZSROXzapVTHpfnCYJKvG1cQOv/aZ9gDQ8LQoBLYIuZEXIK6RzzEaBCY/RcEaCviaSVq3JB/OiXglLcTZ1e+mFBvQQ0LUuPKaCW1jv4EJy3BfNL9ckeh/7dNxXc1qRSe5lZWFk="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
        // 20. Developer Certificates/Operator - sign to operator party domain
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICxTCCAi6gAwIBAgIJAIkqKsPh0EAcMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMRswGQYDVQQDDBJKUF9PcGVyYXRvcl9Eb21haW4wHhcNMTAwMjA1MTI0MzM2WhcNMTUwMjA0MTI0MzM2WjBXMQswCQYDVQQGEwJGSTEQMA4GA1UEBxMHVGFtcGVyZTEXMBUGA1UEAxMOTXkgQ29tbW9uIE5hbWUxHTAbBgNVBAoTFE15IE9yZ2FuaXphdGlvbiBOYW1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvb2WSRLEM1REbIJ18v9UEFEoY9/oJYcstfUduI5uEcd0yXlc+Sy7la7v3oWGYa0N3QQ77vScJo1nfUUoJEIEwpcWYuJ0OHjkD5sFmlGoSXy9I19s+8Ia6hW4mTBPDFn0cUrVHpjiTNBJn2ukhQGqdb30mWUqwntqJDMwNt6WwpQIDAQABo4GAMH4wKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgIBMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwKAYMKwYBBAFeATEBAgIHAQH/BBUwggARDA8qKioqKioqKioqKioqKiowDQYJKoZIhvcNAQEFBQADgYEAVlz/9UYZIorhMH23LQkwRN00FckIYjNbyCsAqnE2o21RLG08ay8uwc2BOCEoKaD5WVE5eyxlatW8IWFygYVN7tzUvtAE7xzb9gazwGYtjooaCi8c4EkHut46ixqjoREakJQzkMu3WGul+IGt4oOcJcC8UMwfUodmA3TuKXigFo0="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "oTIYybIjUD9bop+tDyOkVKP6kUKnAYi1JTI561Atrm6jhobZlQyBksNv8hI76xs1VOU8wnY0EYozhAnMR0WzC9QLGihJE0l5npLyvBi/0Q4CuFIpLg+2xpbBQ4vF3s7rDknimPVzd3VIsxo5mz7qGVeGCDfoxf85W+qMrY9lsy4="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
        // 21. Developer Certificates/Operator - sign to manufacturer domain -> still the operator domain is used
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICxTCCAi6gAwIBAgIJALxFDFpKvETiMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMRswGQYDVQQDDBJKUF9PcGVyYXRvcl9Eb21haW4wHhcNMTAwMjA1MTI0NDM4WhcNMTUwMjA0MTI0NDM4WjBXMQswCQYDVQQGEwJGSTEQMA4GA1UEBxMHVGFtcGVyZTEXMBUGA1UEAxMOTXkgQ29tbW9uIE5hbWUxHTAbBgNVBAoTFE15IE9yZ2FuaXphdGlvbiBOYW1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwhV9kpgw9RYoM6zV/3z8L8y9Bz7Sqanq+T4xUb7eVvad2kRGU7BPD0f08Kt+o+td4StKKOcZDxGNx8qrQbMlLdDrZFI8lha2dCHUU221YMlvDxITG0YCjBWcMwowMC0Q62gBGr41Ee7pCb08V/E+xXJrNmhrPpluezuiMVJ9BIQIDAQABo4GAMH4wKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgICMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwKAYMKwYBBAFeATEBAgIHAQH/BBUwggARDA8qKioqKioqKioqKioqKiowDQYJKoZIhvcNAQEFBQADgYEAPtSTGHXsY+owikYpiOIKqnN7ZwJ2fU2Eb3NkhctVPIcomvwMBBPkKQ4qbxkHs6nF0Q5EkRTt/7FsUjMpmHKjRGlQ3FwbAaMHgwtqD6bDX3CqltMAgntd1yDPex/JzBi+bT+fudlXBB2X5jXly1GXEKQAlw5e9E2FKXBG6zhMqlY="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "lLOY+UtDU4Edj2S8T3ERkDnwJvBDJgh6Y6ah/hTL6/njyWnnGUCXdu3UN2jayqP0xTNQvM5Xv0zc5lv0mpdwzpT+17xDG6t0xSu2QvI+xRgIqzS9ncxaSF9oa4aIFe8IE3kf2+LW+jRleKplC3d0rzOmOHJLCZspRr1Zrs2238M="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN));
        // 22. Developer Certificates/TrustedThirdParty - sign to manufacturer domain -> still the trusted third party domain is used
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyTCCAjKgAwIBAgIJAPFYfswHG2oFMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTEyNDU0M1oXDTE1MDIwNDEyNDU0M1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwWzPnCHOidkD066tY5KQzL4ezGeqJnHJbRFlaqsVbuMC07Lv52Bqomi0vUExK3L1Wh3oml0rh2eivbYsRpSJHOqUBcV28dmAcP+rsQ2BWs28VCaHJ2W/piH4aeXfENCh8n+MOvMTyEOrYMVH6HOKHn526BXCOC0ubUsqcHwhVHsCAwEAAaOBgDB+MCkGA1UdIAQiMCAwDgYMKwYBBAFeATEBAQMEMA4GDCsGAQQBKgJuAgICAjAOBgNVHQ8BAf8EBAMCB4AwFwYDVR0lBBAwDgYMKwYBBAFeATEBAgIDMCgGDCsGAQQBXgExAQICBwEB/wQVMIIAEQwPKioqKioqKioqKioqKioqMA0GCSqGSIb3DQEBBQUAA4GBAKilfiTDHUyKy+S50Q+XUL57HXGEJsDHTxQgzLtrBRkSt/2f8nUBtoC9BXNXRBB7wi8+Gbe8uH8XuHX2QhoWU/gQwsmrmRbRtAbbi3jcezappnal2AFO1+icwiWYdeaKicScTz7tgZZY986EBDVJr8fqpYX5Br394zsGbeUu0ueH"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "P80CAyaqrtCFH+c2vrXX1yJkwAo2NrFEboC/h5R/47W8D1dOfhUUWSkGmCSs3eQRgdgFXjIjZL/zmCQbNuZJ5mkE+o8Z3ptFNJEQCBlV9Nfh9D0YmdR81CJgSh0af7QNHJ4rlttKtTmvFEUD2Kc49g4FDXMjU+7ISp6ZbUhNk4Y="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
        // 23. Developer Certificates/TrustedThirdParty - sign to operator domain -> still the trusted third party domain is used
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyTCCAjKgAwIBAgIJAJP72IjeLQ+5MA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTEyNDYyN1oXDTE1MDIwNDEyNDYyN1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAzyFOFxPXidq4NoJYKtMIBV3q3KEuZqavo4T1cQeVaCHFgTm7hE8VaBi/xujLJJ6SGyn7AFbM5widqhGVmsFa9Wq240zgTBfQWFY6vbZlLUge0PE5Xkre97DsUKz1YNf1JlI2FREWB+UUyff4Y2gs6jg9qDd/Rb7xsn4M/OPb6ucCAwEAAaOBgDB+MCkGA1UdIAQiMCAwDgYMKwYBBAFeATEBAQMEMA4GDCsGAQQBKgJuAgICATAOBgNVHQ8BAf8EBAMCB4AwFwYDVR0lBBAwDgYMKwYBBAFeATEBAgIDMCgGDCsGAQQBXgExAQICBwEB/wQVMIIAEQwPKioqKioqKioqKioqKioqMA0GCSqGSIb3DQEBBQUAA4GBAJbEVhlBD6ioHcCHuQfo5dQSlFGXk4iPhXwjxzXHL55RoYi2ENKhD1ts2jUg61Hi7P+Qdcv3LBQLnTufuNL93aQ0J0IKuHYUM9mXYOnUHPluvqrM2djK/WBfVwF/VxBuf2L3R7P7AwnBkGHxcNhW4ipTmkuzFnFCsqz87/8UP5HX"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "FVXATPVhIFWYUp7a/BcmQodZLHcuBi8L4gibaXVBFECjqIQG0TGqgzm00xw4nxCFikV+vqdCiF7qD/YJClc6DPxgcqd70QTaTouRJGMsitj0ax7CPISLcXkn22aYZREChMpm1qWegAa9OwGudln6hlFqJLqa8iyD8482NiVG2Z4="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
        // 24. Developer Certificates - no domain info -> fail
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIIC3DCCAkWgAwIBAgIJALhAaTo8j0WHMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNTExMVoXDTE1MDIwNDEyNTExMVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqZaB/y491gIIPzwvdfhy91OvJAz8qrtY0gEq6QZjBA8lZclJJBP4pNTDrY7Nk/8SBlB92HlplzRprPj6i2g/mQsGolY5d9YR7415EwTtNZ9J3PoJGtd7Xd25wiQWOHdLeEv413+EiqHB1G4Xn2PZpE3j51C7Ld1618vvU0dPfMMCAwEAAaOBkzCBkDAZBgNVHSAEEjAQMA4GDCsGAQQBXgExAQEDBDAOBgNVHQ8BAf8EBAMCB4AwFwYDVR0lBBAwDgYMKwYBBAFeATEBAgIDMEoGDCsGAQQBXgExAQICBwEB/wQ3MIIAMwwPMDc1MzE2NjE1Nzg3NTExDA84NTMxMTAzODY2NTY3ODIMDzAwMDAwMDAwMDAwMDAwMDANBgkqhkiG9w0BAQUFAAOBgQCQ0VMGqVKujIoaxtho7bF16B8xpT98QKvz8C5WpERVhT8uj4FPuz0l0hRcsi/g7SatO1S0uwDqR7bqcUWlYY3EjmwXhuZ6a6HeIEPhLDowZ64lLK0arT6RsPqD0ITRwOm7OposUcLZaQqpAPS1aaNzQDyRMCxeNv1czI6+rYHi1w=="));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "Z+UFeHCTi5FKIftISDn8mNCgCCTnRZ4iL6nwadOE3lFlcQxGid8720QUkBMt1xGwFHfvMec23snNx6YLDHOpL2EVLYoFAFg91cY58P/BWs4ykFm4N9DJOAysr9uE+etuIt7ZU2O+TxY0wN/KpQ60daogW4tBTmw99PfmKmyZ1Z0="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue("",
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHORIZATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHORIZATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        // 25. Developer Certificates - no IMEI list present, but domain info is present (trusted third party domain) -> domain is trusted third party
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICnjCCAgegAwIBAgIJAKb+FzQaAzk6MA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNTQzM1oXDTE1MDIwNDEyNTQzM1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3w6P5ngznrWh4cLg4+4JiY9Fnqhu8H+gxISVZKhSFojtXHaEscZcWpUWm6WyUKh1yjaherCyERD9lUHtbmUsNrLCvVc54mptHmSf/6c4QzpCofGUtcPncWzEpKMuwbh2LqSiuVGYhoz9n1RpHM+79ZqCC3H5yAhqH6YxF6icaHsCAwEAAaNWMFQwKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgIDMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwDQYJKoZIhvcNAQEFBQADgYEAUwo4DMNoHaMY0shLnPDeaY10zvSPewrWHmfNsFoIspCxRQDCsZc0YkjjzdfBtfvB5gCFpVpkRGjp1aM7IFpAMdYoJ8zDUI4fkkmyLylc3z58th0Pe3FJp0fzKFthwGkKtCUKssF04IbqH7TqCeZiN0vdfL6K49htQ7oS2f45NLg="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "sOpL9KbJMxvT8Cwtvlj9rLfJKSDVkWYm13rGWgU27djNP77+48d/VBN5WkUp1MW2XLmn3umA3sstFBk0YfLGOSe4N0TusvcdmQXwBovK82xJfX1yNXs23Z6eRvDFanxC85IEfKLXcuIw5tK6v0lAG94AbMaQPhB5olAamdtgzLc="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        assertTrue(domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN));
        // 26. Developer Certificates - empty IMEI list -> failure
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIICtzCCAiCgAwIBAgIJAK6/9Mp3gawiMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNTYxOVoXDTE1MDIwNDEyNTYxOVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtnKR28ledYg2hiOUcWyfYfm2KaAo3laoc6lxYS0/laIAbSKW5lysbtzY2yxDFP6f1o2eg/oXjJyTSm2tJGALwFlobP5afKtsldMt9yyddk6OWPpGelb87KuYUZEDiAAlFB/THRSfUL/seoPuC2oSRdSHNTnpkUmE9BHy4deMs6sCAwEAAaNvMG0wKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgIDMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwFwYMKwYBBAFeATEBAgIHAQH/BAQwggARMA0GCSqGSIb3DQEBBQUAA4GBAHKrkiSm6g9+Do1qW+a19rukHghBM3Rb1lqLjIJRvxr6I1GJ+R2pIjKRmxob7zdAQ8yKdFp5TG9v0l3HQKatoMARNQXh8NGCryILCjMLVh4gI/GOHWcmpsndm5xlXod+qeIF866pFeCJfbD6F6gWzz9Qm5CL4mCv3OEFn/tlsvdB"));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "rvwdao/zvNxmzM2kQq42prVmspMV+gnyeEBlzz7d5kc4lsok+pn3hg65Nwr1cM/DfYd8NYyTuU6bLlOV7n9iMjgqKMNPeiU7M9g3EC7xoL7kY+dn0Og5IjHfmovMj11i0yV9u8+oFOai2EbkPMxS9sXXMFkXZpnm1yOWmtzVGxo="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        // 27. Developer Certificates - invalid IMEI list -> failure
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIICvDCCAiWgAwIBAgIJAOPDxqOqcY29MA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNTgwNVoXDTE1MDIwNDEyNTgwNVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAo/4uRMIbsXGeK02CLubUZXqne6VanxwnS784JJ1XjBajMENnCh8DmeQA2SlUbUNljXZ3gfm5tEN3r7AkgMJOSvlLQ086biMn49emNuenXQLp+YdDAylJoODirUed2NAhCCWvC8BT6k8NAJqpsJZTO6Q3rJIDI8Ybw0kAOJpk1jECAwEAAaN0MHIwKQYDVR0gBCIwIDAOBgwrBgEEAV4BMQEBAwQwDgYMKwYBBAEqAm4CAgIDMA4GA1UdDwEB/wQEAwIHgDAXBgNVHSUEEDAOBgwrBgEEAV4BMQECAgMwHAYMKwYBBAFeATEBAgIHAQH/BAkwggARDAN4eXowDQYJKoZIhvcNAQEFBQADgYEAjwgEv/CTRm03vEiQ4IDc8P/ebw7aXhmbeoXy/OYfe+PjktHFD9Z45tQEjm+ydtK1FJQcUtQaIwMusi8CmMdfRQPA3H+tbTNuKyvvVFznaaQIhTKZuZqT1nbocj13BNUGljg/y4jcJhlPkewlm7e8dk2AaM8MzF/bMb++xUWb5kE="));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "oeWf4S/xsTMnNf8ojeLHSNeya04fAXzKP2/9gOrqY7GJEVMJ92r7eQgWmgezhFfZRwOZyhJJa7h70OAYWMzoVX2RwXVvVQUTPb7Mii7H/L5/w8euRYQJcHqkaJ6b2XOt40ML7qRXhetPpQ9nQDCNQFeyz8zVIrEDW76ba1PUlNw="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        // 28. Developer Certificates - 1 IMEI, no match found -> failure
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIICyTCCAjKgAwIBAgIJAJDvl9w146MAMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyNTk0MFoXDTE1MDIwNDEyNTk0MFowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1VmImlDul7gwWQAPSJ/cmWm9C5+KAFOsDmgehzmAAwR1iHdeCkXMq7C9/4wjTikCc0PHs+3mDEZBQQcdKpYdUc7mwz1zyDqvjddNdQDZY1o5Jm/LDYBI8vo6oPIdLB4CpQhsTZEvWmGBrdo5xI9e0xV/0/NrIEQzYbMpWMskGjECAwEAAaOBgDB+MCkGA1UdIAQiMCAwDgYMKwYBBAFeATEBAQMEMA4GDCsGAQQBKgJuAgICAzAOBgNVHQ8BAf8EBAMCB4AwFwYDVR0lBBAwDgYMKwYBBAFeATEBAgIDMCgGDCsGAQQBXgExAQICBwEB/wQVMIIAEQwPKioqKioqKioqKioqKioxMA0GCSqGSIb3DQEBBQUAA4GBAAYblCj3vO3937pO7z6zgaqkvbFQywBEHC297Yy1cwJkzJSxayyDIMX2FRnlnlJKArLbbSgjRYsyUHjKtlq2u7YUiD7CBZxTFFfBpCjvCan2tW2Z0BmR7CY4Skmb9qC5/VwyYJ0++TZvwcHothzkbbVJ4AGm9Y98GWIbLiwOxKaj"));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "hvTba5gR2NAiijc8gbfXBJkp4K8YroJYkXH/CxeDPTW1gRLdsgnqkkhRCdlzcv8w2kpMyi04826Let7EmUED1fDsRO5v/Ot57J9r/i/5PXctUqlKb3XgUttPQrNQepX8wTH0dpGNgTauS6MX8VNb4/pu9GxAOdRz3URYm4Qqyy0="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        // 29. Developer Certificates - 10 IMEIs, no match found -> failure
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIIDZzCCAtCgAwIBAgIJAKVNeS6JpAvfMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEzMDM0M1oXDTE1MDIwNDEzMDM0M1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwkL7axzvM73fdtf8LFVFXxstdoQ4jkkyMsD2fcmkHjKgA0QIZ63+r0ALXrZrKwUnu48MRE0ipOrNZoRjnpm8846enlvl2PamNnBpCKOCQk6mToeGPslVPO207MrTblUpaI9yWZiHg2p05f067PU3dwGubzhTpSjBEwbKE9+1P0sCAwEAAaOCAR0wggEZMCkGA1UdIAQiMCAwDgYMKwYBBAFeATEBAQMEMA4GDCsGAQQBKgJuAgICAzAOBgNVHQ8BAf8EBAMCB4AwFwYDVR0lBBAwDgYMKwYBBAFeATEBAgIDMIHCBgwrBgEEAV4BMQECAgcBAf8Ega4wggCqDA82MzEwMzY0MDcxODI4NDYMDzI1MjQwMDYwNzgwMTQ4OAwPNzQ3MDQyODM2MDg4MjQxDA8wODgxODUyNDI2MTA0NTIMDzUwMzcxMzI1NzAzNDcwMQwPNjU4MjY0NzQwNzA4MzUwDA80MTcwMTA4ODI4MjUwODQMDzE0MDE4NTUzNjg0MTA0NwwPNzY2NDcwMzc2MzYyMzM1DA8zNTI0NDcxNzI0NjIzMjYwDQYJKoZIhvcNAQEFBQADgYEANFnXZBKG3avDMuqCVq0kL9qKDQIgdSCz4d9VF6i+LpbCMvMFDmmfYYvWDLC7Rr8DjKyGsU3HyScP2imHK2d1C4UXrXzN0Mfw6a6mOmNmhyFY3tW+09ESB5iKOeeLnlUHsH+sQ4ooXXZetUQL9c0sAvKSgTz0GNDzff6Q1H2aWrQ="));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "duw2pV1BgJeuuiWM3wvUfFEVIdIyoJaSv5k1odz/J5WPAO2UI90NiNpkXbe/kf99TuPL9dVytegt9+8b8Kllb++CSy29x4fuRrlHl1jJIafjILgSDEoogKiIyDetl/9ywccHCVPlev0evBevLgOjXDLh3OWfqAUsVR5f/aC/jxQ="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
        // 30. Developer Certificates - 2000 IMEIs, the last one is a match
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          " "));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "jEDzd/ZrEth/wjcxTkwk5Rh+Jr8+mCZgFTcHGVhsPFtHxX1/qCugoGAHUfhBNJhouId1TlrpAEXwK0uvLHJK3jW8bdz6r54QZ2htwrA1MQZKc3hxfeAdGX0TmKuWFzsbwMZlzRHN6r+kCfmV4qzp5d9utM6GwaV4mJMhGoHIMKM="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(true);
        // 31. test the signing info for signed application
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" , new Attribute("",
                          "kwxpKeSSWSeSW5ieWCx9ARFD6Lrwabxk5t7Aas5FFVEtr89vslY1QIexKNiytQm51PTIRnCNhl6y+tcv7V7GRskV1VMlTHwbCVjK4rqoFFrcZrO3qHvkRh6K9wnHnw5PPtBsrMbg8lWKBrGaf4TYRYFW+CukmR+06R7u5zAZaL7CMhl69bCXd78Tz1Z4N5CxVFD8vGatp66TMBk+0YhZP7Lo1yIDu2XsojVtigAoV9sm8OF5/aXmgfFb2AUmANGxlaDAieUfOAm7RXvsOZgaPN72KEqya8XQW6r1/aGF6jMmJ62qgPqJV3TtJtbFSwH1suywAk1UDltVim4b/Ucw1A=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        SigningInfo info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
        // app is unknown
        assertTrue(info == null);
        // make the application known
        appPackageEntry = new StorageEntry();
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageAttribute.ID,
                                         appUID.getStringValue()));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.NAME,
                                         "MIDlet-Certificate-1-1"));
        appPackageEntry.addAttribute(new StorageAttribute(
                                         StorageNames.VALUE,
                                         "MIICyjCCAjOgAwIBAgIJAKoRe0pf7UvDMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIwNTEyMDI0NVoXDTE1MDIwNDEyMDI0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKoYd+BJxNOD8+bGcxCFfJvDr95SJzVGDwrIcANqnO5pq+nI0FWbYTNsTNzl0umP3DjQ+jAboZG+S0/hPh1dYs8aAxm7ORzwHOM70cIboYrrZzOB/Kw+BXY3HuFqrtO25oke/MfKbspVNjR4QErZafsa0IVsX2bKT9cgcUUMykQwht0JjsQjn7CMKb8dE/RjATIXl7a+ng0jBnDIm+rUK/+YCimmaIJT3xb+PAmFXFwU+tmGqFeNlIIi0EUIot7q8JJeSJWMCftrlcHgb3J+jFfyeHt/YcfIN0rxXtlDHFVQXvskPq4I7O+NSypfJBiR8dfxffYlPliNKJ2vG2iurZsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBpGzuZaf2N/f3c6auGkYzcYY34VB+4C9kFJA2dQBsNYnlfIeSF30o9uq0VAkFI5uzk4aYiDB0dN5lsZ/bv/jnmrElDaXEBRBn6KtkIsJRgIcKRyXLOfWFcskcChxTVknPV8hxLYyjmi4S+O2Km9cOHEy4bib+XlnEsoe5iiTaHKA=="));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appPackageEntry);
        StorageEntry entry = new StorageEntry();
        entry.addAttribute(new StorageAttribute(
                               StorageNames.ID,
                               appUID.getStringValue()));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.PACKAGE_NAME,
                               "appName"));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.VENDOR,
                               "appVendor"));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.VERSION,
                               "appVersion"));
        session.write(StorageNames.APPLICATION_PACKAGE_TABLE, entry);
        info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
        assertTrue(info.getProtectionDomain() != null
                   && info.getProtectionDomain().getName() != null
                   && info.getProtectionDomain().getCategory() != null
                   && checkCertificateDetails(info.getSigningCertificate())
                   && checkCertificateDetails(info.getRootCertificate()));
        // 32. unsigned application
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        authenticationModule.authenticateJar(session, appUID, null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar", false);
        info = authenticationModule.getSigningInfo("appName","appVersion","appVendor");
        assertTrue(info.getProtectionDomain() != null
                   && info.getProtectionDomain().getName() != null
                   && info.getProtectionDomain().getCategory() != null
                   && info.getSigningCertificate() == null
                   && info.getRootCertificate() == null);
        session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        // authenticate to certain domain - null value
        authenticateToDomain(null, true);
        // authenticate to certain domain - unknown value
        authenticateToDomain(new ProtectionDomain("myOwnDomain", "myOwnCategory"), true);
        // authenticate to operator domain
        authenticateToDomain(ProtectionDomain.getOperatorDomain());
        // authenticate to manufacturer domain
        authenticateToDomain(ProtectionDomain.getManufacturerDomain());
        // authenticate to trusted third party domain
        authenticateToDomain(ProtectionDomain.getIdentifiedThirdPartyDomain());
        // authenticate to untrusted third party domain
        authenticateToDomain(ProtectionDomain.getUnidentifiedThirdPartyDomain());
        // extended key usage - no extension
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICWjCCAcOgAwIBAgIJAKCax8NgVHTGMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIyNDEwMjA1MloXDTE1MDIyMzEwMjA1MlowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1/O0o24bSr6C5kCw8lg/UzubEpOvqmwwgWI5TO2S7KfxFkF/O1P+5qc8vU7+sJlgGwynki9HCI00t4pAE+sF0hTAjY8hQaMg0q/kgh3QoCiEvWH9xC/eX6p7X9H2WcWVogS1hmAfrGopsjT5juYn5W9N7pc2gy+ypfZ8obbP4n8CAwEAAaMSMBAwDgYDVR0PAQH/BAQDAgeAMA0GCSqGSIb3DQEBBQUAA4GBAC7rgPLkOWVy6RvmEUZ/nSRAAfbxZvRVLb49pmMI3ZIYWuDbNgxBPZZY/H02yhBw4plXvySQiBm8jtEHSt/wABdoz10go9Gv2chOnetI+1/c88GY1CDmNZ8pFbvHoBQj2F+yDP2lsDedzhlnEHJaw63u9sgxl1BnRtihgfhIkILm"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "trKz6/JqmFFrAnP/hgZofqpT1EeQHqY0qYHi6vPkmBAtw36bZAaV7UANIXirdTLGJk2OZo3DsFRBIgbz+38vWjif0MP5lxN0821bgLwYNzbjjejzNZc3RAyV8cHR15L45FH73gp0F8Cfs6+C0QT7z1yr6V+Jbm9+DdlsTkwfYeo="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(true);
        // x509 code signing extension
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICcjCCAdugAwIBAgIJANsDitVsBUyMMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIyNDEwMjI0MloXDTE1MDIyMzEwMjI0MlowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAx6iv41CzNgQV3khVn6jl2DCeIb2WRnf3oiulukhjQn3y9o6zZDzKBLF47MT+roVLbnswRHnAhkuVSBA4JyYBumOfFqxXQHNgrnKrxpupVFhXTUxtjqeX1zxeEnS0AOBmGLbndykn+8peSCBZom1r6gTXrMDYPCPKJYvphXMmyXECAwEAAaMqMCgwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMA0GCSqGSIb3DQEBBQUAA4GBAIbDGnCc9oFzcPtAssoGWcSenLfKdiTRoySwwyuIzhfvUGWMO2h3ta5Sp46t+nl+2tygeYy1fkl65UAgUqmeFsSgDhEIC+TBmw+S4Nzm6Ktq28r4Gk6Yqnx/oWoiyjdamQIjdNWQRoKRnVT/3TIW3zYOg/InLbbV1rY1Jr8SQ7qu"));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "deuHPO2Bqid4gJTVOvf4zcnJWBgi/rbEj3VDVPkHmF+QuombD4Iz4whZ+fxlCdk0ygRxsoBOEFvXL/D7hJPVbNggD3kksFBpYDMFANJXn3FFReU0naTZS7qN1DUck0GzX4DmgKeRFvn0DgLOnn++cgNAVkaTEIJlggGKrc/wYjk="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(true);
        // nokia code signing extension
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICdjCCAd+gAwIBAgIJAMlxOCiz1uFuMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIyNDEwMjM0MVoXDTE1MDIyMzEwMjM0MVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3HxYBECqzXsnZfh+Ctn1JBuSjiW7gbsmOb2HorLlt6tVAEISly+OtzYKXUgkW+dWO/7RR2QfWpV1TSULifFx7198btlTLG/M6pcZEPIHzP4/7BQZWDXMgPpOH1vqob1Nps9K/1mIqR2HiFNL7QcbjMwQnWdGYOK88kawO6VEvHsCAwEAAaMuMCwwDgYDVR0PAQH/BAQDAgeAMBoGA1UdJQEB/wQQMA4GDCsGAQQBXgExAQICAzANBgkqhkiG9w0BAQUFAAOBgQBGQIcQWQeWVMfBeBKcwYhEUc3ITlor6jV1VV9pwiblNrtMWoFJpyPRpYIZsVhdqsicp38EwvqobFVhVY0QK6PHqwn+eurkNB4TZWLW0JMUGjoIPtt45iXrCqvJfn6xZpkO/ZFzvyfza9AQLa3WuFTyLzzEf1YRjVEvyBFaRxql7w=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "ryh/rqKP6XcVy1PSot7ghvD/xg+lhVtjLYk3jPVeCRNl2ez4hSGPBnZB+jqQyTecH+se9qA3B9PtYuJzEn0jWhDqTCTYqxnIrJxZFimk9giI68rqlajDUK/XEmN7DyxM3knuGUPtKYFLTlp3Wazfl/eXsTMwR1+G+Q2XMDtFNiM="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(true);
        // nokia and x509 code signing extension
        authenticationModule.removeSecurityData(session, appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                          "MIICgDCCAemgAwIBAgIJAON0Llj25rWmMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIyNDEwMjQ0NVoXDTE1MDIyMzEwMjQ0NVowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAq7maHvQS6JWxWSSAZOhK6fa0Sj11PmwGzPqRbPSXxBamWN8USNyR6H1IVg5KY0Vd+zHLwv63Hj+cnQHMH0cSmkvS9hVu5FCvKjHTWYcmZgGyG4lZ7HKNIcrZb8WEDEVGvel58upfbHiouz+14JlQXUuEPatpFUF2npj3aXHvFSECAwEAAaM4MDYwDgYDVR0PAQH/BAQDAgeAMCQGA1UdJQEB/wQaMBgGDCsGAQQBXgExAQICAwYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADgYEAlIBZziJ1jBCyNZmVeNKF2G7g++TdvwLuCuXVb/Tk+cELLEH0ueOd1Njn7wqciXEMf7uQGGuA9A5XoxW01Hb/KFGenOTZk2e5rSfB/JV1ANtT2qgIOPmnihiq0sEzwLkWHw8G2d+vC2PkO8GWcDB+KRVwHTXz0WD3sCsCqSSu3Zo="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                          "TucdBtmePWgkWjXhteRSz45TUSI4H8dyZA1wKHvMuwBnuA8UhmdlpZ3oFJJQixxXxAulePNouG6cg5GtWJCcyYm4+OV0DeW0C5lo76lmIfjmBCAiQm0Ro26eSnkwDOtqoSPQNz9rPoIiMAQLEzM+jaDKQvCS81Btr9ljB1L6WwQ="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        assertTrue(true);
        // unknown extension
        try
        {
            authenticationModule.removeSecurityData(session, appUID);
            allAttributes.clear();
            allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
            allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",
                              "MIICbDCCAdWgAwIBAgIJAOI97LkyZNDOMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9EZXZpY2VfTWFudWZhY3R1cmVyMB4XDTEwMDIyNDEwMjUzNFoXDTE1MDIyMzEwMjUzNFowVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAooouUypXTdFIwfRasYdNWfkknLJYD/iMfnbRneScXnOSipEwY+5pCrISbcvb/P6nBqhlCeCblwO3dEiPp+iFXHFnyuvC4rh90JpRXApMe0Nf2XlIeZVLQYWGJ16VePatp1rArFCy8jSjOQIWmFik88tP88ajse8sb0bg+QeG6ZMCAwEAAaMkMCIwDgYDVR0PAQH/BAQDAgeAMBAGA1UdJQEB/wQGMAQGAioDMA0GCSqGSIb3DQEBBQUAA4GBACsCSxGu9Rol5YW/121ntS5iSoofJoLoInYuTzw7wuQ3mejyvtwkyKmba3hIyXQz1V/gXFH7PuiWLUMLQkCAet3/v3KneIfM1LSqM5MEDWT02bo9E1iO57pawbTkYy+27sMnmJ/d1YeH4c3b4I6gfofBo9ZDY6jtupoCfflNiCi5"));
            allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("",
                              "njU2OjnbLQigE/LhhszSc/oUXTcsZ7ZmjRiZMzGmHeQBtce+9dX8JkgsjAS7cZ6C1lbszGANXqSnMOr5PhFO0bo6Llnu+iJjRKBK/P8l8YYFXIlsjba7iBwm0Kb9lIY860F00bdgZpW2o5gBMZzO/kRgs3rP5mv37Cha62oE8h4="));
            securityAttributes = new SecurityAttributes();
            securityAttributes.addDescriptorAttributes(allAttributes);
            authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
            assertTrue(false);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(INVALID_CERTIFICATE_MSG + e.getOtaStatusCode() + " " + e.getShortMessage() + "," + e.getDetailedMessage(),
                       e.getOtaStatusCode() == OtaStatusCode.APPLICATION_AUTHENTICATION_FAILURE
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_AUTHENTICATION_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.CERT_UNSUPPORTED,
                                                        null)));
        }
    }

    private void authenticateToDomain(ProtectionDomain domain)
    {
        authenticateToDomain(domain, false);
    }

    private void authenticateToDomain(ProtectionDomain domain, boolean expectToFail)
    {
        session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        try
        {
            authenticationModule.authenticateJar(session, appUID, null, domain, TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar");
            assertTrue(!expectToFail);
        }
        catch (InstallerSecurityException e)
        {
            assertTrue(expectToFail);
            assertTrue("",
                       e.getOtaStatusCode() == OtaStatusCode.INTERNAL_ERROR
                       && e.getShortMessage().equals(errorMessage.get(InstallerErrorMessage.INST_UNEXPECTED_ERR, null))
                       && e.getDetailedMessage().equals(detailedErrorMessage.get(InstallerDetailedErrorMessage.INTERNAL_ERROR,
                                                        new String[] {"Unknown protection domain " + domain})));
            return;
        }
        String domainCategory = authenticationModule.getProtectionDomainCategory(session, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_TABLE, appUID);
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        authenticationModule.removeSecurityData(session, appUID);
        assertTrue(domainCategory.equals(domain.getCategory()));
    }

    private void testVerifyAuthenticity()
    {
        StorageSession session = StorageFactory.createSession();
        SecurityStorage storage = new SecurityStorage();
        session.open();
        Uid appUID = Uid.createUid("myUID");
        StorageEntry entry = null;
        boolean success = false;
        // invalid jar path does
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        null,
                        null,
                        null,
                        null,
                        null));
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.UNEXPECTED_ERR, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.UNIDENTIFIED_APPLICATION, null)));
        }
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        null,
                        null,
                        null,
                        null,
                        ""));
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.UNEXPECTED_ERR, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.UNIDENTIFIED_APPLICATION, null)));
        }
        // cert_hash does not exist
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    "protectionDomain",
                    "protectionDomainCategory",
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    null,
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    "protectionDomain",
                    "protectionDomainCategory",
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    "",
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        assertTrue(true);
        // jar path does not point to an existing jar
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        null,
                        "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                        "6CC300CF",
                        "jar_path"));
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.JAR_TAMPERED, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.JAR_TAMPERED, null)));
        }
        // root not enabled
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        null,
                        "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                        "unknownRoot",
                        TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.CERT_NOT_AVAILABLE, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.SIM_CHANGED, null)));
        }
        // ok (signed MIDlet suite )case
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    null,
                    null,
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    "6CC300CF",
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        assertTrue(true);
        // ok (unsigned MIDlet suite case)
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    null,
                    null,
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    null,
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        assertTrue(true);
        // tampered jar
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        null,
                        "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                        "6CC300CF",
                        TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "modified_app.jar"));
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.JAR_TAMPERED, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.JAR_TAMPERED, null)));
        }
        // ok network restrictions
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        entry = new StorageEntry();
        entry.addAttribute(new StorageAttribute(
                               StorageNames.ID,
                               appUID.getStringValue()));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.NAME,
                               "MIDlet-Operator-Allowed"));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.VALUE,
                               "123-45 456-789 000-000"));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, entry);
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    null,
                    "OPD",
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    "6CC300CF",
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        assertTrue(true);
        // network restrictions for something else than operator MIDlet
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        entry = new StorageEntry();
        entry.addAttribute(new StorageAttribute(
                               StorageNames.ID,
                               appUID.getStringValue()));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.NAME,
                               "MIDlet-Operator-Allowed"));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.VALUE,
                               "123-45"));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, entry);
        authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                    null,
                    "TTPD",
                    "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                    "6CC300CF",
                    TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        assertTrue(true);
        // network restrictions violated
        session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
        entry = new StorageEntry();
        entry.addAttribute(new StorageAttribute(
                               StorageNames.ID,
                               appUID.getStringValue()));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.NAME,
                               "MIDlet-Operator-Allowed"));
        entry.addAttribute(new StorageAttribute(
                               StorageNames.VALUE,
                               "123-45"));
        session.write(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, entry);
        try
        {
            authenticationModule.verifyMIDletSuiteAuthenticity(appUID, new AuthenticationStorageData(
                        null,
                        "OPD",
                        "AE8772B3815F19020E55E70E0F83919AFCE4D164",
                        "6CC300CF",
                        TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "app.jar"));
            session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
            assertTrue(false);
        }
        catch (RuntimeSecurityException e)
        {
            session.remove(StorageNames.APPLICATION_PACKAGE_ATTRIBUTES_TABLE, appUID);
            assertTrue(e.getShortMessage().equals(securityErrorMessage.get(SecurityErrorMessage.NETWORK_RESTRICTION_VIOLATION, null))
                       && e.getDetailedMessage().equals(securityDetailedErrorMessage.get(SecurityDetailedErrorMessage.NETWORK_RESTRICTION_VIOLATION, null)));
        }
    }

    private void testOcsp()
    {
        MyOcspEventListener oscpEventListener = new MyOcspEventListener();
        OcspEvent ocspEvent = null;
        InstallerSecurityException ocspError = null;
        allAttributes = new Hashtable();
        SecurityAttributes securityAttributes;
        StorageSession session = StorageFactory.createSession();
        session.open();
        Uid appUID = Uid.createUid("myUID");
        OcspSettings ocspSettings = null;
        OcspUserPreferences ocspUserPreferences = new OcspUserPreferences();
        SecurityStorage storage = new SecurityStorage();
        // UserInstallation: ocsp undefined, warning undefined, not silent mode, user prefs off
        ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_UNDEFINED, OcspSettings.OCSP_WARNING_UNDEFINED, false, "0", "0");
        ocspUserPreferences.setOcspMode(OcspUserPreferences.OCSP_MODE_OFF);
        ocspUserPreferences.setOcspUrl(null);
        authenticationModule.setOCSPFlags(ocspSettings);
        storage.removeAuthenticationStorageData(appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",        "MIICyjCCAjOgAwIBAgIJAM2cvDMJ0ZWCMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTExMzY0N1oXDTE1MDIwNDExMzY0N1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPKlvYkOR5iZw52pBc9C9zlmqMNqLhRnebv0hl0RRdNE7PHzqqVI64OTJ5Fqv9iP386ERMH3LH+e/IeZcqrn5LBcQmO37aWoE+hniPEZyEUmaVdeojOI6TfSfft0IPHjk7EQ2RVaCZpoKXHTd51WZL9s4EsvAHbbPC6yYxxVTYRAAAOrHSyW3Roa7CYYZH1MvK8hj+Z7PFDmkhf0AE2dlnwfR4YUbySIflWyLu+1BOBInr3+FyijWJPQXIns8AhexxaJrUAzYC5N9vBWpuxaHvf2XuQKt5mqOvFQZwMWNbaCtJJgoejsqCqn6F9W7DWPE9ioME+UEpESSNmx+9Wo2JMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBYEBGOrAJQSVkYi2FfXK11VyaVGxgujdAwa/iFxFDEIHthyKWpYJ16T1H3XwE1RjRkRn/IT2A7GSeu3naZgM/9TweZWbYPTvYz00FPFog3cTVaBezj3xnKXcpzgt2Fe3dV/ZcghbmWphe98Afm4R0GKTveIaoOMX/FsaC8l3syMg=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("", "iVq1INapoB9ghKhO0UuE7b3ckggYyUDjARitXruH3p9pr7pjBgSL7GXgBhdKnQWWFUIKeLCokMuJu+s+GWC8VkVvTaJU6Z85uGq2PtrQ9av7Dr/Omz9YMWaIUUGks8+gVB3Rv8pXICh3iJ+wcbWnECLmoPIGyH0cpBHUSVdux7+c+JIrxRPY755Pr+VESB3aa/F8EC2HjgxdQbPEI8Wlsv9Z2YcTMDUwUNW/3YyfjpskC9sIoJYoD2wF3bhntmO8dedr0oDaSU2ABPPOC6w5R7Gks0Kvx4T90Mecr9wMOSfKeQo3EnkELJ3SzAH0pePoY3rbl5leCGkGE1R56Rm8Ng=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        securityAttributes.addManifestAttributes(allAttributes);
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
        assertTrue(true);
        // PreInstallation: ocsp disabled, warning undefined, silent mode
        ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_DISABLED, OcspSettings.OCSP_WARNING_UNDEFINED, true, "0", "0");
        ocspUserPreferences.setOcspMode(0);
        ocspUserPreferences.setOcspUrl(null);
        authenticationModule.setOCSPFlags(ocspSettings);
        storage.removeAuthenticationStorageData(appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",        "MIICyjCCAjOgAwIBAgIJAM2cvDMJ0ZWCMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTExMzY0N1oXDTE1MDIwNDExMzY0N1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPKlvYkOR5iZw52pBc9C9zlmqMNqLhRnebv0hl0RRdNE7PHzqqVI64OTJ5Fqv9iP386ERMH3LH+e/IeZcqrn5LBcQmO37aWoE+hniPEZyEUmaVdeojOI6TfSfft0IPHjk7EQ2RVaCZpoKXHTd51WZL9s4EsvAHbbPC6yYxxVTYRAAAOrHSyW3Roa7CYYZH1MvK8hj+Z7PFDmkhf0AE2dlnwfR4YUbySIflWyLu+1BOBInr3+FyijWJPQXIns8AhexxaJrUAzYC5N9vBWpuxaHvf2XuQKt5mqOvFQZwMWNbaCtJJgoejsqCqn6F9W7DWPE9ioME+UEpESSNmx+9Wo2JMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBYEBGOrAJQSVkYi2FfXK11VyaVGxgujdAwa/iFxFDEIHthyKWpYJ16T1H3XwE1RjRkRn/IT2A7GSeu3naZgM/9TweZWbYPTvYz00FPFog3cTVaBezj3xnKXcpzgt2Fe3dV/ZcghbmWphe98Afm4R0GKTveIaoOMX/FsaC8l3syMg=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("", "iVq1INapoB9ghKhO0UuE7b3ckggYyUDjARitXruH3p9pr7pjBgSL7GXgBhdKnQWWFUIKeLCokMuJu+s+GWC8VkVvTaJU6Z85uGq2PtrQ9av7Dr/Omz9YMWaIUUGks8+gVB3Rv8pXICh3iJ+wcbWnECLmoPIGyH0cpBHUSVdux7+c+JIrxRPY755Pr+VESB3aa/F8EC2HjgxdQbPEI8Wlsv9Z2YcTMDUwUNW/3YyfjpskC9sIoJYoD2wF3bhntmO8dedr0oDaSU2ABPPOC6w5R7Gks0Kvx4T90Mecr9wMOSfKeQo3EnkELJ3SzAH0pePoY3rbl5leCGkGE1R56Rm8Ng=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        securityAttributes.addManifestAttributes(allAttributes);
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
        assertTrue(true);
        // PreInstallation: ocsp enabled, warning ignore, silent mode, ocsp url not set
        ocspSettings = new OcspSettings(OcspSettings.OCSP_MODE_ENABLED, OcspSettings.OCSP_WARNING_IGNORE, true, "0", "0");
        ocspUserPreferences.setOcspMode(-1);
        ocspUserPreferences.setOcspUrl(null);
        authenticationModule.setOCSPFlags(ocspSettings);
        storage.removeAuthenticationStorageData(appUID);
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        allAttributes.put(AuthenticationAttribute.MAIN_ATTRIBUTE_PREFIX + "1-1", new Attribute("",        "MIICyjCCAjOgAwIBAgIJAM2cvDMJ0ZWCMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAmZpMRIwEAYDVQQIEwlQaXJrYW5tYWExEDAOBgNVBAcTB1RhbXBlcmUxDjAMBgNVBAoTBU5va2lhMQ0wCwYDVQQLEwRKYXZhMR8wHQYDVQQDDBZKUF9UaGlyZF9QYXJ0eV9UcnVzdGVkMB4XDTEwMDIwNTExMzY0N1oXDTE1MDIwNDExMzY0N1owVzELMAkGA1UEBhMCRkkxEDAOBgNVBAcTB1RhbXBlcmUxFzAVBgNVBAMTDk15IENvbW1vbiBOYW1lMR0wGwYDVQQKExRNeSBPcmdhbml6YXRpb24gTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPKlvYkOR5iZw52pBc9C9zlmqMNqLhRnebv0hl0RRdNE7PHzqqVI64OTJ5Fqv9iP386ERMH3LH+e/IeZcqrn5LBcQmO37aWoE+hniPEZyEUmaVdeojOI6TfSfft0IPHjk7EQ2RVaCZpoKXHTd51WZL9s4EsvAHbbPC6yYxxVTYRAAAOrHSyW3Roa7CYYZH1MvK8hj+Z7PFDmkhf0AE2dlnwfR4YUbySIflWyLu+1BOBInr3+FyijWJPQXIns8AhexxaJrUAzYC5N9vBWpuxaHvf2XuQKt5mqOvFQZwMWNbaCtJJgoejsqCqn6F9W7DWPE9ioME+UEpESSNmx+9Wo2JMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBYEBGOrAJQSVkYi2FfXK11VyaVGxgujdAwa/iFxFDEIHthyKWpYJ16T1H3XwE1RjRkRn/IT2A7GSeu3naZgM/9TweZWbYPTvYz00FPFog3cTVaBezj3xnKXcpzgt2Fe3dV/ZcghbmWphe98Afm4R0GKTveIaoOMX/FsaC8l3syMg=="));
        allAttributes.put(AuthenticationAttribute.SECOND_ATTRIBUTE_PREFIX + "1" ,new Attribute("", "iVq1INapoB9ghKhO0UuE7b3ckggYyUDjARitXruH3p9pr7pjBgSL7GXgBhdKnQWWFUIKeLCokMuJu+s+GWC8VkVvTaJU6Z85uGq2PtrQ9av7Dr/Omz9YMWaIUUGks8+gVB3Rv8pXICh3iJ+wcbWnECLmoPIGyH0cpBHUSVdux7+c+JIrxRPY755Pr+VESB3aa/F8EC2HjgxdQbPEI8Wlsv9Z2YcTMDUwUNW/3YyfjpskC9sIoJYoD2wF3bhntmO8dedr0oDaSU2ABPPOC6w5R7Gks0Kvx4T90Mecr9wMOSfKeQo3EnkELJ3SzAH0pePoY3rbl5leCGkGE1R56Rm8Ng=="));
        securityAttributes = new SecurityAttributes();
        securityAttributes.addDescriptorAttributes(allAttributes);
        authenticationModule.authenticateJad(appUID,null,securityAttributes.getAuthenticationAttributes());
        allAttributes.clear();
        allAttributes.put(MIDP_PROFILE_ATTRIBUTE_NAME,new Attribute("",MIDP3));
        securityAttributes.addManifestAttributes(allAttributes);
        authenticationModule.authenticateJar(session, appUID,null,TEST_DATA_DIR + "security_tmp" +  System.getProperty("file.separator") + "HelloWorld.jar", false);
        assertTrue(true);
    }

    private boolean checkCertificateDetails(SigningCertificate[] details)
    {
        if (details == null || details.length == 0)
        {
            return false;
        }
        for (int i=0; i<details.length; i++)
        {
            if (details[i].getIssuer() == null
                    || details[i].getIssuer().length() == 0
                    || details[i].getSerialNumber() == null
                    || details[i].getSerialNumber().length() == 0
                    || details[i].getFingerprint() == null
                    || details[i].getFingerprint().length() == 0
                    || details[i].getSubject() == null
                    || details[i].getSubject().length() == 0
                    || details[i].getOrganization() == null
                    || details[i].getOrganization().length() == 0)
            {
                return false;
            }
        }
        return true;
    }

    private boolean checkCertificateDetails(Certificate cert)
    {
        if (cert == null)
        {
            return false;
        }
        if (cert.getIssuer() == null
                || cert.getIssuer().length() == 0
                || cert.getSerialNumber() == null
                || cert.getSerialNumber().length() == 0
                || cert.getFingerprint() == null
                || cert.getFingerprint().length() == 0
                || cert.getSubject() == null
                || cert.getSubject().length() == 0)
        {
            return false;
        }
        return true;
    }

    class Monitor
    {
        Monitor()
        {
            iNotifyCnt = 0;
            iMonitor = new Object();
        }
        public void waitOnMonitor()
        {
            synchronized (iMonitor)
            {
                try
                {
                    if (iNotifyCnt > 0)
                    {
                        iNotifyCnt--;
                    }
                    else
                    {
                        iMonitor.wait();
                    }
                }
                catch (InterruptedException e) {}
            }
        }
        public void notifyMonitor()
        {
            synchronized (iMonitor)
            {
                iMonitor.notify();
                iNotifyCnt++;
            }
        }
        public void resetMonitor()
        {
            synchronized (iMonitor)
            {
                iNotifyCnt = 0;
            }
        }
        private Object iMonitor;
        private int iNotifyCnt;
    }

    public class OcspEvent
    {
        public int eventId;
        public Throwable eventError;
    }

    public class MyOcspEventListener
            implements OcspEventListener
    {
        private Monitor monitor = new Monitor();
        private OcspEvent event = null;
        public void ocspEvent(int eventId, Throwable eventError)
        {
            event = new OcspEvent();
            event.eventId = eventId;
            event.eventError = eventError;
            monitor.notifyMonitor();
        }

        public OcspEvent getEvent()
        {
            monitor.waitOnMonitor();
            return event;
        }

        public void reset()
        {
            monitor.resetMonitor();
        }
    }
}
