os/ossrv/genericservices/httputils/UriParser/TValidator.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/httputils/UriParser/TValidator.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,155 @@
     1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Internal classes for PREQ748 - Adding support for the SIP scheme in URIs.
    1.18 +// Classes for validating URIs according to their scheme
    1.19 +// File contains internal classes for validatin URIs according to
    1.20 +// their scheme type
    1.21 +// 
    1.22 +//
    1.23 +
    1.24 +/**
    1.25 + @file TValidator.h
    1.26 + @see Uri8.h
    1.27 +*/
    1.28 +
    1.29 +#ifndef __TVALIDATOR_H__
    1.30 +#define __TVALIDATOR_H__
    1.31 +
    1.32 +#include <uri8.h>
    1.33 +#include <delimitedparser8.h>
    1.34 +
    1.35 +// Constants
    1.36 +//
    1.37 +_LIT8(KAlwaysValidChars, "-_.!~*'");
    1.38 +_LIT8(KCommonValidChars, "()/+$");
    1.39 +_LIT8(KValidUserChars, "=,;?&");
    1.40 +_LIT8(KValidParamChars, "[]:&");
    1.41 +_LIT8(KValidHeaderChars, "[]:?");
    1.42 +_LIT8(KUriAlwaysValidSipMarkChars, "-_.!~*'()");	
    1.43 +_LIT8(KUriValidSipPwdChars, "&=+$,");
    1.44 +_LIT8(KUriValidSipToken, "%+`"); 
    1.45 +
    1.46 +const TUint32 KCharSetNumber 		= 0x001;
    1.47 +const TUint32 KCharSetLowerAlpha 	= 0x002;
    1.48 +const TUint32 KCharSetUpperAlpha 	= 0x004;
    1.49 +const TUint32 KCharSetAlways	 	= 0x008;
    1.50 +const TUint32 KCharSetCommon	 	= 0x010;
    1.51 +const TUint32 KCharSetUser	 		= 0x020;
    1.52 +const TUint32 KCharSetParam		 	= 0x040;
    1.53 +const TUint32 KCharSetHeader	 	= 0x080;
    1.54 +const TUint32 KCharSetSipMark 		= 0x100;
    1.55 +const TUint32 KCharSetSipPwd 		= 0x200;
    1.56 +const TUint32 KCharSetSipTkn		= 0x400;
    1.57 +const TUint32 KCharSetAlphnumberic	= KCharSetNumber | KCharSetLowerAlpha | KCharSetUpperAlpha;
    1.58 +const TUint32 KCharSetUserAll	 	= KCharSetUser | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
    1.59 +const TUint32 KCharSetParamAll	 	= KCharSetParam | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
    1.60 +const TUint32 KCharSetHeaderAll 	= KCharSetHeader | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
    1.61 +const TUint32 KCharSetSipPassWord = KCharSetAlphnumberic| KCharSetSipPwd | KCharSetSipMark ;
    1.62 +const TUint32 KCharSetSipToken	= KCharSetAlphnumberic| KCharSetAlways | KCharSetSipTkn;
    1.63 +
    1.64 +/**
    1.65 +	Comments : This class provides Base functionality for Validation of an URI.
    1.66 +	which needs to be overridden by derived classes for validation Based on their RFC 
    1.67 +	specifications.
    1.68 +	
    1.69 +	@internalComponent
    1.70 +	@released
    1.71 +*/
    1.72 +class TValidatorBase
    1.73 +	{
    1.74 +public:
    1.75 +	TValidatorBase(const TUriC8& aUri);
    1.76 +	TInt Validate();
    1.77 +
    1.78 +protected:
    1.79 +	// Implemented by derived validator classes
    1.80 +	virtual TBool IsValidUserInfo() const = 0;
    1.81 +	virtual TBool IsValidHost() const = 0;
    1.82 +	virtual TBool IsValidPort() const = 0;
    1.83 +	virtual TBool IsValidPath() const = 0;
    1.84 +	virtual TBool IsValidQuery() const = 0;
    1.85 +	virtual TBool IsValidFragment() const = 0;
    1.86 +
    1.87 +	// general utility methods
    1.88 +	TBool IsValidCharacters(const TDesC8& aDes, TUint32 aCharTypes, TBool aEscapeValid = EFalse) const;
    1.89 +	TBool IsEmpty(const TDesC8& aDes) const;
    1.90 +
    1.91 +private:
    1.92 +	TBool IsInCharSet(TText8 aChar, const TDesC8& aCharSet) const;
    1.93 +
    1.94 +protected:
    1.95 +	const TUriC8& iUri;
    1.96 +	};
    1.97 +
    1.98 +/**
    1.99 +Dependencies : TValidatorBase.
   1.100 +Comments : This class provides Sip Uri Validation functinality.
   1.101 + 		   This is implemented as specified in RFC 3261.
   1.102 +	
   1.103 +	@internalComponent
   1.104 +	@released
   1.105 +*/
   1.106 +class TValidatorSip: public TValidatorBase
   1.107 +	{
   1.108 +public:
   1.109 +	TValidatorSip(const TUriC8& aUri);
   1.110 +private:
   1.111 +	// from TValidatorBase
   1.112 +	TBool IsValidUserInfo() const;
   1.113 +	TBool IsValidHost() const;
   1.114 +	TBool IsValidPort() const;
   1.115 +	TBool IsValidPath() const;
   1.116 +	TBool IsValidQuery() const;
   1.117 +	TBool IsValidFragment() const;
   1.118 +
   1.119 +	// supporting methods for the above
   1.120 +	TBool IsValidUser(const TDesC8& aUser) const;
   1.121 +	TBool IsValidPassword(const TDesC8& aPassword) const;
   1.122 +	TBool IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const;
   1.123 +	TBool IsValidParam(const TDesC8& aParam) const;
   1.124 +	TBool IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const;
   1.125 +	TBool IsValidHeader(const TDesC8& aHeader) const;
   1.126 +	TBool IsValidHeaderSegment(const TDesC8& aName, const TDesC8& aValue) const;
   1.127 +	TBool IsValidParamToken(const TDesC8& aParam) const;
   1.128 +	TBool IsValidParamTtl(const TDesC8& aParam) const;
   1.129 +	TBool IsValidParamMaddr(const TDesC8& aParam) const;
   1.130 +};
   1.131 +
   1.132 +/**
   1.133 +Dependencies : TValidatorBase.
   1.134 +Comments : This class provides Tel Uri Validation functinality.
   1.135 + 		   Only Partial support for tel-Uris specified in RFC 3966. 
   1.136 +		   section 5 of RFC 3966 is not supported.
   1.137 +	@internalComponent
   1.138 +	@released
   1.139 +*/
   1.140 +class TValidatorTel: public TValidatorBase
   1.141 +	{
   1.142 +public:
   1.143 +	TValidatorTel(const TUriC8& aUri);
   1.144 +private:
   1.145 +	// from TValidatorBase
   1.146 +	TBool IsValidUserInfo() const;
   1.147 +	TBool IsValidHost() const;
   1.148 +	TBool IsValidPort() const;
   1.149 +	TBool IsValidPath() const;
   1.150 +	TBool IsValidQuery() const;
   1.151 +	TBool IsValidFragment() const;
   1.152 +	
   1.153 +	// supporting methods for the above
   1.154 +	TBool IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const;
   1.155 +	TBool IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const;
   1.156 +};
   1.157 +
   1.158 +#endif	// __TVALIDATOR_H__