@@ -70,21 +70,22 @@ class StLoginManagerImpl @Inject constructor(
7070 }
7171
7272 override suspend fun getStAuthData (): StAuthData ? {
73- if (needsAccessTokenRefresh()) {
74- val refreshed = refreshAuthState()
75- if (! refreshed) {
76- return null
77- }
78- }
79-
80- return authStateManager?.current?.let { authState ->
81- StAuthData (
82- authState.accessToken!! ,
83- " SecretKey" ,
84- authState.idToken!! ,
85- authState.accessTokenExpirationTime.toString()
86- )
87- }
73+ // if (needsAccessTokenRefresh()) {
74+ // val refreshed = refreshAuthState()
75+ // if (!refreshed) {
76+ // return null
77+ // }
78+ // }
79+ //
80+ // return authStateManager?.current?.let { authState ->
81+ // StAuthData(
82+ // authState.accessToken!!,
83+ // "SecretKey",
84+ // authState.idToken!!,
85+ // authState.accessTokenExpirationTime.toString()
86+ // )
87+ // }
88+ return null
8889 }
8990
9091 private fun needsAccessTokenRefresh (): Boolean {
@@ -115,51 +116,52 @@ class StLoginManagerImpl @Inject constructor(
115116 }
116117
117118 private fun initAppAuth () {
118- configuration.acceptConfiguration()
119-
120- authStateManager = AuthStateManager .getInstance(context, TAG )
121-
122- val serviceConfig = AuthorizationServiceConfiguration (
123- configuration.authEndpointUri!! ,
124- configuration.tokenEndpointUri!! ,
125- configuration.registrationEndpointUri,
126- configuration.endSessionEndpoint
127- )
128-
129- val authRequestBuilder = AuthorizationRequest .Builder (
130- serviceConfig,
131- configuration.clientId!! ,
132- ResponseTypeValues .CODE ,
133- configuration.redirectUri
134- )
135- .setScope(configuration.scope)
136- .setAdditionalParameters(mapOf (" identity_provider" to configuration.identityProvider))
137-
138- authRequest = authRequestBuilder.build()
139-
140- val builder = AppAuthConfiguration .Builder ()
141- builder.setBrowserMatcher(
142- BrowserDenyList (
143- VersionedBrowserMatcher (
144- Browsers .SBrowser .PACKAGE_NAME ,
145- Browsers .SBrowser .SIGNATURE_SET ,
146- true , // when this browser is used via a custom tab
147- VersionRange .atMost(" 5.3" )
148- )
149- )
150- )
151- builder.setConnectionBuilder(configuration.connectionBuilder)
152- authService = AuthorizationService (context, builder.build())
119+ // configuration.acceptConfiguration()
120+ //
121+ // authStateManager = AuthStateManager.getInstance(context, TAG)
122+ //
123+ // val serviceConfig = AuthorizationServiceConfiguration(
124+ // configuration.authEndpointUri!!,
125+ // configuration.tokenEndpointUri!!,
126+ // configuration.registrationEndpointUri,
127+ // configuration.endSessionEndpoint
128+ // )
129+ //
130+ // val authRequestBuilder = AuthorizationRequest.Builder(
131+ // serviceConfig,
132+ // configuration.clientId!!,
133+ // ResponseTypeValues.CODE,
134+ // configuration.redirectUri
135+ // )
136+ // .setScope(configuration.scope)
137+ // .setAdditionalParameters(mapOf("identity_provider" to configuration.identityProvider))
138+ //
139+ // authRequest = authRequestBuilder.build()
140+ //
141+ // val builder = AppAuthConfiguration.Builder()
142+ // builder.setBrowserMatcher(
143+ // BrowserDenyList(
144+ // VersionedBrowserMatcher(
145+ // Browsers.SBrowser.PACKAGE_NAME,
146+ // Browsers.SBrowser.SIGNATURE_SET,
147+ // true, // when this browser is used via a custom tab
148+ // VersionRange.atMost("5.3")
149+ // )
150+ // )
151+ // )
152+ // builder.setConnectionBuilder(configuration.connectionBuilder)
153+ // authService = AuthorizationService(context, builder.build())
153154 }
154155
155156 override suspend fun login (activityResultRegistry : ActivityResultRegistry ): StAuthData ? {
156- return if (isLoggedIn()) {
157- getStAuthData()
158- } else {
159- startFlow(activityResultRegistry = activityResultRegistry)
160-
161- getStAuthData()
162- }
157+ // return if (isLoggedIn()) {
158+ // getStAuthData()
159+ // } else {
160+ // startFlow(activityResultRegistry = activityResultRegistry)
161+ //
162+ // getStAuthData()
163+ // }
164+ return null
163165 }
164166
165167 private suspend fun startFlow (activityResultRegistry : ActivityResultRegistry ) {
@@ -255,84 +257,85 @@ class StLoginManagerImpl @Inject constructor(
255257 }
256258
257259 override suspend fun logout (activityResultRegistry : ActivityResultRegistry ) {
258- suspendCoroutine { continuation ->
259- authService?.let { authService ->
260-
261- authStateManager?.current?.let { authState ->
262- val serviceConfig = AuthorizationServiceConfiguration (
263- configuration.authEndpointUri!! ,
264- configuration.tokenEndpointUri!! ,
265- configuration.registrationEndpointUri,
266- configuration.endSessionEndpoint
267- )
268-
269-
270- endRequest = EndSessionRequest .Builder (serviceConfig)
271- .setAdditionalParameters(
272- mapOf (
273- " client_id" to configuration.clientId,
274- " response_type" to ResponseTypeValues .CODE ,
275- " redirect_uri" to configuration.redirectUri.toString(),
276- " logout_uri" to configuration.redirectUri.toString(),
277- " identity_provider" to configuration.identityProvider
278- )
279- )
280- .setIdTokenHint(authState.idToken)
281- .build()
282-
283- val intent = authService.getEndSessionRequestIntent(endRequest!! )
284-
285- val launcher: ActivityResultLauncher <Unit > =
286- activityResultRegistry.register(
287- " key2" ,
288- object :
289- ActivityResultContract <Unit , Pair <AuthorizationResponse ?, AuthorizationException ?>? > () {
290- override fun createIntent (
291- context : Context ,
292- input : Unit
293- ): Intent =
294- intent
295-
296- override fun parseResult (
297- resultCode : Int ,
298- intent : Intent ?
299- ): Pair <AuthorizationResponse ?, AuthorizationException ?>? {
300- intent?.let { data ->
301- if (resultCode != 0 ) {
302- val response = AuthorizationResponse .fromIntent(data)
303- val ex = AuthorizationException .fromIntent(data)
304-
305- return Pair (response, ex)
306- }
307- }
308- return null
309- }
310- }
311- ) { result ->
312- result?.let {
313- val response = it.first
314- val ex = it.second
315-
316- ex?.let {
317- Log .w(TAG , it.localizedMessage)
318- }
319- val clearedState =
320- AuthState (authState.authorizationServiceConfiguration!! )
321- if (authState.lastRegistrationResponse != null ) {
322- clearedState.update(authState.lastRegistrationResponse)
323- }
324- authStateManager?.replace(clearedState)
325-
326- continuation.resume(Unit )
327- }
328- }
329-
330- launcher.launch(Unit )
331- }
332- }
333- }
260+ // suspendCoroutine { continuation ->
261+ // authService?.let { authService ->
262+ //
263+ // authStateManager?.current?.let { authState ->
264+ // val serviceConfig = AuthorizationServiceConfiguration(
265+ // configuration.authEndpointUri!!,
266+ // configuration.tokenEndpointUri!!,
267+ // configuration.registrationEndpointUri,
268+ // configuration.endSessionEndpoint
269+ // )
270+ //
271+ //
272+ // endRequest = EndSessionRequest.Builder(serviceConfig)
273+ // .setAdditionalParameters(
274+ // mapOf(
275+ // "client_id" to configuration.clientId,
276+ // "response_type" to ResponseTypeValues.CODE,
277+ // "redirect_uri" to configuration.redirectUri.toString(),
278+ // "logout_uri" to configuration.redirectUri.toString(),
279+ // "identity_provider" to configuration.identityProvider
280+ // )
281+ // )
282+ // .setIdTokenHint(authState.idToken)
283+ // .build()
284+ //
285+ // val intent = authService.getEndSessionRequestIntent(endRequest!!)
286+ //
287+ // val launcher: ActivityResultLauncher<Unit> =
288+ // activityResultRegistry.register(
289+ // "key2",
290+ // object :
291+ // ActivityResultContract<Unit, Pair<AuthorizationResponse?, AuthorizationException?>?>() {
292+ // override fun createIntent(
293+ // context: Context,
294+ // input: Unit
295+ // ): Intent =
296+ // intent
297+ //
298+ // override fun parseResult(
299+ // resultCode: Int,
300+ // intent: Intent?
301+ // ): Pair<AuthorizationResponse?, AuthorizationException?>? {
302+ // intent?.let { data ->
303+ // if (resultCode != 0) {
304+ // val response = AuthorizationResponse.fromIntent(data)
305+ // val ex = AuthorizationException.fromIntent(data)
306+ //
307+ // return Pair(response, ex)
308+ // }
309+ // }
310+ // return null
311+ // }
312+ // }
313+ // ) { result ->
314+ // result?.let {
315+ // val response = it.first
316+ // val ex = it.second
317+ //
318+ // ex?.let {
319+ // Log.w(TAG, it.localizedMessage)
320+ // }
321+ // val clearedState =
322+ // AuthState(authState.authorizationServiceConfiguration!!)
323+ // if (authState.lastRegistrationResponse != null) {
324+ // clearedState.update(authState.lastRegistrationResponse)
325+ // }
326+ // authStateManager?.replace(clearedState)
327+ //
328+ // continuation.resume(Unit)
329+ // }
330+ // }
331+ //
332+ // launcher.launch(Unit)
333+ // }
334+ // }
335+ // }
334336 }
335337
336338 override fun isLoggedIn (): Boolean =
337- authStateManager?.current?.isAuthorized ? : false
339+ // authStateManager?.current?.isAuthorized ?: false
340+ false
338341}
0 commit comments