Provider specific methods
769054
protected function facebookToLocalUser($userProfile)
    {  
        if (!isset($userProfile->emailVerified) || empty($userProfile->emailVerified)) {
            throw new Exception\RuntimeException(
                'Please verify your email with Facebook before attempting login',
                Result::FAILURE_CREDENTIAL_INVALID
            );
        }
        $mapper = $this->getZfcUserMapper();
        if (false != ($localUser = $mapper->findByEmail($userProfile->emailVerified))) {
            return $localUser;
        }
        
        $localUser = $this->instantiateLocalUser();
        $localUser->setEmail($userProfile->emailVerified)
            ->setDisplayName($userProfile->displayName)
            ->setUserName($userProfile->emailVerified)
            ->setPassword(__FUNCTION__);

        
        $result = $this->insert($localUser, 'facebook', $userProfile);

        $fb = json_encode($userProfile);
        
        $sm             = $this->getServiceManager();
        $entityManager  = $sm->get('Doctrine\ORM\EntityManager');

        $fbArray    = json_decode($fb,true);

        $userRole   = ($fbArray['userRole']) ? $fbArray['userRole'] : "candidate" ;
        
        if($userRole == "client"){ //CODE FOR ADDING AN ENTRY INTO EMPLOYERS TABLE, IF USER IS A CLIENT
            
            $employer    = new \Application\Entity\Employer;          
            
            $employer->setUser($localUser);                
            $employer->setFirstname($fbArray['firstName']);                
            $employer->setLastname($fbArray['lastName']);    
            $employer->setEmail($fbArray['email']);   
            
            //Set the user role "candidate" for users.
            $userRole       = $entityManager->getRepository('User\Entity\Role')->findOneBy(array('roleId' => $userRole));  
            //give the user the 'user' role
            $localUser->addRole($userRole); 

            $entityManager->persist($employer);
            $entityManager->flush();
        }       
        else { // IF USER IS A CANDIDATE
            //UPDATE FACEBOOK INFORMATIONS TO PROFILES TABLE
            $userProfile    = new \Application\Entity\Profile();           
            
            $userProfile->setFirstname($fbArray['firstName']);
            $userProfile->setLastname($fbArray['lastName']);
            $userProfile->setEmail($fbArray['email']);            
            $userProfile->setProfile($fbArray['aboutMe']);
            $userProfile->setLinkedinPhotourl($fbArray['photoURL']);
            $genPhotoName = $fbArray['identifier'].".jpg";
            $userProfile->setProfilePhoto("/img/profile_photos/".$genPhotoName);
            
            $localUser->addProfile($userProfile);    

            //Set the user role "candidate" for users.
            $userRole       = $entityManager->getRepository('User\Entity\Role')->findOneBy(array('roleId' => 'candidate'));
            //give the user the 'user' role
            $localUser->addRole($userRole); 
           
            $positionCount = 0;   
            
            if(count($fbArray['work']) > 0){
                foreach($fbArray['work'] as $work){
                    $positionCount++;
                    
                    $profilePosition    = new \Application\Entity\Position();

                    if(isset($work['position']['name'])){
                        $profilePosition->setTitle($work['position']['name']);
                    }
                    
                    if(isset($work['description'])){
                        $profilePosition->setSummary($work['description']);
                    }
                    
                    if(isset($work['employer']['name'])){
                        $profilePosition->setCompanyname($work['employer']['name']);
                    }
                  
                    if(isset($work['start_date']) && isset($work['start_date'])){
                        $startDateArr = explode("-",$work['start_date']);
                        $startDate      = date("Y-m-d H:i:s", mktime(null, null, null, $startDateArr[1],$startDateArr[2],$startDateArr[0]));
                        $profilePosition->setStartdate(new \DateTime($startDate));
                    }
                  
                    if(isset($work['end_date']) && isset($work['end_date'])){
                        $endDateArr = explode("-", $work['end_date']);
                        $endDate      = date("Y-m-d H:i:s", mktime(null, null, null, $endDateArr[1],$endDateArr[2],$endDateArr[0]));
                        $profilePosition->setEnddate(new \DateTime($endDate));
                    }
                    else{
                        $profilePosition->setCurrent("1");
                    }
                    
                    $userProfile->addPosition($profilePosition);
                    $entityManager->persist($profilePosition);
                }
            }

            $educationCount = 0;
            if(count($fbArray['education']) > 0){
                foreach ($fbArray['education'] as $education) {
                    $educationCount++;
                    
                    $profileEducation    = new \Application\Entity\Education();           

                    if(isset($education['type'])){
                        $profileEducation->setCourse($education['type']);
                    }

                    if(isset($education['degree']['name'])){
                        $profileEducation->setSpecialization($education['degree']['name']);
                    }

                    if(isset($education['school']['name'])){
                        $profileEducation->setInstitute($education['school']['name']);
                    }

                    if(isset($education['year']['name'])){
                        $profileEducation->setYear($education['year']['name']);
                    }
                               
                    $userProfile->addEducation($profileEducation);
                    $entityManager->persist($profileEducation);
                }
            }

            $entityManager->persist($userProfile);
            $entityManager->flush();

            if($fbArray['photoURL']){
                //COPYING LINKEDIN PROFILE IMAGE TO PROJECT IMAGE DIRECTORY
                copy($fbArray['photoURL'],"public/img/profile_photos/".$genPhotoName);            
            }
        }
        unset($_SESSION['user_role']);
        return $localUser;
    }
631672
public function setProvider( $provider )
	{
		if ( $provider == $this->getProvider() ) { return; }

		$this->_values['provider'] = (string) $provider;
		$this->setModified();
	}
1240428
def get_provider(self, provider):
        """"""
        if self.provider is not None:
            return self.provider
        return providers.by_id(provider)
1255106
public function registerProvider($provider){
        $providers = (array) $provider;

        foreach($providers as $provider){
            $this->app()['config']->add('general.providers', $provider);
        }
    }
622784
@Inject
  @Provides
  @Singleton
  public ResponseHandler provideResponseHandler(PageResponseWriter pageResponseWriter,
      ApiResponseWriter apiResponseWriter, BinaryResponseWriter binaryResponseWriter,
      RedirectResponseWriter redirectResponseWriter, ExceptionStatusMapper exceptionStatusMapper) {
    return new DefaultResponseHandler(pageResponseWriter, apiResponseWriter, binaryResponseWriter,
      redirectResponseWriter, exceptionStatusMapper);
  }
991139
function addProviderIcon(providerId) {
  var pElt = $('<i>').addClass('fa ' + providersIcons[providerId])
      .attr('title', providerId)
      .data({
        'toggle': 'tooltip',
        'placement': 'bottom'
      });
  $('.profile-providers').append(pElt);
  pElt.tooltip();
}
1107262
function(provider) {
        if (!this.isCurrent()) {
          return;
        }
        var authType;
        if (_.isString(provider)) {
          authType = provider;
          provider = AV.User._authProviders[authType];
        } else {
          authType = provider.getAuthType();
        }
        var authData = this.get('authData');
        if (!authData || !provider) {
          return;
        }
        var success = provider.restoreAuthentication(authData[authType]);
        if (!success) {
          this.dissociateAuthData(provider);
        }
      }
863751
protected List<ProviderInfo<? extends Object>> prepareProviders(boolean custom,
                                                                    boolean busGlobal,
                                                                    Object[] providers,
                                                                    ProviderInfo<Application> application) {
        List<ProviderInfo<? extends Object>> theProviders =
            new ArrayList<ProviderInfo<? extends Object>>(providers.length);
        @SuppressWarnings("unchecked")
        Map<String, Object> beanCustomizerContexts = (Map<String, Object>) getBus().getProperty(JaxRsConstants.ENDPOINT_BEANCUSTOMIZER_CONTEXTOBJ);

        for (Object o : providers) {
            if (o == null) {
                continue;
            }

            /**
             * using POJO object to create ProviderInfo to get info of @Context
             */
            ProviderInfo<? extends Object> pi = null;

            if (o instanceof Constructor) {
                Map<Class<?>, Object> values = CastUtils.cast(application == null ? null : Collections.singletonMap(Application.class, application.getProvider()));
                pi = createProviderFromConstructor((Constructor<?>) o, values, getBus(), true, custom);

            } else if (o instanceof ProviderInfo) {
                pi = (ProviderInfo<?>) o;
            } else {
                pi = new ProviderInfo<Object>(o, getBus(), custom);
                pi.setBusGlobal(busGlobal);
            }

            /**
             * then using EJB proxy to help CXF classify provider type
             */
            JaxRsFactoryBeanCustomizer beanCustomizer = InjectionRuntimeContextHelper.findBeanCustomizer(o.getClass(), getBus());
            if (beanCustomizer != null) {
                Object proxyObject = beanCustomizer.onSetupProviderProxy(o, beanCustomizerContexts.get(createCustomizerKey(beanCustomizer)));

                if (proxyObject != null && (proxyObject != o || !proxyObject.equals(o))) {
                    pi.setProvider(proxyObject);
                }
            }

            if (beanCustomizer != null && DynamicFeature.class.isAssignableFrom(pi.getProvider().getClass())) {
                Object newProviderInstance = beanCustomizer.onSingletonProviderInit(pi.getProvider(), beanCustomizerContexts.get(Integer.toString(beanCustomizer.hashCode())),
                                                                                    null);
                if (newProviderInstance != null) {
                    pi.setProvider(newProviderInstance);
                }

            }

            theProviders.add(pi);
        }

        return theProviders;
    }
660506
private boolean customComparatorAvailable(Class<?> providerClass) {
        if (providerComparator != null) {
            Type type = ((ParameterizedType)providerComparator.getClass()
                .getGenericInterfaces()[0]).getActualTypeArguments()[0];
            if (type instanceof ParameterizedType) {
                ParameterizedType pt = (ParameterizedType)type;
                if (pt.getRawType() == ProviderInfo.class) {
                    Type type2 = pt.getActualTypeArguments()[0];
                    if (type2 == providerClass
                        || type2 instanceof WildcardType
                        || type2 instanceof ParameterizedType
                           && ((ParameterizedType)type2).getRawType() == providerClass) {
                        return true;
                    }
                }
            } else if (type == Object.class) {
                return true;
            }
        }
        return false;
    }
124630
def _get_provider_manager(self, osid, local=False):
        """"""
        return get_provider_manager(osid,
                                    runtime=self._runtime,
                                    proxy=getattr(self, '_proxy', None),
                                    local=local)
471936
function(provider) {
        if (!this.isCurrent()) {
          return;
        }
        if (_.isString(provider)) {
          provider = AV.User._authProviders[provider];
        }
        if (provider && provider.deauthenticate) {
          provider.deauthenticate();
        }
      }
1232891
public static ProviderContext of(String provider) {
        return ProviderContextBuilder.of(provider, RateType.ANY).build();
    }
1263526
public B setProviderName(String provider) {
        set(AbstractContext.KEY_PROVIDER, Objects.requireNonNull(provider));
        return (B) this;
    }
1326029
def provider_parser(subparser):
    """"""
    identity_group = subparser.add_mutually_exclusive_group()
    identity_group.add_argument(
        "--auth-id", help="specify user id for authentication")
    identity_group.add_argument(
        "--auth-subid", help="specify subuser id for authentication")
    identity_group.add_argument(
        "--auth-subuser", help="specify subuser name for authentication")
    subparser.add_argument(
        "--auth-password", help="specify password for authentication")
    subparser.add_argument("--weight", help="specify the SRV record weight")
    subparser.add_argument("--port", help="specify the SRV record port")
986618
public void unregisterProvider(Object provider) {
		if (provider != null) {
			Collection<Object> providerList = new ArrayList<>(1);
			providerList.add(provider);
			unregisterProviders(providerList);
		}
	}
737849
def provider_factory(factory=_sentinel, scope=NoneScope):
    '''
    
    '''
    if factory is _sentinel:
        return functools.partial(provider_factory, scope=scope)
    provider = Provider(factory, scope)
    return provider
842443
public void registerProtocol(String protocol, IOProviderFrom<URL> provider) {
		protocols.put(protocol.toLowerCase(), provider);
	}