├── .gitignore
├── LICENSE.md
├── README.md
├── certs
├── ca.crt
├── client
│ ├── client.crt
│ ├── client.key
│ └── client.p12
└── server
│ ├── server.crt
│ └── server.key
├── digest-auth-session-lib
├── DigestManager.cpp
├── DigestManager.h
├── Digestinfo.cpp
├── Digestinfo.h
├── IDigestListener.h
├── Makefile
├── digest-auth-session.pro
├── digeststruct.h
├── libs
│ ├── httpserverimpl
│ │ ├── clientSocket.h
│ │ └── httpserver.h
│ ├── httpserverinter
│ │ ├── IClientEventListener.h
│ │ └── IHttpClient.h
│ ├── libhttpServer.a
│ ├── libhttpdecoder.a
│ ├── protocol
│ │ ├── http
│ │ │ ├── httpconstants.h
│ │ │ ├── httpdecoder.h
│ │ │ ├── httpdecoder_global.h
│ │ │ ├── httpparser.h
│ │ │ └── httpstates.h
│ │ └── inter
│ │ │ └── http
│ │ │ ├── IhttpFrame.h
│ │ │ ├── httpconsumer.h
│ │ │ └── httpframe.h
│ └── utils
│ │ └── stringutils.h
├── release
│ ├── DigestManager.h
│ ├── Digestinfo.h
│ ├── IDigestListener.h
│ ├── digeststruct.h
│ ├── libdigestauthsession.a
│ ├── libs
│ │ ├── httpserverimpl
│ │ │ ├── clientSocket.h
│ │ │ └── httpserver.h
│ │ ├── httpserverinter
│ │ │ ├── IClientEventListener.h
│ │ │ └── IHttpClient.h
│ │ ├── protocol
│ │ │ ├── http
│ │ │ │ ├── httpconstants.h
│ │ │ │ ├── httpdecoder.h
│ │ │ │ ├── httpdecoder_global.h
│ │ │ │ ├── httpparser.h
│ │ │ │ └── httpstates.h
│ │ │ └── inter
│ │ │ │ └── http
│ │ │ │ ├── IhttpFrame.h
│ │ │ │ ├── httpconsumer.h
│ │ │ │ └── httpframe.h
│ │ └── utils
│ │ │ └── stringutils.h
│ └── utils
│ │ └── stringutil.h
└── utils
│ ├── stringutil.cpp
│ └── stringutil.h
├── digest-auth-session-test
├── ClientSocketHandler.cpp
├── ClientSocketHandler.h
├── HashDigestListener.cpp
├── HashDigestListener.h
├── Makefile
├── SslHandler.cpp
├── SslHandler.h
├── digest-auth-session-test.pro
├── main.cpp
├── release
│ ├── ClientSocketHandler.h
│ ├── HashDigestListener.h
│ ├── SslHandler.h
│ ├── digest-auth-session-test
│ └── utils
│ │ ├── fileutils.h
│ │ └── stringutil.h
└── utils
│ ├── fileutils.cpp
│ ├── fileutils.h
│ ├── stringutil.cpp
│ └── stringutil.h
├── memcheck.suppress
├── test.png
└── test_authentication_session.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | *.user
2 | *.o
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Bertrand Martel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/certs/ca.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIEpzCCA4+gAwIBAgIJAKpq46muqS1dMA0GCSqGSIb3DQEBBQUAMIGTMQswCQYD
3 | VQQGEwJGUjEOMAwGA1UECBMFUGFyaXMxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQK
4 | Ewdha2luYXJ1MRAwDgYDVQQLEwdha2luYXJ1MRgwFgYDVQQDEw9XZWJzb2NrZXRT
5 | ZXJ2ZXIxJjAkBgkqhkiG9w0BCQEWF2tpcnVhem9sZGlrOTJAZ21haWwuY29tMB4X
6 | DTE1MDUxNjAyNDk0MVoXDTI1MDUxMzAyNDk0MVowgZMxCzAJBgNVBAYTAkZSMQ4w
7 | DAYDVQQIEwVQYXJpczEOMAwGA1UEBxMFUGFyaXMxEDAOBgNVBAoTB2FraW5hcnUx
8 | EDAOBgNVBAsTB2FraW5hcnUxGDAWBgNVBAMTD1dlYnNvY2tldFNlcnZlcjEmMCQG
9 | CSqGSIb3DQEJARYXa2lydWF6b2xkaWs5MkBnbWFpbC5jb20wggEiMA0GCSqGSIb3
10 | DQEBAQUAA4IBDwAwggEKAoIBAQDE5fwn6uxk0Ge06EIHQGDGdHHTgUxo8nzAOREb
11 | vUTc/L55qeeJeI/CTc9c3ynxGsLNlr/5C7rfu15lBYQNprqTFDBjVKWuXB6OTvrb
12 | +IYzcInfOQ2Q94fYMK2GVKW+BJICKxZpG9sQvQR6IenEBmWLb5f1ZyTJa3A1/UKP
13 | TWoNkybVstZHNxyNFKNz9WAUPlNJjOqNKjpaaohkVF+ELKAoi05/kSQZNKrzRRjW
14 | mq4tsmrRLnQLDPVm5xU0pIA49IDEEs5dnE0rIpcgfISYKiMBXMTRb24wRC/FCjcy
15 | PL8u4j2IFOJqyaQeBJOz2OyZ+Ke7t0uyu1c5vQYSt+ml2AajAgMBAAGjgfswgfgw
16 | HQYDVR0OBBYEFAFLgPdQ2d4VA1B4l7xkS39kKiKwMIHIBgNVHSMEgcAwgb2AFAFL
17 | gPdQ2d4VA1B4l7xkS39kKiKwoYGZpIGWMIGTMQswCQYDVQQGEwJGUjEOMAwGA1UE
18 | CBMFUGFyaXMxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdha2luYXJ1MRAwDgYD
19 | VQQLEwdha2luYXJ1MRgwFgYDVQQDEw9XZWJzb2NrZXRTZXJ2ZXIxJjAkBgkqhkiG
20 | 9w0BCQEWF2tpcnVhem9sZGlrOTJAZ21haWwuY29tggkAqmrjqa6pLV0wDAYDVR0T
21 | BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAGu959FFkWld0JOUIY/OilSOhDEIU
22 | 0fF49npXE2uPKFe4Le43UZgyoqnt/hlMiBT5OnSiN5musVgwcgt8Bf1bBHrhlRB5
23 | E0VF7/4M+4vSM1FNRTQMQlJ+2ZUjy89dqcBfQJkeJD++ntcG/ozoqsXFpV0jHyp+
24 | Vo1THfl/+xOApVuBecBbQHDRN8loeCoCViNU80FU9Kzdplrv0fYkSuht7C9QdEv+
25 | x/QQ7pdp4w11JFxeZo5A0AgFuZ5qBmrSsUxEmv/2lKFjqZoxG4Sq0sOjZZd9U7jf
26 | 9y4gyh1PKDbmn8nuHuTrpzjSRURqhpr2iQHqtyU8ZtjwrrHrZuahcSK0Pg==
27 | -----END CERTIFICATE-----
28 |
--------------------------------------------------------------------------------
/certs/client/client.crt:
--------------------------------------------------------------------------------
1 | Certificate:
2 | Data:
3 | Version: 3 (0x2)
4 | Serial Number: 2 (0x2)
5 | Signature Algorithm: md5WithRSAEncryption
6 | Issuer: C=FR, ST=Paris, L=Paris, O=akinaru, OU=akinaru, CN=WebsocketServer/emailAddress=bmartel.fr@gmail.com
7 | Validity
8 | Not Before: May 16 02:51:42 2015 GMT
9 | Not After : May 13 02:51:42 2025 GMT
10 | Subject: C=FR, ST=Paris, O=akinaru, OU=akinaru, CN=websocket-client1/emailAddress=bmartel.fr@gmail.com
11 | Subject Public Key Info:
12 | Public Key Algorithm: rsaEncryption
13 | Public-Key: (2048 bit)
14 | Modulus:
15 | 00:d4:5e:b7:ad:ee:88:eb:43:b1:cd:0b:92:8a:48:
16 | ab:ed:7f:2f:be:d1:bb:ee:79:a7:0d:1e:14:1b:40:
17 | d1:c5:51:c0:8a:8d:0e:b8:0c:5b:19:15:2f:e3:ee:
18 | 24:a5:8f:aa:04:a2:3b:8b:8d:3f:2f:0d:1b:95:fc:
19 | f5:1f:7f:26:55:4c:b0:d6:74:d4:7b:9f:8e:a1:ab:
20 | 52:6b:59:55:33:e7:15:c6:af:8b:1a:dd:54:fc:37:
21 | 0a:87:ad:6f:5f:71:36:9c:1d:ab:c0:b9:6f:5e:b4:
22 | d9:35:69:ee:44:dd:83:be:50:8d:88:fa:2c:93:d6:
23 | a4:00:7f:16:8d:d1:39:da:48:77:0e:cb:b4:1d:2e:
24 | 88:a5:5e:e7:5d:c7:88:dd:06:f6:00:8e:fb:ad:e4:
25 | 62:e9:0e:68:99:57:03:eb:4a:20:1c:c4:a6:ce:ef:
26 | 56:da:e3:fb:a4:c3:f0:04:9c:68:b8:b7:07:98:a4:
27 | 29:ec:68:ff:46:d6:6f:14:ca:d9:53:9e:66:ba:d5:
28 | ed:da:e4:00:6c:9c:f4:59:9b:b7:e1:40:40:09:df:
29 | e3:7a:54:ff:56:72:72:55:10:2c:a1:00:62:3a:7e:
30 | c0:9c:d0:b3:4b:8a:44:b7:53:2f:d1:9b:3b:8d:94:
31 | 33:c6:8d:38:1c:bf:1c:be:62:fb:54:24:cf:95:f2:
32 | 31:9b
33 | Exponent: 65537 (0x10001)
34 | X509v3 extensions:
35 | X509v3 Basic Constraints:
36 | CA:FALSE
37 | Netscape Comment:
38 | OpenSSL Generated Certificate
39 | X509v3 Subject Key Identifier:
40 | 9F:00:4A:EB:F5:E2:3E:42:C4:FC:1B:2B:D1:A4:E3:AC:65:E0:56:09
41 | X509v3 Authority Key Identifier:
42 | keyid:01:4B:80:F7:50:D9:DE:15:03:50:78:97:BC:64:4B:7F:64:2A:22:B0
43 | DirName:/C=FR/ST=Paris/L=Paris/O=akinaru/OU=akinaru/CN=WebsocketServer/emailAddress=bmartel.fr@gmail.com
44 | serial:AA:6A:E3:A9:AE:A9:2D:5D
45 |
46 | Signature Algorithm: md5WithRSAEncryption
47 | 19:9b:92:a9:d9:b7:67:6c:45:c5:06:de:a4:37:1e:23:fe:52:
48 | 63:fc:61:79:81:1f:f6:20:93:62:8b:6b:90:f9:eb:76:a1:d5:
49 | dd:2a:f1:f7:ca:71:fd:32:50:d0:53:1b:b3:07:43:db:12:3b:
50 | a1:bd:28:44:4b:fb:8a:c9:8f:ac:17:df:67:10:32:ad:c0:f2:
51 | e7:1c:b8:f6:9c:c2:b5:2f:ea:b3:e6:3c:ff:6c:fd:a9:07:b8:
52 | cf:f0:f9:61:0a:40:2c:36:c2:2e:62:b9:8c:c0:52:89:05:2b:
53 | ff:7b:39:e9:65:b3:fd:5b:3a:8e:a1:54:9d:39:3e:10:c7:24:
54 | ff:df:f7:4a:39:41:5d:0e:5d:96:4f:0d:2f:fd:8d:51:65:dd:
55 | a4:4c:d5:f4:64:f9:aa:9c:20:47:0a:1e:44:e3:4e:a5:44:eb:
56 | f3:ab:9f:83:7e:c9:8c:81:58:8e:48:4d:d6:5c:f9:5a:ff:bb:
57 | 11:4c:4a:9f:7f:4d:fb:cd:f0:4a:44:6f:89:56:1a:86:ad:c7:
58 | 8d:0d:d9:bb:36:37:d5:a2:ca:6c:1e:a4:36:a8:c0:dd:df:82:
59 | b2:7c:8b:7b:c9:a0:06:5d:b7:34:61:67:1c:a2:ec:d5:c6:f3:
60 | 73:9b:ba:f5:e5:7b:e1:57:cf:12:1c:d6:91:82:30:2f:52:6f:
61 | d1:8b:17:8c
62 | -----BEGIN CERTIFICATE-----
63 | MIIEvjCCA6agAwIBAgIBAjANBgkqhkiG9w0BAQQFADCBkzELMAkGA1UEBhMCRlIx
64 | DjAMBgNVBAgTBVBhcmlzMQ4wDAYDVQQHEwVQYXJpczEQMA4GA1UEChMHYWtpbmFy
65 | dTEQMA4GA1UECxMHYWtpbmFydTEYMBYGA1UEAxMPV2Vic29ja2V0U2VydmVyMSYw
66 | JAYJKoZIhvcNAQkBFhdraXJ1YXpvbGRpazkyQGdtYWlsLmNvbTAeFw0xNTA1MTYw
67 | MjUxNDJaFw0yNTA1MTMwMjUxNDJaMIGFMQswCQYDVQQGEwJGUjEOMAwGA1UECBMF
68 | UGFyaXMxEDAOBgNVBAoTB2FraW5hcnUxEDAOBgNVBAsTB2FraW5hcnUxGjAYBgNV
69 | BAMTEXdlYnNvY2tldC1jbGllbnQxMSYwJAYJKoZIhvcNAQkBFhdraXJ1YXpvbGRp
70 | azkyQGdtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANRe
71 | t63uiOtDsc0LkopIq+1/L77Ru+55pw0eFBtA0cVRwIqNDrgMWxkVL+PuJKWPqgSi
72 | O4uNPy8NG5X89R9/JlVMsNZ01HufjqGrUmtZVTPnFcavixrdVPw3Coetb19xNpwd
73 | q8C5b1602TVp7kTdg75QjYj6LJPWpAB/Fo3ROdpIdw7LtB0uiKVe513HiN0G9gCO
74 | +63kYukOaJlXA+tKIBzEps7vVtrj+6TD8AScaLi3B5ikKexo/0bWbxTK2VOeZrrV
75 | 7drkAGyc9Fmbt+FAQAnf43pU/1ZyclUQLKEAYjp+wJzQs0uKRLdTL9GbO42UM8aN
76 | OBy/HL5i+1Qkz5XyMZsCAwEAAaOCAScwggEjMAkGA1UdEwQCMAAwLAYJYIZIAYb4
77 | QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBSf
78 | AErr9eI+QsT8GyvRpOOsZeBWCTCByAYDVR0jBIHAMIG9gBQBS4D3UNneFQNQeJe8
79 | ZEt/ZCoisKGBmaSBljCBkzELMAkGA1UEBhMCRlIxDjAMBgNVBAgTBVBhcmlzMQ4w
80 | DAYDVQQHEwVQYXJpczEQMA4GA1UEChMHYWtpbmFydTEQMA4GA1UECxMHYWtpbmFy
81 | dTEYMBYGA1UEAxMPV2Vic29ja2V0U2VydmVyMSYwJAYJKoZIhvcNAQkBFhdraXJ1
82 | YXpvbGRpazkyQGdtYWlsLmNvbYIJAKpq46muqS1dMA0GCSqGSIb3DQEBBAUAA4IB
83 | AQAZm5Kp2bdnbEXFBt6kNx4j/lJj/GF5gR/2IJNii2uQ+et2odXdKvH3ynH9MlDQ
84 | UxuzB0PbEjuhvShES/uKyY+sF99nEDKtwPLnHLj2nMK1L+qz5jz/bP2pB7jP8Plh
85 | CkAsNsIuYrmMwFKJBSv/eznpZbP9WzqOoVSdOT4QxyT/3/dKOUFdDl2WTw0v/Y1R
86 | Zd2kTNX0ZPmqnCBHCh5E406lROvzq5+DfsmMgViOSE3WXPla/7sRTEqff037zfBK
87 | RG+JVhqGrceNDdm7NjfVospsHqQ2qMDd34KyfIt7yaAGXbc0YWccouzVxvNzm7r1
88 | 5XvhV88SHNaRgjAvUm/RixeM
89 | -----END CERTIFICATE-----
90 |
--------------------------------------------------------------------------------
/certs/client/client.key:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDUXret7ojrQ7HN
3 | C5KKSKvtfy++0bvueacNHhQbQNHFUcCKjQ64DFsZFS/j7iSlj6oEojuLjT8vDRuV
4 | /PUffyZVTLDWdNR7n46hq1JrWVUz5xXGr4sa3VT8NwqHrW9fcTacHavAuW9etNk1
5 | ae5E3YO+UI2I+iyT1qQAfxaN0TnaSHcOy7QdLoilXuddx4jdBvYAjvut5GLpDmiZ
6 | VwPrSiAcxKbO71ba4/ukw/AEnGi4tweYpCnsaP9G1m8UytlTnma61e3a5ABsnPRZ
7 | m7fhQEAJ3+N6VP9WcnJVECyhAGI6fsCc0LNLikS3Uy/RmzuNlDPGjTgcvxy+YvtU
8 | JM+V8jGbAgMBAAECggEASprnrguhP/ztBlptZXT4KRvIOyHVAobsH5iUeaqAxu/c
9 | UxAQvqlgi2Q9CbaMWzkoAi63+mNpce8J5NwThLgXUFn7uasbRj6cTcEw2BNu8ifZ
10 | J45dsNdWVrBDW7ya5o2QILHvt2mtbTjdIX2QPdMPyBjmT9uLM3hw7te2paV9zGeK
11 | teCft/ZlUTDNvwYlt7XIczK1GxFcxbwCgfbZyXyIo2V+H4if9jba0RQ06MIaGBmm
12 | m2s8GWSNhlMdpr40TnxT9r4pW0fKBqXHF0yLG8KTSBBDCqgHNmNiCQ7KoZVidzM+
13 | K1vNdEHJ19XzWkmEHyJAI9+znoWCLbfTrgaw6Qu22QKBgQDxqIX2WSg9CpPl+Ih7
14 | 1XR9W+fFRXpdy0+AoT6dUUKrkYydL7ScHxa355YEkX4DiiOjYFaPrfyMEtkIz6I8
15 | vI5RoWleRDNiH8ai14/R0hkNQBqsJ/dnusa0IH+VKKrSHdKLpB2/7vHXWxh0DSdJ
16 | QAljDEeo8WHn5io3P+9/W1LePQKBgQDg+Ti5nJgfPkG3SYQSRLNZa5v9YSAzXD/0
17 | R0tRo1UZnF/iKMRb2rF8+2FsrcMKY/Zg/ptU9qnXNil/vCXl5F5NQx6/L31r75fA
18 | vql0cEuDfCx64jRL6g4wTo11oTscCsYZhbbpQ8Nm+IkzTCHb8iModSfjLziYBsGK
19 | SyIwWlPktwKBgQDHB10Nv/B8FbIpvb/q/aqrdH424zoc9c3MywCe4MZgN8fvzdKa
20 | oqA7ZukPaiS3FZa0gCvKuik91Ggb8aZVD5bHdIEruk/3iOQ4SgGRddBcMWfGUkRZ
21 | kmMFB58MYioOU7GMgOZfpZRZIhXJvuuUUMFqajq60dMpA0/RoT7HTZe6oQKBgCeb
22 | eOMksJt/iG5OYRQeSD0L9vCK8vJX4WKOUrJSwR67Kx5T8w4A2JKaZzKM/PONWckF
23 | yi8RJiGfhXrZkwqARCHyGS2rnLct/VePuaGoS4Mgj2wq+u4KjOjwS3NUKWXsd6fy
24 | pJs4tOQiCXWgh62DWbE7vwP+QkZxmg1Q4PoGTRLNAoGBAK7YLGe181K/pUobaL4j
25 | keKr1T8/Fhwcr3MeKLQiLX9VJNGPeaxg5RyLAXii2GY3JpIt4CMC8MfXzYup18ux
26 | GjGfFZgkUjThKiVRkvcEaiU/uAf93gSxQJQfWBwICGTCHsBK4WmMo66T8AnqDFaR
27 | Ycp0ifzenixobqox1EgylTSO
28 | -----END PRIVATE KEY-----
29 |
--------------------------------------------------------------------------------
/certs/client/client.p12:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bertrandmartel/digest-auth-session-cpp/HEAD/certs/client/client.p12
--------------------------------------------------------------------------------
/certs/server/server.crt:
--------------------------------------------------------------------------------
1 | Certificate:
2 | Data:
3 | Version: 3 (0x2)
4 | Serial Number: 1 (0x1)
5 | Signature Algorithm: md5WithRSAEncryption
6 | Issuer: C=FR, ST=Paris, L=Paris, O=akinaru, OU=akinaru, CN=WebsocketServer/emailAddress=bmartel.fr@gmail.com
7 | Validity
8 | Not Before: May 16 02:50:46 2015 GMT
9 | Not After : May 13 02:50:46 2025 GMT
10 | Subject: C=FR, ST=Paris, O=akinaru, OU=akinaru, CN=websocket-main-server/emailAddress=bmartel.fr@gmail.com
11 | Subject Public Key Info:
12 | Public Key Algorithm: rsaEncryption
13 | Public-Key: (2048 bit)
14 | Modulus:
15 | 00:cd:c5:7b:d4:38:97:73:78:24:7b:b0:31:de:09:
16 | f7:69:a6:67:47:76:d5:a3:6e:af:02:ed:d7:78:a8:
17 | 81:78:43:6e:36:d1:38:76:1b:d3:9f:ae:5f:6d:a2:
18 | d1:76:a4:13:7d:88:22:57:21:b8:f2:1c:a2:13:7c:
19 | b9:8f:d4:5a:13:a5:f3:9b:e0:a7:31:cd:2f:bb:e4:
20 | 97:f5:a5:c6:32:ec:53:26:68:03:a7:c8:90:42:3c:
21 | 38:47:5f:cd:73:95:5c:10:f5:8b:b7:30:b2:eb:64:
22 | 25:5e:42:0f:e5:19:31:f1:73:2a:77:a8:47:40:75:
23 | 3b:c9:db:20:f9:0e:37:5f:6d:af:2d:7c:94:dc:4a:
24 | 99:98:a0:8c:bd:42:8d:5d:cf:e5:78:3b:9e:79:c4:
25 | 1a:24:b8:66:7d:b5:21:62:38:ed:db:0e:48:dc:a4:
26 | 63:5c:97:38:3f:1b:55:e4:52:85:d0:ce:6c:a4:75:
27 | ad:12:21:29:8c:8b:80:98:ae:78:ae:cc:30:bd:cc:
28 | 76:a7:03:49:b0:ad:b0:f4:d1:83:a2:17:4c:40:19:
29 | 1e:11:70:d0:44:36:12:2b:b7:bf:36:72:12:31:42:
30 | 63:eb:fc:c4:2d:3c:f7:61:c5:ec:9d:f2:4b:74:9d:
31 | 71:e0:05:99:ec:e5:0c:6c:91:78:9a:05:88:2e:f8:
32 | dc:31
33 | Exponent: 65537 (0x10001)
34 | X509v3 extensions:
35 | X509v3 Basic Constraints:
36 | CA:FALSE
37 | Netscape Cert Type:
38 | SSL Server
39 | Netscape Comment:
40 | OpenSSL Generated Server Certificate
41 | X509v3 Subject Key Identifier:
42 | 65:85:D3:97:31:24:14:E0:0B:55:9C:61:D6:92:F4:AE:7E:41:03:C1
43 | X509v3 Authority Key Identifier:
44 | keyid:01:4B:80:F7:50:D9:DE:15:03:50:78:97:BC:64:4B:7F:64:2A:22:B0
45 | DirName:/C=FR/ST=Paris/L=Paris/O=akinaru/OU=akinaru/CN=WebsocketServer/emailAddress=bmartel.fr@gmail.com
46 | serial:AA:6A:E3:A9:AE:A9:2D:5D
47 |
48 | Signature Algorithm: md5WithRSAEncryption
49 | 2e:a5:d5:35:b9:1a:83:3b:8b:55:03:3d:f4:40:06:e6:34:8f:
50 | 73:96:02:3a:0c:40:05:f0:1d:3b:66:2c:2c:1d:ad:54:9f:01:
51 | da:ae:17:d1:52:c8:41:f1:61:fb:d3:fa:8d:ac:94:52:75:6e:
52 | 3a:77:54:3c:b2:f3:fe:cc:19:e9:2b:b3:b1:fc:29:10:90:36:
53 | 9c:64:75:09:70:f5:41:b2:e6:c3:42:02:6d:f1:6f:66:ca:41:
54 | fd:11:58:dd:58:ac:a2:87:0d:e5:8c:67:b4:62:97:40:6b:f8:
55 | fb:6e:be:bd:7b:1d:bd:ec:91:d9:65:38:ed:1c:04:ef:ef:41:
56 | 11:9c:90:5c:86:5a:b0:e7:c1:58:03:aa:6b:fb:c4:c5:3f:85:
57 | ca:c3:18:39:8f:86:90:da:bd:8b:19:7f:31:32:88:bf:3a:b5:
58 | 29:ab:ab:c7:8a:ef:b5:27:de:bf:f1:29:44:01:91:c3:ac:d8:
59 | 57:1a:d2:6e:30:98:db:59:33:f5:cf:31:20:e0:b3:75:9c:0c:
60 | 1e:18:16:46:d7:16:d1:ad:c9:a0:25:e8:07:b7:78:b9:1a:43:
61 | 66:f3:37:f1:26:a4:56:6d:a7:e1:24:bd:51:af:d5:d0:65:07:
62 | 36:58:8e:57:4d:ef:20:d3:02:62:76:4d:d6:64:5f:94:a6:9d:
63 | 34:0b:37:47
64 | -----BEGIN CERTIFICATE-----
65 | MIIE3DCCA8SgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBkzELMAkGA1UEBhMCRlIx
66 | DjAMBgNVBAgTBVBhcmlzMQ4wDAYDVQQHEwVQYXJpczEQMA4GA1UEChMHYWtpbmFy
67 | dTEQMA4GA1UECxMHYWtpbmFydTEYMBYGA1UEAxMPV2Vic29ja2V0U2VydmVyMSYw
68 | JAYJKoZIhvcNAQkBFhdraXJ1YXpvbGRpazkyQGdtYWlsLmNvbTAeFw0xNTA1MTYw
69 | MjUwNDZaFw0yNTA1MTMwMjUwNDZaMIGJMQswCQYDVQQGEwJGUjEOMAwGA1UECBMF
70 | UGFyaXMxEDAOBgNVBAoTB2FraW5hcnUxEDAOBgNVBAsTB2FraW5hcnUxHjAcBgNV
71 | BAMTFXdlYnNvY2tldC1tYWluLXNlcnZlcjEmMCQGCSqGSIb3DQEJARYXa2lydWF6
72 | b2xkaWs5MkBnbWFpbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
73 | AQDNxXvUOJdzeCR7sDHeCfdppmdHdtWjbq8C7dd4qIF4Q2420Th2G9Ofrl9totF2
74 | pBN9iCJXIbjyHKITfLmP1FoTpfOb4KcxzS+75Jf1pcYy7FMmaAOnyJBCPDhHX81z
75 | lVwQ9Yu3MLLrZCVeQg/lGTHxcyp3qEdAdTvJ2yD5Djdfba8tfJTcSpmYoIy9Qo1d
76 | z+V4O555xBokuGZ9tSFiOO3bDkjcpGNclzg/G1XkUoXQzmykda0SISmMi4CYrniu
77 | zDC9zHanA0mwrbD00YOiF0xAGR4RcNBENhIrt782chIxQmPr/MQtPPdhxeyd8kt0
78 | nXHgBZns5QxskXiaBYgu+NwxAgMBAAGjggFBMIIBPTAJBgNVHRMEAjAAMBEGCWCG
79 | SAGG+EIBAQQEAwIGQDAzBglghkgBhvhCAQ0EJhYkT3BlblNTTCBHZW5lcmF0ZWQg
80 | U2VydmVyIENlcnRpZmljYXRlMB0GA1UdDgQWBBRlhdOXMSQU4AtVnGHWkvSufkED
81 | wTCByAYDVR0jBIHAMIG9gBQBS4D3UNneFQNQeJe8ZEt/ZCoisKGBmaSBljCBkzEL
82 | MAkGA1UEBhMCRlIxDjAMBgNVBAgTBVBhcmlzMQ4wDAYDVQQHEwVQYXJpczEQMA4G
83 | A1UEChMHYWtpbmFydTEQMA4GA1UECxMHYWtpbmFydTEYMBYGA1UEAxMPV2Vic29j
84 | a2V0U2VydmVyMSYwJAYJKoZIhvcNAQkBFhdraXJ1YXpvbGRpazkyQGdtYWlsLmNv
85 | bYIJAKpq46muqS1dMA0GCSqGSIb3DQEBBAUAA4IBAQAupdU1uRqDO4tVAz30QAbm
86 | NI9zlgI6DEAF8B07ZiwsHa1UnwHarhfRUshB8WH70/qNrJRSdW46d1Q8svP+zBnp
87 | K7Ox/CkQkDacZHUJcPVBsubDQgJt8W9mykH9EVjdWKyihw3ljGe0YpdAa/j7br69
88 | ex297JHZZTjtHATv70ERnJBchlqw58FYA6pr+8TFP4XKwxg5j4aQ2r2LGX8xMoi/
89 | OrUpq6vHiu+1J96/8SlEAZHDrNhXGtJuMJjbWTP1zzEg4LN1nAweGBZG1xbRrcmg
90 | JegHt3i5GkNm8zfxJqRWbafhJL1Rr9XQZQc2WI5XTe8g0wJidk3WZF+Upp00CzdH
91 | -----END CERTIFICATE-----
92 |
--------------------------------------------------------------------------------
/certs/server/server.key:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNxXvUOJdzeCR7
3 | sDHeCfdppmdHdtWjbq8C7dd4qIF4Q2420Th2G9Ofrl9totF2pBN9iCJXIbjyHKIT
4 | fLmP1FoTpfOb4KcxzS+75Jf1pcYy7FMmaAOnyJBCPDhHX81zlVwQ9Yu3MLLrZCVe
5 | Qg/lGTHxcyp3qEdAdTvJ2yD5Djdfba8tfJTcSpmYoIy9Qo1dz+V4O555xBokuGZ9
6 | tSFiOO3bDkjcpGNclzg/G1XkUoXQzmykda0SISmMi4CYrniuzDC9zHanA0mwrbD0
7 | 0YOiF0xAGR4RcNBENhIrt782chIxQmPr/MQtPPdhxeyd8kt0nXHgBZns5QxskXia
8 | BYgu+NwxAgMBAAECggEAM+9dIqIp75XqN2GwJGeFj5/VP19J6pb8CxQ2pxh4nP7/
9 | 6UwDISRC1HGxWj2W+ofM94kNicpUIJ+DdMGtIBUrqvvesYAREuvD2XuHsxNlI+Mr
10 | 1Wy5R3bCmkUSu0j91Odktk8TNWhQMEM1f0XTNzKVvWgg1tSdLzKnpXnuJ44kAax7
11 | 7CU0Dq/c6jNNqrNy9rEDRj4URDyP/DgpER3XogLQ03zjg31rlVFP06TAeN2MVJjx
12 | D0KkbtWNPOAiEobwlB3Qt9RDN1zIkkkPBHncE0aNFyjVO2UPKvyDKAiAv6Fuf2bn
13 | PsP45LMSZBraq+h15SyL6fEKdQjIll5d4gBqcpe8sQKBgQD+Q5yRyd0e/unBxZTK
14 | XaHZOUFUFQ1sslwHoVtmZnAp8WPLpr/IQOcpdclLB5HpU7FymGVw9dpCwK8s4F3y
15 | kUX6dmRjcT417rp3Q5UYQxus2e34GA624sTsuLHQuu96jrKVkxGvqq5Gvvc1TQQ4
16 | XmkH6pocBgmK0LCnM1rB0aX3jQKBgQDPLR6M2OL0A54gAwlvdJCiiUadIH612pwN
17 | ftd7gBpgXKmHjv5Ly02rkOYjGtBJQLgLBZ0/akOme+r0DF5H8c/eQMRwcov8E8QA
18 | U9ISDYzhmO7sJlKw7X7bPt86TPwBSBA0xvg9lxhyVuvkorTwCaV0ThYpoUk2AL2S
19 | 2qEcRooMNQKBgDz6MAFSnQIC9kJvRPinLdpvfbhReC+6MpHt44KSTJHyfxFnAxVe
20 | Y1GxGr4wqZCAbszhuWo2u8pIdXpYsI8swdCINhkXHmlGwFc70PTJm0h/1y8pbdX0
21 | Wm++933sZuRIdpGifJpZX4Q95gFVYA64rY2leKIB3KX62HKwwTI8OgY9AoGBAI/q
22 | Ar/KZZUl8jDAi0xeB56wh1nc2chPrHl/dAY5TZlEpQsinKlf93tHc2ZNWQSZrX8S
23 | jlIf6hB7IhIXiWKmqkP0b8DBAVbBEDU+BL4/pW6NAuMOGAEJaUa5nO1tztzBB2jy
24 | Ej0OeY/rq3+uOsxHlyR8nc6bWDToPMgHkUUIBxtFAoGBAN7VwFVsH3F80Rb9E0tt
25 | jtg9SnFs4SozNsl7VEKJ9wglmz/Swi9e8UpBakYKesxXjwWaYoYDSAnx8aqn1B8j
26 | myG2JT09xqJIPFOnHqFE6X296i2Dji1Fqjh4JlQCbaEHysNDg0qoFl+6kHA+AvKr
27 | rXh71I4w46HTW+0g7PXCkJyV
28 | -----END PRIVATE KEY-----
29 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/DigestManager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | DigestManager.h
26 | Client socket managing event handler
27 |
28 | @author Bertrand Martel
29 | @version 1.0
30 | */
31 | #ifndef DIGESTMANAGER_H
32 | #define DIGESTMANAGER_H
33 |
34 | #include "Digestinfo.h"
35 | #include "QList"
36 | #include "digeststruct.h"
37 | #include "IDigestListener.h"
38 | #include "QDateTime"
39 | #include "map"
40 |
41 | /* nonce structure used to store stateful data about nonce creation / lifetime */
42 | typedef struct {
43 | std::string nonce; // nonce value
44 | unsigned long expiring_date; // expiring date in millisecond since 1970
45 | unsigned int nonce_count; // nonce server count
46 | bool stale; // true if former nonce was rejected due to expiration (NOT IMPLEMENTED FOR NOW)
47 | std::string session_id; // session id (only for COOKIE session type => this must match an entry in session structure below for this type of session)
48 | } nonce;
49 |
50 | /* session structure used to store stateful data about session entry for COOKIE session type*/
51 | typedef struct{
52 | QDateTime session_start_date; // session record date
53 | bool validity; // validity of session entry
54 | } session;
55 |
56 | /**
57 | * @brief The DigestManager class
58 | * Client socket managing event handler
59 | */
60 | class DigestManager{
61 |
62 | public:
63 |
64 | /**
65 | * @brief DigestManager
66 | * build client socket handler
67 | */
68 | DigestManager();
69 |
70 | ~DigestManager();
71 |
72 | /**
73 | * @brief process_digest
74 | * process digest request / response according to method / uri / headers given in parameters.
75 | * Will return following http content body according digest processing :
76 | *
77 | * - unauthorized_page : when client has not been authorized yet / or token expired / or authorization issue happened
78 | * - internal_error_page : when processing error occured
79 | * - expected_page : when client is fully authorized and session token is valid
80 | *
81 | * @param method
82 | * http method
83 | * @param uri
84 | * http uri
85 | * @param headers
86 | * http headers
87 | * @param realm
88 | * chosen realm for given uri
89 | * @return
90 | * DigestInfo
91 | */
92 | DigestInfo process_digest(std::string method,std::string uri,std::map headers,std::string realm);
93 |
94 | /**
95 | * @brief DigestManager::remove_expired_nonces
96 | * Remove all nonces in map that expired
97 | */
98 | void remove_expired_nonces();
99 |
100 | /**
101 | * @brief DigestManager::remove_expired_sessions
102 | * Remove all session in map that expired
103 | */
104 | void remove_expired_sessions();
105 |
106 | /**
107 | * @brief getAuthenticationCookieField
108 | * Retrieve HSID value from cookie http header
109 | *
110 | * @param cookieStr
111 | * cookie header value
112 | * @return
113 | */
114 | std::string getAuthenticationCookieField(std::string cookieStr);
115 |
116 | /**
117 | * @brief splitHeader
118 | * @param header
119 | * @param delim
120 | * @return
121 | */
122 | std::map splitHeader(std::string header,char delim);
123 |
124 | /**
125 | * @brief remove_session_for_headers
126 | * Remove a session (cookie or digest)
127 | * @param headers
128 | * @return
129 | */
130 | int remove_session_for_headers(std::map *headers);
131 |
132 | /**
133 | * @brief DigestManager::generateHandshakeProcess
134 | * build digest authentication request
135 | * @param host
136 | * host address
137 | * @param path_realm
138 | * realm used for authentication
139 | * @return
140 | * DigestInfo
141 | */
142 | DigestInfo generateHandshakeProcess(std::string host,std::string realm);
143 |
144 | /**
145 | * @brief DigestManager::generateRandomNum
146 | * Generate random alpha numeric string
147 | * @param num
148 | * length of random string
149 | * @return
150 | */
151 | std::string generateRandomNum(unsigned int num);
152 |
153 | /**
154 | * @brief DigestManager::processDigestResponse
155 | * Process digest response request to authenticate and validate session cookie
156 | *
157 | * @param authorizationHeader
158 | * header Authorization
159 | * @param cookieHeader
160 | * Cookie header
161 | * @param realm
162 | * realm used for this authentication
163 | * @param http_method_requested
164 | * http method requested by client
165 | * @param uri_requested
166 | * uri requested by client
167 | * @return
168 | * DigestInfo
169 | */
170 | DigestInfo processDigestResponse(std::string authorizationHeader,std::string cookieHeader,std::string realm,std::string http_method_requested,std::string uri_requested);
171 |
172 | /**
173 | * @brief DigestManager::set_show_algorithm
174 | * algorithm used in digest authentication will be sent to client if set to true (default)
175 | * @param show_in_response
176 | */
177 | void set_show_algorithm(bool show_in_response);
178 |
179 | /**
180 | * @brief DigestManager::set_digest_algorithm
181 | * Set digest algorithm used for processing hash
182 | * @param algorithm
183 | */
184 | void set_digest_algorithm(digest_algorithm algorithm);
185 |
186 | /**
187 | * @brief DigestManager::getAlgorithm
188 | * Retrieve digest get_algorithm used for processing hash
189 | * @return
190 | */
191 | digest_algorithm get_algorithm();
192 |
193 | /**
194 | * @brief DigestManager::set_nonce_timeout_millis
195 | * set nonce timeout in milliseconds
196 | * @param nonce_timeout
197 | */
198 | void set_nonce_timeout_millis(long nonce_timeout);
199 |
200 | /**
201 | * @brief DigestManager::get_nonce_timeout_millis
202 | * Retrieve nonce timeout in milliseconds
203 | * @return
204 | */
205 | long get_nonce_timeout_millis();
206 |
207 | /**
208 | * @brief DigestManager::set_digest_listener
209 | * Set digest listener
210 | * @param digest_listener
211 | */
212 | void set_digest_listener(IDigestListener* digest_listener);
213 |
214 | /**
215 | * @brief DigestManager::set_session_type
216 | * Set session type (default is DIGEST session)
217 | * @param session
218 | */
219 | void set_session_type(session_type session);
220 |
221 | /**
222 | * @brief DigestManager::get_session_type
223 | * Retrieve session type
224 | * @return
225 | */
226 | session_type get_session_type();
227 |
228 | /**
229 | * @brief DigestManager::set_max_session_time
230 | * Set maximum session time for user
231 | * @param session_time
232 | */
233 | void set_max_session_time(int session_time);
234 |
235 | /**
236 | * @brief DigestManager::get_max_session_time
237 | * Retrieve maximum session time for user
238 | * @return
239 | */
240 | int get_max_session_time();
241 |
242 | /**
243 | * @brief show_algorithm
244 | * if set to true will show algorithm used in response to client
245 | */
246 | bool show_algorithm;
247 |
248 | /**
249 | * @brief algorithm
250 | * algorithm used to compute hashes
251 | */
252 | digest_algorithm algorithm;
253 |
254 | /**
255 | * @brief nonce_timeout_millis
256 | * nonce timeout in milliseconds (it is the session duration when digest session is used)
257 | */
258 | long nonce_timeout_millis;
259 |
260 | /**
261 | * @brief digest_listener
262 | * listener for retrievinf username / password hash from storage
263 | */
264 | IDigestListener * digest_listener;
265 |
266 | /**
267 | * @brief session_t
268 | * type of session used (can be DIGEST or COOKIE)
269 | */
270 | session_type session_t;
271 |
272 | /**
273 | * @brief session_time_seconds
274 | * session duration for COOKIE session type (DIGEST session duration is set by nonce timeout)
275 | */
276 | int session_time_seconds;
277 |
278 | /**
279 | * @brief nonce_map
280 | * map of nonces
281 | */
282 | std::map< std::string, nonce> nonce_map;
283 |
284 | /**
285 | * @brief session_map
286 | * map of sessions (used only for COOKIE session)
287 | */
288 | std::map< std::string, session> session_map;
289 | };
290 |
291 | #endif // DIGESTMANAGER_H
292 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/Digestinfo.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | DigestInfo.cpp
26 | Output digest information to be sent to client
27 |
28 | @author Bertrand Martel
29 | @version 1.0
30 | */
31 | #include "Digestinfo.h"
32 |
33 | /**
34 | * @brief DigestInfo
35 | * @param status_code
36 | * http status code
37 | * @param headers
38 | * http headers
39 | */
40 | DigestInfo::DigestInfo(int status_code,std::map< std::string,std::string> headers){
41 | this->status_code=status_code;
42 | this->headers=headers;
43 | }
44 |
45 | DigestInfo::~DigestInfo()
46 | {
47 | }
48 |
49 | /**
50 | * @brief get_status_code
51 | * Retrieve status code to return
52 | * @return
53 | */
54 |
55 | int DigestInfo::get_status_code(){
56 | return status_code;
57 | }
58 |
59 |
60 | /**
61 | * @brief get_headers
62 | * Retrieve headers to return
63 | * @return
64 | */
65 |
66 | std::map< std::string,std::string > *DigestInfo::get_headers(){
67 | return &headers;
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/Digestinfo.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | DigestInfo.h
26 | Output digest information to be sent to client
27 |
28 | @author Bertrand Martel
29 | @version 1.0
30 | */
31 | #ifndef DIGESTINFO_H
32 | #define DIGESTINFO_H
33 |
34 | #include "map"
35 | #include "string"
36 |
37 | /**
38 | * @brief The DigestInfo class
39 | * Digest information used to build http request/response
40 | */
41 | class DigestInfo
42 | {
43 | public:
44 |
45 | /**
46 | * @brief DigestInfo
47 | * @param status_code
48 | * http status code
49 | * @param headers
50 | * http headers
51 | */
52 | DigestInfo(int status_code,std::map< std::string,std::string> headers);
53 |
54 | ~DigestInfo();
55 |
56 | /**
57 | * @brief get_status_code
58 | * Retrieve status code to return
59 | * @return
60 | */
61 | int get_status_code();
62 |
63 | /**
64 | * @brief get_headers
65 | * Retrieve headers to return
66 | * @return
67 | */
68 | std::map< std::string,std::string >* get_headers();
69 |
70 | private:
71 |
72 | /**
73 | * @brief status_code
74 | * http status code
75 | */
76 | int status_code;
77 |
78 | /**
79 | * @brief headers
80 | * http headers
81 | */
82 | std::map< std::string,std::string > headers;
83 | };
84 |
85 | #endif // DIGESTINFO_H
86 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/IDigestListener.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | IDigestListener.h
26 |
27 | Generic interface for digest listener. Used to implement a listener to retrieve username / password hashe from storage
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef IDIGESTLISTENER_H
33 | #define IDIGESTLISTENER_H
34 |
35 | #include "string"
36 | #include "digeststruct.h"
37 |
38 | class IDigestListener{
39 |
40 | public:
41 |
42 | /**
43 | * @brief getUri
44 | * retrieve HTTP uri
45 | * @return
46 | */
47 | virtual std::string get_hash_for_username(std::string username,std::string realm,digest_algorithm algo)=0;
48 | };
49 |
50 | #endif // IDIGESTLISTENER_H
51 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/Makefile:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Makefile for building: libdigestauthsession.a
3 | # Generated by qmake (2.01a) (Qt 4.8.4) on: Sat Oct 10 20:32:36 2015
4 | # Project: digest-auth-session.pro
5 | # Template: lib
6 | # Command: /usr/lib/i386-linux-gnu/qt4/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile digest-auth-session.pro
7 | #############################################################################
8 |
9 | ####### Compiler, tools and options
10 |
11 | CC = gcc
12 | CXX = g++
13 | DEFINES = -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
14 | CFLAGS = -pipe -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
15 | CXXFLAGS = -pipe -std=c++0x -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
16 | INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4 -Ilibs -I.
17 | AR = ar cqs
18 | RANLIB =
19 | QMAKE = /usr/lib/i386-linux-gnu/qt4/bin/qmake
20 | TAR = tar -cf
21 | COMPRESS = gzip -9f
22 | COPY = cp -f
23 | SED = sed
24 | COPY_FILE = $(COPY)
25 | COPY_DIR = $(COPY) -r
26 | STRIP = strip
27 | INSTALL_FILE = install -m 644 -p
28 | INSTALL_DIR = $(COPY_DIR)
29 | INSTALL_PROGRAM = install -m 755 -p
30 | DEL_FILE = rm -f
31 | SYMLINK = ln -f -s
32 | DEL_DIR = rmdir
33 | MOVE = mv -f
34 | CHK_DIR_EXISTS= test -d
35 | MKDIR = mkdir -p
36 |
37 | ####### Output directory
38 |
39 | OBJECTS_DIR = bin/
40 |
41 | ####### Files
42 |
43 | SOURCES = utils/stringutil.cpp \
44 | DigestManager.cpp \
45 | Digestinfo.cpp
46 | OBJECTS = bin/stringutil.o \
47 | bin/DigestManager.o \
48 | bin/Digestinfo.o
49 | DIST = /usr/share/qt4/mkspecs/common/unix.conf \
50 | /usr/share/qt4/mkspecs/common/linux.conf \
51 | /usr/share/qt4/mkspecs/common/gcc-base.conf \
52 | /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
53 | /usr/share/qt4/mkspecs/common/g++-base.conf \
54 | /usr/share/qt4/mkspecs/common/g++-unix.conf \
55 | /usr/share/qt4/mkspecs/qconfig.pri \
56 | /usr/share/qt4/mkspecs/modules/qt_phonon.pri \
57 | /usr/share/qt4/mkspecs/features/qt_functions.prf \
58 | /usr/share/qt4/mkspecs/features/qt_config.prf \
59 | /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
60 | /usr/share/qt4/mkspecs/features/default_pre.prf \
61 | /usr/share/qt4/mkspecs/features/debug.prf \
62 | /usr/share/qt4/mkspecs/features/default_post.prf \
63 | /usr/share/qt4/mkspecs/features/staticlib.prf \
64 | /usr/share/qt4/mkspecs/features/static.prf \
65 | /usr/share/qt4/mkspecs/features/declarative_debug.prf \
66 | /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
67 | /usr/share/qt4/mkspecs/features/warn_on.prf \
68 | /usr/share/qt4/mkspecs/features/qt.prf \
69 | /usr/share/qt4/mkspecs/features/unix/thread.prf \
70 | /usr/share/qt4/mkspecs/features/moc.prf \
71 | /usr/share/qt4/mkspecs/features/resources.prf \
72 | /usr/share/qt4/mkspecs/features/uic.prf \
73 | /usr/share/qt4/mkspecs/features/yacc.prf \
74 | /usr/share/qt4/mkspecs/features/lex.prf \
75 | /usr/share/qt4/mkspecs/features/include_source_dir.prf \
76 | digest-auth-session.pro
77 | QMAKE_TARGET = digestauthsession
78 | DESTDIR = release/
79 | TARGET = libdigestauthsession.a
80 |
81 | first: all
82 | ####### Implicit rules
83 |
84 | .SUFFIXES: .o .c .cpp .cc .cxx .C
85 |
86 | .cpp.o:
87 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
88 |
89 | .cc.o:
90 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
91 |
92 | .cxx.o:
93 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
94 |
95 | .C.o:
96 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
97 |
98 | .c.o:
99 | $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
100 |
101 | ####### Build rules
102 |
103 | all: Makefile release/$(TARGET)
104 |
105 | staticlib: release/$(TARGET)
106 |
107 | release/$(TARGET): $(OBJECTS) $(OBJCOMP)
108 | @$(CHK_DIR_EXISTS) release/ || $(MKDIR) release/
109 | -$(DEL_FILE) $(TARGET)
110 | $(AR) $(TARGET) $(OBJECTS)
111 | rsync -avm --include=*/ --include=*.h --exclude=* /home/abathur/Bureau/open_source/digest-auth-session-cpp/digest-auth-session-lib// /home/abathur/Bureau/open_source/digest-auth-session-cpp/digest-auth-session-lib/release
112 | -$(DEL_FILE) release/$(TARGET)
113 | -$(MOVE) $(TARGET) release/
114 |
115 |
116 | Makefile: digest-auth-session.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \
117 | /usr/share/qt4/mkspecs/common/linux.conf \
118 | /usr/share/qt4/mkspecs/common/gcc-base.conf \
119 | /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \
120 | /usr/share/qt4/mkspecs/common/g++-base.conf \
121 | /usr/share/qt4/mkspecs/common/g++-unix.conf \
122 | /usr/share/qt4/mkspecs/qconfig.pri \
123 | /usr/share/qt4/mkspecs/modules/qt_phonon.pri \
124 | /usr/share/qt4/mkspecs/features/qt_functions.prf \
125 | /usr/share/qt4/mkspecs/features/qt_config.prf \
126 | /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
127 | /usr/share/qt4/mkspecs/features/default_pre.prf \
128 | /usr/share/qt4/mkspecs/features/debug.prf \
129 | /usr/share/qt4/mkspecs/features/default_post.prf \
130 | /usr/share/qt4/mkspecs/features/staticlib.prf \
131 | /usr/share/qt4/mkspecs/features/static.prf \
132 | /usr/share/qt4/mkspecs/features/declarative_debug.prf \
133 | /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
134 | /usr/share/qt4/mkspecs/features/warn_on.prf \
135 | /usr/share/qt4/mkspecs/features/qt.prf \
136 | /usr/share/qt4/mkspecs/features/unix/thread.prf \
137 | /usr/share/qt4/mkspecs/features/moc.prf \
138 | /usr/share/qt4/mkspecs/features/resources.prf \
139 | /usr/share/qt4/mkspecs/features/uic.prf \
140 | /usr/share/qt4/mkspecs/features/yacc.prf \
141 | /usr/share/qt4/mkspecs/features/lex.prf \
142 | /usr/share/qt4/mkspecs/features/include_source_dir.prf \
143 | /usr/lib/i386-linux-gnu/libQtNetwork.prl \
144 | /usr/lib/i386-linux-gnu/libQtCore.prl
145 | $(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile digest-auth-session.pro
146 | /usr/share/qt4/mkspecs/common/unix.conf:
147 | /usr/share/qt4/mkspecs/common/linux.conf:
148 | /usr/share/qt4/mkspecs/common/gcc-base.conf:
149 | /usr/share/qt4/mkspecs/common/gcc-base-unix.conf:
150 | /usr/share/qt4/mkspecs/common/g++-base.conf:
151 | /usr/share/qt4/mkspecs/common/g++-unix.conf:
152 | /usr/share/qt4/mkspecs/qconfig.pri:
153 | /usr/share/qt4/mkspecs/modules/qt_phonon.pri:
154 | /usr/share/qt4/mkspecs/features/qt_functions.prf:
155 | /usr/share/qt4/mkspecs/features/qt_config.prf:
156 | /usr/share/qt4/mkspecs/features/exclusive_builds.prf:
157 | /usr/share/qt4/mkspecs/features/default_pre.prf:
158 | /usr/share/qt4/mkspecs/features/debug.prf:
159 | /usr/share/qt4/mkspecs/features/default_post.prf:
160 | /usr/share/qt4/mkspecs/features/staticlib.prf:
161 | /usr/share/qt4/mkspecs/features/static.prf:
162 | /usr/share/qt4/mkspecs/features/declarative_debug.prf:
163 | /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
164 | /usr/share/qt4/mkspecs/features/warn_on.prf:
165 | /usr/share/qt4/mkspecs/features/qt.prf:
166 | /usr/share/qt4/mkspecs/features/unix/thread.prf:
167 | /usr/share/qt4/mkspecs/features/moc.prf:
168 | /usr/share/qt4/mkspecs/features/resources.prf:
169 | /usr/share/qt4/mkspecs/features/uic.prf:
170 | /usr/share/qt4/mkspecs/features/yacc.prf:
171 | /usr/share/qt4/mkspecs/features/lex.prf:
172 | /usr/share/qt4/mkspecs/features/include_source_dir.prf:
173 | /usr/lib/i386-linux-gnu/libQtNetwork.prl:
174 | /usr/lib/i386-linux-gnu/libQtCore.prl:
175 | qmake: FORCE
176 | @$(QMAKE) -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug CONFIG+=declarative_debug -o Makefile digest-auth-session.pro
177 |
178 | dist:
179 | @$(CHK_DIR_EXISTS) bin/digestauthsession1.0.0 || $(MKDIR) bin/digestauthsession1.0.0
180 | $(COPY_FILE) --parents $(SOURCES) $(DIST) bin/digestauthsession1.0.0/ && $(COPY_FILE) --parents utils/stringutil.h IDigestListener.h digeststruct.h DigestManager.h Digestinfo.h bin/digestauthsession1.0.0/ && $(COPY_FILE) --parents utils/stringutil.cpp DigestManager.cpp Digestinfo.cpp bin/digestauthsession1.0.0/ && (cd `dirname bin/digestauthsession1.0.0` && $(TAR) digestauthsession1.0.0.tar digestauthsession1.0.0 && $(COMPRESS) digestauthsession1.0.0.tar) && $(MOVE) `dirname bin/digestauthsession1.0.0`/digestauthsession1.0.0.tar.gz . && $(DEL_FILE) -r bin/digestauthsession1.0.0
181 |
182 |
183 | clean:compiler_clean
184 | -$(DEL_FILE) $(OBJECTS)
185 | -$(DEL_FILE) -r /home/abathur/Bureau/open_source/digest-auth-session-cpp/digest-auth-session-lib/release
186 | -$(DEL_FILE) *~ core *.core
187 |
188 |
189 | ####### Sub-libraries
190 |
191 | distclean: clean
192 | -$(DEL_FILE) $(TARGET)
193 | -$(DEL_FILE) Makefile
194 |
195 |
196 | check: first
197 |
198 | mocclean: compiler_moc_header_clean compiler_moc_source_clean
199 |
200 | mocables: compiler_moc_header_make_all compiler_moc_source_make_all
201 |
202 | compiler_moc_header_make_all:
203 | compiler_moc_header_clean:
204 | compiler_rcc_make_all:
205 | compiler_rcc_clean:
206 | compiler_image_collection_make_all: qmake_image_collection.cpp
207 | compiler_image_collection_clean:
208 | -$(DEL_FILE) qmake_image_collection.cpp
209 | compiler_moc_source_make_all:
210 | compiler_moc_source_clean:
211 | compiler_uic_make_all:
212 | compiler_uic_clean:
213 | compiler_yacc_decl_make_all:
214 | compiler_yacc_decl_clean:
215 | compiler_yacc_impl_make_all:
216 | compiler_yacc_impl_clean:
217 | compiler_lex_make_all:
218 | compiler_lex_clean:
219 | compiler_clean:
220 |
221 | ####### Compile
222 |
223 | bin/stringutil.o: utils/stringutil.cpp utils/stringutil.h
224 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o bin/stringutil.o utils/stringutil.cpp
225 |
226 | bin/DigestManager.o: DigestManager.cpp DigestManager.h \
227 | Digestinfo.h \
228 | digeststruct.h \
229 | IDigestListener.h \
230 | libs/protocol/inter/http/IhttpFrame.h \
231 | utils/stringutil.h
232 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o bin/DigestManager.o DigestManager.cpp
233 |
234 | bin/Digestinfo.o: Digestinfo.cpp Digestinfo.h
235 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o bin/Digestinfo.o Digestinfo.cpp
236 |
237 | ####### Install
238 |
239 | install: FORCE
240 |
241 | uninstall: FORCE
242 |
243 | FORCE:
244 |
245 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/digest-auth-session.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-05-23T13:52:17
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core
8 | QT += network
9 | QT -= gui
10 |
11 | TARGET = digestauthsession
12 | CONFIG+= staticlib
13 |
14 | TEMPLATE = lib
15 |
16 | OBJECTS_DIR=bin
17 | DESTDIR = release
18 | QMAKE_CXXFLAGS += -std=c++0x
19 |
20 | SOURCES += \
21 | utils/stringutil.cpp \
22 | DigestManager.cpp \
23 | Digestinfo.cpp
24 |
25 | HEADERS += \
26 | utils/stringutil.h \
27 | IDigestListener.h \
28 | digeststruct.h \
29 | DigestManager.h \
30 | Digestinfo.h
31 |
32 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libs/ -lhttpdecoder
33 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libs/ -lhttpdecoder
34 | else:unix: LIBS += -L$$PWD/libs/ -lhttpdecoder
35 |
36 | INCLUDEPATH += $$PWD/libs
37 | DEPENDPATH += $$PWD/libs
38 |
39 | QMAKE_CLEAN += -r $${PWD}/$${DESTDIR}
40 |
41 | QMAKE_POST_LINK +=$$quote(rsync -avm --include=*/ --include=*.h --exclude=* $${PWD}/$${SOURCES_DIR}/ $${PWD}/$${DESTDIR})
42 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/digeststruct.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | digeststruct.h
26 |
27 | Algorithm and session type structure for digest authentication / session and cookie session
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef DIGESTSTRUCT_H
33 | #define DIGESTSTRUCT_H
34 |
35 | enum digest_algorithm{
36 | ALGO_MD5,
37 | ALGO_SHA1
38 | };
39 |
40 | enum session_type{
41 | SESSION_COOKIE,
42 | SESSION_DIGEST
43 | };
44 |
45 | #endif // DIGESTSTRUCT_H
46 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/httpserverimpl/clientSocket.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | clientsocket.h
26 |
27 | http client object featuring one physical http connection
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef CLIENTSOCKET_H
33 | #define CLIENTSOCKET_H
34 |
35 | #include
36 | #include
37 | #include
38 | #include "httpserverinter/IHttpClient.h"
39 |
40 | class ClientSocket : public IHttpClient
41 | {
42 |
43 | public:
44 |
45 | /**
46 | * @brief ClientSocket::ClientSocket
47 | * Build one client
48 | */
49 | ClientSocket();
50 |
51 |
52 | ~ClientSocket();
53 |
54 | /**
55 | * @brief getPeerAddress
56 | * Retrieve client ip address
57 | * @return
58 | */
59 | std::string getPeerAddress();
60 |
61 | /**
62 | * close websoclet client object
63 | *
64 | * @return
65 | * 0 if success -1 if error
66 | */
67 | int close();
68 |
69 | /**
70 | * Send a message to HTTP client
71 | *
72 | * @param string
73 | * Message to be sent to client
74 | * @return
75 | * 0 if success -1 if error
76 | */
77 | void sendHttpMessage(std::string message);
78 |
79 | /**
80 | * @brief setSocketClient
81 | * Define client socket for this object
82 | * @param clientSocket
83 | * client socket
84 | */
85 | void setSocketClient(QTcpSocket * clientSocket);
86 |
87 | void writeStringToSocket(std::string message);
88 |
89 | void writeByteArrayToSocket(const QByteArray array);
90 |
91 | void flush();
92 |
93 | void writeCharToSocket(char * data,int size);
94 |
95 | private:
96 |
97 | /**
98 | * @brief clientSocket
99 | * client socket
100 | */
101 | QTcpSocket* clientSocket;
102 | };
103 |
104 | #endif // CLIENTSOCKET_H
105 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/httpserverimpl/httpserver.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | HttpServer.h
26 |
27 | Http server main process class
28 |
29 | manage incoming connections
30 | manage socket encryption for SSL socket
31 | manage process of incoming data from client socket
32 |
33 | @author Bertrand Martel
34 | @version 1.0
35 | */
36 | #ifndef HTTPSERVER_H
37 | #define HTTPSERVER_H
38 |
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include "protocol/inter/http/httpconsumer.h"
45 | #include "protocol/http/httpdecoder.h"
46 | #include "clientSocket.h"
47 | #include "QSslCertificate"
48 | #include "QList"
49 | #include "QSslKey"
50 | #include "httpserverinter/IClientEventListener.h"
51 | #include
52 | #include "protocol/inter/http/httpframe.h"
53 | /**
54 | * @brief The HttpServer class
55 | * Http server main process class
56 | *
57 | *
58 | * - manage incoming connections
59 | * - manage socket encryption for SSL socket
60 | * - manage process of incoming data from client socket
61 | *
62 | */
63 | class HttpServer: public QTcpServer
64 | {
65 |
66 | Q_OBJECT
67 | public:
68 |
69 | /**
70 | * @brief HttpServer
71 | * Http server build object
72 | * @param parent
73 | */
74 | HttpServer(QObject * parent = 0);
75 |
76 | /**
77 | * @brief socketClientList
78 | * socket client list
79 | */
80 | static std::map socketClientList;
81 |
82 | ~HttpServer();
83 |
84 | /**
85 | * @brief HttpServer::addClientEventListener
86 | * add a client event listener to list
87 | * @param clientListener
88 | * client listener
89 | */
90 | void addClientEventListener(IClientEventListener * clientListener);
91 |
92 | /**
93 | * @brief HttpServer::setSSL
94 | * set Http server to secured Http server
95 | * @param use_ssl
96 | */
97 | void setSSL(bool use_ssl);
98 |
99 | /**
100 | * @brief HttpServer::setPublicCert
101 | * set public server cert
102 | * @param cert
103 | * public certificate
104 | */
105 | void setPublicCert(QSslCertificate cert);
106 |
107 | /**
108 | * @brief HttpServer::setCaCert
109 | * set certification authoritycert
110 | * @param cert
111 | * certification authority cert
112 | */
113 | void setCaCert(QList< QSslCertificate > cert);
114 |
115 | /**
116 | * @brief HttpServer::setPrivateCert
117 | * set private certificate
118 | * @param cert
119 | * private certificate
120 | */
121 | void setPrivateCert(QSslKey key);
122 |
123 |
124 | /**
125 | * @brief HttpServer::containsHttpProcessedFrames
126 | * check if http frame list buffer already contains finished http processed frame or no
127 | * @param frameList
128 | * list of http frames
129 | * @return
130 | */
131 | bool containsHttpProcessedFrames(std::vector frameList);
132 |
133 | /**
134 | * @brief HttpServer::set_debug
135 | * activate / desactivate debug
136 | * @param use_ssl
137 | */
138 | void set_debug(bool state);
139 |
140 | private slots:
141 |
142 | /**
143 | * @brief incomingData
144 | * slot called when data comes from client socket
145 | */
146 | void incomingData();
147 |
148 | /**
149 | * @brief handleNewConnection
150 | * called when a new connection pop up
151 | */
152 | void handleNewConnection();
153 |
154 | /**
155 | * @brief slot_connected
156 | * called when a socket connect successfully to server
157 | */
158 | void slot_connected ();
159 |
160 | /**
161 | * @brief slot_disconnected
162 | * called when a socket disconnect from server
163 | */
164 | void slot_disconnected ();
165 |
166 | void ready();
167 |
168 | void slot_error (QAbstractSocket::SocketError err);
169 | void slot_hostFound ();
170 | void slot_proxyAuthenticationRequired (const QNetworkProxy &, QAuthenticator *);
171 | void slot_stateChanged (QAbstractSocket::SocketState state);
172 |
173 | //bunch of slots used to check different state of SSL encryption process through QTNetwork processing
174 | void slot_encrypted ();
175 | void slot_encryptedBytesWritten (qint64 written);
176 | void slot_modeChanged (QSslSocket::SslMode mode);
177 | void slot_peerVerifyError (const QSslError &);
178 | void slot_sslErrors (const QList &);
179 |
180 | private:
181 |
182 | /**
183 | * @brief nextPendingConnection
184 | * overidde of next pending connection for queuing socket in a list
185 | * @return
186 | */
187 | QSslSocket* nextPendingConnection();
188 |
189 | /**
190 | * @brief incomingConnection
191 | * new connection has come
192 | * @param socketDescriptor
193 | */
194 | void incomingConnection(int socketDescriptor);
195 |
196 | /**
197 | * @brief HttpServer::startServerEncryption
198 | * add respective certificates for SSL encryption
199 | *
200 | * @param clientSocket
201 | * ssl client socket
202 | */
203 | void startServerEncryption(QSslSocket* clientSocket);
204 |
205 | /**
206 | * @brief HttpServer::connectSocketSignals
207 | * connect signals to slots : we take the maximum of slots here to manage errors quickly
208 | * @param clientSocket
209 | * client socket incoming
210 | */
211 | void connectSocketSignals(QSslSocket* clientSocket);
212 |
213 | /**
214 | * @brief HttpServer::closeClientSocket
215 | * close client socket function
216 | * @param socket
217 | * client socket
218 | */
219 | void closeClientSocket(QSslSocket* socket);
220 |
221 | //ssl certs used to encrypt ssl socket
222 |
223 | /**
224 | * @brief localCertificate
225 | * public certificate
226 | */
227 | QSslCertificate localCertificate;
228 |
229 | /**
230 | * @brief caCertificate
231 | * certification authority list of certificates
232 | */
233 | QList< QSslCertificate > caCertificate;
234 |
235 | /**
236 | * @brief keyCertificate
237 | * private certificate
238 | */
239 | QSslKey keyCertificate;
240 |
241 | /**
242 | * @brief consumer
243 | * http consumer used to retrieve chunk of http frames
244 | */
245 | httpconsumer * consumer;
246 |
247 | /**
248 | * @brief decoder
249 | * http decoder used to decode http frames streaming
250 | */
251 | httpdecoder decoder;
252 |
253 | /**
254 | * @brief debug
255 | * debug state for Http server
256 | */
257 | bool debug;
258 |
259 | /**
260 | * @brief ssl
261 | * define if Http protocol must use encryption or not
262 | */
263 | bool ssl;
264 |
265 | /**
266 | * @brief clientEventListenerList
267 | * list of client event listener
268 | */
269 | std::vector clientEventListenerList;
270 |
271 | /**
272 | * @brief queue
273 | * used to store connection in a list
274 | */
275 | QQueue queue;
276 | };
277 |
278 |
279 | #endif // HTTPSERVER_H
280 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/httpserverinter/IClientEventListener.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | IClientEventListener.h
26 |
27 | Define all client socket event that can happen and that will pop event in class that will inherit this one
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef ICLIENTEVENTLISTENER_H
33 | #define ICLIENTEVENTLISTENER_H
34 |
35 | #include "IHttpClient.h"
36 | #include "string"
37 | #include "protocol/inter/http/IhttpFrame.h"
38 |
39 | /**
40 | * @brief The IClientEventListener class
41 | * Client Socket event listener template class
42 | */
43 | class IClientEventListener
44 | {
45 |
46 | public :
47 |
48 | /**
49 | * called when an http request has been received from client
50 | *
51 | * @param client
52 | * client object
53 | * @param message
54 | * message delivered
55 | */
56 | virtual void onHttpRequestReceived(IHttpClient &client,Ihttpframe* consumer,std::string peer_address)= 0;
57 |
58 | /**
59 | * called when an http response has been received from client
60 | *
61 | * @param client
62 | * client object
63 | * @param message
64 | * message delivered
65 | */
66 | virtual void onHttpResponseReceived(IHttpClient &client,Ihttpframe* consumer,std::string peer_address)= 0;
67 |
68 | };
69 |
70 |
71 | #endif // ICLIENTEVENTLISTENER_H
72 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/httpserverinter/IHttpClient.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | IWebsocketClient.h
26 |
27 | Define generic template for http client socket
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef IHTTPCLIENT_H
33 | #define IHTTPCLIENT_H
34 | #include "string"
35 | #include "QByteArray"
36 |
37 | class IHttpClient
38 | {
39 |
40 | public :
41 | /**
42 | * Send http message to client
43 | *
44 | * @param string
45 | * Message to be sent to client
46 | * @return
47 | * 0 if success -1 if error
48 | */
49 | virtual void sendHttpMessage(std::string message)= 0;
50 |
51 | virtual void writeStringToSocket(std::string message)=0;
52 |
53 | virtual void writeByteArrayToSocket(const QByteArray array)=0;
54 |
55 | virtual void flush()=0;
56 |
57 | virtual void writeCharToSocket(char * data,int size)=0;
58 |
59 | };
60 |
61 | #endif // IHTTPCLIENT_H
62 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/libhttpServer.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bertrandmartel/digest-auth-session-cpp/HEAD/digest-auth-session-lib/libs/libhttpServer.a
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/libhttpdecoder.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bertrandmartel/digest-auth-session-cpp/HEAD/digest-auth-session-lib/libs/libhttpdecoder.a
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/protocol/http/httpconstants.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | httpconstants.h
26 | HTTP constants file
27 | Regroup all constants used for HTTP parser
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef HTTPCONSTANTS_H
33 | #define HTTPCONSTANTS_H
34 | #include "vector"
35 | #include "string"
36 |
37 | /**
38 | * @brief The httpconstants class
39 | * store HTTP parser constants
40 | */
41 | class httpconstants
42 | {
43 |
44 | public:
45 |
46 | #define HTTP_HEADERS_CONTENT_LENGTH "Content-Length"
47 |
48 | #define HTTP_METHOD_GET "GET"
49 |
50 | #define HTTP_METHOD_POST "POST"
51 |
52 | #define HTTP_METHOD_PUT "PUT"
53 |
54 | #define HTTP_METHOD_DELETE "DELETE"
55 |
56 | // struct for status code / status code phrase
57 | typedef struct statusCodeStruct
58 | {
59 | int code_value;
60 | std::string code_phrase;
61 |
62 | statusCodeStruct(int code_value,std::string code_phrase) :
63 | code_value(code_value), code_phrase(code_phrase){}
64 | } statusCode;
65 |
66 | /**
67 | * @brief http_status_code_list
68 | * list of status code / code phrase
69 | */
70 | static std::vector http_status_code_list;
71 |
72 | /**
73 | * @brief static_init
74 | * list of status code is statically stored : this must be called only once to avoid doublons (TODO : check if there is another way)
75 | */
76 | static void static_init(){
77 | http_status_code_list.push_back(statusCodeStruct(100, "Continue" ));
78 | http_status_code_list.push_back(statusCodeStruct(101, "Switching Protocols" ));
79 | http_status_code_list.push_back(statusCodeStruct(200, "OK" ));
80 | http_status_code_list.push_back(statusCodeStruct(201, "Created" ));
81 | http_status_code_list.push_back(statusCodeStruct(202, "Accepted" ));
82 | http_status_code_list.push_back(statusCodeStruct(203, "Non-Authoritative Information" ));
83 | http_status_code_list.push_back(statusCodeStruct(204, "No Content" ));
84 | http_status_code_list.push_back(statusCodeStruct(205, "Reset Content" ));
85 | http_status_code_list.push_back(statusCodeStruct(206, "Partial Content" ));
86 | http_status_code_list.push_back(statusCodeStruct(300, "Multiple Choices" ));
87 | http_status_code_list.push_back(statusCodeStruct(301, "Moved Permanently" ));
88 | http_status_code_list.push_back(statusCodeStruct(302, "Found" ));
89 | http_status_code_list.push_back(statusCodeStruct(303, "See Other" ));
90 | http_status_code_list.push_back(statusCodeStruct(304, "Not Modified" ));
91 | http_status_code_list.push_back(statusCodeStruct(305, "Use Proxy" ));
92 | http_status_code_list.push_back(statusCodeStruct(307, "Temporary Redirect" ));
93 | http_status_code_list.push_back(statusCodeStruct(400, "Bad Request" ));
94 | http_status_code_list.push_back(statusCodeStruct(401, "Unauthorized" ));
95 | http_status_code_list.push_back(statusCodeStruct(402, "Payment Required" ));
96 | http_status_code_list.push_back(statusCodeStruct(403, "Forbidden" ));
97 | http_status_code_list.push_back(statusCodeStruct(404, "Not Found" ));
98 | http_status_code_list.push_back(statusCodeStruct(405, "Method Not Allowed" ));
99 | http_status_code_list.push_back(statusCodeStruct(406, "Not Acceptable" ));
100 | http_status_code_list.push_back(statusCodeStruct(407, "Proxy Authentication Required" ));
101 | http_status_code_list.push_back(statusCodeStruct(408, "Request Time-out" ));
102 | http_status_code_list.push_back(statusCodeStruct(409, "Conflict" ));
103 | http_status_code_list.push_back(statusCodeStruct(410, "Gone" ));
104 | http_status_code_list.push_back(statusCodeStruct(411, "Length Required" ));
105 | http_status_code_list.push_back(statusCodeStruct(412, "Precondition Failed" ));
106 | http_status_code_list.push_back(statusCodeStruct(413, "Request Entity Too Large" ));
107 | http_status_code_list.push_back(statusCodeStruct(414, "Request-URI Too Large" ));
108 | http_status_code_list.push_back(statusCodeStruct(415, "Unsupported Media Type" ));
109 | http_status_code_list.push_back(statusCodeStruct(416, "Requested range not satisfiable" ));
110 | http_status_code_list.push_back(statusCodeStruct(417, "Expectation Failed" ));
111 | http_status_code_list.push_back(statusCodeStruct(500, "Internal Server Error" ));
112 | http_status_code_list.push_back(statusCodeStruct(501, "Not Implemented" ));
113 | http_status_code_list.push_back(statusCodeStruct(502, "Bad Gateway" ));
114 | http_status_code_list.push_back(statusCodeStruct(503, "Service Unavailable" ));
115 | http_status_code_list.push_back(statusCodeStruct(504, "Gateway Time-out" ));
116 | http_status_code_list.push_back(statusCodeStruct(505, "HTTP Version not supported" ));
117 | }
118 | };
119 |
120 | #endif // HTTPCONSTANTS_H
121 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/protocol/http/httpdecoder.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | HttpDecoder.h
26 | HTTP Decoder main class
27 | Will decode according to CRLF presence or add data to http consumer buffer
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef HTTPDECODER_H
33 | #define HTTPDECODER_H
34 |
35 | #include "protocol/inter/http/httpconsumer.h"
36 | #include "QByteArray"
37 |
38 | /**
39 | * @brief The HttpDecoder class
40 | *
41 | * Http decoder main input class
42 | */
43 | class httpdecoder
44 | {
45 |
46 | public :
47 |
48 | httpdecoder();
49 |
50 | /**
51 | * @brief httpDecode
52 | * http decoder
53 | *
54 | * @param consumer
55 | * http client consumer featuring connection monitoring
56 | * @param data
57 | * non-blocking or blocking data stream
58 | */
59 | void httpdecode(httpconsumer * consumer,QByteArray* data);
60 |
61 | };
62 |
63 | #endif // HTTPDECODER_H
64 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/protocol/http/httpdecoder_global.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | httpdecoder_global.h
26 | This will make access this library to QLibrary (no need to access header and lib)
27 |
28 | @author Bertrand Martel
29 | @version 1.0
30 | */
31 | #ifndef HTTPDECODER_GLOBAL_H
32 | #define HTTPDECODER_GLOBAL_H
33 |
34 | #include
35 |
36 | #if defined(HTTPDECODER_LIBRARY)
37 | # define HTTPDECODERSHARED_EXPORT Q_DECL_EXPORT
38 | #else
39 | # define HTTPDECODERSHARED_EXPORT Q_DECL_IMPORT
40 | #endif
41 |
42 | #endif // HTTPDECODER_GLOBAL_H
43 |
--------------------------------------------------------------------------------
/digest-auth-session-lib/libs/protocol/http/httpparser.h:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Bertrand Martel
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | /**
25 | httpparser.h
26 | HTTP Parser
27 | Will parse streaming data through parseHttp() method
28 |
29 | @author Bertrand Martel
30 | @version 1.0
31 | */
32 | #ifndef HTTPPARSER_H
33 | #define HTTPPARSER_H
34 | #include
35 | #include