├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── fidoclient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── yalin │ │ └── fidoclient │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── yalin │ │ └── fidoclient │ │ ├── api │ │ ├── UAFClientApi.java │ │ ├── UAFClientError.java │ │ └── UAFIntent.java │ │ ├── asm │ │ ├── api │ │ │ ├── ASMApi.java │ │ │ ├── ASMIntent.java │ │ │ └── StatusCode.java │ │ ├── exceptions │ │ │ └── ASMException.java │ │ └── msg │ │ │ ├── ASMRequest.java │ │ │ ├── ASMResponse.java │ │ │ ├── Request.java │ │ │ └── obj │ │ │ ├── AuthenticateIn.java │ │ │ ├── AuthenticateOut.java │ │ │ ├── AuthenticatorInfo.java │ │ │ ├── DeregisterIn.java │ │ │ ├── GetInfoOut.java │ │ │ ├── RegisterIn.java │ │ │ └── RegisterOut.java │ │ ├── constants │ │ └── Constants.java │ │ ├── msg │ │ ├── AsmInfo.java │ │ ├── AuthenticationRequest.java │ │ ├── AuthenticationResponse.java │ │ ├── Authenticator.java │ │ ├── AuthenticatorRegistrationAssertion.java │ │ ├── AuthenticatorSignAssertion.java │ │ ├── ChannelBinding.java │ │ ├── DeregResponse.java │ │ ├── DeregisterAuthenticator.java │ │ ├── DeregistrationRequest.java │ │ ├── DiscoverData.java │ │ ├── DisplayPNGCharacteristicsDescriptor.java │ │ ├── Extension.java │ │ ├── FinalChallengeParams.java │ │ ├── MatchCriteria.java │ │ ├── Operation.java │ │ ├── OperationHeader.java │ │ ├── Policy.java │ │ ├── RegRecord.java │ │ ├── RegistrationRequest.java │ │ ├── RegistrationResponse.java │ │ ├── Transaction.java │ │ ├── Version.java │ │ ├── client │ │ │ ├── JsonSerializable.java │ │ │ ├── UAFIntentType.java │ │ │ └── UAFMessage.java │ │ └── rgbPalletteEntry.java │ │ ├── net │ │ ├── BaseRequest.java │ │ ├── ErrorCodeConstants.java │ │ ├── GetRequest.java │ │ ├── MyVolleyError.java │ │ ├── RequestQueueHelper.java │ │ └── response │ │ │ ├── BaseResponse.java │ │ │ ├── FacetIdList.java │ │ │ └── FacetIdListResponse.java │ │ ├── op │ │ ├── ASMMessageHandler.java │ │ ├── Auth.java │ │ ├── CheckPolicy.java │ │ ├── Completion.java │ │ ├── Dereg.java │ │ ├── Discover.java │ │ ├── Reg.java │ │ └── traffic │ │ │ └── Traffic.java │ │ ├── tlv │ │ ├── Tag.java │ │ ├── Tags.java │ │ └── TagsEnum.java │ │ ├── ui │ │ ├── AuthenticatorAdapter.java │ │ ├── MainActivity.java │ │ ├── UAFClientActivity.java │ │ └── fragment │ │ │ ├── AsmListAdapter.java │ │ │ ├── AsmListFragment.java │ │ │ └── AuthenticatorListFragment.java │ │ └── utils │ │ ├── StatLog.java │ │ └── Utils.java │ └── res │ ├── anim │ ├── push_left_in.xml │ ├── push_left_out.xml │ ├── push_right_in.xml │ └── push_right_out.xml │ ├── color │ ├── navdrawer_item_icon.xml │ └── navdrawer_item_title.xml │ ├── drawable-xhdpi │ ├── ic_fp_40px.png │ ├── ic_linked_camera_black_48dp.png │ └── ic_register.png │ ├── drawable │ ├── ic_fingerprint_error.xml │ ├── ic_fingerprint_success.xml │ └── item_bg.xml │ ├── layout │ ├── activity_content.xml │ ├── activity_fido_client.xml │ ├── activity_main.xml │ ├── asm_item.xml │ ├── authenticator_item.xml │ ├── content_main.xml │ ├── fingerprint_dialog_container.xml │ ├── fingerprint_dialog_content.xml │ ├── fragment_asm_list.xml │ ├── fragment_authenticator_list.xml │ └── toolbar.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-sw360dp │ └── dimens.xml │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── array.xml │ ├── attr.xml │ ├── colors.xml │ ├── dimen.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshot ├── asm_list.png ├── default_asm.png ├── device_list.png ├── test.png ├── test1.png └── touch.png ├── settings.gradle └── uitoolkit ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── jin │ └── uitoolkit │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── jin │ │ └── uitoolkit │ │ ├── activity │ │ ├── BaseLoadActivity.java │ │ ├── RevealBackgroundActivity.java │ │ ├── RevealBackgroundNoToolbarActivity.java │ │ └── ToolbarActivity.java │ │ ├── fragment │ │ ├── BaseLoadingFragment.java │ │ └── BaseSlideFragment.java │ │ ├── util │ │ ├── PixelUtil.java │ │ └── Utils.java │ │ └── widget │ │ ├── CircleImageView.java │ │ ├── CircularProgress.java │ │ └── RevealBackgroundView.java └── res │ ├── drawable-xhdpi │ ├── btn_following.xml │ ├── loading_failed.png │ ├── right_arrow_more.png │ └── warning.png │ ├── drawable │ ├── btn_following1.xml │ ├── drawer_shadow.9.png │ ├── other_options_selector.xml │ ├── shadow_vertical_left.xml │ ├── shape_module.xml │ └── shape_module2.xml │ ├── layout │ ├── activity_base_loading.xml │ ├── activity_reveal_background.xml │ ├── activity_toolbar.xml │ ├── dialog_content_loading.xml │ ├── dialog_loading_failed.xml │ ├── dialog_loading_failed_head.xml │ ├── fragment_base_loading.xml │ └── fragment_shadow.xml │ ├── values-v11 │ └── bools.xml │ ├── values-v21 │ └── styles.xml │ └── values │ ├── attrs.xml │ ├── bools.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── test └── java └── com └── jin └── uitoolkit └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | /.idea 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UAF - Universal Authentication Framework 2 | 3 | [UAF Architectural Overview](https://fidoalliance.org/wp-content/uploads/html/fido-uaf-overview-v1.0-ps-20141208.html) 4 | 5 | ## UAFClient 6 | FIDO UAF Client implementation 7 | 8 | ### Screenshots 9 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/asm_list.png) 10 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/default_asm.png) 11 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/device_list.png) 12 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/touch.png) 13 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/test.png) 14 | ![image](https://github.com/jinkg/UAFClient/blob/master/screenshot/test1.png) 15 | 16 | #License 17 | 18 | Copyright 2016 YaLin Jin 19 | 20 | Licensed under the Apache License, Version 2.0 (the "License"); 21 | you may not use this file except in compliance with the License. 22 | You may obtain a copy of the License at 23 | 24 | http://www.apache.org/licenses/LICENSE-2.0 25 | 26 | Unless required by applicable law or agreed to in writing, software 27 | distributed under the License is distributed on an "AS IS" BASIS, 28 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | See the License for the specific language governing permissions and 30 | limitations under the License. 31 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /fidoclient/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /fidoclient/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.yalin.fidoclient" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled true 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | debug { 20 | minifyEnabled true 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:23.1.1' 30 | compile 'com.android.support:design:23.1.1' 31 | compile 'com.mcxiaoke.volley:library:1.0.19' 32 | compile 'com.google.code.gson:gson:2.5' 33 | compile project(':uitoolkit') 34 | compile 'com.android.support:recyclerview-v7:23.1.1' 35 | } 36 | -------------------------------------------------------------------------------- /fidoclient/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | ##---------------Begin: proguard configuration common for all Android apps ---------- 2 | -optimizationpasses 5 3 | -dontusemixedcaseclassnames 4 | -dontskipnonpubliclibraryclasses 5 | -dontskipnonpubliclibraryclassmembers 6 | -dontpreverify 7 | -verbose 8 | -dump class_files.txt 9 | -printseeds seeds.txt 10 | -printusage unused.txt 11 | -printmapping mapping.txt 12 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 13 | 14 | -allowaccessmodification 15 | -keepattributes *Annotation* 16 | -renamesourcefileattribute SourceFile 17 | -keepattributes SourceFile,LineNumberTable 18 | -repackageclasses '' 19 | 20 | -keep public class * extends android.app.Activity 21 | -keep public class * extends android.app.Application 22 | -keep public class * extends android.app.Service 23 | -keep public class * extends android.content.BroadcastReceiver 24 | -keep public class * extends android.content.ContentProvider 25 | -keep public class * extends android.app.backup.BackupAgentHelper 26 | -keep public class * extends android.preference.Preference 27 | -keep public class com.android.vending.licensing.ILicensingService 28 | -dontnote com.android.vending.licensing.ILicensingService 29 | 30 | # Explicitly preserve all serialization members. The Serializable interface 31 | # is only a marker interface, so it wouldn't save them. 32 | -keepclassmembers class * implements java.io.Serializable { 33 | static final long serialVersionUID; 34 | private static final java.io.ObjectStreamField[] serialPersistentFields; 35 | private void writeObject(java.io.ObjectOutputStream); 36 | private void readObject(java.io.ObjectInputStream); 37 | java.lang.Object writeReplace(); 38 | java.lang.Object readResolve(); 39 | } 40 | 41 | # Preserve all native method names and the names of their classes. 42 | -keepclasseswithmembernames class * { 43 | native ; 44 | } 45 | 46 | -keepclasseswithmembernames class * { 47 | public (android.content.Context, android.util.AttributeSet); 48 | } 49 | 50 | -keepclasseswithmembernames class * { 51 | public (android.content.Context, android.util.AttributeSet, int); 52 | } 53 | 54 | # Preserve static fields of inner classes of R classes that might be accessed 55 | # through introspection. 56 | -keepclassmembers class **.R$* { 57 | public static ; 58 | } 59 | 60 | # Preserve the special static methods that are required in all enumeration classes. 61 | -keepclassmembers enum * { 62 | public static **[] values(); 63 | public static ** valueOf(java.lang.String); 64 | } 65 | 66 | -keep class * implements android.os.Parcelable { 67 | public static final android.os.Parcelable$Creator *; 68 | } 69 | ##---------------End: proguard configuration common for all Android apps ---------- 70 | 71 | -keepattributes Signature 72 | -keepattributes *Annotation* 73 | -keep class sun.misc.Unsafe { *; } 74 | -keep class com.yalin.fidoclient.msg.** { *; } 75 | -keep class com.yalin.fidoclient.asm.** { *; } 76 | -keep class com.yalin.fidoclient.net.response.** { *; } 77 | 78 | -------------------------------------------------------------------------------- /fidoclient/src/androidTest/java/com/yalin/fidoclient/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient; 18 | 19 | import android.app.Application; 20 | import android.test.ApplicationTestCase; 21 | 22 | import com.google.gson.Gson; 23 | import com.yalin.fidoclient.constants.Constants; 24 | import com.yalin.fidoclient.net.response.FacetIdListResponse; 25 | import com.yalin.fidoclient.op.ASMMessageHandler; 26 | import com.yalin.fidoclient.op.Completion; 27 | 28 | 29 | /** 30 | * Testing Fundamentals 31 | */ 32 | public class ApplicationTest extends ApplicationTestCase { 33 | public ApplicationTest() { 34 | super(Application.class); 35 | } 36 | 37 | public void testBase64Encoded() { 38 | String base64String = "VkNhalNrYWVsajhHclZJdG5hMkF5eXRIMVlrQ3pBb3Z6T1ZHblRNTg"; 39 | String base64String1 = base64String.trim(); 40 | assertTrue(base64String1.matches(Constants.BASE64_REGULAR)); 41 | } 42 | 43 | public void testFacetIdMatch() { 44 | String facetIdListJson = "{\"trustedFacets\":[{\"version\":{\"major\":1,\"minor\":0},\"ids\":[\"android:apk-key-hash:q/e9IaNQq0aVXc8lllq7i/AsAX0\",\"android:apk-key-hash:fX7gLfYPhfPY74RGgK0NYG6Qn8Y\",\"android:apk-key-hash:Tr3wU3S3ZzXhrdXsQY8ykrKPYok\",\"android:apk-key-hash:EVXld/jIwGnA0Lpa+HZ+r+095m4\",\"android:apk-key-hash:LGVXnmy3laAWV/WZJ7PBiA9ASkg\",\"ios:bundle-id:com.raonsecure.fido.rp1\",\"android:apk-key-hash:Df+2X53Z0UscvUu6obxC3rIfFyk\",\"android:apk-key-hash:/G50F1N5KDg/rxYX1gYwLlp7FvM\",\"ios:bundle-id:com.kt.fidocert\",\"android:apk-key-hash:NVvf2qB+6Pr/9cLsS35pOpv67As\",\"ios:bundle-id:com.raonsecure.fidocert\",\"android:apk-key-hash:Y9a2IZqAfkqQtyVXx7p5sFr4RCc\",\"android:apk-key-hash:NVvf2qB+6Pr/9cLsS35pOpv67As\",\"android:apk-key-hash:f+jGL/M5P0cm1tqfxD05s/851eE\",\"android:apk-key-hash:/M90Btryt52setdCdLo1ih96MXg\",\"ios:bundle-id:com.crosscert.fidorpc\",\"android:apk-key-hash:AwHDCRdzkMAsOa7aDPbnG2J95Is\",\"ios:bundle-id:com.crosscert.fidorpc\"]}]}"; 45 | String facetId = "android:apk-key-hash:q/e9IaNQq0aVXc8lllq7i/AsAX0"; 46 | String facetId1 = "android:apk-key-hash:SvYZ4Sgas9T2+6DpNj566iscuns"; 47 | FacetIdListResponse facetIdListResponse = new Gson().fromJson(facetIdListJson, FacetIdListResponse.class); 48 | boolean match = ASMMessageHandler.checkFacetId(facetId, facetIdListResponse.trustedFacets); 49 | boolean match1 = ASMMessageHandler.checkFacetId(facetId1, facetIdListResponse.trustedFacets); 50 | assertTrue(match); 51 | assertTrue(!match1); 52 | } 53 | } -------------------------------------------------------------------------------- /fidoclient/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/api/UAFClientApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.api; 18 | 19 | import android.app.Activity; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.support.v4.app.Fragment; 23 | import android.text.TextUtils; 24 | 25 | import com.yalin.fidoclient.msg.AsmInfo; 26 | import com.yalin.fidoclient.msg.DeregisterAuthenticator; 27 | import com.yalin.fidoclient.msg.DeregistrationRequest; 28 | import com.yalin.fidoclient.msg.RegRecord; 29 | import com.yalin.fidoclient.msg.client.UAFMessage; 30 | import com.yalin.fidoclient.ui.UAFClientActivity; 31 | import com.yalin.fidoclient.utils.Utils; 32 | 33 | import java.util.List; 34 | 35 | /** 36 | * Created by YaLin on 2016/1/11. 37 | */ 38 | public class UAFClientApi { 39 | public static void doDiscover(Activity activity, int requestCode) { 40 | if (activity == null) { 41 | throw new IllegalArgumentException(); 42 | } 43 | Intent intent = UAFIntent.getDiscoverIntent(); 44 | activity.startActivityForResult(intent, requestCode); 45 | } 46 | 47 | public static void doCheckPolicy(Activity activity, int requestCode, String responseMessage) { 48 | if (activity == null || TextUtils.isEmpty(responseMessage)) { 49 | throw new IllegalArgumentException(); 50 | } 51 | Intent intent = UAFIntent.getCheckPolicyIntent(new UAFMessage(responseMessage).toJson(), activity.getApplication().getPackageName()); 52 | activity.startActivityForResult(intent, requestCode); 53 | } 54 | 55 | public static void doOperation(Activity activity, int requestCode, String responseMessage, String channelBinding) { 56 | if (activity == null || TextUtils.isEmpty(responseMessage)) { 57 | throw new IllegalArgumentException(); 58 | } 59 | Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding); 60 | activity.startActivityForResult(intent, requestCode); 61 | } 62 | 63 | public static void doOperation(Fragment fragment, int requestCode, String responseMessage, String channelBinding) { 64 | if (fragment == null || TextUtils.isEmpty(responseMessage)) { 65 | throw new IllegalArgumentException(); 66 | } 67 | Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding); 68 | fragment.startActivityForResult(intent, requestCode); 69 | } 70 | 71 | public static List getRegRecords(String username) { 72 | if (TextUtils.isEmpty(username)) { 73 | throw new IllegalArgumentException(); 74 | } 75 | return null; 76 | } 77 | 78 | public static DeregistrationRequest[] getDeRegistrationRequests(RegRecord regRecord) { 79 | if (regRecord == null) { 80 | throw new IllegalArgumentException("regRecord must not be null!"); 81 | } 82 | DeregistrationRequest[] deRegistrationRequests = new DeregistrationRequest[1]; 83 | deRegistrationRequests[0] = new DeregistrationRequest(); 84 | deRegistrationRequests[0].authenticators = new DeregisterAuthenticator[1]; 85 | deRegistrationRequests[0].authenticators[0] = new DeregisterAuthenticator(); 86 | deRegistrationRequests[0].authenticators[0].aaid = regRecord.aaid; 87 | deRegistrationRequests[0].authenticators[0].keyID = regRecord.keyId; 88 | 89 | return deRegistrationRequests; 90 | } 91 | 92 | public static AsmInfo getDefaultAsmInfo(Context context) { 93 | return UAFClientActivity.getAsmInfo(context); 94 | } 95 | 96 | public static void clearDefaultAsm(Context context) { 97 | UAFClientActivity.setAsmInfo(context, null); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/api/UAFClientError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.api; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public interface UAFClientError { 23 | short NO_ERROR = 0x0; 24 | short WAIT_USER_ACTION = 0x1; 25 | short INSECURE_TRANSPORT = 0x2; 26 | short USER_CANCELLED = 0x3; 27 | short UNSUPPORTED_VERSION = 0x4; 28 | short NO_SUITABLE_AUTHENTICATOR = 0x5; 29 | short PROTOCOL_ERROR = 0x6; 30 | short UNTRUSTED_FACET_ID = 0x7; 31 | short UNKNOWN = 0xFF; 32 | } 33 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/api/ASMApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.api; 18 | 19 | import android.content.Intent; 20 | import android.support.v4.app.Fragment; 21 | import android.text.TextUtils; 22 | 23 | 24 | /** 25 | * Created by YaLin on 2016/1/13. 26 | */ 27 | public class ASMApi { 28 | public static void doOperation(Fragment fragment, int requestCode, String asmMessage, String pack) { 29 | if (TextUtils.isEmpty(asmMessage)) { 30 | throw new IllegalArgumentException("asmMessage can not be null"); 31 | } 32 | Intent intent = ASMIntent.getASMOperationIntent(asmMessage); 33 | if (!TextUtils.isEmpty(pack)) { 34 | intent.setPackage(pack); 35 | } 36 | fragment.startActivityForResult(intent, requestCode); 37 | } 38 | 39 | public static void doDiscover(Fragment fragment, int requestCode, String asmMessage) { 40 | if (TextUtils.isEmpty(asmMessage)) { 41 | throw new IllegalArgumentException("asmMessage can not be null"); 42 | } 43 | Intent intent = ASMIntent.getASMOperationIntent(asmMessage); 44 | fragment.startActivityForResult(intent, requestCode); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/api/ASMIntent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.api; 18 | 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | 22 | import com.yalin.fidoclient.constants.Constants; 23 | 24 | /** 25 | * Created by YaLin on 2016/1/13. 26 | */ 27 | public class ASMIntent { 28 | public static final String MESSAGE_KEY = "message"; 29 | 30 | public static Intent getASMIntent(){ 31 | Intent intent = new Intent(Constants.ACTION_FIDO_OPERATION); 32 | intent.setType(Constants.FIDO_ASM_INTENT_MIME); 33 | 34 | return intent; 35 | } 36 | 37 | public static Intent getASMOperationIntent(String asmRequest) { 38 | Intent intent = new Intent(Constants.ACTION_FIDO_OPERATION); 39 | intent.setType(Constants.FIDO_ASM_INTENT_MIME); 40 | 41 | Bundle bundle = new Bundle(); 42 | bundle.putString(MESSAGE_KEY, asmRequest); 43 | intent.putExtras(bundle); 44 | return intent; 45 | } 46 | 47 | public static Intent getASMOperationResultIntent(String asmResponse) { 48 | Intent intent = new Intent(); 49 | 50 | Bundle bundle = new Bundle(); 51 | bundle.putString(MESSAGE_KEY, asmResponse); 52 | intent.putExtras(bundle); 53 | return intent; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/api/StatusCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.api; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public interface StatusCode { 23 | short UAF_ASM_STATUS_OK = 0x00; 24 | short UAF_ASM_STATUS_ERROR = 0x01; 25 | short UAF_ASM_STATUS_ACCESS_DENIED = 0x02; 26 | short UAF_ASM_STATUS_USER_CANCELLED = 0x03; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/exceptions/ASMException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.exceptions; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class ASMException extends Exception { 23 | public short statusCode; 24 | 25 | public ASMException(short statusCode) { 26 | this.statusCode = statusCode; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/ASMRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg; 18 | 19 | 20 | import com.google.gson.Gson; 21 | import com.yalin.fidoclient.msg.Version; 22 | 23 | import java.lang.reflect.ParameterizedType; 24 | import java.lang.reflect.Type; 25 | 26 | /** 27 | * Created by YaLin on 2016/1/13. 28 | */ 29 | public class ASMRequest { 30 | public static final String authenticatorIndexName = "authenticatorIndex"; 31 | 32 | public Request requestType; 33 | public Version asmVersion; 34 | public int authenticatorIndex; 35 | public T args; 36 | 37 | public static ASMRequest fromJson(String json, Class clazz) { 38 | Gson gson = new Gson(); 39 | Type objectType = type(ASMRequest.class, clazz); 40 | return gson.fromJson(json, objectType); 41 | } 42 | 43 | static ParameterizedType type(final Class raw, final Type... args) { 44 | return new ParameterizedType() { 45 | public Type getRawType() { 46 | return raw; 47 | } 48 | 49 | public Type[] getActualTypeArguments() { 50 | return args; 51 | } 52 | 53 | public Type getOwnerType() { 54 | return null; 55 | } 56 | }; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/ASMResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg; 18 | 19 | import com.google.gson.Gson; 20 | 21 | import java.lang.reflect.ParameterizedType; 22 | import java.lang.reflect.Type; 23 | 24 | /** 25 | * Created by YaLin on 2016/1/13. 26 | */ 27 | public class ASMResponse { 28 | public short statusCode; 29 | public T responseData; 30 | 31 | public static ASMResponse fromJson(String json, Class clazz) { 32 | Gson gson = new Gson(); 33 | Type objectType = type(ASMResponse.class, clazz); 34 | return gson.fromJson(json, objectType); 35 | } 36 | 37 | static ParameterizedType type(final Class raw, final Type... args) { 38 | return new ParameterizedType() { 39 | public Type getRawType() { 40 | return raw; 41 | } 42 | 43 | public Type[] getActualTypeArguments() { 44 | return args; 45 | } 46 | 47 | public Type getOwnerType() { 48 | return null; 49 | } 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public enum Request { 23 | GetInfo, 24 | Register, 25 | Authenticate, 26 | Deregister, 27 | GetRegistrations, 28 | OpenSettings 29 | } 30 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/AuthenticateIn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | import com.yalin.fidoclient.msg.Transaction; 20 | 21 | /** 22 | * Created by YaLin on 2016/1/13. 23 | */ 24 | public class AuthenticateIn { 25 | public String appID; 26 | public String[] keyIDs; 27 | public String finalChallenge; 28 | public Transaction[] transaction; 29 | 30 | public AuthenticateIn(String appID, String[] keyIDs, String finalChallenge) { 31 | this.appID = appID; 32 | this.keyIDs = keyIDs; 33 | this.finalChallenge = finalChallenge; 34 | } 35 | 36 | public void setTransaction(Transaction[] transaction) { 37 | this.transaction = transaction; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/AuthenticateOut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class AuthenticateOut { 23 | public String assertion; 24 | public String assertionScheme; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/AuthenticatorInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | import com.yalin.fidoclient.msg.DisplayPNGCharacteristicsDescriptor; 20 | import com.yalin.fidoclient.msg.Version; 21 | 22 | /** 23 | * Created by YaLin on 2016/1/13. 24 | */ 25 | public class AuthenticatorInfo { 26 | public int authenticatorIndex; 27 | public Version[] asmVersions; 28 | public boolean isUserEnrolled; 29 | public boolean hasSettings; 30 | public String aaid; 31 | public String assertionScheme; 32 | public int authenticationAlgorithm; 33 | public int[] attestationTypes; 34 | public long userVerification; 35 | public int keyProtection; 36 | public int matcherProtection; 37 | public long attachmentHint; 38 | public boolean isSecondFactorOnly; 39 | public boolean isRoamingAuthenticator; 40 | public String[] supportedExtensionIDs; 41 | public int tcDisplay; 42 | 43 | public String tcDisplayContentType; 44 | public DisplayPNGCharacteristicsDescriptor[] tcDisplayPNGCharacteristics; 45 | public String title; 46 | public String description; 47 | public String icon; 48 | 49 | public AuthenticatorInfo authenticatorIndex(int authenticatorIndex) { 50 | this.authenticatorIndex = authenticatorIndex; 51 | return this; 52 | } 53 | 54 | public AuthenticatorInfo asmVersions(Version[] asmVersions) { 55 | this.asmVersions = asmVersions; 56 | return this; 57 | } 58 | 59 | public AuthenticatorInfo isUserEnrolled(boolean isUserEnrolled) { 60 | this.isUserEnrolled = isUserEnrolled; 61 | return this; 62 | } 63 | 64 | public AuthenticatorInfo hasSettings(boolean hasSettings) { 65 | this.hasSettings = hasSettings; 66 | return this; 67 | } 68 | 69 | public AuthenticatorInfo aaid(String aaid) { 70 | this.aaid = aaid; 71 | return this; 72 | } 73 | 74 | public AuthenticatorInfo assertionScheme(String assertionScheme) { 75 | this.assertionScheme = assertionScheme; 76 | return this; 77 | } 78 | 79 | public AuthenticatorInfo authenticationAlgorithm(int authenticationAlgorithm) { 80 | this.authenticationAlgorithm = authenticationAlgorithm; 81 | return this; 82 | } 83 | 84 | public AuthenticatorInfo attestationTypes(int[] attestationTypes) { 85 | this.attestationTypes = attestationTypes; 86 | return this; 87 | } 88 | 89 | public AuthenticatorInfo userVerification(int userVerification) { 90 | this.userVerification = userVerification; 91 | return this; 92 | } 93 | 94 | public AuthenticatorInfo keyProtection(int keyProtection) { 95 | this.keyProtection = keyProtection; 96 | return this; 97 | } 98 | 99 | public AuthenticatorInfo matcherProtection(int matcherProtection) { 100 | this.matcherProtection = matcherProtection; 101 | return this; 102 | } 103 | 104 | public AuthenticatorInfo attachmentHint(long attachmentHint) { 105 | this.attachmentHint = attachmentHint; 106 | return this; 107 | } 108 | 109 | public AuthenticatorInfo isSecondFactorOnly(boolean isSecondFactorOnly) { 110 | this.isSecondFactorOnly = isSecondFactorOnly; 111 | return this; 112 | } 113 | 114 | public AuthenticatorInfo isRoamingAuthenticator(boolean isRoamingAuthenticator) { 115 | this.isRoamingAuthenticator = isRoamingAuthenticator; 116 | return this; 117 | } 118 | 119 | public AuthenticatorInfo supportedExtensionIDs(String[] supportedExtensionIDs) { 120 | this.supportedExtensionIDs = supportedExtensionIDs; 121 | return this; 122 | } 123 | 124 | public AuthenticatorInfo tcDisplay(int tcDisplay) { 125 | this.tcDisplay = tcDisplay; 126 | return this; 127 | } 128 | 129 | 130 | } 131 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/DeregisterIn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class DeregisterIn { 23 | public String appID; 24 | public String keyID; 25 | 26 | public DeregisterIn(String appID, String keyID) { 27 | this.appID = appID; 28 | this.keyID = keyID; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/GetInfoOut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class GetInfoOut { 23 | public AuthenticatorInfo[] Authenticators; 24 | } 25 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/RegisterIn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class RegisterIn { 23 | public String appID; 24 | public String username; 25 | public String finalChallenge; 26 | public int attestationType; 27 | 28 | public RegisterIn(String appID, String username, String finalChallenge, int attestationType) { 29 | this.appID = appID; 30 | this.username = username; 31 | this.finalChallenge = finalChallenge; 32 | this.attestationType = attestationType; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/asm/msg/obj/RegisterOut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.asm.msg.obj; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/13. 21 | */ 22 | public class RegisterOut { 23 | public String assertion; 24 | public String assertionScheme; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/constants/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.constants; 18 | 19 | /** 20 | * Created by YaLin on 2015/10/21. 21 | */ 22 | public interface Constants { 23 | String ACTION_FIDO_OPERATION = "org.fidoalliance.intent.FIDO_OPERATION"; 24 | 25 | String PERMISSION_FIDO_CLIENT = "org.fidoalliance.uaf.permissions.FIDO_CLIENT"; 26 | 27 | String FIDO_CLIENT_INTENT_MIME = "application/fido.uaf_client+json"; 28 | String FIDO_ASM_INTENT_MIME = "application/fido.uaf_asm+json"; 29 | 30 | int CHALLENGE_MAX_LEN = 64; 31 | int CHALLENGE_MIN_LEN = 8; 32 | 33 | int USERNAME_MAX_LEN = 128; 34 | 35 | int APP_ID_MAX_LEN = 512; 36 | 37 | int SERVER_DATA_MAX_LEN = 1536; 38 | 39 | int KEY_ID_MAX_LEN = 2048; 40 | int KEY_ID_MIN_LEN = 32; 41 | 42 | String APP_ID_PREFIX = "https://"; 43 | 44 | String BASE64_REGULAR = "^[a-zA-Z0-9-_]+={0,2}$"; 45 | } 46 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/AsmInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | import android.graphics.drawable.Drawable; 20 | 21 | /** 22 | * Created by YaLin on 2016/2/26. 23 | */ 24 | public class AsmInfo { 25 | public String appName; 26 | public String pack; 27 | public Drawable icon; 28 | 29 | public AsmInfo appName(String appName) { 30 | this.appName = appName; 31 | return this; 32 | } 33 | 34 | public AsmInfo pack(String pack) { 35 | this.pack = pack; 36 | return this; 37 | } 38 | 39 | public AsmInfo icon(Drawable icon) { 40 | this.icon = icon; 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/AuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class AuthenticationRequest { 23 | public OperationHeader header; 24 | public String challenge; 25 | public Transaction[] transaction; 26 | public Policy policy; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/AuthenticationResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class AuthenticationResponse { 23 | public OperationHeader header; 24 | public String fcParams; 25 | public AuthenticatorSignAssertion[] assertions; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Authenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | import com.yalin.fidoclient.asm.msg.obj.AuthenticatorInfo; 20 | 21 | /** 22 | * Created by YaLin on 2016/1/21. 23 | */ 24 | public class Authenticator { 25 | public String title; 26 | public String aaid; 27 | public String description; 28 | public Version[] supportedUAFVersions; 29 | public String assertionScheme; 30 | public int authenticationAlgorithm; 31 | public int[] attestationTypes; 32 | public long userVerification; 33 | public int keyProtection; 34 | public int matcherProtection; 35 | public long attachmentHint; 36 | public boolean isSecondFactorOnly; 37 | public int tcDisplay; 38 | public String tcDisplayContentType; 39 | public DisplayPNGCharacteristicsDescriptor[] tcDisplayPNGCharacteristics; 40 | public String icon; 41 | public String[] supportedExtensionIDs; 42 | 43 | public static Authenticator[] fromInfo(AuthenticatorInfo[] infos) { 44 | if (infos == null) { 45 | return null; 46 | } 47 | Authenticator[] authenticators = new Authenticator[infos.length]; 48 | for (int i = 0; i < infos.length; i++) { 49 | authenticators[i] = new Authenticator(); 50 | authenticators[i].aaid = infos[i].aaid; 51 | authenticators[i].assertionScheme = infos[i].assertionScheme; 52 | authenticators[i].title = infos[i].title; 53 | authenticators[i].description = infos[i].description; 54 | authenticators[i].authenticationAlgorithm = infos[i].authenticationAlgorithm; 55 | authenticators[i].attestationTypes = infos[i].attestationTypes; 56 | authenticators[i].userVerification = infos[i].userVerification; 57 | authenticators[i].keyProtection = infos[i].keyProtection; 58 | authenticators[i].matcherProtection = infos[i].matcherProtection; 59 | authenticators[i].attachmentHint = infos[i].attachmentHint; 60 | authenticators[i].isSecondFactorOnly = infos[i].isSecondFactorOnly; 61 | authenticators[i].tcDisplay = infos[i].tcDisplay; 62 | authenticators[i].tcDisplayContentType = infos[i].tcDisplayContentType; 63 | authenticators[i].tcDisplayPNGCharacteristics = infos[i].tcDisplayPNGCharacteristics; 64 | authenticators[i].icon = infos[i].icon; 65 | authenticators[i].supportedExtensionIDs = infos[i].supportedExtensionIDs; 66 | 67 | authenticators[i].supportedUAFVersions = new Version[1]; 68 | authenticators[i].supportedUAFVersions[0] = new Version(1, 0); 69 | } 70 | return authenticators; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/AuthenticatorRegistrationAssertion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class AuthenticatorRegistrationAssertion { 23 | public String assertionScheme; 24 | public String assertion; 25 | public DisplayPNGCharacteristicsDescriptor[] tcDisplayPNGCharacteristics; 26 | public Extension[] exts; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/AuthenticatorSignAssertion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class AuthenticatorSignAssertion { 23 | public String assertionScheme; 24 | public String assertion; 25 | public Extension[] exts; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/ChannelBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class ChannelBinding { 23 | public String serverEndPoint; 24 | public String tlsServerCertificate; 25 | public String tlsUnique; 26 | public String cid_pubkey; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/DeregResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/14. 21 | */ 22 | public class DeregResponse { 23 | public short error; 24 | 25 | public DeregResponse(short error) { 26 | this.error = error; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/DeregisterAuthenticator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class DeregisterAuthenticator { 23 | public String aaid; 24 | public String keyID; 25 | } 26 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/DeregistrationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class DeregistrationRequest { 23 | public OperationHeader header; 24 | public DeregisterAuthenticator[] authenticators; 25 | } 26 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/DiscoverData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class DiscoverData { 23 | public Version[] supportedUAFVersions; 24 | public String clientVendor; 25 | public Version clientVersion; 26 | public Authenticator[] availableAuthenticators; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/DisplayPNGCharacteristicsDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class DisplayPNGCharacteristicsDescriptor { 23 | public long width; 24 | public long height; 25 | public String bitDepth; 26 | public String colorType; 27 | public String compression; 28 | public String filter; 29 | public String interlace; 30 | public rgbPalletteEntry[] plte; 31 | } 32 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Extension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class Extension { 23 | public String id; 24 | public String data; 25 | public boolean fail_if_unknown; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/FinalChallengeParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class FinalChallengeParams { 23 | public String appID; 24 | public String challenge; 25 | public String facetID; 26 | public ChannelBinding channelBinding; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/MatchCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | import com.yalin.fidoclient.asm.msg.obj.AuthenticatorInfo; 20 | 21 | import java.util.Arrays; 22 | 23 | /** 24 | * Created by YaLin on 2016/1/21. 25 | */ 26 | public class MatchCriteria { 27 | public String[] aaid; 28 | //public String[] vendorID; 29 | public String[] keyIDs; 30 | // public long userVerification; 31 | // public int keyProtection; 32 | //public int matcherProtection; 33 | public long attachmentHint; 34 | //public int tcDisplay; 35 | //public int[] authenticationAlgorithms; 36 | public String[] assertionSchemes; 37 | //public int[] attestationTypes; 38 | public int authenticatorVersion; 39 | public Extension[] exts; 40 | 41 | public boolean isMatch(AuthenticatorInfo info) { 42 | boolean match = false; 43 | if (aaid != null) { 44 | if (!Arrays.asList(aaid).contains(info.aaid)) { 45 | return false; 46 | } 47 | match = true; 48 | } 49 | if (match) { 50 | if (assertionSchemes != null) { 51 | for (String assertionScheme : assertionSchemes) { 52 | if (!assertionScheme.equals(info.assertionScheme)) { 53 | return false; 54 | } 55 | } 56 | } 57 | } 58 | return match; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public enum Operation { 23 | Reg, 24 | Auth, 25 | Dereg 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/OperationHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class OperationHeader { 23 | public Version upv; 24 | public Operation op; 25 | public String appID; 26 | public String serverData; 27 | public Extension[] exts; 28 | } 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Policy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class Policy { 23 | public MatchCriteria[][] accepted; 24 | public MatchCriteria[] disallowed; 25 | } 26 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/RegRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | import com.google.gson.Gson; 20 | 21 | /** 22 | * Created by YaLin on 2016/1/13. 23 | */ 24 | public class RegRecord { 25 | public int id; 26 | public String type; 27 | public String biometricsId; 28 | public String aaid; 29 | public String keyId; 30 | public String appId; 31 | public String username; 32 | public String userPrivateKey; 33 | public String userPublicKey; 34 | 35 | public RegRecord id(int id) { 36 | this.id = id; 37 | return this; 38 | } 39 | 40 | public RegRecord type(String type) { 41 | this.type = type; 42 | return this; 43 | } 44 | 45 | public RegRecord biometricsId(String biometricsId) { 46 | this.biometricsId = biometricsId; 47 | return this; 48 | } 49 | 50 | public RegRecord aaid(String aaid) { 51 | this.aaid = aaid; 52 | return this; 53 | } 54 | 55 | public RegRecord keyId(String keyId) { 56 | this.keyId = keyId; 57 | return this; 58 | } 59 | 60 | public RegRecord appId(String appId) { 61 | this.appId = appId; 62 | return this; 63 | } 64 | 65 | public RegRecord username(String username) { 66 | this.username = username; 67 | return this; 68 | } 69 | 70 | public RegRecord userPrivateKey(String userPrivateKey) { 71 | this.userPrivateKey = userPrivateKey; 72 | return this; 73 | } 74 | 75 | public RegRecord userPublicKey(String userPublicKey) { 76 | this.userPublicKey = userPublicKey; 77 | return this; 78 | } 79 | 80 | @Override 81 | public String toString() { 82 | return new Gson().toJson(this); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/RegistrationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class RegistrationRequest { 23 | public OperationHeader header; 24 | public String challenge; 25 | public String username; 26 | public Policy policy; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/RegistrationResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class RegistrationResponse { 23 | public OperationHeader header; 24 | public String fcParams; 25 | public AuthenticatorRegistrationAssertion[] assertions; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Transaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class Transaction { 23 | public String contentType; 24 | public String content; 25 | public DisplayPNGCharacteristicsDescriptor tcDisplayPNGCharacteristics; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | 20 | /** 21 | * Created by YaLin on 2016/1/21. 22 | */ 23 | public class Version { 24 | public int major; 25 | public int minor; 26 | 27 | public Version(int major, int minor) { 28 | this.major = major; 29 | this.minor = minor; 30 | } 31 | 32 | public static Version getCurrentSupport() { 33 | return new Version(1, 0); 34 | } 35 | 36 | @Override 37 | public boolean equals(Object o) { 38 | if (o instanceof Version) { 39 | if (((Version) o).major == this.major && ((Version) o).minor == this.minor) { 40 | return true; 41 | } 42 | } 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/client/JsonSerializable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg.client; 18 | 19 | import com.google.gson.Gson; 20 | 21 | /** 22 | * Created by YaLin on 2016/1/11. 23 | */ 24 | public abstract class JsonSerializable { 25 | protected transient Gson gson = new Gson(); 26 | 27 | public abstract String toJson(); 28 | 29 | public abstract void loadFromJson(String json); 30 | } 31 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/client/UAFIntentType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg.client; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public enum UAFIntentType { 23 | DISCOVER, 24 | DISCOVER_RESULT, 25 | 26 | //Perform a no-op check if a message could be processed. 27 | CHECK_POLICY, 28 | 29 | //Check Policy results. 30 | CHECK_POLICY_RESULT, 31 | 32 | //Process a Registration, Authentication, Transaction Confirmation or Deregistration message. 33 | UAF_OPERATION, 34 | 35 | //UAF Operation results. 36 | UAF_OPERATION_RESULT, 37 | 38 | //Inform the FIDO UAF Client of the completion status of a Registration, Authentication, 39 | // Transaction Confirmation or Deregistration message. 40 | UAF_OPERATION_COMPLETION_STATUS 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/client/UAFMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg.client; 18 | 19 | 20 | public class UAFMessage extends JsonSerializable { 21 | public String uafProtocolMessage; 22 | 23 | public UAFMessage(){ 24 | } 25 | 26 | public UAFMessage(String uafProtocolMessage) { 27 | this.uafProtocolMessage = uafProtocolMessage; 28 | } 29 | 30 | @Override 31 | public String toJson() { 32 | return gson.toJson(this); 33 | } 34 | 35 | @Override 36 | public void loadFromJson(String json) { 37 | UAFMessage message = gson.fromJson(json, UAFMessage.class); 38 | this.uafProtocolMessage = message.uafProtocolMessage; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/msg/rgbPalletteEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.msg; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class rgbPalletteEntry { 23 | public short r; 24 | public short g; 25 | public short b; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/BaseRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net; 18 | 19 | 20 | import com.android.volley.AuthFailureError; 21 | import com.android.volley.NetworkResponse; 22 | import com.android.volley.Request; 23 | import com.android.volley.Response; 24 | import com.android.volley.VolleyError; 25 | import com.android.volley.toolbox.HttpHeaderParser; 26 | import com.google.gson.Gson; 27 | import com.yalin.fidoclient.net.response.BaseResponse; 28 | 29 | import java.util.Map; 30 | 31 | /** 32 | * Created by 雅麟 on 2015/6/17. 33 | */ 34 | public class BaseRequest extends Request { 35 | private static final String TAG = BaseRequest.class.getSimpleName(); 36 | 37 | protected Response.Listener mListener; 38 | protected Gson mGson; 39 | protected Class mCls; 40 | protected Map mHeaders; 41 | 42 | protected BaseRequest(int method, String url, Response.ErrorListener errorListener) { 43 | super(method, url, errorListener); 44 | } 45 | 46 | public BaseRequest(int method, String url, Map headers, Class cls, Response.Listener listener, Response.ErrorListener errorListener) { 47 | this(method, url, cls, headers, listener, errorListener); 48 | } 49 | 50 | public BaseRequest(int method, String url, Class cls, Response.Listener listener, Response.ErrorListener errorListener) { 51 | this(method, url, cls, null, listener, errorListener); 52 | } 53 | 54 | public BaseRequest(int method, String url, Class cls, Map headers, Response.Listener listener, Response.ErrorListener errorListener) { 55 | this(method, url, errorListener); 56 | mListener = listener; 57 | mGson = new Gson(); 58 | mCls = cls; 59 | mHeaders = headers; 60 | } 61 | 62 | public void setHeaders(Map headers) { 63 | mHeaders = headers; 64 | } 65 | 66 | @Override 67 | protected Response parseNetworkResponse(NetworkResponse response) { 68 | T parsedGSON; 69 | try { 70 | String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); 71 | parsedGSON = mGson.fromJson(jsonString, mCls); 72 | } catch (Exception e) { 73 | return Response.error(new MyVolleyError(ErrorCodeConstants.ServerError)); 74 | } 75 | 76 | return Response.success(parsedGSON, HttpHeaderParser.parseCacheHeaders(response)); 77 | } 78 | 79 | @Override 80 | protected VolleyError parseNetworkError(VolleyError volleyError) { 81 | if (volleyError != null) { 82 | if (volleyError.networkResponse != null) { 83 | volleyError = new MyVolleyError(ErrorCodeConstants.ServerError); 84 | } else { 85 | volleyError = new MyVolleyError(ErrorCodeConstants.NetworkError); 86 | } 87 | } else { 88 | volleyError = new MyVolleyError(ErrorCodeConstants.UnknownError); 89 | } 90 | return super.parseNetworkError(volleyError); 91 | } 92 | 93 | @Override 94 | protected void deliverResponse(T response) { 95 | if (mListener != null) { 96 | mListener.onResponse(response); 97 | } 98 | } 99 | 100 | @Override 101 | public void deliverError(VolleyError error) { 102 | super.deliverError(error); 103 | } 104 | 105 | @Override 106 | public Map getHeaders() throws AuthFailureError { 107 | if (mHeaders != null && mHeaders.size() > 0) { 108 | return mHeaders; 109 | } 110 | return super.getHeaders(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/ErrorCodeConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net; 18 | 19 | 20 | /** 21 | * Created by 雅麟 on 2015/6/19. 22 | */ 23 | public enum ErrorCodeConstants { 24 | Success(1200, "success"), 25 | NetworkError(7777, "network error"), 26 | ServerError(8888, "server error"), 27 | UnknownError(9999, "unknown"); 28 | 29 | public final int number; 30 | public final String msg; 31 | 32 | ErrorCodeConstants(int number, String msg) { 33 | this.number = number; 34 | this.msg = msg; 35 | } 36 | 37 | public static ErrorCodeConstants getValue(int error) { 38 | for (ErrorCodeConstants item : values()) { 39 | if (error == item.number) { 40 | return item; 41 | } 42 | } 43 | return UnknownError; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/GetRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net; 18 | 19 | 20 | import com.android.volley.Request; 21 | import com.android.volley.Response; 22 | import com.yalin.fidoclient.net.response.BaseResponse; 23 | 24 | import java.util.Map; 25 | 26 | /** 27 | * Created by 雅麟 on 2015/3/21. 28 | */ 29 | public class GetRequest extends BaseRequest { 30 | 31 | public GetRequest(String url, Class cls, Map header, Response.Listener listener, Response.ErrorListener errorListener) { 32 | super(Request.Method.GET, url, cls, header, listener, errorListener); 33 | } 34 | 35 | public GetRequest(String url, Class cls, Response.Listener listener, Response.ErrorListener errorListener) { 36 | this(url, cls, null, listener, errorListener); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/MyVolleyError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net; 18 | 19 | import com.android.volley.VolleyError; 20 | 21 | /** 22 | * Created by YaLin on 2015/7/20. 23 | */ 24 | public class MyVolleyError extends VolleyError { 25 | 26 | public MyVolleyError( ErrorCodeConstants errorConstant) { 27 | super(errorConstant.msg); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/RequestQueueHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net; 18 | 19 | import android.content.Context; 20 | 21 | import com.android.volley.RequestQueue; 22 | import com.android.volley.toolbox.Volley; 23 | 24 | 25 | /** 26 | * Created by 雅麟 on 2015/3/27. 27 | */ 28 | public class RequestQueueHelper { 29 | private static RequestQueue sInstance; 30 | 31 | public static RequestQueue getInstance(Context context) { 32 | if (sInstance == null) { 33 | sInstance = Volley.newRequestQueue(context); 34 | } 35 | return sInstance; 36 | } 37 | 38 | public static RequestQueue getInstance() { 39 | return sInstance; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/response/BaseResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net.response; 18 | 19 | /** 20 | * Created by 雅麟 on 2015/3/21. 21 | */ 22 | public class BaseResponse { 23 | public int errorCode; 24 | } 25 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/response/FacetIdList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net.response; 18 | 19 | import com.yalin.fidoclient.msg.Version; 20 | 21 | /** 22 | * Created by YaLin on 2016/3/2. 23 | */ 24 | public class FacetIdList { 25 | public Version version; 26 | public String[] ids; 27 | } 28 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/net/response/FacetIdListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.net.response; 18 | 19 | import java.util.ArrayList; 20 | 21 | /** 22 | * Created by YaLin on 2016/3/2. 23 | */ 24 | public class FacetIdListResponse extends BaseResponse{ 25 | public ArrayList trustedFacets; 26 | } 27 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/op/CheckPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.op; 18 | 19 | 20 | import com.yalin.fidoclient.asm.exceptions.ASMException; 21 | import com.yalin.fidoclient.asm.msg.ASMRequest; 22 | import com.yalin.fidoclient.asm.msg.Request; 23 | import com.yalin.fidoclient.msg.Policy; 24 | import com.yalin.fidoclient.msg.RegistrationRequest; 25 | import com.yalin.fidoclient.ui.fragment.AuthenticatorListFragment; 26 | 27 | /** 28 | * Created by YaLin on 2016/1/18. 29 | */ 30 | public class CheckPolicy extends ASMMessageHandler { 31 | private Policy policy; 32 | 33 | public CheckPolicy(AuthenticatorListFragment fragment, String message, int callerUid) { 34 | super(fragment, callerUid); 35 | try { 36 | RegistrationRequest registrationRequest = getRegistrationRequest(message); 37 | policy = registrationRequest.policy; 38 | } catch (Exception e) { 39 | throw new IllegalStateException("register message error"); 40 | } 41 | } 42 | 43 | @Override 44 | public void start() { 45 | ASMRequest asmRequest = new ASMRequest(); 46 | asmRequest.requestType = Request.GetInfo; 47 | gson.toJson(asmRequest); 48 | } 49 | 50 | @Override 51 | public void trafficStart() { 52 | 53 | } 54 | 55 | @Override 56 | public void traffic(String asmResponseMsg) throws ASMException { 57 | } 58 | 59 | private RegistrationRequest getRegistrationRequest(String uafMsg) { 60 | RegistrationRequest[] requests = gson.fromJson(uafMsg, RegistrationRequest[].class); 61 | return requests[0]; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/op/Completion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.op; 18 | 19 | 20 | import com.yalin.fidoclient.asm.exceptions.ASMException; 21 | import com.yalin.fidoclient.ui.fragment.AuthenticatorListFragment; 22 | 23 | /** 24 | * Created by YaLin on 2016/1/22. 25 | */ 26 | public class Completion extends ASMMessageHandler { 27 | public Completion(AuthenticatorListFragment fragment, int callerUid) { 28 | super(fragment, callerUid); 29 | } 30 | 31 | @Override 32 | public void start() { 33 | if (fragment.getActivity() != null) { 34 | fragment.getActivity().finish(); 35 | } 36 | } 37 | 38 | @Override 39 | public void trafficStart() { 40 | 41 | } 42 | 43 | @Override 44 | public void traffic(String asmResponseMsg) throws ASMException { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/op/Discover.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.op; 18 | 19 | import android.app.Activity; 20 | import android.content.Intent; 21 | 22 | import com.yalin.fidoclient.api.UAFClientError; 23 | import com.yalin.fidoclient.api.UAFIntent; 24 | import com.yalin.fidoclient.asm.api.ASMApi; 25 | import com.yalin.fidoclient.asm.api.StatusCode; 26 | import com.yalin.fidoclient.asm.exceptions.ASMException; 27 | import com.yalin.fidoclient.asm.msg.ASMResponse; 28 | import com.yalin.fidoclient.asm.msg.obj.AuthenticatorInfo; 29 | import com.yalin.fidoclient.asm.msg.obj.GetInfoOut; 30 | import com.yalin.fidoclient.msg.Authenticator; 31 | import com.yalin.fidoclient.msg.DiscoverData; 32 | import com.yalin.fidoclient.msg.Version; 33 | import com.yalin.fidoclient.op.traffic.Traffic; 34 | import com.yalin.fidoclient.ui.fragment.AuthenticatorListFragment; 35 | import com.yalin.fidoclient.utils.StatLog; 36 | 37 | /** 38 | * Created by YaLin on 2016/1/21. 39 | */ 40 | public class Discover extends ASMMessageHandler { 41 | private static final String TAG = Discover.class.getSimpleName(); 42 | 43 | public Discover(AuthenticatorListFragment fragment, int callerUid) { 44 | super(fragment, callerUid); 45 | updateState(Traffic.OpStat.PREPARE); 46 | } 47 | 48 | @Override 49 | public void start() { 50 | switch (mCurrentState) { 51 | case PREPARE: 52 | String getInfoMessage = getInfoRequest(new Version(1, 0)); 53 | ASMApi.doOperation(fragment, REQUEST_ASM_OPERATION, getInfoMessage, asmPackage); 54 | updateState(Traffic.OpStat.GET_INFO_PENDING); 55 | break; 56 | default: 57 | error(UAFClientError.PROTOCOL_ERROR); 58 | break; 59 | } 60 | } 61 | 62 | @Override 63 | public void trafficStart() { 64 | 65 | } 66 | 67 | @Override 68 | public void traffic(String asmResponseMsg) throws ASMException { 69 | StatLog.printLog(TAG, "asm response: " + asmResponseMsg); 70 | switch (mCurrentState) { 71 | case GET_INFO_PENDING: 72 | if (!handleGetInfo(asmResponseMsg)) { 73 | error(UAFClientError.PROTOCOL_ERROR); 74 | } 75 | updateState(Traffic.OpStat.PREPARE); 76 | break; 77 | default: 78 | error(UAFClientError.PROTOCOL_ERROR); 79 | break; 80 | } 81 | } 82 | 83 | private boolean handleGetInfo(String asmResponseMsg) { 84 | StatLog.printLog(TAG, "get info :" + asmResponseMsg); 85 | ASMResponse asmResponse = ASMResponse.fromJson(asmResponseMsg, GetInfoOut.class); 86 | if (asmResponse.statusCode != StatusCode.UAF_ASM_STATUS_OK) { 87 | return false; 88 | 89 | } 90 | GetInfoOut getInfoOut = (GetInfoOut) asmResponse.responseData; 91 | AuthenticatorInfo[] authenticatorInfos = getInfoOut.Authenticators; 92 | if (authenticatorInfos == null) { 93 | return false; 94 | } 95 | 96 | Authenticator[] authenticators = Authenticator.fromInfo(authenticatorInfos); 97 | if (authenticators == null) { 98 | return false; 99 | } 100 | DiscoverData discoverData = new DiscoverData(); 101 | discoverData.supportedUAFVersions = authenticators[0].supportedUAFVersions; 102 | discoverData.availableAuthenticators = authenticators; 103 | discoverData.clientVendor = "yalin"; 104 | discoverData.clientVersion = new Version(1, 0); 105 | String result = gson.toJson(discoverData); 106 | StatLog.printLog(TAG, "discover prepare result:" + result); 107 | if (fragment.getActivity() != null) { 108 | Intent intent = UAFIntent.getDiscoverResultIntent(result, fragment.getActivity().getComponentName().flattenToString(), UAFClientError.NO_ERROR); 109 | fragment.getActivity().setResult(Activity.RESULT_OK, intent); 110 | fragment.getActivity().finish(); 111 | } 112 | return true; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/op/traffic/Traffic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.op.traffic; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public class Traffic { 23 | public enum OpStat { 24 | PREPARE, 25 | GET_INFO_PENDING, 26 | REG_PENDING, 27 | AUTH_PENDING, 28 | DEREG_PENDING, 29 | 30 | PICK_AUTHENTICATOR_PENDING, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/tlv/Tag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.tlv; 18 | 19 | 20 | import android.util.Base64; 21 | 22 | /** 23 | * Created by YaLin on 2016/1/21. 24 | */ 25 | public class Tag { 26 | public int statusId = 0x00; 27 | public int id; 28 | public int lenght; 29 | public byte[] value; 30 | 31 | public String toString() { 32 | String ret = "Tag id:" + id; 33 | ret = ret + " Tag name: " + TagsEnum.get(id); 34 | if (value != null) { 35 | ret = ret + " Tag value:" + Base64.encode(value, Base64.URL_SAFE); 36 | } 37 | return ret; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/tlv/Tags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.tlv; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import java.util.Map.Entry; 22 | 23 | /** 24 | * Created by YaLin on 2016/1/21. 25 | */ 26 | public class Tags { 27 | 28 | private Map tags = new HashMap(); 29 | 30 | public void add(Tag t) { 31 | tags.put(t.id, t); 32 | } 33 | 34 | public void addAll(Tags all) { 35 | tags.putAll(all.getTags()); 36 | } 37 | 38 | public Map getTags() { 39 | return tags; 40 | } 41 | 42 | public String toString() { 43 | StringBuilder res = new StringBuilder(); 44 | for (Entry tag : tags.entrySet()) { 45 | res.append(", "); 46 | res.append(tag.getValue().toString()); 47 | } 48 | if (res.length() > 0) { 49 | return "{" + res.substring(1) + "}"; 50 | } else { 51 | return "{}"; 52 | } 53 | 54 | } 55 | 56 | public String toUAFV1TLV() { 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/tlv/TagsEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.tlv; 18 | 19 | /** 20 | * Created by YaLin on 2016/1/21. 21 | */ 22 | public enum TagsEnum { 23 | UAF_CMD_STATUS_ERR_UNKNOWN(0x01), 24 | TAG_UAFV1_REG_ASSERTION(0x3E01), 25 | TAG_UAFV1_AUTH_ASSERTION(0x3E02), 26 | TAG_UAFV1_KRD(0x3E03), 27 | TAG_UAFV1_SIGNED_DATA(0x3E04), 28 | TAG_ATTESTATION_CERT(0x2E05), 29 | TAG_SIGNATURE(0x2E06), 30 | TAG_ATTESTATION_BASIC_FULL(0x3E07), 31 | TAG_ATTESTATION_BASIC_SURROGATE(0x3E08), 32 | TAG_KEYID(0x2E09), 33 | TAG_FINAL_CHALLENGE(0x2E0A), 34 | TAG_AAID(0x2E0B), 35 | TAG_PUB_KEY(0x2E0C), 36 | TAG_COUNTERS(0x2E0D), 37 | TAG_ASSERTION_INFO(0x2E0E), 38 | TAG_AUTHENTICATOR_NONCE(0x2E0F), 39 | TAG_TRANSACTION_CONTENT_HASH(0x2E10), 40 | TAG_EXTENSION(0x3E11), 41 | TAG_EXTENSION_NON_CRITICAL(0x3E12), 42 | TAG_EXTENSION_ID(0x2E13), 43 | TAG_EXTENSION_DATA(0x2E14); 44 | 45 | final public int id; 46 | 47 | TagsEnum(int id) { 48 | this.id = id; 49 | } 50 | 51 | public static TagsEnum get(int id) { 52 | for (TagsEnum tag : TagsEnum.values()) { 53 | if (tag.id == id) { 54 | return tag; 55 | } 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/ui/AuthenticatorAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.ui; 18 | 19 | import android.content.Context; 20 | import android.content.res.Resources; 21 | import android.graphics.PorterDuff; 22 | import android.graphics.drawable.Drawable; 23 | import android.support.v7.widget.RecyclerView; 24 | import android.text.TextUtils; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | import android.widget.ImageView; 28 | import android.widget.TextView; 29 | 30 | import com.yalin.fidoclient.R; 31 | import com.yalin.fidoclient.asm.msg.obj.AuthenticatorInfo; 32 | 33 | import java.util.List; 34 | 35 | /** 36 | * Created by YaLin on 2016/1/19. 37 | */ 38 | public class AuthenticatorAdapter extends RecyclerView.Adapter { 39 | public interface OnAuthenticatorClickCallback { 40 | void onAuthenticatorClick(AuthenticatorInfo info); 41 | } 42 | 43 | private final Context mContext; 44 | private final List mInfos; 45 | private final OnAuthenticatorClickCallback mCallback; 46 | 47 | public AuthenticatorAdapter(Context context, List infos, OnAuthenticatorClickCallback callback) { 48 | mContext = context; 49 | mInfos = infos; 50 | mCallback = callback; 51 | } 52 | 53 | @Override 54 | public AuthenticatorItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 55 | View view = View.inflate(mContext, R.layout.authenticator_item, null); 56 | return new AuthenticatorItemViewHolder(view); 57 | } 58 | 59 | @Override 60 | public void onBindViewHolder(AuthenticatorItemViewHolder holder, int position) { 61 | final AuthenticatorInfo info = mInfos.get(position); 62 | if (TextUtils.isEmpty(info.title)) { 63 | info.title = mContext.getString(R.string.unknown_device); 64 | } 65 | holder.tvTitle.setText(info.title); 66 | // if (TextUtils.isEmpty(info.icon)) { 67 | holder.ivIcon.setImageResource(R.drawable.ic_fp_40px); 68 | // } 69 | holder.itemView.setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | if (mCallback != null) { 73 | mCallback.onAuthenticatorClick(info); 74 | } 75 | } 76 | }); 77 | } 78 | 79 | @Override 80 | public int getItemCount() { 81 | return mInfos == null ? 0 : mInfos.size(); 82 | } 83 | } 84 | 85 | class AuthenticatorItemViewHolder extends RecyclerView.ViewHolder { 86 | ImageView ivIcon; 87 | TextView tvTitle; 88 | 89 | public AuthenticatorItemViewHolder(View itemView) { 90 | super(itemView); 91 | ivIcon = (ImageView) itemView.findViewById(R.id.item_iv_icon); 92 | tvTitle = (TextView) itemView.findViewById(R.id.item_tv_title); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/ui/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.ui; 18 | 19 | import android.content.DialogInterface; 20 | import android.os.Bundle; 21 | import android.support.design.widget.FloatingActionButton; 22 | import android.support.v7.app.AlertDialog; 23 | import android.support.v7.app.AppCompatActivity; 24 | import android.text.TextUtils; 25 | import android.view.View; 26 | import android.widget.Button; 27 | 28 | import com.yalin.fidoclient.R; 29 | import com.yalin.fidoclient.api.UAFClientApi; 30 | import com.yalin.fidoclient.msg.AsmInfo; 31 | 32 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 33 | private static final String TAG = MainActivity.class.getSimpleName(); 34 | private View rootCoordinator; 35 | 36 | private AsmInfo asmInfo; 37 | 38 | private Button btnDefaultAsm; 39 | 40 | private boolean hasDefault = false; 41 | 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_main); 46 | 47 | initView(); 48 | initData(); 49 | } 50 | 51 | private void initView() { 52 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 53 | rootCoordinator = findViewById(R.id.root_coordinator); 54 | 55 | btnDefaultAsm = (Button) findViewById(R.id.setting_btn_asm_name); 56 | btnDefaultAsm.setOnClickListener(this); 57 | } 58 | 59 | private void initData() { 60 | asmInfo = UAFClientApi.getDefaultAsmInfo(getApplicationContext()); 61 | if (asmInfo != null) { 62 | if (!TextUtils.isEmpty(asmInfo.appName)) { 63 | hasDefault = true; 64 | btnDefaultAsm.setText(asmInfo.appName); 65 | } else if (!TextUtils.isEmpty(asmInfo.pack)) { 66 | hasDefault = true; 67 | btnDefaultAsm.setText(asmInfo.pack); 68 | } else { 69 | hasDefault = false; 70 | btnDefaultAsm.setText(R.string.default_asm_none); 71 | } 72 | } else { 73 | hasDefault = false; 74 | btnDefaultAsm.setText(R.string.default_asm_none); 75 | } 76 | } 77 | 78 | @Override 79 | public void onClick(View v) { 80 | switch (v.getId()) { 81 | case R.id.setting_btn_asm_name: 82 | if (hasDefault) { 83 | showAsmInfoAction(asmInfo); 84 | } else { 85 | showNoAsmInfoAction(); 86 | } 87 | break; 88 | } 89 | } 90 | 91 | private void showAsmInfoAction(final AsmInfo asmInfo) { 92 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 93 | builder.setTitle(asmInfo.appName); 94 | builder.setIcon(asmInfo.icon); 95 | builder.setMessage(getString(R.string.asm_pack_prompt, asmInfo.pack)); 96 | builder.setPositiveButton(R.string.reset, new DialogInterface.OnClickListener() { 97 | @Override 98 | public void onClick(DialogInterface dialog, int which) { 99 | UAFClientApi.clearDefaultAsm(getApplicationContext()); 100 | initData(); 101 | } 102 | }); 103 | builder.setNegativeButton(R.string.confirm, null); 104 | 105 | builder.create().show(); 106 | } 107 | 108 | private void showNoAsmInfoAction() { 109 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 110 | builder.setMessage(getString(R.string.no_default_asm_prompt)); 111 | builder.setPositiveButton(R.string.confirm, null); 112 | 113 | builder.create().show(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/ui/fragment/AsmListAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.ui.fragment; 18 | 19 | import android.content.Context; 20 | import android.content.pm.ResolveInfo; 21 | import android.graphics.drawable.Drawable; 22 | import android.support.v7.widget.RecyclerView; 23 | import android.view.LayoutInflater; 24 | import android.view.View; 25 | import android.view.ViewGroup; 26 | import android.widget.ImageView; 27 | import android.widget.TextView; 28 | 29 | import com.yalin.fidoclient.R; 30 | import com.yalin.fidoclient.msg.AsmInfo; 31 | 32 | import java.util.List; 33 | 34 | /** 35 | * Created by YaLin on 2016/2/26. 36 | */ 37 | public class AsmListAdapter extends RecyclerView.Adapter { 38 | public interface ASMClickListener { 39 | void onAsmItemClicked(AsmInfo info); 40 | } 41 | 42 | private final Context mContext; 43 | private final List mInfos; 44 | private final ASMClickListener mCallback; 45 | 46 | public AsmListAdapter(Context context, List infos, ASMClickListener callback) { 47 | mContext = context; 48 | mInfos = infos; 49 | mCallback = callback; 50 | } 51 | 52 | @Override 53 | public AsmListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 54 | View view = LayoutInflater.from(mContext).inflate(R.layout.asm_item, parent, false); 55 | return new AsmListViewHolder(view); 56 | } 57 | 58 | @Override 59 | public void onBindViewHolder(AsmListViewHolder holder, int position) { 60 | final ResolveInfo info = mInfos.get(position); 61 | final String label = info.loadLabel(mContext.getPackageManager()).toString(); 62 | Drawable drawable = info.loadIcon(mContext.getPackageManager()); 63 | final AsmInfo asmInfo = new AsmInfo(); 64 | asmInfo.appName(label) 65 | .pack(info.activityInfo.packageName) 66 | .icon(drawable); 67 | 68 | holder.tvName.setText(label); 69 | holder.tvPack.setText(info.activityInfo.packageName); 70 | holder.ivIcon.setImageDrawable(drawable); 71 | 72 | holder.itemView.setOnClickListener(new View.OnClickListener() { 73 | @Override 74 | public void onClick(View v) { 75 | if (mCallback != null) { 76 | mCallback.onAsmItemClicked(asmInfo); 77 | } 78 | } 79 | } 80 | ); 81 | } 82 | 83 | @Override 84 | public int getItemCount() { 85 | return mInfos == null ? 0 : mInfos.size(); 86 | } 87 | } 88 | 89 | class AsmListViewHolder extends RecyclerView.ViewHolder { 90 | ImageView ivIcon; 91 | TextView tvName; 92 | TextView tvPack; 93 | 94 | public AsmListViewHolder(View itemView) { 95 | super(itemView); 96 | ivIcon = (ImageView) itemView.findViewById(R.id.item_iv_icon); 97 | tvName = (TextView) itemView.findViewById(R.id.item_tv_name); 98 | tvPack = (TextView) itemView.findViewById(R.id.item_tv_pack); 99 | } 100 | } -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/ui/fragment/AsmListFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.ui.fragment; 18 | 19 | import android.content.Intent; 20 | import android.content.pm.PackageManager; 21 | import android.content.pm.ResolveInfo; 22 | import android.os.Bundle; 23 | import android.support.annotation.Nullable; 24 | import android.support.v4.app.Fragment; 25 | import android.support.v4.app.FragmentManager; 26 | import android.support.v7.widget.LinearLayoutManager; 27 | import android.support.v7.widget.RecyclerView; 28 | import android.view.LayoutInflater; 29 | import android.view.View; 30 | import android.view.ViewGroup; 31 | import android.widget.TextView; 32 | 33 | import com.yalin.fidoclient.R; 34 | import com.yalin.fidoclient.asm.api.ASMIntent; 35 | import com.yalin.fidoclient.msg.AsmInfo; 36 | 37 | import java.util.List; 38 | 39 | /** 40 | * Created by YaLin on 2016/2/26. 41 | */ 42 | public class AsmListFragment extends Fragment implements AsmListAdapter.ASMClickListener { 43 | public interface AsmItemPickListener { 44 | void onAsmItemPick(AsmInfo info); 45 | } 46 | 47 | private static final String TAG = AsmListFragment.class.getSimpleName(); 48 | 49 | private TextView tvAsmListPrompt; 50 | private RecyclerView rvAsmList; 51 | 52 | private AsmItemPickListener listener; 53 | 54 | public static AsmListFragment getInstance(AsmItemPickListener listener) { 55 | AsmListFragment fragment = new AsmListFragment(); 56 | fragment.listener = listener; 57 | return fragment; 58 | } 59 | 60 | public static void open(int container, FragmentManager manager, AsmItemPickListener listener) { 61 | if (manager.findFragmentByTag(TAG) != null) { 62 | return; 63 | } 64 | manager.beginTransaction() 65 | .add(container, getInstance(listener), TAG) 66 | .addToBackStack(null) 67 | .commit(); 68 | } 69 | 70 | @Nullable 71 | @Override 72 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 73 | View view = inflater.inflate(R.layout.fragment_asm_list, container, false); 74 | findView(view); 75 | initData(); 76 | return view; 77 | } 78 | 79 | private void findView(View view) { 80 | tvAsmListPrompt = (TextView) view.findViewById(R.id.tv_asm_list_prompt); 81 | rvAsmList = (RecyclerView) view.findViewById(R.id.rv_asm_list); 82 | 83 | rvAsmList.setLayoutManager(new LinearLayoutManager(getActivity())); 84 | } 85 | 86 | private void initData() { 87 | Intent intent = ASMIntent.getASMIntent(); 88 | PackageManager pm = getActivity().getApplicationContext().getPackageManager(); 89 | 90 | List infos = pm.queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS); 91 | if (infos != null && infos.size() > 0) { 92 | AsmListAdapter asmListAdapter = new AsmListAdapter(getActivity(), infos, this); 93 | rvAsmList.setAdapter(asmListAdapter); 94 | } else { 95 | tvAsmListPrompt.setText(R.string.no_asm); 96 | } 97 | } 98 | 99 | @Override 100 | public void onAsmItemClicked(AsmInfo info) { 101 | if (listener != null) { 102 | listener.onAsmItemPick(info); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/utils/StatLog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.utils; 18 | 19 | import android.os.Environment; 20 | import android.os.Process; 21 | import android.util.Log; 22 | 23 | import com.yalin.fidoclient.BuildConfig; 24 | 25 | import java.io.BufferedWriter; 26 | import java.io.File; 27 | import java.io.FileOutputStream; 28 | import java.io.OutputStreamWriter; 29 | import java.util.Calendar; 30 | import java.util.Locale; 31 | 32 | public class StatLog { 33 | 34 | private static final String FILE_NAME = "FidoUAF/stat_log.txt"; 35 | 36 | public static synchronized boolean isLogEnabled() { 37 | if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { 38 | return false; 39 | } 40 | // if (BuildConfig.DEBUG) { 41 | // return true; 42 | // } 43 | return false; 44 | // return true; 45 | } 46 | 47 | public static void printLog(String tag, String msg) { 48 | if (!isLogEnabled()) { 49 | return; 50 | } 51 | String procInfo = "Process id: " + Process.myPid() 52 | + " Thread id: " + Thread.currentThread().getId() + " "; 53 | 54 | Log.d(tag, procInfo + msg); 55 | 56 | writeLog(tag, procInfo + msg); 57 | } 58 | 59 | private static synchronized void writeLog(String tag, String msg) { 60 | internalWriteLog(FILE_NAME, tag, msg); 61 | } 62 | 63 | private static synchronized void internalWriteLog(String filename, String tag, String msg) { 64 | try { 65 | if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { 66 | return; 67 | } 68 | 69 | File file = new File(Environment.getExternalStorageDirectory(), filename); 70 | file.getParentFile().mkdirs(); 71 | 72 | BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); 73 | 74 | String time = getCurrentTime(); 75 | bw.write(time + " " + tag + " \t" + msg + "\r\n"); 76 | 77 | bw.close(); 78 | } catch (Exception e) { 79 | // ignore 80 | } 81 | } 82 | 83 | private static String getCurrentTime() { 84 | Calendar c = Calendar.getInstance(); 85 | return String.format(Locale.getDefault(), "%d-%02d-%02d %02d:%02d:%02d.%03d", 86 | c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH), 87 | c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND), 88 | c.get(Calendar.MILLISECOND)); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /fidoclient/src/main/java/com/yalin/fidoclient/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 YaLin Jin 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.yalin.fidoclient.utils; 18 | 19 | import android.content.Context; 20 | import android.content.pm.PackageInfo; 21 | import android.content.pm.PackageManager; 22 | import android.util.Base64; 23 | 24 | import java.io.ByteArrayInputStream; 25 | import java.io.InputStream; 26 | import java.security.MessageDigest; 27 | import java.security.NoSuchAlgorithmException; 28 | import java.security.cert.CertificateException; 29 | import java.security.cert.CertificateFactory; 30 | import java.security.cert.X509Certificate; 31 | 32 | /** 33 | * Created by YaLin on 2016/1/13. 34 | */ 35 | public class Utils { 36 | public static String getFacetId(Context context, int callingUid) { 37 | String packageNames[] = context.getPackageManager().getPackagesForUid(callingUid); 38 | 39 | if (packageNames == null) { 40 | return null; 41 | } 42 | try { 43 | PackageInfo info = context.getPackageManager().getPackageInfo(packageNames[0], PackageManager.GET_SIGNATURES); 44 | 45 | byte[] cert = info.signatures[0].toByteArray(); 46 | InputStream input = new ByteArrayInputStream(cert); 47 | 48 | CertificateFactory cf = CertificateFactory.getInstance("X509"); 49 | X509Certificate c = (X509Certificate) cf.generateCertificate(input); 50 | 51 | MessageDigest md = MessageDigest.getInstance("SHA1"); 52 | 53 | return "android:apk-key-hash:" + 54 | Base64.encodeToString(md.digest(c.getEncoded()), Base64.DEFAULT | Base64.NO_WRAP | Base64.NO_PADDING); 55 | } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException | CertificateException e) { 56 | e.printStackTrace(); 57 | } 58 | 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/anim/push_left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/anim/push_left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/anim/push_right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/anim/push_right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/color/navdrawer_item_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/color/navdrawer_item_title.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable-xhdpi/ic_fp_40px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinkg/UAFClient/c3277e4fdfff69dbd3ef1b1cd376b9522ea88d35/fidoclient/src/main/res/drawable-xhdpi/ic_fp_40px.png -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable-xhdpi/ic_linked_camera_black_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinkg/UAFClient/c3277e4fdfff69dbd3ef1b1cd376b9522ea88d35/fidoclient/src/main/res/drawable-xhdpi/ic_linked_camera_black_48dp.png -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable-xhdpi/ic_register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinkg/UAFClient/c3277e4fdfff69dbd3ef1b1cd376b9522ea88d35/fidoclient/src/main/res/drawable-xhdpi/ic_register.png -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable/ic_fingerprint_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable/ic_fingerprint_success.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/drawable/item_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/activity_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/activity_fido_client.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/asm_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | 33 | 34 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/authenticator_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /fidoclient/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 18 | 19 |