diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-04-07 16:25:33 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-04-07 16:29:25 +0200 |
commit | 13478762551a635857b3030493d1db17ad994d21 (patch) | |
tree | c0e03b7e46a1752b187a465afc4e90483750de21 | |
parent | 74f873e2195c5c9f504928c7868f8a32be777c09 (diff) |
auth: Split the authentication code into one file per class
-rw-r--r-- | package.xml | 4 | ||||
-rw-r--r-- | src/auth/GSMAuthenticatorBase.st | 86 | ||||
-rw-r--r-- | src/auth/GSMIdentityAuthenticator.st (renamed from src/GSMAuthenticator.st) | 89 | ||||
-rw-r--r-- | src/auth/GSMNullAuthenticator.st | 37 |
4 files changed, 127 insertions, 89 deletions
diff --git a/package.xml b/package.xml index 19a7efb..559df90 100644 --- a/package.xml +++ b/package.xml @@ -11,7 +11,6 @@ <filein>src/BSCConfig.st</filein> <filein>src/BSCListener.st</filein> <filein>src/BSCSCCPHandler.st</filein> - <filein>src/GSMAuthenticator.st</filein> <filein>src/GSMProcessor.st</filein> <filein>src/GSMCMServiceRequest.st</filein> <filein>src/GSMLURequest.st</filein> @@ -22,6 +21,9 @@ <filein>src/call/Extensions.st</filein> <filein>src/call/GSMMOCall.st</filein> <filein>src/call/SIPMTCall.st</filein> + <filein>src/auth/GSMAuthenticatorBase.st</filein> + <filein>src/auth/GSMNullAuthenticator.st</filein> + <filein>src/auth/GSMIdentityAuthenticator.st</filein> <test> <sunit>OsmoMSC.HLRTest</sunit> diff --git a/src/auth/GSMAuthenticatorBase.st b/src/auth/GSMAuthenticatorBase.st new file mode 100644 index 0000000..350fefd --- /dev/null +++ b/src/auth/GSMAuthenticatorBase.st @@ -0,0 +1,86 @@ +" + (C) 2010-2012 by Holger Hans Peter Freyther + All Rights Reserved + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +" + +Object subclass: GSMAuthenticatorBase [ + | connection onAccept onReject | + <category: 'OsmoMSC-GSM-Auth'> + <comment: 'I am the base class for authenticating a given + subscriber. My subclasses can either allow everyone, store + the IMSI and IMEI or be fully GSM compliant and ask a HLR + for an authentication tuple. + When calling the callbacks make sure to go through the + connection>>#takeLocks: selector to take the required locks.'> + <import: OsmoGSM> + + LegalMessages := {OsmoGSM.GSM48CMServiceReq. + OsmoGSM.GSM48RRPagingResponse. + OsmoGSM.GSM48LURequest. + "As part of Local-Call-Routing deal with CC Setup" + OsmoGSM.GSM48CCSetup. + }. + + appropriateInitialMessage: aMsg [ + "Check if the message is one of the allowed initial messages." + ^ LegalMessages includes: aMsg class + ] + + connection: aCon [ + <category: 'creation'> + connection := aCon. + ] + + connection [ + <category: 'access'> + ^ connection + ] + + onAccept: aBlock [ + <category: 'creation'> + "Called when the connection is accepted" + onAccept := aBlock + ] + + onReject: aBlock [ + <category: 'creation'> + "Called when the connection is rejected" + onReject := aBlock + ] + + start: aMsg [ + <category: 'auth'> + "Start authentication with the initial message." + ^ self subclassResponsibility + ] + + onData: aMsg [ + <category: 'auth'> + "Called with data from the GSM connection" + ^ self subclassResponsibility + ] + + cancel [ + <category: 'auth'> + "The GSM Connection has failed cancel everything." + ^ self subclassResponsibility + ] + + nextPut: aMsg [ + connection nextPutData: (BSSAPDTAP initWith: aMsg + linkIdentifier: 0). + ] +] diff --git a/src/GSMAuthenticator.st b/src/auth/GSMIdentityAuthenticator.st index 4a3bcc9..217a488 100644 --- a/src/GSMAuthenticator.st +++ b/src/auth/GSMIdentityAuthenticator.st @@ -16,97 +16,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. " -Object subclass: GSMAuthenticatorBase [ - | connection onAccept onReject | - <category: 'OsmoMSC-GSM-Authentication'> - <comment: 'I am the base class for authenticating a given - subscriber. My subclasses can either allow everyone, store - the IMSI and IMEI or be fully GSM compliant and ask a HLR - for an authentication tuple. - When calling the callbacks make sure to go through the - connection>>#takeLocks: selector to take the required locks.'> - <import: OsmoGSM> - - LegalMessages := {OsmoGSM.GSM48CMServiceReq. - OsmoGSM.GSM48RRPagingResponse. - OsmoGSM.GSM48LURequest. - "As part of Local-Call-Routing deal with CC Setup" - OsmoGSM.GSM48CCSetup. - }. - - appropriateInitialMessage: aMsg [ - "Check if the message is one of the allowed initial messages." - ^ LegalMessages includes: aMsg class - ] - - connection: aCon [ - <category: 'creation'> - connection := aCon. - ] - - connection [ - <category: 'access'> - ^ connection - ] - - onAccept: aBlock [ - <category: 'creation'> - "Called when the connection is accepted" - onAccept := aBlock - ] - - onReject: aBlock [ - <category: 'creation'> - "Called when the connection is rejected" - onReject := aBlock - ] - - start: aMsg [ - <category: 'auth'> - "Start authentication with the initial message." - ^ self subclassResponsibility - ] - - onData: aMsg [ - <category: 'auth'> - "Called with data from the GSM connection" - ^ self subclassResponsibility - ] - - cancel [ - <category: 'auth'> - "The GSM Connection has failed cancel everything." - ^ self subclassResponsibility - ] - - nextPut: aMsg [ - connection nextPutData: (BSSAPDTAP initWith: aMsg - linkIdentifier: 0). - ] -] - -GSMAuthenticatorBase subclass: GSMNullAuthenticator [ - <category: 'OsmoMSC-GSM-Authentication'> - <comment: 'I accept everything...'> - - start: aMsg [ - (self appropriateInitialMessage: aMsg) - ifTrue: [onAccept value: self] - ifFalse: [onReject value: self]. - ] - - onData: aMsg [ - ^ self shouldNotImplement - ] - - cancel [ - "Nothing" - ] -] GSMAuthenticatorBase subclass: GSMIdentityAuthenticator [ | state timeout | - <category: 'OsmoMSC-GSM-Authentication'> + <category: 'OsmoMSC-GSM-Auth'> <comment: 'I query for the IMSI and IMEI but do this in an insecure way and will never switch on the crypto. I will ask for the IMSI and IMEI'> diff --git a/src/auth/GSMNullAuthenticator.st b/src/auth/GSMNullAuthenticator.st new file mode 100644 index 0000000..65b003c --- /dev/null +++ b/src/auth/GSMNullAuthenticator.st @@ -0,0 +1,37 @@ +" + (C) 2010-2012 by Holger Hans Peter Freyther + All Rights Reserved + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +" + +GSMAuthenticatorBase subclass: GSMNullAuthenticator [ + <category: 'OsmoMSC-GSM-Auth'> + <comment: 'I accept everything...'> + + start: aMsg [ + (self appropriateInitialMessage: aMsg) + ifTrue: [onAccept value: self] + ifFalse: [onReject value: self]. + ] + + onData: aMsg [ + ^ self shouldNotImplement + ] + + cancel [ + "Nothing" + ] +] + |