1. hurou927

    No comment

    hurou927
Changes in body
Source | HTML | Preview
@@ -1,89 +1,93 @@
Python script for HINET login without SSO/logout (Hiroshima-univ)
Pythonとseleniumの練習のために
広島大学の非SSO認証のログインとログアウトを端末上で行うための
プログラムを書いた
- SSO認証には対応できなかった
- 需要なし
- ターミナル用
- X11 Forwarding使いたくない時用
ログイン(login)
```
./nsso.py login
```
ログアウト(logout)
```
./nsso.py logout
```
X11 Forwarding使いたくないなら
```
DISPLAY=unix:0.0 ./nsso.py login
```
とか...
```Python:nsso.py
-#!/usr/bin/env python
+#!/usr/bin/env python2
# coding: utf-8
# program for Only "without SSO" !!!!!!
-from selenium import webdriver
-from selenium.webdriver.common.by import By
+#sudo pip install selenium
+
+from selenium import webdriver
+from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
-from selenium.webdriver.support.ui import Select
-from selenium.common.exceptions import NoSuchElementException
+from selenium.webdriver.support.ui import Select
+from selenium.common.exceptions import NoSuchElementException
-from getpass import getpass
+from getpass import getpass
import sys
-import re
+#import re
-def logout(webdriver):
+# https://idp.media.hiroshima-u.ac.jp/idp/Authn/UserPassword
+# https://hinet.hiroshima-u.ac.jp/loginweb.html
+def logout(browser):
try:
browser.get('https://hinet.hiroshima-u.ac.jp/cgi-bin/Logout.cgi')
browser.close()
print "logout success!"
except:
print "ERROR!!!"
browser.close()
-def without_sso_login(webdriver):
+def without_sso_login(browser):
try:
browser.get('https://hinet.hiroshima-u.ac.jp/login_frame.html')
username = raw_input("Username :")
password = getpass( "Password :")
browser.find_element(By.NAME,"uid").send_keys(username)
browser.find_element(By.NAME,"pwd").send_keys(password)
#raw_input("y:")
browser.find_element_by_xpath("//input[@type='submit']").click()
page=browser.page_source
if page.count("Login succeeded") >= 1 :
print "login success!"
else:
print "login filure..."
browser.close()
except:
print "ERROR!!!"
browser.close()
if __name__ == '__main__':
param = sys.argv
print "login : [./nsso.py] or [./nsso.py login]"
print "logout: [./nsso.py logout]"
- # print "SSO :https://idp.media.hiroshima-u.ac.jp/idp/Authn/UserPassword"
- # print "Not SSO:https://hinet.hiroshima-u.ac.jp/loginweb.html"
- # print " ---> https://hinet.hiroshima-u.ac.jp/login_frame.html"
+ print "SSO :https://idp.media.hiroshima-u.ac.jp/idp/Authn/UserPassword"
+ print "Not SSO:https://hinet.hiroshima-u.ac.jp/loginweb.html"
+ print " ---> https://hinet.hiroshima-u.ac.jp/login_frame.html"
browser = webdriver.Firefox()
if len(param) == 2 and param[1]=="logout":
print "=======LOGOUT========="
- logout(webdriver)
+ logout(browser)
print "======= END ========="
elif (len(param)==2 and param[1]=="login") or len(param)==1:
print "=======LOGIN========="
without_sso_login(browser)
print "======= END ========="
```