public List < AuthFactor > getFactors ( long userId ) throws OAuthSystemException , OAuthProblemException , URISyntaxException { cleanError ( ) ; prepareToken ( ) ; URIBuilder url = new URIBuilder ( settings . getURL ( Constants . GET_FACTORS_URL , userId ) ) ; OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient ( ) ; OAuthClient oAuthClient = new OAuthClient ( httpClient ) ; OAuthClientRequest bearerRequest = new OAuthBearerClientRequest ( url . toString ( ) ) . buildHeaderMessage ( ) ; Map < String , String > headers = getAuthorizedHeader ( ) ; bearerRequest . setHeaders ( headers ) ; List < AuthFactor > authFactors = new ArrayList < AuthFactor > ( ) ; OneloginOAuthJSONResourceResponse oAuthResponse = oAuthClient . resource ( bearerRequest , OAuth . HttpMethod . GET , OneloginOAuthJSONResourceResponse . class ) ; if ( oAuthResponse . getResponseCode ( ) == 200 ) { JSONObject data = oAuthResponse . getData ( ) ; if ( data . has ( "auth_factors" ) ) { JSONArray dataArray = data . getJSONArray ( "auth_factors" ) ; if ( dataArray != null && dataArray . length ( ) > 0 ) { AuthFactor authFactor ; for ( int i = 0 ; i < dataArray . length ( ) ; i ++ ) { authFactor = new AuthFactor ( dataArray . getJSONObject ( i ) ) ; authFactors . add ( authFactor ) ; } } } } else { error = oAuthResponse . getError ( ) ; errorDescription = oAuthResponse . getErrorDescription ( ) ; } return authFactors ; }
Returns a list of authentication factors that are available for user enrollment via API .