auth: Split the authentication code into one file per class
This commit is contained in:
parent
74f873e219
commit
1347876255
|
@ -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>
|
||||
|
|
|
@ -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).
|
||||
]
|
||||
]
|
|
@ -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'>
|
|
@ -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"
|
||||
]
|
||||
]
|
||||
|
Reference in New Issue