Skip to content

Commit

Permalink
Merge pull request #715 from haiwen/changed_single_sign_on
Browse files Browse the repository at this point in the history
Changed single sign on
  • Loading branch information
freeplant authored Nov 25, 2017
2 parents c6ef1f6 + 9cb3ddc commit c7c1480
Show file tree
Hide file tree
Showing 34 changed files with 109 additions and 561 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
android:label="@string/app_name">
</activity>

<activity android:name=".account.ui.ShibbolethActivity"
<activity android:name=".account.ui.SingleSignOnActivity"
android:label="@string/app_name">
</activity>

<activity android:name=".account.ui.ShibbolethAuthorizeActivity"
<activity android:name=".account.ui.SingleSignOnAuthorizeActivity"
android:label="@string/app_name">
</activity>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class SeafileAuthenticatorActivity extends BaseAuthenticatorActivity {

public static final int SEACLOUD_CC = 0;
public static final int SHIBBOLETH_LOGIN = 1;
public static final int SINGLE_SIGN_ON_LOGIN = 1;
public static final int OTHER_SERVER = 2;

public final static String ARG_ACCOUNT_TYPE = "ACCOUNT_TYPE";
Expand Down Expand Up @@ -69,8 +69,8 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
intent.putExtra(SeafileAuthenticatorActivity.ARG_SERVER_URI, getString(R.string.server_url_seacloud));
startActivityForResult(intent, SeafileAuthenticatorActivity.REQ_SIGNUP);
break;
case SHIBBOLETH_LOGIN:
intent = new Intent(SeafileAuthenticatorActivity.this, ShibbolethActivity.class);
case SINGLE_SIGN_ON_LOGIN:
intent = new Intent(SeafileAuthenticatorActivity.this, SingleSignOnActivity.class);
intent.putExtras(getIntent());
startActivityForResult(intent, SeafileAuthenticatorActivity.REQ_SIGNUP);
break;
Expand All @@ -88,9 +88,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
mAccountManager = AccountManager.get(getBaseContext());

if (getIntent().getBooleanExtra(ARG_SHIB, false)) {
Intent intent = new Intent(this, ShibbolethAuthorizeActivity.class);
Intent intent = new Intent(this, SingleSignOnAuthorizeActivity.class);
android.accounts.Account account = new android.accounts.Account(getIntent().getStringExtra(SeafileAuthenticatorActivity.ARG_ACCOUNT_NAME), com.seafile.seadroid2.account.Account.ACCOUNT_TYPE);
intent.putExtra(ShibbolethActivity.SHIBBOLETH_SERVER_URL, mAccountManager.getUserData(account, Authenticator.KEY_SERVER_URI));
intent.putExtra(SingleSignOnActivity.SINGLE_SIGN_ON_SERVER_URL, mAccountManager.getUserData(account, Authenticator.KEY_SERVER_URI));
intent.putExtras(getIntent().getExtras());
startActivityForResult(intent, SeafileAuthenticatorActivity.REQ_SIGNUP);
} else if (getIntent().getBooleanExtra(ARG_IS_EDITING, false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
import com.seafile.seadroid2.ui.activity.BaseActivity;

/**
* Shibboleth welcome page
* Single Sign-On welcome page
* <p/>
*/
public class ShibbolethActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener {
public static final String DEBUG_TAG = "ShibbolethActivity";
public class SingleSignOnActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener {
public static final String DEBUG_TAG = "SingleSignOnActivity";

public static final String SHIBBOLETH_SERVER_URL = "shibboleth server url";
public static final String SHIBBOLETH_HTTPS_PREFIX = "https://";
public static final String SINGLE_SIGN_ON_SERVER_URL = "single sign on server url";
public static final String SINGLE_SIGN_ON_HTTPS_PREFIX = "https://";

private Button mNextBtn;
private EditText mServerUrlEt;

private static final int SHIBBOLETH_AUTH = 1;
private static final int SINGLE_SIGN_ON_AUTH = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.shibboleth_welcome_layout);
mNextBtn = (Button) findViewById(R.id.shibboleth_next_btn);
mServerUrlEt = (EditText) findViewById(R.id.shibboleth_server_url_et);
setContentView(R.layout.single_sign_on_welcome_layout);
mNextBtn = (Button) findViewById(R.id.single_sign_on_next_btn);
mServerUrlEt = (EditText) findViewById(R.id.single_sign_on_server_url_et);

mServerUrlEt.setText(SHIBBOLETH_HTTPS_PREFIX);
int prefixLen = SHIBBOLETH_HTTPS_PREFIX.length();
mServerUrlEt.setText(SINGLE_SIGN_ON_HTTPS_PREFIX);
int prefixLen = SINGLE_SIGN_ON_HTTPS_PREFIX.length();
mServerUrlEt.setSelection(prefixLen, prefixLen);

mNextBtn.setOnClickListener(new View.OnClickListener() {
Expand All @@ -52,7 +52,7 @@ public void onClick(View v) {
toolbar.setOnMenuItemClickListener(this);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.shib_actionbar_title);
getSupportActionBar().setTitle(R.string.shib_login_title);
}

@Override
Expand All @@ -76,7 +76,7 @@ private boolean isServerUrlValid(String serverUrl) {
return false;
}

if (!serverUrl.startsWith(SHIBBOLETH_HTTPS_PREFIX)) {
if (!serverUrl.startsWith(SINGLE_SIGN_ON_HTTPS_PREFIX)) {
showShortToast(this, getString(R.string.shib_server_incorrect_prefix));
return false;
}
Expand All @@ -90,18 +90,18 @@ private String getServerUrl() {
}

private void openAuthorizePage(String serverUrl) {
Intent intent = new Intent(ShibbolethActivity.this, ShibbolethAuthorizeActivity.class);
intent.putExtra(SHIBBOLETH_SERVER_URL, serverUrl);
Intent intent = new Intent(SingleSignOnActivity.this, SingleSignOnAuthorizeActivity.class);
intent.putExtra(SINGLE_SIGN_ON_SERVER_URL, serverUrl);
intent.putExtras(getIntent());
startActivityForResult(intent, SHIBBOLETH_AUTH);
startActivityForResult(intent, SINGLE_SIGN_ON_AUTH);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(DEBUG_TAG, "onActivityResult");

// pass auth result back to the SeafileAuthenticatorActivity
if (requestCode == SHIBBOLETH_AUTH) {
if (requestCode == SINGLE_SIGN_ON_AUTH) {
setResult(resultCode, data);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import java.security.cert.X509Certificate;

/**
* Shibboleth Authorize page
* Single sign on Authorize page
* use cookie to get authorized data
* <p/>
*/
public class ShibbolethAuthorizeActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener {
public static final String DEBUG_TAG = "ShibbolethAuthorizeActivity";
public class SingleSignOnAuthorizeActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener {
public static final String DEBUG_TAG = "SingleSignOnAuthorizeActivity";

public static final String SEAHUB_SHIB_COOKIE_NAME = "seahub_auth";
private WebView mWebview;
Expand All @@ -50,9 +50,9 @@ public class ShibbolethAuthorizeActivity extends BaseActivity implements Toolbar
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shibboleth_authorize_layout);
mWebview = (WebView) findViewById(R.id.shibboleth_authorize_wv);
mloadingAnimation = (LinearLayout) findViewById(R.id.shibboleth_loading_ll);
setContentView(R.layout.single_sign_on_authorize_layout);
mWebview = (WebView) findViewById(R.id.single_sign_on_authorize_wv);
mloadingAnimation = (LinearLayout) findViewById(R.id.single_sign_on_loading_ll);

mWebview.getSettings().setLoadsImagesAutomatically(true);
mWebview.getSettings().setJavaScriptEnabled(true);
Expand All @@ -65,9 +65,9 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
toolbar.setOnMenuItemClickListener(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.shib_actionbar_title);
getSupportActionBar().setTitle(R.string.shib_login_title);

String url = getIntent().getStringExtra(ShibbolethActivity.SHIBBOLETH_SERVER_URL);
String url = getIntent().getStringExtra(SingleSignOnActivity.SINGLE_SIGN_ON_SERVER_URL);
CookieManager.getInstance().removeAllCookie();
openAuthorizePage(url);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ class CustomWebviewClient extends WebViewClient {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
// Display error messages
showShortToast(ShibbolethAuthorizeActivity.this,
showShortToast(SingleSignOnAuthorizeActivity.this,
String.format((R.string.shib_load_page_error) + description));

showPageLoading(false);
Expand Down Expand Up @@ -239,7 +239,7 @@ private void returnAccount(Account account) {
retData.putExtra(SeafileAuthenticatorActivity.ARG_SHIB, account.isShib());
retData.putExtra(SeafileAuthenticatorActivity.ARG_SERVER_URI, account.getServer());

// pass auth result back to the ShibbolethActivity
// pass auth result back to the SingleSignOnActivity
setResult(RESULT_OK, retData);
finish();
}
Expand Down
56 changes: 0 additions & 56 deletions app/src/main/res/layout/shibboleth_welcome_layout.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_actionbar" /> <!-- placeholder, empty except on L -->
<LinearLayout android:id="@+id/shibboleth_loading_ll"
<LinearLayout android:id="@+id/single_sign_on_loading_ll"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -24,7 +24,7 @@

</LinearLayout>

<WebView android:id="@+id/shibboleth_authorize_wv"
<WebView android:id="@+id/single_sign_on_authorize_wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
Expand Down
47 changes: 47 additions & 0 deletions app/src/main/res/layout/single_sign_on_welcome_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_actionbar"/><!-- placeholder, empty except on L -->

<android.support.design.widget.TextInputLayout
android:id="@+id/server_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">

<EditText
android:id="@+id/single_sign_on_server_url_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/et_margin_left"
android:layout_marginRight="@dimen/et_margin_right"
android:background="@drawable/edit_text_holo_light"
android:hint="@string/server_hint"
android:inputType="textUri"/>

</android.support.design.widget.TextInputLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:layout_marginTop="15dp">

<Button
android:id="@+id/single_sign_on_next_btn"
android:layout_width="match_parent"
android:layout_height="@dimen/long_btn_height"
android:layout_marginLeft="@dimen/long_btn_margin_left"
android:layout_marginRight="@dimen/long_btn_margin_right"
android:onClick="login"
android:text="@string/lockpattern_continue_button_text"
android:textColor="@color/white"
android:textSize="@dimen/long_btn_txt_size"/>
</LinearLayout>

</LinearLayout>
5 changes: 1 addition & 4 deletions app/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,9 @@
<string name="saf_file_not_downloaded_exception">Nelze stáhnout soubor %s ze serveru.</string>
<string name="saf_write_diretory_exception">Nelze otevřít složku pro čtení/zápis.</string>
<string name="saf_account_not_found_exception">Nelze nalézt Seafile účet.</string>
<!--shibboleth SSO-->
<!--Single sign on SSO-->
<string name="shib_server_url_empty">Zadejte adresu serveru!</string>
<string name="shib_load_page_error">Chyba:</string>
<string name="shib_login_title">Shibboleth Login</string>
<string name="shib_server_hint">Zadejte server...</string>
<string name="shib_actionbar_title">Přihlásit pomocí Shibboleth</string>
<string name="shib_loading">načítání...</string>
<!--Transfer List-->
<string name="transfer_list_network_error">Chyba připojení k síti. Prosím, zkuste to později!</string>
Expand Down
12 changes: 2 additions & 10 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="delete_account">Löschen</string>
<string name="delete">Löschen</string>
<string name="delete_repo">Möchten Sie die Bibliothek wirklich löschen?</string>
<string name="delete_file">Diese Datei oder diesen Ordner wirklich löschen?</string>
<string name="delete_file">Möchten Sie die Datei oder den Ordner wirklich löschen?</string>
<string name="delete_successful">Erfolgreich gelöscht</string>
<string name="delete_repo_title">Bibliothek löschen</string>
<string name="delete_file_f">Datei löschen</string>
Expand Down Expand Up @@ -41,11 +41,6 @@
<item>Andere</item>
</string-array>
<string name="choose_server">Bitte wählen Sie einen Seafile-Server aus</string>
<string-array name="choose_server_array">
<item>SeaCloud.cc</item>
<item>Shibboleth-Login</item>
<item>Anderer Seafile-Server</item>
</string-array>
<string name="network_down">Keine Netzwerkverbindung</string>
<string name="unknow_error">Unbekannter Fehler</string>
<string name="invalid_server_address">Die Serveradresse ist nicht gültig</string>
Expand Down Expand Up @@ -418,13 +413,10 @@ Zum Aktualisieren einmal antippen</string>
<string name="saf_failed_to_create_directory">Konnte Ordner %s nicht erstellen</string>
<string name="saf_file_exist">Die Datei ist schon vorhanden</string>
<string name="saf_bad_mime_type">Ungültige Anforderungsart</string>
<!--shibboleth SSO-->
<!--Single sign on SSO-->
<string name="shib_server_url_empty">Geben Sie die Serveradresse an</string>
<string name="shib_server_incorrect_prefix">Die Serveradresse sollte mit https:// beginnen</string>
<string name="shib_load_page_error">Fehler:</string>
<string name="shib_login_title">Shibboleth-Anmeldung</string>
<string name="shib_server_hint">Server eintragen …</string>
<string name="shib_actionbar_title">Mit Shibboleth anmelden</string>
<string name="shib_loading">Lade…</string>
<!--Transfer List-->
<string name="transfer_list_network_error">Problem bei der Netzwerkverbindung. Bitte versuchen Sie es später nochmal!</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<!--storage access framework-->
<string name="saf_file_not_downloaded_exception">Δεν ήταν δυνατή η λήψη του αρχείου %s από το διακομιστή.</string>
<string name="saf_upload_path_not_available">Αποτυχία μεταφόρτωσης, δεν υπάρχει η διαδρομή</string>
<!--shibboleth SSO-->
<!--Single Sign-On SSO-->
<!--Transfer List-->
<string name="transfer_tabs_downloads">Λίστα λήψεων</string>
<string name="transfer_tabs_uploads">Λίστα μεταφορτώσεων</string>
Expand Down
Loading

0 comments on commit c7c1480

Please sign in to comment.