Following code can be used to get SAML token Id from SAML
//Calling method to display Token id from the SAML Reponse
view.loadUrl("javascript:window.HtmlViewer.showHTML(document.getElementsByName('SAMLResponse')[0].value);");
don't forget to use below inner class class MyJavaScriptInterface { private Context ctx; MyJavaScriptInterface(Context ctx) { this.ctx = ctx; } @JavascriptInterface public void showHTML(String html) { System.out.println("html>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>:"+html); new AlertDialog.Builder(ctx).setTitle("Token Id").setMessage(html) .setPositiveButton(android.R.string.ok, null).setCancelable(false).create().show(); } }
Please refer to the below files for complete code
1- MainActivity
import android.annotation.SuppressLint; import android.app.AlertDialog; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.Menu; import android.view.MenuItem; import android.view.inputmethod.InputMethodManager; import android.webkit.JavascriptInterface; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.view.KeyEvent; import android.view.MotionEvent; public class MainActivity extends AppCompatActivity { private long pageStartTime = 0; private WebView wv; private ImageButton newActivityBtn; private EditText et; private TextView pageLoadTime; @SuppressLint("JavascriptInterface") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); wv = (WebView) findViewById(R.id.wv); newActivityBtn = (ImageButton) findViewById(R.id.new_activity); pageLoadTime = (TextView) findViewById(R.id.page_load_time); et = (EditText) findViewById(R.id.et); // setup edit text et.setSelected(false); if (getIntent().getStringExtra("url") != null) { et.setText(getIntent().getStringExtra("url")); } else { et.setText(""); } //wv.setWebChromeClient(new WebChromeClient()); WebSettings settings = wv.getSettings(); settings.setJavaScriptEnabled(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setAppCacheEnabled(false); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); wv.addJavascriptInterface(new MyJavaScriptInterface(this), "HtmlViewer"); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); et.setText(url); pageStartTime = System.currentTimeMillis(); pageLoadTime.setText("0ms"); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (pageStartTime == 0) { } else { //Calling method to display Token id from the SAML Reponse view.loadUrl("javascript:window.HtmlViewer.showHTML(document.getElementsByName('SAMLResponse')[0].value);"); long loadTime = (System.currentTimeMillis() - pageStartTime); pageLoadTime.setText(String.format("%sms", loadTime)); System.out.println(String.format("page load time: %sms", loadTime)); view.clearCache(true); view.clearView(); } } }); handleLoadUrl(); // setup events newActivityBtn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { newActivityBtn.setColorFilter(getResources().getColor(android.R.color.holo_blue_dark)); return false; } else if (event.getAction() == MotionEvent.ACTION_UP) { newActivityBtn.setColorFilter(null); return false; } return false; } }); newActivityBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, MainActivity.class); intent.putExtra("url", et.getText().toString()); startActivity(intent); } }); et.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { handleLoadUrl(); return true; } else { return false; } } }); } private void handleLoadUrl() { String url = et.getText().toString(); if (url.startsWith("http://")) { } else if (url.startsWith("https://")) { } else { url = String.format("http://%s", url); } wv.loadUrl(url); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et.getWindowToken(), 0); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } class MyJavaScriptInterface { private Context ctx; MyJavaScriptInterface(Context ctx) { this.ctx = ctx; } @JavascriptInterface public void showHTML(String html) { System.out.println("html>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>:"+html); new AlertDialog.Builder(ctx).setTitle("Token Id").setMessage(html) .setPositiveButton(android.R.string.ok, null).setCancelable(false).create().show(); } } }
For Android Menifest file and content_main.xml Please refer to below site
We can use below code to check if the Package com.package.name is installed in the Android Device. If not then we can direct the user to google Play Store link for the same.
Intent intent = getPackageManager().getLaunchIntentForPackage("com.package.name"); if (intent != null) { // We found the activity now start the activity intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { // Bring user to the market or let them choose an app? intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(""https://play.google.com/store/apps/details?id=com.package.name")); startActivity(intent);
try {
//Invole web service
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the response
//SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
//SoapObject result = (SoapObject)envelope.bodyIn;
SoapObject result = (SoapObject)envelope.getResponse();
//soapResponse = result.toString();
//Assign it to fahren static variable
System.out.println("result:" + result);
//if(result.getProperty(5).toString().equals(ed1.getText().toString()) && result.getProperty(6).toString().equals(ed2.getText().toString()))
if(result.getProperty("userName").toString().equals(ed1.getText().toString()) && result.getProperty("userPassword").toString().equals(ed2.getText().toString()))
{
soapResponse = result.toString();
//Toast.makeText(getApplicationContext(), "Redirecting...",Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
When you get below error from Oracle DB it indicate its time for you to change the Password. However you can get ride of this message if you set the password expired field as unlimited. I am using sqldeveloper hence showing you the UI screen wise navigation to do the same.
A database warning was encountered performing the requested operation:
ORA-28002: the password will expire within 7 days 28002. 00000 - "the password will expire within %s days" *Cause: The user's account is about to expire and the password needs to be changed *Action: change the password or contact the DBA Vendor code 28002
Use another user to log into any database connection you have, you can also use the default "system" or "sys" username.
Open connection tree and find the "Other Users" node and open that like so : Image-1
Find your username in the child notes under "Other Users" and right click to edit user like so:
Type in your new password and Un-check password expired, then apply. Right click edit user again to see if the settings were changed if you wish.
This can be done from depending on your Mobile O/S.
Follow below link
http://docs.phonegap.com/getting-started/2-install-mobile-app/
iTunes :- https://itunes.apple.com/app/id843536693
Google Play :- https://play.google.com/store/apps/details?id=com.adobe.phonegap.app
Windows Phone Store :[- http://www.windowsphone.com/en-us/store/app/phonegap-developer/5c6a2d1e-4fad-4bf8-aaf7-71380cc84fe3
Step 3- Hello World Example
(A)- Create your appplication by giving proper name and package structure.
If you are not able to connect through Mobile screen you can also check the same screen using your PC browser.
Note:- Make sure your application run properly on PhoneGap Mobile. Ruuning application on browser is work arround