os/security/cryptoservices/filebasedcertificateandkeystores/test/keytool/compiledsecuritypolicy.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/keytool/compiledsecuritypolicy.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,82 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __COMPILEDSECURITYPOLICY_H_
    1.23 +#define __COMPILEDSECURITYPOLICY_H_
    1.24 +
    1.25 +#include <e32cmn.h>
    1.26 +
    1.27 +/**
    1.28 +TCompiledSecurityPolicy is a test class used for accessing private data members
    1.29 +of TSecurityPolicy class. It uses the fact that TSecurityPolicy class has a friend class, 
    1.30 +which name is TCompiledSecurityPolicy.
    1.31 +@internalComponent
    1.32 +*/
    1.33 +class TCompiledSecurityPolicy
    1.34 +	{
    1.35 +public:
    1.36 +	TCompiledSecurityPolicy(const TSecurityPolicy& aSecurityPolicy) :
    1.37 +        iSecurityPolicy(aSecurityPolicy)
    1.38 +		{
    1.39 +		}
    1.40 +	TSecurityPolicy::TType Type() const
    1.41 +        {
    1.42 +		return static_cast <TSecurityPolicy::TType> (iSecurityPolicy.iType);
    1.43 +		}
    1.44 +	TUint32 SecureId() const
    1.45 +        {
    1.46 +        return iSecurityPolicy.iSecureId;
    1.47 +        }
    1.48 +    TUint32 VendorId() const
    1.49 +        {
    1.50 +        return iSecurityPolicy.iVendorId;
    1.51 +	    }
    1.52 +    TCapability Capability(TInt aIndex) const
    1.53 +		{
    1.54 +		if(aIndex < 3)
    1.55 +			{
    1.56 +		    return static_cast <TCapability> (iSecurityPolicy.iCaps[aIndex]);
    1.57 +		    }
    1.58 +		else if(aIndex < 7)
    1.59 +		    {
    1.60 +		    return static_cast <TCapability> (iSecurityPolicy.iExtraCaps[aIndex - 3]);
    1.61 +			}
    1.62 +		User::Invariant();
    1.63 +		return ECapability_None;
    1.64 +		}
    1.65 +
    1.66 +private:
    1.67 +	const TSecurityPolicy& iSecurityPolicy;
    1.68 +};
    1.69 +
    1.70 +
    1.71 +inline TBool operator==(const TCompiledSecurityPolicy& aLeft, const TCompiledSecurityPolicy& aRight)
    1.72 +	{
    1.73 +    return aLeft.Type() == aRight.Type() && 
    1.74 +		aLeft.SecureId() == aRight.SecureId() &&
    1.75 +        aLeft.VendorId() == aRight.VendorId() &&
    1.76 +		aLeft.Capability(0) == aRight.Capability(0) &&
    1.77 +	    aLeft.Capability(1) == aRight.Capability(1) &&
    1.78 +	    aLeft.Capability(2) == aRight.Capability(2) &&
    1.79 +		aLeft.Capability(3) == aRight.Capability(3) &&
    1.80 +	    aLeft.Capability(4) == aRight.Capability(4) &&
    1.81 +        aLeft.Capability(5) == aRight.Capability(5) &&
    1.82 +		aLeft.Capability(6) == aRight.Capability(6);
    1.83 +	}
    1.84 +
    1.85 +#endif // __COMPILEDSECURITYPOLICY_H_