This repository was archived by the owner on Dec 12, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
api/src/main/java/com/stormpath/sdk/factor/google
impl/src/main/java/com/stormpath/sdk/impl/factor/google Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 2828 * <p/>
2929 * As such, the challenge can be created with the code at the same time:
3030 * <p/>
31+ *
3132 * <pre>
32- * GoogleAuthenticatorChallenge challenge = client.instantiate(GoogleAuthenticatorChallenge.class);
33- * challenge = (GoogleAuthenticatorChallenge) googleAuthenticatorFactor.createChallenge(
34- * Challenges.GOOGLE_AUTHENTICATOR
35- * .newCreateRequestFor(challenge)
36- * <b>.withCode(code)</b>
37- * .build()
38- * );
33+ * GoogleAuthenticatorChallenge challenge = googleAuthenticatorFactor.createChallenge(code);
3934 * </pre>
4035 *
4136 * @since 1.1.0
@@ -93,4 +88,12 @@ public interface GoogleAuthenticatorFactor<T extends GoogleAuthenticatorChalleng
9388 * @return the base64QRImage.
9489 */
9590 String getBase64QrImage ();
91+
92+ /**
93+ *
94+ * @param code The code to validate the challenge that is created. With Google Authenticator, you can create a
95+ * challenge and validate it all in one call.
96+ * @return the {@link GoogleAuthenticatorChallenge}
97+ */
98+ GoogleAuthenticatorChallenge createChallenge (String code );
9699}
Original file line number Diff line number Diff line change 1818import com .stormpath .sdk .challenge .google .GoogleAuthenticatorChallenge ;
1919import com .stormpath .sdk .factor .FactorType ;
2020import com .stormpath .sdk .factor .google .GoogleAuthenticatorFactor ;
21+ import com .stormpath .sdk .impl .challenge .google .DefaultGoogleAuthenticatorChallenge ;
2122import com .stormpath .sdk .impl .ds .InternalDataStore ;
2223import com .stormpath .sdk .impl .factor .AbstractFactor ;
2324import com .stormpath .sdk .impl .resource .Property ;
@@ -89,6 +90,13 @@ public String getBase64QrImage() {
8990 return getString (BASE64_QR_IMAGE );
9091 }
9192
93+ @ Override
94+ public GoogleAuthenticatorChallenge createChallenge (String code ) {
95+ GoogleAuthenticatorChallenge challenge = new DefaultGoogleAuthenticatorChallenge (getDataStore ());
96+ challenge .setCode (code );
97+ return createChallenge (challenge );
98+ }
99+
92100 protected FactorType getConcreteFactorType () {
93101 return FactorType .GOOGLE_AUTHENTICATOR ;
94102 }
You can’t perform that action at this time.
0 commit comments