-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Firebase Auth MFA info to user record
- Loading branch information
Showing
6 changed files
with
280 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/main/java/com/google/firebase/auth/MultiFactorInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2022 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.firebase.auth; | ||
|
||
import com.google.firebase.auth.internal.GetAccountInfoResponse; | ||
import com.google.firebase.internal.Nullable; | ||
|
||
/** | ||
* Interface representing the common properties of a user-enrolled second factor. | ||
*/ | ||
public abstract class MultiFactorInfo { | ||
|
||
/** | ||
* The ID of the enrolled second factor. This ID is unique to the user. | ||
*/ | ||
private final String uid; | ||
|
||
/** | ||
* The optional display name of the enrolled second factor. | ||
*/ | ||
private final String displayName; | ||
|
||
/** | ||
* The type identifier of the second factor. For SMS second factors, this is `phone`. | ||
*/ | ||
private final String factorId; | ||
|
||
/** | ||
* The optional date the second factor was enrolled, formatted as a UTC string. | ||
*/ | ||
private final String enrollmentTime; | ||
|
||
MultiFactorInfo(GetAccountInfoResponse.MultiFactorInfo response) { | ||
this.uid = response.getMfaEnrollmentId(); | ||
this.displayName = response.getDisplayName(); | ||
this.factorId = response.getFactorId(); | ||
this.enrollmentTime = response.getEnrollmentTime(); | ||
} | ||
|
||
public String getUid() { | ||
return uid; | ||
} | ||
|
||
@Nullable | ||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public String getFactorId() { | ||
return factorId; | ||
} | ||
|
||
@Nullable | ||
public String getEnrollmentTime() { | ||
return enrollmentTime; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/google/firebase/auth/MultiFactorSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2022 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.firebase.auth; | ||
|
||
/** | ||
* The multi-factor related user settings. | ||
*/ | ||
public class MultiFactorSettings { | ||
|
||
private final PhoneMultiFactorInfo[] enrolledFactors; | ||
|
||
public MultiFactorSettings(PhoneMultiFactorInfo[] enrolledFactors) { | ||
this.enrolledFactors = enrolledFactors; | ||
} | ||
|
||
public PhoneMultiFactorInfo[] getEnrolledFactors() { | ||
return enrolledFactors; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/google/firebase/auth/PhoneMultiFactorInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2022 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.firebase.auth; | ||
|
||
import com.google.firebase.auth.internal.GetAccountInfoResponse; | ||
|
||
/** | ||
* Interface representing the common properties of a user-enrolled second factor. | ||
*/ | ||
public class PhoneMultiFactorInfo extends MultiFactorInfo { | ||
|
||
/** | ||
* The phone number associated with a phone second factor. | ||
*/ | ||
private final String phoneNumber; | ||
|
||
private final String unobfuscatedPhoneNumber; | ||
|
||
public PhoneMultiFactorInfo(GetAccountInfoResponse.MultiFactorInfo response) { | ||
super(response); | ||
|
||
this.phoneNumber = response.getPhoneInfo(); | ||
this.unobfuscatedPhoneNumber = response.getUnobfuscatedPhoneInfo(); | ||
} | ||
|
||
public String getPhoneNumber() { | ||
return phoneNumber; | ||
} | ||
|
||
public String getUnobfuscatedPhoneNumber() { | ||
return unobfuscatedPhoneNumber; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters