9191import com .owncloud .android .ui .dialog .SslUntrustedCertDialog ;
9292import com .owncloud .android .ui .dialog .SslUntrustedCertDialog .OnSslUntrustedCertListener ;
9393import com .owncloud .android .utils .DisplayUtils ;
94-
94+ import edu . umd . cs . findbugs . annotations . SuppressFBWarnings ;
9595import java .security .cert .X509Certificate ;
9696import java .util .Map ;
9797
@@ -142,6 +142,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
142142 private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS" ;
143143 public static final String PROTOCOL_SUFFIX = "://" ;
144144 public static final String LOGIN_URL_DATA_KEY_VALUE_SEPARATOR = ":" ;
145+ private static final String HTTPS_PROTOCOL = "https://" ;
146+ private static final String HTTP_PROTOCOL = "http://" ;
145147
146148 /// parameters from EXTRAs in starter Intent
147149 private byte mAction ;
@@ -167,7 +169,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
167169
168170 private boolean mServerIsChecked = false ;
169171 private boolean mServerIsValid = false ;
170- private boolean mPendingAutoCheck = false ;
171172
172173 private GetServerInfoOperation .ServerInfo mServerInfo = new GetServerInfoOperation .ServerInfo ();
173174
@@ -408,11 +409,11 @@ private void initServerPreFragment(Bundle savedInstanceState) {
408409 if (mAccount != null ) {
409410 mServerInfo .mBaseUrl = mAccountMgr .getUserData (mAccount , Constants .KEY_OC_BASE_URL );
410411 // TODO do next in a setter for mBaseUrl
411- mServerInfo .mIsSslConn = mServerInfo .mBaseUrl .startsWith ("https://" );
412+ mServerInfo .mIsSslConn = mServerInfo .mBaseUrl .startsWith (HTTPS_PROTOCOL );
412413 mServerInfo .mVersion = AccountUtils .getServerVersion (mAccount );
413414 } else {
414415 mServerInfo .mBaseUrl = getString (R .string .server_url ).trim ();
415- mServerInfo .mIsSslConn = mServerInfo .mBaseUrl .startsWith ("https://" );
416+ mServerInfo .mIsSslConn = mServerInfo .mBaseUrl .startsWith (HTTPS_PROTOCOL );
416417 }
417418 } else {
418419 mServerStatusText = savedInstanceState .getInt (KEY_SERVER_STATUS_TEXT );
@@ -492,24 +493,16 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
492493 findViewById (R .id .scroll ).setOnTouchListener (new OnTouchListener () {
493494 @ Override
494495 public boolean onTouch (View view , MotionEvent event ) {
495- if (event .getAction () == MotionEvent .ACTION_DOWN ) {
496- if (
497- AccountTypeUtils .getAuthTokenTypeSamlSessionCookie (
498- MainApp .getAccountType ()
499- ).equals (mAuthTokenType ) &&
500- mHostUrlInput .hasFocus ()
501- ) {
502- checkOcServer ();
503- }
496+ if (event .getAction () == MotionEvent .ACTION_DOWN &&
497+ AccountTypeUtils
498+ .getAuthTokenTypeSamlSessionCookie (MainApp
499+ .getAccountType ()).equals (mAuthTokenType ) &&
500+ mHostUrlInput .hasFocus ()) {
501+ checkOcServer ();
504502 }
505503 return false ;
506504 }
507505 });
508-
509-
510- /// step 4 - mark automatic check to be started when OperationsService is ready
511- mPendingAutoCheck = (savedInstanceState == null &&
512- (mAction != ACTION_CREATE || checkHostUrl ));
513506 }
514507
515508
@@ -1127,8 +1120,9 @@ private void onGetUserNameFinish(RemoteOperationResult result) {
11271120 }
11281121 }
11291122
1130- if (success )
1123+ if (success ) {
11311124 finish ();
1125+ }
11321126 } else {
11331127 updateStatusIconFailUserName ();
11341128 showAuthStatus ();
@@ -1197,14 +1191,15 @@ private boolean authSupported(AuthenticationMethod authMethod) {
11971191
11981192 // TODO remove, if possible
11991193 private String normalizeUrl (String url , boolean sslWhenUnprefixed ) {
1194+
12001195 if (url != null && url .length () > 0 ) {
12011196 url = url .trim ();
1202- if (!url .toLowerCase ().startsWith ("http://" ) &&
1203- !url .toLowerCase ().startsWith ("https://" )) {
1197+ if (!url .toLowerCase ().startsWith (HTTP_PROTOCOL ) &&
1198+ !url .toLowerCase ().startsWith (HTTP_PROTOCOL )) {
12041199 if (sslWhenUnprefixed ) {
1205- url = "https://" + url ;
1200+ url = HTTPS_PROTOCOL + url ;
12061201 } else {
1207- url = "http://" + url ;
1202+ url = HTTP_PROTOCOL + url ;
12081203 }
12091204 }
12101205
@@ -1259,7 +1254,7 @@ private void updateServerStatusIconAndText(RemoteOperationResult result) {
12591254
12601255 case OK_NO_SSL :
12611256 case OK :
1262- if (mHostUrlInput .getText ().toString ().trim ().toLowerCase ().startsWith ("http://" )) {
1257+ if (mHostUrlInput .getText ().toString ().trim ().toLowerCase ().startsWith (HTTP_PROTOCOL )) {
12631258 mServerStatusText = R .string .auth_connection_established ;
12641259 mServerStatusIcon = R .drawable .ic_ok ;
12651260 } else {
@@ -1340,7 +1335,7 @@ private void updateAuthStatusIconAndText(RemoteOperationResult result) {
13401335
13411336 case OK_NO_SSL :
13421337 case OK :
1343- if (mHostUrlInput .getText ().toString ().trim ().toLowerCase ().startsWith ("http://" )) {
1338+ if (mHostUrlInput .getText ().toString ().trim ().toLowerCase ().startsWith (HTTP_PROTOCOL )) {
13441339 mAuthStatusText = R .string .auth_connection_established ;
13451340 mAuthStatusIcon = R .drawable .ic_ok ;
13461341 } else {
@@ -1576,6 +1571,7 @@ private void updateAccountAuthentication() throws AccountNotFoundException {
15761571 *
15771572 * TODO Decide how to name the OAuth accounts
15781573 */
1574+ @ SuppressFBWarnings ("DMI" )
15791575 private boolean createAccount (RemoteOperationResult authResult ) {
15801576 /// create and save new ownCloud account
15811577 boolean isOAuth = AccountTypeUtils .
@@ -1782,11 +1778,10 @@ public boolean onEditorAction(TextView inputField, int actionId, KeyEvent event)
17821778 }
17831779
17841780 } else if (actionId == EditorInfo .IME_ACTION_NEXT && inputField != null &&
1785- inputField .equals (mHostUrlInput )) {
1786- if ( AccountTypeUtils .getAuthTokenTypeSamlSessionCookie (MainApp .getAccountType ()).
1787- equals (mAuthTokenType )) {
1781+ inputField .equals (mHostUrlInput ) &&
1782+ AccountTypeUtils .getAuthTokenTypeSamlSessionCookie (MainApp .getAccountType ()).
1783+ equals (mAuthTokenType )) {
17881784 checkOcServer ();
1789- }
17901785 }
17911786 return false ; // always return false to grant that the software keyboard is hidden anyway
17921787 }
@@ -1847,7 +1842,7 @@ public void onSsoFinished(String sessionCookie) {
18471842 mAuthToken = sessionCookie ;
18481843 getRemoteUserNameOperation (sessionCookie );
18491844 Fragment fd = getSupportFragmentManager ().findFragmentByTag (SAML_DIALOG_TAG );
1850- if (fd != null && fd instanceof DialogFragment ) {
1845+ if (fd instanceof DialogFragment ) {
18511846 Dialog d = ((DialogFragment ) fd ).getDialog ();
18521847 if (d != null && d .isShowing ()) {
18531848 d .dismiss ();
@@ -1950,7 +1945,7 @@ private void doOnResumeAndBound() {
19501945
19511946 private void dismissDialog (String dialogTag ) {
19521947 Fragment frag = getSupportFragmentManager ().findFragmentByTag (dialogTag );
1953- if (frag != null && frag instanceof DialogFragment ) {
1948+ if (frag instanceof DialogFragment ) {
19541949 DialogFragment dialog = (DialogFragment ) frag ;
19551950 dialog .dismiss ();
19561951 }
0 commit comments