1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef NL_SECURITY_CHECK_H
21 #define NL_SECURITY_CHECK_H
23 #include "nel/misc/types_nl.h"
24 #include "nel/net/login_cookie.h"
25 #include "nel/misc/md5.h"
26 #include "game_share/r2_basic_types.h"
35 CSecurityCode() : AsNum(0) {}
36 void serial( NLMISC::IStream
& s
) { s
.serial(AsNum
); } // dependency on msg.xml:CLIENT_QUIT_REQUEST format
44 friend class CSecurityCheckForFastDisconnection
;
45 friend bool operator!=( const CSecurityCode
& sc1
, const CSecurityCode
& sc2
);
48 inline bool operator!=( const CSecurityCode
& sc1
, const CSecurityCode
& sc2
)
50 return sc1
.AsNum
!= sc2
.AsNum
;
55 * CSecurityCheckForFastDisconnection
57 class CSecurityCheckForFastDisconnection
60 /// Default constructor
61 CSecurityCheckForFastDisconnection();
62 /// Set session (or can be set by receiveSecurityCode())
63 void setSessionId(TSessionId sessionId
) { Block
.SessionId
= sessionId
; }
65 void setCookie(const NLNET::CLoginCookie
& cookie
) { Block
.Cookie
.set(cookie
.getUserAddr(), cookie
.getUserKey(), cookie
.getUserId()); } // don't use the default generated bitwise assignment operator, because of padding junk that would be copied
66 /// Return the security code
67 CSecurityCode
encode(const char *passPhrase
);
68 /// Check the security code
69 void check(const char *passPhrase
);
71 /// Read some data from stream
72 void receiveSecurityCode(NLMISC::IStream
& msgin
);
73 /// Write some data to stream
74 static void forwardSecurityCode(NLMISC::IStream
& msgout
, TSessionId sessionId
, CSecurityCode
& securityCode
);
80 NLNET::CLoginCookie Cookie
;
84 CSecurityCode SecurityCode
;
87 #endif // NL_SECURITY_CHECK_H
89 /* End of security_check.h */