protected Response migrateClientsOrganization ( final String organizationSid , UriInfo info , MediaType responseType , UserIdentityContext userIdentityContext ) { //First check if the account has the required permissions in general, this way we can fail fast and avoid expensive DAO operations permissionEvaluator . checkPermission ( "RestComm:Read:Organizations" , userIdentityContext ) ; Organization organization = null ; if ( ! Sid . pattern . matcher ( organizationSid ) . matches ( ) ) { return status ( BAD_REQUEST ) . build ( ) ; } else { try { if ( ! permissionEvaluator . isSuperAdmin ( userIdentityContext ) ) { return status ( FORBIDDEN ) . build ( ) ; } else { organization = organizationsDao . getOrganization ( new Sid ( organizationSid ) ) ; } } catch ( Exception e ) { return status ( NOT_FOUND ) . build ( ) ; } } if ( organization == null ) { return status ( NOT_FOUND ) . build ( ) ; } else { Response . ResponseBuilder ok = Response . ok ( ) ; List < Client > clients = clientsDao . getClientsByOrg ( organization . getSid ( ) ) ; Map < String , String > migratedClients = clientPasswordHashingService . hashClientPassword ( clients , organization . getDomainName ( ) ) ; if ( APPLICATION_XML_TYPE . equals ( responseType ) ) { final RestCommResponse response = new RestCommResponse ( migratedClients ) ; return ok . type ( APPLICATION_XML ) . entity ( xstream . toXML ( response ) ) . build ( ) ; } else if ( APPLICATION_JSON_TYPE . equals ( responseType ) ) { return ok . type ( APPLICATION_JSON ) . entity ( gson . toJson ( migratedClients ) ) . build ( ) ; } else { return null ; } } }
Hash password for clients of the given organization