need help to build a fingerprint app that we have sslserversocket to tell a file use finger print before open the file
what have been done below
Here is my mainactivity.java and fingerprintHandler.java below
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/heading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:padding="20dp" android:text="Fingerprint Authentication" android:textAlignment="center" android:textColor="@android:color/black" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" /> <TextView android:id="@+id/paraMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:text="Place your finger on the fingerprint scanner to proceed" android:textAlignment="center" android:textColor="@color/colorAccent" android:textSize="16sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/fingerprint_image_view" app:layout_constraintVertical_bias="0.178" /> <ImageView android:id="@+id/fingerprint_image_view" android:layout_width="110dp" android:layout_height="119dp" app:srcCompat="@drawable/fingerprint_icon" tools:layout_editor_absoluteX="137dp" tools:layout_editor_absoluteY="90dp" /> </android.support.constraint.ConstraintLayout>
.................................................... package com.believe.securefolder;
import android.Manifest;
import android.app.KeyguardManager;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView heading, paraMesaage;
private ImageView fingerPrintImageView;
private FingerprintManager fingerprintManager;
private KeyguardManager keyguardManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
heading = (TextView) findViewById(R.id.heading);
paraMesaage = (TextView) findViewById(R.id.paraMessage);
fingerPrintImageView = (ImageView) findViewById(R.id.fingerprint_image_view);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
// Add
// this line to AndroidManifest.xml file
if(!fingerprintManager.isHardwareDetected())
{
paraMesaage.setText("Fingerprint Scanner not detected in your device!");
}
else if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.USE_FINGERPRINT)
!= PackageManager.PERMISSION_GRANTED)
{
paraMesaage.setText("Permission not granted to use Fingerprint Scanner!");
}
else if(!keyguardManager.isKeyguardSecure())
{
paraMesaage.setText("Add lock to your device in Device Settings!");
}
else if(!fingerprintManager.hasEnrolledFingerprints())
{
paraMesaage.setText("You should add at least 1 fingerprint to use this feature!");
}
else
{
paraMesaage.setText("Place your finger on the fingerprint scanner to proceed");
FingerprintHandler fingerprintHandler = new FingerprintHandler(MainActivity.this);
fingerprintHandler.startAuth(fingerprintManager, null);
}
}
}
}
--------------------------------------------------------------
package com.believe.securefolder;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
import android.support.v4.content.ContextCompat;
import android.widget.ImageView;
import android.widget.TextView;
import static com.believe.securefolder.R.drawable.*;
@TargetApi(Build.VERSION_CODES.M)
public class FingerprintHandler extends FingerprintManager.AuthenticationCallback {
private Context context;
private int done_icon;
public FingerprintHandler(Context context)
{
this.context = context;
}
public void startAuth(FingerprintManager fingerprintManager, FingerprintManager.CryptoObject cryptoObject)
{
CancellationSignal cancellationSignal = new CancellationSignal();
fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
this.update("There was an auth error: " + errString, false);
}
@Override
public void onAuthenticationFailed() {
this.update("Authentication failed!", false);
}
@Override
public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
this.update("Error: " + helpString, false);
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
this.update("You can now access the app!", true);
}
public void update(String s, boolean b)
{
TextView paraMessage = (TextView) ((Activity) context).findViewById(R.id.paraMessage);
ImageView fingerPrintImageView = (ImageView) ((Activity) context).findViewById(R.id.fingerprint_image_view);
paraMessage.setText(s);
if(b == false)
{
paraMessage.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary));
}
else
{
paraMessage.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
fingerPrintImageView.setImageResource(done_icon);
}
}
}
To Implement Android biometric authentication
the main activity code can be implemented as:
import androidx.appcompat.app.AppCompatActivity; import androidx.biometric.BiometricPrompt; import android.os.Bundle; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import androidx.fragment.app.FragmentActivity; import android.util.Log; import android.view.View; import androidx.annotation.NonNull; public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getName(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main)
/Create a thread pool with a single thread// Executor newExecutor = Executors.newSingleThreadExecutor(); FragmentActivity activity = this; //Start listening for authentication events// final BiometricPrompt myBiometricPrompt = new BiometricPrompt(activity, newExecutor, new BiometricPrompt.AuthenticationCallback() { @Override //onAuthenticationError is called when a fatal error occurrs// public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) { super.onAuthenticationError(errorCode, errString); if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) { } else { //Print a message to Logcat// Log.d(TAG, "An unrecoverable error occurred"); } } //onAuthenticationSucceeded is called when a fingerprint is matched successfully//
@Override public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) { super.onAuthenticationSucceeded(result); //Print a message to Logcat// Log.d(TAG, "Fingerprint recognised successfully"); } //onAuthenticationFailed is called when the fingerprint doesn’t match// @Override public void onAuthenticationFailed() { super.onAuthenticationFailed();
//Print a message to Logcat// Log.d(TAG, "Fingerprint not recognised"); } }); //Create the BiometricPrompt instance// final BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder() //Add some text to the dialog// .setTitle("Title text goes here") .setSubtitle("Subtitle goes here") .setDescription("This is the description") .setNegativeButtonText("Cancel") //Build the dialog//
.build(); //Assign an onClickListener to the app’s “Authentication” button// findViewById(R.id.launchAuthentication).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myBiometricPrompt.authenticate(promptInfo); } }); }
Certificate pinning is the solution to this problem. It means hard-coding the certificate known to be used by the server in the mobile application. The app can then ignore the device’s trust store and rely on its own, and allow only SSL connections to hosts signed with certificates stored inside the application.
This also gives a possibility of trusting a host with a self-signed certificate without the need to install additional certificates on the device.
There are three important steps in the process:
To obtain a .pem certificate for a site.
converting it to .bks keystore
following is the command:
keytool -importcert -v -trustcacerts -file "mycertfile.pem" -alias ca -keystore "keystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-ext-jdk15on-1.46.jar" -storetype BKS -storepass testing
Pinning the certificate to DefaultHttpClient
Using trial and error it has been established that only .bks keystores can be used for certificate pinning. Keystore file must be placed in res/raw folder.
The following code snippet demonstrates loading a keystore:
InputStream in = resources.openRawResource(certificateRawResource); keyStore = KeyStore.getInstance("BKS"); keyStore.load(resourceStream, password);
to create a new instance of DefaultHttpClient we can use HttpClientBuilder class:
DefaultHttpClient httpClient = new HttpClientBuilder() .setConnectionTimeout(10000) //timeout until a connection is etablished in ms; zero means no timeout .setSocketTimeout(60000) //timeout for waiting for data in ms (socket timeout); zero means no timeout .setHttpPort(80) //sets the port for HTTP connections, default is 80 .setHttpsPort(443) //sets the port for HTTPS connections, default is 443 .setCookieStore(new BasicCookieStore()) //assigns a cookie store, BasicCookieStore is assigned by default .pinCertificates(getResources(), R.raw.keystore, STORE_PASS) //pins the certificate from raw resources .build();
Need help to build a fingerprint app that we have sslserversocket to tell a file use finger print...
Need a help with this app. when I run this app, it is stopped. Here a source code for Tip calculator application. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFF" android:id="@+id/tableLayout" android:stretchColumns="1,2,3" android:padding="5dp"> <!-- tableRow0 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow0"> <TextView android:id="@+id/billTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/billTotal" android:textColor="#000" android:gravity="right" android:paddingRight="5dp"> </TextView> <EditText android:layout_width="wrap_content" android:id="@+id/billEditText" android:layout_height="wrap_content" android:layout_span="3" android:inputType="numberDecimal" android:layout_weight="1"> </EditText> </TableRow> <!-- tableRow1 --> <TableRow android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/tableRow1"> <TextView android:id="@+id/tenTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="10%" android:textColor="#000" android:layout_column="1"...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Need help to edit the code below. Am using it play a lottery game in Android Studio what i need help with is if play one game u need to clear it up before u could another game. Here is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="simpleapps.my.lotteryapplication.MainActivity" android:orientation="vertical" android:layout_margin="10dp" android:weightSum="100"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:text="Enter White Balls : " android:textColor="#000000" android:textSize="22sp" android:layout_weight="15" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:weightSum="100" android:layout_margin="10dp" android:layout_weight="15"> <EditText android:id="@+id/wBall1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:inputType="number"/>...
Why is my app crashing? Following is an app that takes notes from users and shows it's encrypted string. It also decrypt and encrypted strings. It saves the note in a file and also loads it back. Please help me identify what I am doing wrong? activity_krypto_note.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".KryptoNoteActivity"> <EditText android:id="@+id/key" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:ems="10" android:hint="Cryptographic Key" android:inputType="number" app:layout_constraintEnd_toStartOf="@+id/encrypt" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button android:id="@+id/encrypt" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:onClick="enryptClicked" android:text="ENCRYPT" android:textSize="9sp"...
If anyone here is a Java and Android Studio expert please I really need help fulfilling the requirements needed to make a Rock Paper Scissors game. I mainly need Java code to complete it I will post what I have so far I don't have much time left please if anyone can help me I would really appreciate it. Here's what the app is supposed to do... The player should be able to select either Rock, Paper, or Scissors.The app...
Exercise 11-4 Create a Reminder app In this exercise, you’ll add a service to a Reminder app that displays a notification every hour that says, “Look into the distance. It’s good for your eyes.” Test the app 1. Start Android Studio and open the project named ch11_ex4_Reminder. 2. Review the code. Note that it contains a layout and a class for an activity, but no class for a service. 1. Run the app. Note that it displays a message that...
I have a java project that I need help trying to finish. I have most of it completed but the issue I am running into is adding numbers with different lengths. Project requirements: . Use a Stack ADT with the implementation of your choice (Array or Link), it should not make a difference 2.Read two “integer” numbers from the user. Hint: You don’t need to use an int type when you read, it may be easier to parse the input...