@ -1647,258 +1647,6 @@ sub dev_cacert :Chained('/') :PathPart('device/autoprov/cacert') :Args(0) {
return ;
return ;
}
}
sub dev_static_jitsi_config :Chained('/') :PathPart('device/autoprov/static/jitsi') :Args(0) {
my ( $ self , $ c ) = @ _ ;
unless ( $ c - > req - > params - > { user } && $ c - > req - > params - > { pass } && $ c - > req - > params - > { uuid } ) {
$ c - > response - > content_type ( 'text/plain' ) ;
if ( $ c - > config - > { features } - > { debug } ) {
$ c - > response - > body ( "404 - user/pass/uuid triple not specified in params" ) ;
} else {
$ c - > response - > body ( "404 - missing config parameters" ) ;
}
$ c - > response - > status ( 404 ) ;
return ;
}
my $ uri = $ c - > req - > params - > { user } ;
my $ pass = $ c - > req - > params - > { pass } ;
my $ uuid = $ c - > req - > params - > { uuid } ;
my ( $ user , $ domain , $ tmp ) = split /\@/ , $ uri ;
if ( defined $ tmp ) {
$ user = $ user . '@' . $ domain ;
$ domain = $ tmp ;
}
unless ( $ user && $ domain ) {
$ c - > response - > content_type ( 'text/plain' ) ;
if ( $ c - > config - > { features } - > { debug } ) {
$ c - > response - > body ( "404 - user param not in format user\@domain" ) ;
} else {
$ c - > response - > body ( "404 - invalid user config parameters" ) ;
}
$ c - > response - > status ( 404 ) ;
return ;
}
my $ sub ;
if ( $ c - > config - > { deviceprovisioning } - > { softphone_webauth } ) {
my $ authrs = $ c - > model ( 'DB' ) - > resultset ( 'provisioning_voip_subscribers' ) - > search ( {
webusername = > $ user ,
'voip_subscriber.status' = > 'active' ,
'domain.domain' = > $ domain ,
'contract.status' = > 'active' ,
} , {
join = > [ 'domain' , 'contract' , 'voip_subscriber' ] ,
} ) ;
$ sub = $ authrs - > first ;
if ( defined $ sub ) {
my ( $ db_b64salt , $ db_b64hash ) = split /\$/ , $ sub - > webpassword ;
my $ salt = de_base64 ( $ db_b64salt ) ;
my $ usr_b64hash = en_base64 ( bcrypt_hash ( {
key_nul = > 1 ,
cost = > NGCP::Panel::Utils::Auth:: get_bcrypt_cost ( ) ,
salt = > $ salt ,
} , $ pass ) ) ;
unless ( $ usr_b64hash eq $ db_b64hash ) {
# wrong password
$ sub = undef ;
}
}
unless ( $ sub ) {
if ( $ c - > config - > { features } - > { debug } ) {
$ c - > response - > body ( "404 - webuser authentication failed" ) ;
} else {
$ c - > response - > body ( "404 - invalid user config parameters" ) ;
}
$ c - > response - > status ( 404 ) ;
return ;
}
$ user = $ sub - > username ;
$ pass = $ sub - > password ;
} else {
$ sub = $ c - > model ( 'DB' ) - > resultset ( 'provisioning_voip_subscribers' ) - > search ( {
username = > $ user ,
password = > $ pass ,
'voip_subscriber.status' = > 'active' ,
'domain.domain' = > $ domain ,
'contract.status' = > 'active' ,
} , {
join = > [ 'domain' , 'contract' , 'voip_subscriber' ] ,
} ) - > first ;
unless ( $ sub ) {
if ( $ c - > config - > { features } - > { debug } ) {
$ c - > response - > body ( "404 - sipuser authentication failed" ) ;
} else {
$ c - > response - > body ( "404 - invalid user config parameters" ) ;
}
$ c - > response - > status ( 404 ) ;
return ;
}
}
my $ jitsi_prov ;
my $ jitsi_prov_usr = NGCP::Panel::Utils::Preferences:: get_usr_preference_rs (
c = > $ c ,
prov_subscriber = > $ sub ,
attribute = > 'softphone_autoprov' ,
) ;
my $ jitsi_prov_dom = NGCP::Panel::Utils::Preferences:: get_dom_preference_rs (
c = > $ c ,
prov_domain = > $ sub - > domain ,
attribute = > 'softphone_autoprov' ,
) ;
my $ jitsi_prov_prof ;
if ( $ sub - > voip_subscriber_profile ) {
$ jitsi_prov_prof = NGCP::Panel::Utils::Preferences:: get_prof_preference_rs (
c = > $ c ,
profile = > $ sub - > voip_subscriber_profile ,
attribute = > 'softphone_autoprov' ,
) ;
}
if ( $ jitsi_prov_usr - > first && $ jitsi_prov_usr - > first - > value ) {
$ jitsi_prov = 1 ;
} elsif ( $ jitsi_prov_prof && $ jitsi_prov_prof - > first && $ jitsi_prov_prof - > first - > value ) {
$ jitsi_prov = 1 ;
} elsif ( $ jitsi_prov_dom - > first && $ jitsi_prov_dom - > first - > value ) {
$ jitsi_prov = 1 ;
} else {
$ jitsi_prov = 0 ;
}
unless ( $ jitsi_prov ) {
if ( $ c - > config - > { features } - > { debug } ) {
$ c - > response - > body ( "403 - softphone auto provisioning disabled via softphone_autoprov preference" ) ;
} else {
$ c - > response - > body ( "403 - autoprov disabled" ) ;
}
$ c - > response - > status ( 403 ) ;
return ;
}
my $ sipacc = 'accsipngcp' . $ user . $ domain ;
my $ xmppacc = 'accxmppngcp' . $ user . $ domain ;
$ sipacc =~ s/[^a-zA-Z0-9]//g ;
$ xmppacc =~ s/[^a-zA-Z0-9]//g ;
my $ provserver = 'https\://' . $ c - > req - > uri - > host . '\:' . $ c - > req - > uri - > port .
'/device/autoprov/static/jitsi' ;
my $ server_ip ;
if ( defined $ c - > config - > { sip } - > { lb } ) {
if ( ref $ c - > config - > { sip } - > { lb } eq 'ARRAY' ) {
# if we have more lbs, pick a random one
$ server_ip = $ c - > config - > { sip } - > { lb } - > [ rand @ { $ c - > config - > { sip } - > { lb } } ] ;
} else {
$ server_ip = $ c - > config - > { sip } - > { lb } ;
}
} else {
$ server_ip = $ c - > req - > uri - > host ;
}
my $ server_port ;
my $ server_proto ;
$ server_port = $ c - > config - > { sip } - > { tls_port } // 5060 ;
$ server_proto = $ c - > config - > { sip } - > { tls_port } ? 'TLS' : 'UDP' ;
$ c - > log - > info ( "jitsiprov gathered required information, sipacc=" . $ c - > qs ( $ sipacc ) . ", xmppacc=" . $ c - > qs ( $ xmppacc ) ) ;
my $ config = << "EOF" ;
net . java . sip . communicator . plugin . provisioning . METHOD = Manual
net . java . sip . communicator . plugin . provisioning . URL = $ provserver ? user \ \= \ $ { username } & pass \ \= \ $ { password } & uuid \ \= \ $ { uuid }
net . java . sip . communicator . impl . protocol . sip . $ sipacc = $ sipacc
net . java . sip . communicator . impl . protocol . sip . $ sipacc . ACCOUNT_UID = SIP \ \ : $ user \ @$ domain
net . java . sip . communicator . impl . protocol . sip . $ sipacc . DEFAULT_ENCRYPTION = true
net . java . sip . communicator . impl . protocol . sip . $ sipacc . DEFAULT_SIPZRTP_ATTRIBUTE = true
net . java . sip . communicator . impl . protocol . sip . $ sipacc . DTMF_METHOD = AUTO_DTMF
net . java . sip . communicator . impl . protocol . sip . $ sipacc . DTMF_MINIMAL_TONE_DURATION = 70
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PASSWORD = $ pass
net . java . sip . communicator . impl . protocol . sip . $ sipacc . ENCRYPTION_PROTOCOL . ENCRYPTION_PROTOCOL . ZRTP = 0
net . java . sip . communicator . impl . protocol . sip . $ sipacc . ENCRYPTION_PROTOCOL_STATUS . ENCRYPTION_PROTOCOL_STATUS . ZRTP = true
net . java . sip . communicator . impl . protocol . sip . $ sipacc . FORCE_P2P_MODE = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . VOICEMAIL_CHECK_URI = sip \ \ : voicebox \ @$ domain
net . java . sip . communicator . impl . protocol . sip . $ sipacc . VOICEMAIL_URI =
net . java . sip . communicator . impl . protocol . sip . $ sipacc . IS_PRESENCE_ENABLED = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . KEEP_ALIVE_INTERVAL = 25
net . java . sip . communicator . impl . protocol . sip . $ sipacc . KEEP_ALIVE_METHOD = OPTIONS
net . java . sip . communicator . impl . protocol . sip . $ sipacc . OVERRIDE_ENCODINGS = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . POLLING_PERIOD = 30
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PROTOCOL_NAME = SIP
net . java . sip . communicator . impl . protocol . sip . $ sipacc . SAVP_OPTION = 0
net . java . sip . communicator . impl . protocol . sip . $ sipacc . SERVER_ADDRESS = $ domain
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PROXY_AUTO_CONFIG = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PROXY_ADDRESS = $ server_ip
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PROXY_PORT = $ server_port
net . java . sip . communicator . impl . protocol . sip . $ sipacc . PREFERRED_TRANSPORT = $ server_proto
net . java . sip . communicator . impl . protocol . sip . $ sipacc . SUBSCRIPTION_EXPIRATION = 3600
net . java . sip . communicator . impl . protocol . sip . $ sipacc . USER_ID = $ user \ @$ domain
net . java . sip . communicator . impl . protocol . sip . $ sipacc . XCAP_ENABLE = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . XIVO_ENABLE = false
net . java . sip . communicator . impl . protocol . sip . $ sipacc . cusax . XMPP_ACCOUNT_ID = $ xmppacc
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc = $ xmppacc
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ACCOUNT_UID = Jabber \ \ : $ user \ @$ domain \ @$ domain
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ALLOW_NON_SECURE = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . AUTO_DISCOVER_JINGLE_NODES = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . AUTO_DISCOVER_STUN = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . AUTO_GENERATE_RESOURCE = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . BYPASS_GTALK_CAPABILITIES = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . CALLING_DISABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . DEFAULT_ENCRYPTION = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . DEFAULT_SIPZRTP_ATTRIBUTE = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . DTMF_METHOD = AUTO_DTMF
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . DTMF_MINIMAL_TONE_DURATION = 70
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . PASSWORD = $ pass
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ENCRYPTION_PROTOCOL . SDES = 1
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ENCRYPTION_PROTOCOL . ZRTP = 0
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ENCRYPTION_PROTOCOL_STATUS . SDES = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ENCRYPTION_PROTOCOL_STATUS . ZRTP = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . GMAIL_NOTIFICATIONS_ENABLED = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . GOOGLE_CONTACTS_ENABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . GTALK_ICE_ENABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . ICE_ENABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . IS_PREFERRED_PROTOCOL = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . IS_SERVER_OVERRIDDEN = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . JINGLE_NODES_ENABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . OVERRIDE_ENCODINGS = false
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . OVERRIDE_PHONE_SUFFIX =
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . PROTOCOL_NAME = Jabber
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . RESOURCE = sipwise
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . RESOURCE_PRIORITY = 30
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . SDES_CIPHER_SUITES = AES_CM_128_HMAC_SHA1_80 , AES_CM_128_HMAC_SHA1_32
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . SERVER_ADDRESS = $ domain
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . SERVER_PORT = 5222
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . TELEPHONY_BYPASS_GTALK_CAPS =
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . UPNP_ENABLED = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . USER_ID = $ user \ @$ domain
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . USE_DEFAULT_STUN_SERVER = true
EOF
if ( $ c - > config - > { deviceprovisioning } - > { softphone_lockdown } ) {
$ config . = << "EOF" ;
net . java . sip . communicator . impl . protocol . sip . $ sipacc . IS_CALL_PARK_ENABLED = true
net . java . sip . communicator . impl . protocol . sip . $ sipacc . CALL_PARK_PREFIX_PROPERTY = * 97 *
net . java . sip . communicator . impl . protocol . sip . $ sipacc . IS_STATUS_MENU_HIDDEN = true
net . java . sip . communicator . impl . protocol . jabber . $ xmppacc . IS_STATUS_MENU_HIDDEN = true
net . java . sip . communicator . impl . gui . main . menus . AUTO_ANSWER_MENU_DISABLED = true
net . java . sip . communicator . impl . gui . main . configforms . SHOW_ACCOUNT_CONFIG = false
net . java . sip . communicator . plugin . generalconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . AUDIO_CONFIG_DISABLED = true
net . java . sip . communicator . impl . neomedia . VIDEO_CONFIG_DISABLED = true
net . java . sip . communicator . impl . neomedia . devicesconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . encodingsconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . videomoresettingsconfig . DISABLED = true
net . java . sip . communicator . plugin . securityconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . zrtpconfig . DISABLED = true
net . java . sip . communicator . plugin . securityconfig . masterpasswordconfig . DISABLED = true
net . java . sip . communicator . plugin . advancedconfig . DISABLED = true
net . java . sip . communicator . plugin . generalconfig . sipconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . callrecordingconfig . DISABLED = true
net . java . sip . communicator . impl . neomedia . h264config . DISABLED = true
net . java . sip . communicator . plugin . accountinfo . ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP = true
net . java . sip . communicator . plugin . connectioninfo . CONNECT_INFO_TOOLS_MENU_DISABLED_PROP = true
EOF
}
$ c - > response - > content_type ( 'text/plain' ) ;
$ c - > response - > body ( $ config ) ;
}
sub dev_field_firmware_base :Chained('/') :PathPart('device/autoprov/firmware') :CaptureArgs(1) {
sub dev_field_firmware_base :Chained('/') :PathPart('device/autoprov/firmware') :CaptureArgs(1) {
my ( $ self , $ c , $ id ) = @ _ ;
my ( $ self , $ c , $ id ) = @ _ ;