1、添加国土调查云安全库

main
shisaiqun 2 years ago
parent fc4a2d405f
commit daf865b400
  1. 4
      app/build.gradle
  2. 4
      app/src/main/java/cn/org/landcloud/survey/data/DataRepositories.java
  3. 1
      security/.gitignore
  4. 47
      security/build.gradle
  5. 0
      security/consumer-rules.pro
  6. 21
      security/proguard-rules.pro
  7. 26
      security/src/androidTest/java/com/kingoit/survey/security/ExampleInstrumentedTest.java
  8. 4
      security/src/main/AndroidManifest.xml
  9. 48
      security/src/main/cpp/CMakeLists.txt
  10. 23
      security/src/main/cpp/security.cpp
  11. 13
      security/src/main/java/com/kingoit/survey/security/JNIBridge.java
  12. 17
      security/src/test/java/com/kingoit/survey/security/ExampleUnitTest.java
  13. 1
      settings.gradle

@ -29,7 +29,7 @@ android {
}
dependencies {
// implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
@ -41,5 +41,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:2.4.3"
implementation "androidx.exifinterface:exifinterface:1.3.2"
// implementation 'com.alibaba:fastjson:1.2.83'
// implementation 'org.bouncycastle:bcprov-jdk15on:1.63'
}

@ -118,8 +118,8 @@ public class DataRepositories {
tbjbxx.setTBBH("CS110101201600000100099");
tbjbxx.setTBMC("1");
tbjbxx.setTBMJ(9.43);
tbjbxx.setXZB(40498699.025);
tbjbxx.setYZB(3350604.784);
tbjbxx.setXZB(40498699.02);
tbjbxx.setYZB(3350604.78);
tbjbxx.setBZ("");
HashMap<String,Object> jbxxMap = new HashMap<>();

@ -0,0 +1 @@
/build

@ -0,0 +1,47 @@
plugins {
id 'com.android.library'
}
android {
namespace 'com.kingoit.survey.security'
compileSdk 32
defaultConfig {
minSdk 21
targetSdk 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.18.1"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,26 @@
package com.kingoit.survey.security;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.kingoit.survey.security.test", appContext.getPackageName());
}
}

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

@ -0,0 +1,48 @@
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.18.1)
# Declares and names the project.
project("security")
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
security
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
security.cpp)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
security
# Links the target library to the log library
# included in the NDK.
${log-lib})

@ -0,0 +1,23 @@
#include <jni.h>
#include <string>
#define PROVIDER AndroidKeyStore
extern "C" JNIEXPORT void JNICALL
Java_com_kingoit_survey_security_JNIBridge_init(
JNIEnv* env,
jobject /* this */) {
jclass keyStore_cls = env->FindClass("java/security/KeyStore");//获得ArrayList类引用
jmethodID getInstance = env->GetStaticMethodID(keyStore_cls,"getInstance","(Ljava/lang/String;)Ljava/security/KeyStore;");
jobject keyStore = env->CallStaticObjectMethod(keyStore_cls,getInstance,env->NewStringUTF("AndroidKeyStore"));
jclass keyPairGenerator_cls = env->FindClass("java/security/KeyPairGenerator");//获得ArrayList类引用
jmethodID getInstanceKeyPairGenerator = env->GetStaticMethodID(keyPairGenerator_cls,"getInstance","(Ljava/lang/String;Ljava/lang/String;)Ljava/security/KeyPairGenerator;");
jobject keyPairGenerator = env->CallStaticObjectMethod(keyPairGenerator_cls,getInstanceKeyPairGenerator,env->NewStringUTF("RSA"),env->NewStringUTF("AndroidKeyStore"));
}

@ -0,0 +1,13 @@
package com.kingoit.survey.security;
public class JNIBridge {
static {
System.loadLibrary("security");
}
/**
*
*/
public native void init();
}

@ -0,0 +1,17 @@
package com.kingoit.survey.security;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

@ -15,3 +15,4 @@ dependencyResolutionManagement {
rootProject.name = "landsurvey"
include ':app'
include ':ssl'
include ':security'

Loading…
Cancel
Save