epoc32/include/mw/senwssecurityheader2.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* 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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:        CSenWsSecurityHeader represents security header functionality
williamr@2
    15
*                according to oasis wss spesifications (2004/01)
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
williamr@2
    25
williamr@2
    26
williamr@2
    27
#ifndef SEN_WS_SECURITY_HEADER2_H
williamr@2
    28
#define SEN_WS_SECURITY_HEADER2_H
williamr@2
    29
williamr@2
    30
//  INCLUDES
williamr@2
    31
#include <SenFragmentBase.h>
williamr@2
    32
#include <SenSoapConstants.h>
williamr@2
    33
williamr@2
    34
// FORWARD DECLARATIONS
williamr@2
    35
class CSenIdentityProvider;
williamr@2
    36
williamr@2
    37
// CLASS DECLARATION
williamr@2
    38
williamr@2
    39
/**
williamr@2
    40
* CSenWsSecurityHeader represents security header functionality according to 
williamr@2
    41
* oasis web services security (WSS) specifications (2004/01)
williamr@2
    42
* @lib SenUtils.lib
williamr@2
    43
* @since Series60 3.0
williamr@2
    44
*/
williamr@2
    45
class CSenWsSecurityHeader2 : public CSenFragmentBase
williamr@2
    46
    {
williamr@2
    47
    public:  // Constructors and destructor
williamr@2
    48
williamr@2
    49
		/**
williamr@2
    50
		* PasswordType Enumeration
williamr@2
    51
		*/
williamr@2
    52
        enum TPasswordType
williamr@2
    53
            {
williamr@2
    54
            EText = 1,        // default, wsse:PasswordText
williamr@2
    55
            EDigest           // wsse:Digest
williamr@2
    56
            };
williamr@2
    57
williamr@2
    58
        
williamr@2
    59
        /**
williamr@2
    60
        * Basic constructor
williamr@2
    61
        * @param    aDocument   The document which will be the owner of
williamr@2
    62
        *                       the elements of this header
williamr@2
    63
        * @param    aElement    An element which will be parent for this header.
williamr@2
    64
        * @return a pointer to new CSenWsSecurityHeader class instance.
williamr@2
    65
        */
williamr@2
    66
        IMPORT_C static CSenWsSecurityHeader2* NewL(RSenDocument aDocument,
williamr@2
    67
                                                    TXmlEngElement aElement);
williamr@2
    68
        
williamr@2
    69
        /**
williamr@2
    70
        * Basic constructor.
williamr@2
    71
        * @param    aDocument   The document which will be the owner of
williamr@2
    72
        *                       the elements of this header
williamr@2
    73
        * @param    aElement    An element which will be parent for this header.
williamr@2
    74
        * @return a new CSenWsSecurityHeader class instance, which pointer
williamr@2
    75
        * is left on cleanup stack.
williamr@2
    76
        */
williamr@2
    77
        IMPORT_C static CSenWsSecurityHeader2* NewLC(RSenDocument aDocument,
williamr@2
    78
                                                     TXmlEngElement aElement);
williamr@2
    79
        
williamr@2
    80
        /**
williamr@2
    81
        * Basic constructor.
williamr@2
    82
        * @param    aData       Data to be set as header's content.
williamr@2
    83
        * @param    aDocument   The document which will be the owner of
williamr@2
    84
        *                       the elements of this header
williamr@2
    85
        * @param    aElement    An element which will be parent for this header.
williamr@2
    86
        * @return a pointer to new CSenWsSecurityHeader class instance.
williamr@2
    87
        */
williamr@2
    88
        IMPORT_C static CSenWsSecurityHeader2* NewL(const TDesC8& aData,
williamr@2
    89
                                                    RSenDocument aDocument,
williamr@2
    90
                                                    TXmlEngElement aElement);
williamr@2
    91
williamr@2
    92
        /**
williamr@2
    93
        * Basic constructor.
williamr@2
    94
        * @param    aData       Data to be set as header's content.
williamr@2
    95
        * @param    aDocument   The document which will be the owner of
williamr@2
    96
        *                       the elements of this header
williamr@2
    97
        * @param    aElement    An element which will be parent for this header.
williamr@2
    98
        * @return a new CSenWsSecurityHeader class instance, which pointer
williamr@2
    99
        * is left on cleanup stack.
williamr@2
   100
        */
williamr@2
   101
        IMPORT_C static CSenWsSecurityHeader2* NewLC(const TDesC8& aData,
williamr@2
   102
                                                     RSenDocument aDocument,
williamr@2
   103
                                                     TXmlEngElement aElement);
williamr@2
   104
williamr@2
   105
        /**
williamr@2
   106
        * Basic constructor.
williamr@2
   107
        * @param    aData           Data to be set as header's content.
williamr@2
   108
        * @param    aSecurityNs     A namespace to be set to the header.
williamr@2
   109
        * @param    aDocument       The document which will be the owner of
williamr@2
   110
        *                           the elements of this header
williamr@2
   111
        * @param    aElement        An element which will be parent for this header.
williamr@2
   112
        * @return a pointer to new CSenWsSecurityHeader class instance.
williamr@2
   113
        */
williamr@2
   114
        IMPORT_C static CSenWsSecurityHeader2* NewL(const TDesC8& aData,
williamr@2
   115
                                                    const TDesC8& aSecurityNs,
williamr@2
   116
                                                    RSenDocument aDocument,
williamr@2
   117
                                                    TXmlEngElement aElement);
williamr@2
   118
williamr@2
   119
        /**
williamr@2
   120
        * Basic constructor.
williamr@2
   121
        * @param    aData           Data to be set as header's content.
williamr@2
   122
        * @param    aSecurityNs     A namespace to be set to the header.
williamr@2
   123
        * @param    aDocument       The document which will be the owner of
williamr@2
   124
        *                           the elements of this header
williamr@2
   125
        * @param    aElement        An element which will be parent for this header.
williamr@2
   126
        * @return a new CSenWsSecurityHeader class instance, which pointer
williamr@2
   127
        * is left on cleanup stack.
williamr@2
   128
        */
williamr@2
   129
        IMPORT_C static CSenWsSecurityHeader2* NewLC(const TDesC8& aData,
williamr@2
   130
                                                     const TDesC8& aSecurityNs,
williamr@2
   131
                                                     RSenDocument aDocument,
williamr@2
   132
                                                     TXmlEngElement aElement);
williamr@2
   133
williamr@2
   134
        /**
williamr@2
   135
        * Destructor.
williamr@2
   136
        */
williamr@2
   137
        IMPORT_C virtual ~CSenWsSecurityHeader2();
williamr@2
   138
williamr@2
   139
        // New functions
williamr@2
   140
    
williamr@2
   141
        /**
williamr@2
   142
        * Constructs a username token.
williamr@2
   143
        * @since Series60 3.0
williamr@2
   144
        * @param  aIdentityProvider  Identity provider which is used to get
williamr@2
   145
        * the authorization ID used in username token. Method takes the
williamr@2
   146
        * AuthzID out from aIdentityProvider, and uses it as username for
williamr@2
   147
        * this token.
williamr@2
   148
        * Format of the token is as follows:
williamr@2
   149
        *
williamr@2
   150
        * <wsse:UsernameToken>
williamr@2
   151
        *   <wsse:Username>
williamr@2
   152
        *       username
williamr@2
   153
        *   </wsse:Username>
williamr@2
   154
        * </wsse:UsernameToken>"
williamr@2
   155
        *
williamr@2
   156
        * The above token assumes, that wsse namespace is declared in 
williamr@2
   157
        * top level of the security header.
williamr@2
   158
        * @return a pointer to buffer containing the username token. Does not
williamr@2
   159
        * return NULL. Ownership is transferred to the caller. Method leaves
williamr@2
   160
        * with value KErrNotSupported, if a password type is not supported.
williamr@2
   161
        */
williamr@2
   162
        IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider);
williamr@2
   163
williamr@2
   164
        /**
williamr@2
   165
        * Constructs a username token.
williamr@2
   166
        * @since Series60 3.0
williamr@2
   167
        * @param  aIdentityProvider  Identity provider which is used to get
williamr@2
   168
        * the authorization ID used in username token. Method takes the
williamr@2
   169
        * AuthzID out from aIdentityProvider, and uses it as username for
williamr@2
   170
        * this token. Password is also fetched from aIdentityProvider via
williamr@2
   171
        * calling Password() getter, which must return a Base64 [XML-Schema]
williamr@2
   172
        * encoded, SHA-1 hash value, of the UTF8 encoded password.
williamr@2
   173
        * @param  aType Specifies the type of the password, either
williamr@2
   174
        * wsse:PasswordText or wsse:PasswordDigest
williamr@2
   175
        *
williamr@2
   176
        * Format of the token is as follows (if password type is wsse:PasswordText):
williamr@2
   177
        *
williamr@2
   178
        * <wsse:UsernameToken>
williamr@2
   179
        *   <wsse:Username>
williamr@2
   180
        *       username
williamr@2
   181
        *   </wsse:Username>
williamr@2
   182
        *   <wsse:Password>
williamr@2
   183
        *       password
williamr@2
   184
        *   </wsse:Password>
williamr@2
   185
        * </wsse:UsernameToken>"
williamr@2
   186
        *
williamr@2
   187
        * If the password type is wsse:Password:Digest, then the password element
williamr@2
   188
        * will be declared as follows:
williamr@2
   189
        *
williamr@2
   190
        *   <wsse:Password Type="wsse:PasswordDigest">
williamr@2
   191
        *
williamr@2
   192
        * The above token assumes, that wsse namespace is declared in 
williamr@2
   193
        * top level of the security header.
williamr@2
   194
        * @return a pointer to buffer containing the username token. Does not
williamr@2
   195
        * return NULL. Ownership is transferred to the caller. Method leaves
williamr@2
   196
        * with value KErrNotSupported, if a password type is not supported.
williamr@2
   197
        */
williamr@2
   198
        IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider,
williamr@2
   199
                                        CSenWsSecurityHeader2::TPasswordType aType);
williamr@2
   200
williamr@2
   201
        // Static methods:
williamr@2
   202
williamr@2
   203
        /**
williamr@2
   204
        * Constructs a username token. This method does not add the <Password>
williamr@2
   205
        * element, since it is optional for basic username tokens.
williamr@2
   206
        * @since Series60 3.0
williamr@2
   207
        * @param  aUsername     User name which is used in the username 
williamr@2
   208
        *                       token.
williamr@2
   209
        * @param  aToken        Ref-to-pointer where the token will be
williamr@2
   210
        *                       allocated. Shouldn't contain any data when
williamr@2
   211
        *                       called, or that data will be lost.
williamr@2
   212
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   213
        */
williamr@2
   214
        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
williamr@2
   215
                                            HBufC8*& aToken);
williamr@2
   216
williamr@2
   217
        /**
williamr@2
   218
        * Constructs a username token using a password, too.
williamr@2
   219
        * @since Series60 5.0
williamr@2
   220
        * @param  aUsername     User name which is to be used in new token.
williamr@2
   221
        * @param  aPassword     Password which is to be use in new token.
williamr@2
   222
        *                       The type will be set to default: wsse:PasswordDigest,
williamr@2
   223
        *                       defined in KSecurityAttrTypeText. This is
williamr@2
   224
        *                       a Base64 [XML-Schema] encoded, SHA-1 hash value, 
williamr@2
   225
        *                       of the UTF8 encoded password.
williamr@2
   226
        * @param  aToken        Ref-to-pointer in which the token will be
williamr@2
   227
        *                       allocated. Shouldn't contain any data when
williamr@2
   228
        *                       called, or that data will be lost.
williamr@2
   229
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   230
        */
williamr@2
   231
        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
williamr@2
   232
                                            const TDesC8& aPassword,
williamr@2
   233
                                            HBufC8*& aToken);
williamr@2
   234
williamr@2
   235
       /**
williamr@2
   236
        * Constructs a username token using a password, too.
williamr@2
   237
        * @since Series60 5.0
williamr@2
   238
        * @param  aUsername     User name which is to be used in new token.
williamr@2
   239
        * @param  aPassword     Password which is to be use in new token
williamr@2
   240
        *                       This is a Base64 [XML-Schema] encoded, SHA-1 
williamr@2
   241
        *                       hash value, of the UTF8 encoded password.
williamr@2
   242
        * @param  aType         Specifies the type of the password:
williamr@2
   243
        *                       - EText, being default refers to wsse:PasswordText,
williamr@2
   244
        *                       but this method does not add this, since it can
williamr@2
   245
        *                       be omitted.
williamr@2
   246
        *                       - EDigest: will add wsse:PasswordDigest attribute
williamr@2
   247
        *                       to the <Password> -element, as in here:
williamr@2
   248
        *
williamr@2
   249
        *                        <wsse:UsernameToken>
williamr@2
   250
        *                           <wsse:Username>
williamr@2
   251
        *                               username
williamr@2
   252
        *                           </wsse:Username>
williamr@2
   253
        *                           <wsse:Password Type="wsse:PasswordDigest">
williamr@2
   254
        *                               password
williamr@2
   255
        *                           </wsse:Password>
williamr@2
   256
        *                         </wsse:UsernameToken>"
williamr@2
   257
        *                        
williamr@2
   258
        * @param  aToken        Ref-to-pointer where the token will be
williamr@2
   259
        *                       allocated. Shouldn't contain any data when
williamr@2
   260
        *                       called, or that data will be lost.
williamr@2
   261
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   262
        */
williamr@2
   263
        IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
williamr@2
   264
                                            const TDesC8& aPassword,
williamr@2
   265
                                            CSenWsSecurityHeader2::TPasswordType aType,
williamr@2
   266
                                            HBufC8*& aToken);
williamr@2
   267
williamr@2
   268
williamr@2
   269
        /**
williamr@2
   270
        * Constructs a timestamp.
williamr@2
   271
        * @since Series60 5.0
williamr@2
   272
        * Format of the timestamp is as follows:
williamr@2
   273
        *   <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
williamr@2
   274
        *       <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
williamr@2
   275
        *       <wsu:Expires>2002-09-13T08:42:00Z</wsu:Expires>
williamr@2
   276
        *   </wsu:Timestamp>
williamr@2
   277
        * The wsu namespace is declared inside this element.
williamr@2
   278
        *   Based on chapter 10 from WS-Security 2004
williamr@2
   279
        * @param aCreated - creation time of token
williamr@2
   280
        * @param aExpires - end of validation time for token
williamr@2
   281
        * @param aTimestamp - a pointer to buffer containing the timestamp. Does not
williamr@2
   282
        *         return NULL. Ownership is transferred to the caller.
williamr@2
   283
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   284
        */
williamr@2
   285
        IMPORT_C static TInt TimestampL(const TDesC8& aCreated, const TDesC8& aExpires, HBufC8*& aTimestamp);
williamr@2
   286
        
williamr@2
   287
        /**
williamr@2
   288
        * Constructs a timestamp.
williamr@2
   289
        * @since Series60 5.0
williamr@2
   290
        * Format of the timestamp is as follows:
williamr@2
   291
        *   <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
williamr@2
   292
        *       <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
williamr@2
   293
        *   </wsu:Timestamp>
williamr@2
   294
        * The wsu namespace is declared inside this element.
williamr@2
   295
        *   Based on chapter 10 from WS-Security 2004
williamr@2
   296
        * @param aCreated - creation time of token
williamr@2
   297
        * @param aTimestamp - a pointer to buffer containing the timestamp. Does not
williamr@2
   298
        *         return NULL. Ownership is transferred to the caller.
williamr@2
   299
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   300
        */
williamr@2
   301
        IMPORT_C static TInt TimestampL(const TDesC8& aCreated, HBufC8*& aTimestamp);
williamr@2
   302
williamr@2
   303
        /**
williamr@2
   304
        * Constructs a security token reference.
williamr@2
   305
        * @since Series60 5.0
williamr@2
   306
        * Format of the token reference is as follows:
williamr@2
   307
        *   <wsse:SecurityTokenReference wsu:Id="...">
williamr@2
   308
        *       <wsse:Reference URI="..."/>
williamr@2
   309
        *   </wsse:SecurityTokenReference>
williamr@2
   310
        *
williamr@2
   311
        * The above token assumes, that wsse namespace is declared in 
williamr@2
   312
        * top level of the security header.
williamr@2
   313
        * @param  
williamr@2
   314
        * @param aSTR - a pointer to buffer containing the token reference. Does not
williamr@2
   315
        *         return NULL. Ownership is transferred to the caller.
williamr@2
   316
        * @return KErrNone or some system-wide Symbian error code.
williamr@2
   317
        */
williamr@2
   318
//        IMPORT_C static TInt SecurityTokenReferenceL(const TDesC8& aURI, HBufC8*& aSTR); 
williamr@2
   319
williamr@2
   320
       
williamr@2
   321
        // Virtual methods: 
williamr@2
   322
williamr@2
   323
        /** Basic getter for XML namespace of the WS security header.
williamr@2
   324
        * Subclasses should override this to use different namespace 
williamr@2
   325
        * @since Series60 3.0
williamr@2
   326
        * @return the WS security header namespace as string
williamr@2
   327
        */
williamr@2
   328
        IMPORT_C virtual TPtrC8 XmlNs();
williamr@2
   329
        
williamr@2
   330
        /**
williamr@2
   331
        * Basic getter for XML namespace prefix of the WS security header.
williamr@2
   332
        * Subclasses should override this to use different namespace prefix
williamr@2
   333
        * @since Series60 3.0
williamr@2
   334
        * @return the WS security header namespace prefix as string
williamr@2
   335
        */
williamr@2
   336
        IMPORT_C virtual TPtrC8 XmlNsPrefix();    
williamr@2
   337
        
williamr@2
   338
    protected:  
williamr@2
   339
        
williamr@2
   340
        /**
williamr@2
   341
        * C++ default constructor
williamr@2
   342
        */
williamr@2
   343
        IMPORT_C CSenWsSecurityHeader2();
williamr@2
   344
        
williamr@2
   345
        /**
williamr@2
   346
        * Basic BaseConstructL function 
williamr@2
   347
        */
williamr@2
   348
        IMPORT_C void BaseConstructL(RSenDocument aDocument,
williamr@2
   349
                                     TXmlEngElement aElement);
williamr@2
   350
        
williamr@2
   351
        // Functions from base classes
williamr@2
   352
        
williamr@2
   353
        /**
williamr@2
   354
        * From CSenBaseFragment Basic BaseConstructL function 
williamr@2
   355
        * @since Series60 3.0
williamr@2
   356
        * @param    aData           Data which will be used as current token
williamr@2
   357
        *                           (content) of this security header
williamr@2
   358
        * @param    aDocument       The document which will be the owner of
williamr@2
   359
        *                           the elements of this header
williamr@2
   360
        * @param    aElement        An element which will be parent for this header.
williamr@2
   361
        */
williamr@2
   362
        IMPORT_C void BaseConstructL(const TDesC8& aData,
williamr@2
   363
                                     RSenDocument aDocument,
williamr@2
   364
                                     TXmlEngElement aElement);
williamr@2
   365
                                     
williamr@2
   366
        /**
williamr@2
   367
        * From CSenBaseFragment Basic BaseConstructL function 
williamr@2
   368
        * @since Series60 3.0
williamr@2
   369
        * @param    aData           Data which will be used as current token
williamr@2
   370
        *                           (content) of this security header
williamr@2
   371
        * @param    aSecurityNs     A namespace to be set to the header.
williamr@2
   372
        * @param    aDocument       The document which will be the owner of
williamr@2
   373
        *                           the elements of this header
williamr@2
   374
        * @param    aElement        An element which will be parent for this header.
williamr@2
   375
        */
williamr@2
   376
        IMPORT_C void BaseConstructL(const TDesC8& aData,
williamr@2
   377
                                     const TDesC8& aSecurityNs,
williamr@2
   378
                                     RSenDocument aDocument,
williamr@2
   379
                                     TXmlEngElement aElement);
williamr@2
   380
    };
williamr@2
   381
williamr@2
   382
#endif // SEN_WS_SECURITY_HEADER2_H
williamr@2
   383
williamr@2
   384
// End of File