williamr@2: /* williamr@2: * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: CSenWsSecurityHeader represents security header functionality williamr@2: * according to oasis wss spesifications (2004/01) williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef SEN_WS_SECURITY_HEADER_H williamr@2: #define SEN_WS_SECURITY_HEADER_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CSenIdentityProvider; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * CSenWsSecurityHeader represents security header functionality according to williamr@2: * oasis web services security (WSS) specifications (2004/01) or older (2003/06) williamr@2: * @lib SenUtils.lib williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: class CSenWsSecurityHeader : public CSenBaseFragment williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * PasswordType Enumeration williamr@2: */ williamr@2: enum TPasswordType williamr@2: { williamr@2: EText = 1, // default, wsse:PasswordText williamr@2: EDigest // wsse:Digest williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @return a pointer to new CSenWsSecurityHeader class instance. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewL(); williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @return a new CSenWsSecurityHeader class instance, which pointer williamr@2: * is left on cleanup stack. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewLC(); williamr@2: williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @param aData Data to be set as header's content. williamr@2: * @return a pointer to new CSenWsSecurityHeader class instance. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData); williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @param aData Data to be set as header's content. williamr@2: * @return a new CSenWsSecurityHeader class instance, which pointer williamr@2: * is left on cleanup stack. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData); williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @param aData Data to be set as header's content. williamr@2: * @param aSecurityNs A namespace to be set to the header. williamr@2: * @return a pointer to new CSenWsSecurityHeader class instance. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData, const TDesC8& aSecurityNs); williamr@2: williamr@2: /** williamr@2: * Basic constructor. williamr@2: * @param aData Data to be set as header's content. williamr@2: * @param aSecurityNs A namespace to be set to the header. williamr@2: * @return a new CSenWsSecurityHeader class instance, which pointer williamr@2: * is left on cleanup stack. williamr@2: */ williamr@2: IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData, const TDesC8& aSecurityNs); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C virtual ~CSenWsSecurityHeader(); williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * Constructs a username token. williamr@2: * @since Series60 3.0 williamr@2: * @param aIdentityProvider Identity provider which is used to get williamr@2: * the authorization ID used in username token. Method takes the williamr@2: * AuthzID out from aIdentityProvider, and uses it as username for williamr@2: * this token. williamr@2: * Format of the token is as follows: williamr@2: * williamr@2: * williamr@2: * williamr@2: * username williamr@2: * williamr@2: * " williamr@2: * williamr@2: * The above token assumes, that wsse namespace is declared in williamr@2: * top level of the security header. williamr@2: * @return a pointer to buffer containing the username token. Does not williamr@2: * return NULL. Ownership is transferred to the caller. Method leaves williamr@2: * with value KErrNotSupported, if a password type is not supported. williamr@2: */ williamr@2: IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider); williamr@2: williamr@2: /** williamr@2: * Constructs a username token. williamr@2: * @since Series60 3.0 williamr@2: * @param aIdentityProvider Identity provider which is used to get williamr@2: * the authorization ID used in username token. Method takes the williamr@2: * AuthzID out from aIdentityProvider, and uses it as username for williamr@2: * this token. Password is also fetched from aIdentityProvider via williamr@2: * calling Password() getter, which must return a Base64 [XML-Schema] williamr@2: * encoded, SHA-1 hash value, of the UTF8 encoded password. williamr@2: * @param aType Specifies the type of the password, either williamr@2: * wsse:PasswordText or wsse:PasswordDigest williamr@2: * williamr@2: * Format of the token is as follows (if password type is wsse:PasswordText): williamr@2: * williamr@2: * williamr@2: * williamr@2: * username williamr@2: * williamr@2: * williamr@2: * password williamr@2: * williamr@2: * " williamr@2: * williamr@2: * If the password type is wsse:Password:Digest, then the password element williamr@2: * will be declared as follows: williamr@2: * williamr@2: * williamr@2: * williamr@2: * The above token assumes, that wsse namespace is declared in williamr@2: * top level of the security header. williamr@2: * @return a pointer to buffer containing the username token. Does not williamr@2: * return NULL. Ownership is transferred to the caller. Method leaves williamr@2: * with value KErrNotSupported, if a password type is not supported. williamr@2: */ williamr@2: IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider, williamr@2: CSenWsSecurityHeader::TPasswordType aType); williamr@2: williamr@2: // Static methods: williamr@2: williamr@2: /** williamr@2: * Constructs a username token. This method does not add the williamr@2: * element, since it is optional for basic username tokens. williamr@2: * @since Series60 3.0 williamr@2: * @param aUsername User name which is used in the username williamr@2: * token. williamr@2: * @param aToken Ref-to-pointer where the token will be williamr@2: * allocated. Shouldn't contain any data when williamr@2: * called, or that data will be lost. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername, williamr@2: HBufC8*& aToken); williamr@2: williamr@2: /** williamr@2: * Constructs a username token using a password, too. williamr@2: * @since Series60 5.0 williamr@2: * @param aUsername User name which is to be used in new token. williamr@2: * @param aPassword Password which is to be use in new token. williamr@2: * The type will be set to default: wsse:PasswordDigest, williamr@2: * defined in KSecurityAttrTypeText. This is williamr@2: * a Base64 [XML-Schema] encoded, SHA-1 hash value, williamr@2: * of the UTF8 encoded password. williamr@2: * @param aToken Ref-to-pointer in which the token will be williamr@2: * allocated. Shouldn't contain any data when williamr@2: * called, or that data will be lost. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername, williamr@2: const TDesC8& aPassword, williamr@2: HBufC8*& aToken); williamr@2: williamr@2: /** williamr@2: * Constructs a username token using a password, too. williamr@2: * @since Series60 5.0 williamr@2: * @param aUsername User name which is to be used in new token. williamr@2: * @param aPassword Password which is to be use in new token williamr@2: * This is a Base64 [XML-Schema] encoded, SHA-1 williamr@2: * hash value, of the UTF8 encoded password. williamr@2: * @param aType Specifies the type of the password: williamr@2: * - EText, being default refers to wsse:PasswordText, williamr@2: * but this method does not add this, since it can williamr@2: * be omitted. williamr@2: * - EDigest: will add wsse:PasswordDigest attribute williamr@2: * to the -element, as in here: williamr@2: * williamr@2: * williamr@2: * williamr@2: * username williamr@2: * williamr@2: * williamr@2: * password williamr@2: * williamr@2: * " williamr@2: * williamr@2: * @param aToken Ref-to-pointer where the token will be williamr@2: * allocated. Shouldn't contain any data when williamr@2: * called, or that data will be lost. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername, williamr@2: const TDesC8& aPassword, williamr@2: CSenWsSecurityHeader::TPasswordType aType, williamr@2: HBufC8*& aToken); williamr@2: williamr@2: williamr@2: /** williamr@2: * Constructs a BinarySecurityToken. williamr@2: * @since Series60 5.0 williamr@2: * williamr@2: * @param aContent Encoded EncryptedData which is to be used in token. williamr@2: * @param aToken Ref-to-pointer where the token will be williamr@2: * allocated. Shouldn't contain any data when williamr@2: * called, or that data will be lost. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent, williamr@2: HBufC8*& aToken); williamr@2: /** williamr@2: * Constructs a BinarySecurityToken. williamr@2: * @since Series60 5.0 williamr@2: * williamr@2: * @param aContent Encoded EncryptedData which is to be used in token. williamr@2: * @param aValueType Indicates what the security token is williamr@2: * @param aToken Ref-to-pointer where the token will be williamr@2: * allocated. Shouldn't contain any data when williamr@2: * called, or that data will be lost. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent, williamr@2: const TDesC8& aValueType, williamr@2: HBufC8*& aToken); williamr@2: williamr@2: /** williamr@2: * Constructs a timestamp. williamr@2: * @since Series60 5.0 williamr@2: * Format of the timestamp is as follows: williamr@2: * williamr@2: * 2001-09-13T08:42:00Z williamr@2: * 2002-09-13T08:42:00Z williamr@2: * williamr@2: * The wsu namespace is declared inside this element. williamr@2: * Based on chapter 10 from WS-Security 2004 williamr@2: * @param aCreated - creation time of token williamr@2: * @param aExpires - end of validation time for token williamr@2: * @param aTimestamp - a pointer to buffer containing the timestamp. Does not williamr@2: * return NULL. Ownership is transferred to the caller. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt TimestampL(const TDesC8& aCreated, const TDesC8& aExpires, HBufC8*& aTimestamp); williamr@2: williamr@2: /** williamr@2: * Constructs a timestamp. williamr@2: * @since Series60 5.0 williamr@2: * Format of the timestamp is as follows: williamr@2: * williamr@2: * 2001-09-13T08:42:00Z williamr@2: * williamr@2: * The wsu namespace is declared inside this element. williamr@2: * Based on chapter 10 from WS-Security 2004 williamr@2: * @param aCreated - creation time of token williamr@2: * @param aTimestamp - a pointer to buffer containing the timestamp. Does not williamr@2: * return NULL. Ownership is transferred to the caller. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: IMPORT_C static TInt TimestampL(const TDesC8& aCreated, HBufC8*& aTimestamp); williamr@2: williamr@2: /** williamr@2: * Constructs a security token reference. williamr@2: * @since Series60 5.0 williamr@2: * Format of the token reference is as follows: williamr@2: * williamr@2: * williamr@2: * williamr@2: * williamr@2: * The above token assumes, that wsse namespace is declared in williamr@2: * top level of the security header. williamr@2: * @param williamr@2: * @param aSTR - a pointer to buffer containing the token reference. Does not williamr@2: * return NULL. Ownership is transferred to the caller. williamr@2: * @return KErrNone or some system-wide Symbian error code. williamr@2: */ williamr@2: // IMPORT_C static TInt SecurityTokenReferenceL(const TDesC8& aURI, HBufC8*& aSTR); williamr@2: williamr@2: williamr@2: // Virtual methods: williamr@2: williamr@2: /** Basic getter for XML namespace of the WS security header. williamr@2: * Subclasses should override this to use different namespace williamr@2: * @since Series60 3.0 williamr@2: * @return the WS security header namespace as string williamr@2: */ williamr@2: IMPORT_C virtual TPtrC8 XmlNs(); williamr@2: williamr@2: /** williamr@2: * Basic getter for XML namespace prefix of the WS security header. williamr@2: * Subclasses should override this to use different namespace prefix williamr@2: * @since Series60 3.0 williamr@2: * @return the WS security header namespace prefix as string williamr@2: */ williamr@2: IMPORT_C virtual TPtrC8 XmlNsPrefix(); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * C++ default constructor williamr@2: */ williamr@2: IMPORT_C CSenWsSecurityHeader(); williamr@2: williamr@2: /** williamr@2: * Basic BaseConstructL function williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(); williamr@2: williamr@2: // Functions from base classes williamr@2: williamr@2: /** williamr@2: * From CSenBaseFragment Basic BaseConstructL function williamr@2: * @since Series60 3.0 williamr@2: * @param aData will be used as current token (content) of this security williamr@2: * header williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aData); williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aData, const TDesC8& aSecurityNs); williamr@2: }; williamr@2: williamr@2: #endif // SEN_WS_SECURITY_HEADER_H williamr@2: williamr@2: // End of File