epoc32/include/mw/senwssecurityheader.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/senwssecurityheader.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/senwssecurityheader.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,363 @@
     1.4 -senwssecurityheader.h
     1.5 +/*
     1.6 +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:        CSenWsSecurityHeader represents security header functionality
    1.19 +*                according to oasis wss spesifications (2004/01)
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +
    1.28 +
    1.29 +
    1.30 +
    1.31 +#ifndef SEN_WS_SECURITY_HEADER_H
    1.32 +#define SEN_WS_SECURITY_HEADER_H
    1.33 +
    1.34 +//  INCLUDES
    1.35 +#include <SenBaseFragment.h>
    1.36 +#include <SenSoapConstants.h>
    1.37 +
    1.38 +
    1.39 +// FORWARD DECLARATIONS
    1.40 +class CSenIdentityProvider;
    1.41 +
    1.42 +// CLASS DECLARATION
    1.43 +
    1.44 +/**
    1.45 +* CSenWsSecurityHeader represents security header functionality according to 
    1.46 +* oasis web services security (WSS) specifications (2004/01) or older (2003/06)
    1.47 +* @lib SenUtils.lib
    1.48 +* @since Series60 3.0
    1.49 +*/
    1.50 +class CSenWsSecurityHeader : public CSenBaseFragment
    1.51 +    {
    1.52 +    public:  // Constructors and destructor
    1.53 +
    1.54 +		/**
    1.55 +		* PasswordType Enumeration
    1.56 +		*/
    1.57 +        enum TPasswordType
    1.58 +            {
    1.59 +            EText = 1,        // default, wsse:PasswordText
    1.60 +            EDigest           // wsse:Digest
    1.61 +            };
    1.62 +
    1.63 +        
    1.64 +        /**
    1.65 +        * Basic constructor.
    1.66 +        * @return a pointer to new CSenWsSecurityHeader class instance.
    1.67 +        */
    1.68 +        IMPORT_C static CSenWsSecurityHeader* NewL();
    1.69 +        
    1.70 +        /**
    1.71 +        * Basic constructor.
    1.72 +        * @return a new CSenWsSecurityHeader class instance, which pointer
    1.73 +        * is left on cleanup stack.
    1.74 +        */
    1.75 +        IMPORT_C static CSenWsSecurityHeader* NewLC();
    1.76 +
    1.77 +        
    1.78 +        /**
    1.79 +        * Basic constructor.
    1.80 +        * @param    aData   Data to be set as header's content.
    1.81 +        * @return a pointer to new CSenWsSecurityHeader class instance.
    1.82 +        */
    1.83 +        IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData);
    1.84 +
    1.85 +        /**
    1.86 +        * Basic constructor.
    1.87 +        * @param    aData   Data to be set as header's content.
    1.88 +        * @return a new CSenWsSecurityHeader class instance, which pointer
    1.89 +        * is left on cleanup stack.
    1.90 +        */
    1.91 +        IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData);
    1.92 +        
    1.93 +        /**
    1.94 +        * Basic constructor.
    1.95 +        * @param    aData           Data to be set as header's content.
    1.96 +        * @param    aSecurityNs     A namespace to be set to the header.
    1.97 +        * @return a pointer to new CSenWsSecurityHeader class instance.
    1.98 +        */
    1.99 +        IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData, const TDesC8& aSecurityNs);
   1.100 +
   1.101 +        /**
   1.102 +        * Basic constructor.
   1.103 +        * @param    aData           Data to be set as header's content.
   1.104 +        * @param    aSecurityNs     A namespace to be set to the header.
   1.105 +        * @return a new CSenWsSecurityHeader class instance, which pointer
   1.106 +        * is left on cleanup stack.
   1.107 +        */
   1.108 +        IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData, const TDesC8& aSecurityNs);
   1.109 +
   1.110 +        /**
   1.111 +        * Destructor.
   1.112 +        */
   1.113 +        IMPORT_C virtual ~CSenWsSecurityHeader();
   1.114 +
   1.115 +        // New functions
   1.116 +    
   1.117 +        /**
   1.118 +        * Constructs a username token.
   1.119 +        * @since Series60 3.0
   1.120 +        * @param  aIdentityProvider  Identity provider which is used to get
   1.121 +        * the authorization ID used in username token. Method takes the
   1.122 +        * AuthzID out from aIdentityProvider, and uses it as username for
   1.123 +        * this token.
   1.124 +        * Format of the token is as follows:
   1.125 +        *
   1.126 +        * <wsse:UsernameToken>
   1.127 +        *   <wsse:Username>
   1.128 +        *       username
   1.129 +        *   </wsse:Username>
   1.130 +        * </wsse:UsernameToken>"
   1.131 +        *
   1.132 +        * The above token assumes, that wsse namespace is declared in 
   1.133 +        * top level of the security header.
   1.134 +        * @return a pointer to buffer containing the username token. Does not
   1.135 +        * return NULL. Ownership is transferred to the caller. Method leaves
   1.136 +        * with value KErrNotSupported, if a password type is not supported.
   1.137 +        */
   1.138 +        IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider);
   1.139 +
   1.140 +        /**
   1.141 +        * Constructs a username token.
   1.142 +        * @since Series60 3.0
   1.143 +        * @param  aIdentityProvider  Identity provider which is used to get
   1.144 +        * the authorization ID used in username token. Method takes the
   1.145 +        * AuthzID out from aIdentityProvider, and uses it as username for
   1.146 +        * this token. Password is also fetched from aIdentityProvider via
   1.147 +        * calling Password() getter, which must return a Base64 [XML-Schema]
   1.148 +        * encoded, SHA-1 hash value, of the UTF8 encoded password.
   1.149 +        * @param  aType Specifies the type of the password, either
   1.150 +        * wsse:PasswordText or wsse:PasswordDigest
   1.151 +        *
   1.152 +        * Format of the token is as follows (if password type is wsse:PasswordText):
   1.153 +        *
   1.154 +        * <wsse:UsernameToken>
   1.155 +        *   <wsse:Username>
   1.156 +        *       username
   1.157 +        *   </wsse:Username>
   1.158 +        *   <wsse:Password>
   1.159 +        *       password
   1.160 +        *   </wsse:Password>
   1.161 +        * </wsse:UsernameToken>"
   1.162 +        *
   1.163 +        * If the password type is wsse:Password:Digest, then the password element
   1.164 +        * will be declared as follows:
   1.165 +        *
   1.166 +        *   <wsse:Password Type="wsse:PasswordDigest">
   1.167 +        *
   1.168 +        * The above token assumes, that wsse namespace is declared in 
   1.169 +        * top level of the security header.
   1.170 +        * @return a pointer to buffer containing the username token. Does not
   1.171 +        * return NULL. Ownership is transferred to the caller. Method leaves
   1.172 +        * with value KErrNotSupported, if a password type is not supported.
   1.173 +        */
   1.174 +        IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider,
   1.175 +                                        CSenWsSecurityHeader::TPasswordType aType);
   1.176 +
   1.177 +        // Static methods:
   1.178 +
   1.179 +        /**
   1.180 +        * Constructs a username token. This method does not add the <Password>
   1.181 +        * element, since it is optional for basic username tokens.
   1.182 +        * @since Series60 3.0
   1.183 +        * @param  aUsername     User name which is used in the username 
   1.184 +        *                       token.
   1.185 +        * @param  aToken        Ref-to-pointer where the token will be
   1.186 +        *                       allocated. Shouldn't contain any data when
   1.187 +        *                       called, or that data will be lost.
   1.188 +        * @return KErrNone or some system-wide Symbian error code.
   1.189 +        */
   1.190 +        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
   1.191 +                                            HBufC8*& aToken);
   1.192 +
   1.193 +        /**
   1.194 +        * Constructs a username token using a password, too.
   1.195 +        * @since Series60 5.0
   1.196 +        * @param  aUsername     User name which is to be used in new token.
   1.197 +        * @param  aPassword     Password which is to be use in new token.
   1.198 +        *                       The type will be set to default: wsse:PasswordDigest,
   1.199 +        *                       defined in KSecurityAttrTypeText. This is
   1.200 +        *                       a Base64 [XML-Schema] encoded, SHA-1 hash value, 
   1.201 +        *                       of the UTF8 encoded password.
   1.202 +        * @param  aToken        Ref-to-pointer in which the token will be
   1.203 +        *                       allocated. Shouldn't contain any data when
   1.204 +        *                       called, or that data will be lost.
   1.205 +        * @return KErrNone or some system-wide Symbian error code.
   1.206 +        */
   1.207 +        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
   1.208 +                                            const TDesC8& aPassword,
   1.209 +                                            HBufC8*& aToken);
   1.210 +
   1.211 +       /**
   1.212 +        * Constructs a username token using a password, too.
   1.213 +        * @since Series60 5.0
   1.214 +        * @param  aUsername     User name which is to be used in new token.
   1.215 +        * @param  aPassword     Password which is to be use in new token
   1.216 +        *                       This is a Base64 [XML-Schema] encoded, SHA-1 
   1.217 +        *                       hash value, of the UTF8 encoded password.
   1.218 +        * @param  aType         Specifies the type of the password:
   1.219 +        *                       - EText, being default refers to wsse:PasswordText,
   1.220 +        *                       but this method does not add this, since it can
   1.221 +        *                       be omitted.
   1.222 +        *                       - EDigest: will add wsse:PasswordDigest attribute
   1.223 +        *                       to the <Password> -element, as in here:
   1.224 +        *
   1.225 +        *                        <wsse:UsernameToken>
   1.226 +        *                           <wsse:Username>
   1.227 +        *                               username
   1.228 +        *                           </wsse:Username>
   1.229 +        *                           <wsse:Password Type="wsse:PasswordDigest">
   1.230 +        *                               password
   1.231 +        *                           </wsse:Password>
   1.232 +        *                         </wsse:UsernameToken>"
   1.233 +        *                        
   1.234 +        * @param  aToken        Ref-to-pointer where the token will be
   1.235 +        *                       allocated. Shouldn't contain any data when
   1.236 +        *                       called, or that data will be lost.
   1.237 +        * @return KErrNone or some system-wide Symbian error code.
   1.238 +        */
   1.239 +        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
   1.240 +                                            const TDesC8& aPassword,
   1.241 +                                            CSenWsSecurityHeader::TPasswordType aType,
   1.242 +                                            HBufC8*& aToken);
   1.243 +
   1.244 +
   1.245 +       /**
   1.246 +        * Constructs a BinarySecurityToken.
   1.247 +        * @since Series60 5.0
   1.248 +        *                        
   1.249 +        * @param  aContent      Encoded EncryptedData which is to be used in token.
   1.250 +        * @param  aToken        Ref-to-pointer where the token will be
   1.251 +        *                       allocated. Shouldn't contain any data when
   1.252 +        *                       called, or that data will be lost.
   1.253 +        * @return KErrNone or some system-wide Symbian error code.
   1.254 +        */
   1.255 +        IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent,
   1.256 +                                                  HBufC8*& aToken);
   1.257 +        /**
   1.258 +        * Constructs a BinarySecurityToken.
   1.259 +        * @since Series60 5.0
   1.260 +        *                        
   1.261 +        * @param  aContent      Encoded EncryptedData which is to be used in token.
   1.262 +        * @param  aValueType  Indicates what the security token is
   1.263 +        * @param  aToken        Ref-to-pointer where the token will be
   1.264 +        *                       allocated. Shouldn't contain any data when
   1.265 +        *                       called, or that data will be lost.
   1.266 +        * @return KErrNone or some system-wide Symbian error code.
   1.267 +        */
   1.268 +        IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent,
   1.269 +                                                  const TDesC8& aValueType,
   1.270 +                                                  HBufC8*& aToken);
   1.271 +
   1.272 +        /**
   1.273 +        * Constructs a timestamp.
   1.274 +        * @since Series60 5.0
   1.275 +        * Format of the timestamp is as follows:
   1.276 +        *   <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   1.277 +        *       <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
   1.278 +        *       <wsu:Expires>2002-09-13T08:42:00Z</wsu:Expires>
   1.279 +        *   </wsu:Timestamp>
   1.280 +        * The wsu namespace is declared inside this element.
   1.281 +        *   Based on chapter 10 from WS-Security 2004
   1.282 +        * @param aCreated - creation time of token
   1.283 +        * @param aExpires - end of validation time for token
   1.284 +        * @param aTimestamp - a pointer to buffer containing the timestamp. Does not
   1.285 +        *         return NULL. Ownership is transferred to the caller.
   1.286 +        * @return KErrNone or some system-wide Symbian error code.
   1.287 +        */
   1.288 +        IMPORT_C static TInt TimestampL(const TDesC8& aCreated, const TDesC8& aExpires, HBufC8*& aTimestamp);
   1.289 +        
   1.290 +        /**
   1.291 +        * Constructs a timestamp.
   1.292 +        * @since Series60 5.0
   1.293 +        * Format of the timestamp is as follows:
   1.294 +        *   <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   1.295 +        *       <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
   1.296 +        *   </wsu:Timestamp>
   1.297 +        * The wsu namespace is declared inside this element.
   1.298 +        *   Based on chapter 10 from WS-Security 2004
   1.299 +        * @param aCreated - creation time of token
   1.300 +        * @param aTimestamp - a pointer to buffer containing the timestamp. Does not
   1.301 +        *         return NULL. Ownership is transferred to the caller.
   1.302 +        * @return KErrNone or some system-wide Symbian error code.
   1.303 +        */
   1.304 +        IMPORT_C static TInt TimestampL(const TDesC8& aCreated, HBufC8*& aTimestamp);
   1.305 +
   1.306 +        /**
   1.307 +        * Constructs a security token reference.
   1.308 +        * @since Series60 5.0
   1.309 +        * Format of the token reference is as follows:
   1.310 +        *   <wsse:SecurityTokenReference wsu:Id="...">
   1.311 +        *       <wsse:Reference URI="..."/>
   1.312 +        *   </wsse:SecurityTokenReference>
   1.313 +        *
   1.314 +        * The above token assumes, that wsse namespace is declared in 
   1.315 +        * top level of the security header.
   1.316 +        * @param  
   1.317 +        * @param aSTR - a pointer to buffer containing the token reference. Does not
   1.318 +        *         return NULL. Ownership is transferred to the caller.
   1.319 +        * @return KErrNone or some system-wide Symbian error code.
   1.320 +        */
   1.321 +//        IMPORT_C static TInt SecurityTokenReferenceL(const TDesC8& aURI, HBufC8*& aSTR); 
   1.322 +
   1.323 +       
   1.324 +        // Virtual methods: 
   1.325 +
   1.326 +        /** Basic getter for XML namespace of the WS security header.
   1.327 +        * Subclasses should override this to use different namespace 
   1.328 +        * @since Series60 3.0
   1.329 +        * @return the WS security header namespace as string
   1.330 +        */
   1.331 +        IMPORT_C virtual TPtrC8 XmlNs();
   1.332 +        
   1.333 +        /**
   1.334 +        * Basic getter for XML namespace prefix of the WS security header.
   1.335 +        * Subclasses should override this to use different namespace prefix
   1.336 +        * @since Series60 3.0
   1.337 +        * @return the WS security header namespace prefix as string
   1.338 +        */
   1.339 +        IMPORT_C virtual TPtrC8 XmlNsPrefix();    
   1.340 +        
   1.341 +    protected:  
   1.342 +        
   1.343 +        /**
   1.344 +        * C++ default constructor
   1.345 +        */
   1.346 +        IMPORT_C CSenWsSecurityHeader();
   1.347 +        
   1.348 +        /**
   1.349 +        * Basic BaseConstructL function 
   1.350 +        */
   1.351 +        IMPORT_C void BaseConstructL();
   1.352 +        
   1.353 +        // Functions from base classes
   1.354 +        
   1.355 +        /**
   1.356 +        * From CSenBaseFragment Basic BaseConstructL function 
   1.357 +        * @since Series60 3.0
   1.358 +        * @param aData will be used as current token (content) of this security 
   1.359 +        *        header
   1.360 +        */
   1.361 +        IMPORT_C void BaseConstructL(const TDesC8& aData);
   1.362 +        IMPORT_C void BaseConstructL(const TDesC8& aData, const TDesC8& aSecurityNs);
   1.363 +    };
   1.364 +
   1.365 +#endif // SEN_WS_SECURITY_HEADER_H
   1.366 +
   1.367 +// End of File