|
|
@@ -122,6 +122,8 @@ class Atlas:
|
|
|
self.code_challenge = None
|
|
|
self.Agrimail = None
|
|
|
self.loadedInMemory = False
|
|
|
+ self.liferayServer = None
|
|
|
+ self.laymanServer = None
|
|
|
self.uri = 'http://layman.lesprojekt.cz/rest/'
|
|
|
# global dlgGetLayers
|
|
|
self.dlgGetLayers= GetLayersDialog()
|
|
|
@@ -537,8 +539,13 @@ class Atlas:
|
|
|
if len(config['DEFAULT']['login']) > 0:
|
|
|
self.Agrimail = config['DEFAULT']['login']
|
|
|
self.dlg.pushButton_Connect.setEnabled(True)
|
|
|
- self.dlg.lineEdit_userName.setText(config['DEFAULT']['login'] + "@lesprojekt.cz")
|
|
|
- self.dlg.lineEdit_AgriID.setText(config['DEFAULT']['id'])
|
|
|
+ self.dlg.lineEdit_userName.setText(config['DEFAULT']['login'] + "@lesprojekt.cz")
|
|
|
+ try:
|
|
|
+ self.dlg.lineEdit_AgriID.setText(config['DEFAULT']['id'])
|
|
|
+ self.dlg.lineEdit_server.setText(config['DEFAULT']['server'])
|
|
|
+ self.dlg.lineEdit_serverLayman.setText(config['DEFAULT']['layman'])
|
|
|
+ except:
|
|
|
+ print("udaj v ini nenalezen")
|
|
|
else:
|
|
|
try:
|
|
|
os.makedirs(os.getenv("HOME") + os.sep + ".layman")
|
|
|
@@ -2077,7 +2084,7 @@ class Atlas:
|
|
|
#self.expires_in = 60
|
|
|
path = tempfile.gettempdir() + os.sep + "atlas" + os.sep + "tsts.txt"
|
|
|
i = 0
|
|
|
- tokenEndpoint = "https://www.agrihub.cz/o/oauth2/token"
|
|
|
+ tokenEndpoint = "https://www."+self.liferayServer+"/o/oauth2/token"
|
|
|
while (i < self.expires_in):
|
|
|
f = open(path, "a")
|
|
|
f.write(str(i))
|
|
|
@@ -2157,7 +2164,7 @@ class Atlas:
|
|
|
def getToken(self):
|
|
|
self.saveIni()
|
|
|
|
|
|
- tokenEndpoint = "https://www.agrihub.cz/o/oauth2/token"
|
|
|
+ tokenEndpoint = "https://www."+self.liferayServer+"/o/oauth2/token"
|
|
|
# data to be sent to api
|
|
|
data = {'grant_type':'authorization_code',
|
|
|
'client_id': self.client_id,
|
|
|
@@ -2195,7 +2202,7 @@ class Atlas:
|
|
|
def setAuthHeader(self):
|
|
|
self.authHeader ={
|
|
|
"Authorization": "Bearer " + self.access_token,
|
|
|
- "AuthorizationIssUrl" : 'https://www.agrihub.cz/o/oauth2/authorize'
|
|
|
+ "AuthorizationIssUrl" : 'https://www.'+self.liferayServer+'/o/oauth2/authorize'
|
|
|
}
|
|
|
|
|
|
def registerUserIfNotExists(self):
|
|
|
@@ -2227,12 +2234,13 @@ class Atlas:
|
|
|
#API_ENDPOINT = "http://layman.lesprojekt.cz/rest/current-user"
|
|
|
#headers ={
|
|
|
# "Authorization": "Bearer "+ self.access_token,
|
|
|
- # "AuthorizationIssUrl" : 'https://www.agrihub.cz/o/oauth2/authorize'
|
|
|
+ # "AuthorizationIssUrl" : 'https://www.'+self.liferayServer+'/o/oauth2/authorize'
|
|
|
#}
|
|
|
|
|
|
|
|
|
def openAuthLiferayUrl(self):
|
|
|
-
|
|
|
+ self.liferayServer = self.dlg.lineEdit_server.text()
|
|
|
+ self.URI = self.dlg.lineEdit_serverLayman.text()
|
|
|
self.getCodeChallenge(self.getCodeVerifier()) ##generování kódů
|
|
|
self.client_id = self.dlg.lineEdit_AgriID.text()
|
|
|
path = tempfile.gettempdir() + os.sep + "atlas" + os.sep + "auth.txt"
|
|
|
@@ -2247,7 +2255,7 @@ class Atlas:
|
|
|
thread = StartFlaskDaemon()
|
|
|
thread.daemon = True
|
|
|
thread.start()
|
|
|
- url = 'https://www.agrihub.cz/o/oauth2/authorize?response_type=code&client_id='+self.client_id+'&redirect_uri=http%3A%2F%2Flocalhost:3000%2Fclient%2Fauthn%2Foauth2-liferay%2Fcallback&code_challenge='+self.code_challenge ##n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg'
|
|
|
+ url = 'https://www.'+self.liferayServer+'/o/oauth2/authorize?response_type=code&client_id='+self.client_id+'&redirect_uri=http%3A%2F%2Flocalhost:3000%2Fclient%2Fauthn%2Foauth2-liferay%2Fcallback&code_challenge='+self.code_challenge ##n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg'
|
|
|
webbrowser.open(url, new=2)
|
|
|
|
|
|
def saveIni(self):
|
|
|
@@ -2259,8 +2267,12 @@ class Atlas:
|
|
|
except OSError:
|
|
|
print ("vytváření adresáře selhalo")
|
|
|
config = configparser.ConfigParser()
|
|
|
+
|
|
|
config['DEFAULT']['login'] = self.Agrimail
|
|
|
config['DEFAULT']['id'] = self.client_id
|
|
|
+ print("saveliferay" + self.liferayServer)
|
|
|
+ config['DEFAULT']['server'] = self.liferayServer
|
|
|
+ config['DEFAULT']['layman'] = self.URI
|
|
|
|
|
|
|
|
|
with open(file, 'w') as configfile:
|