DefaultUserResolver implements UserResolver { protected User importUser( long companyId, String subjectNameIdentifier, String subjectNameIdentifierType, UserResolverSAMLContext userResolverSAMLContext, ServiceContext serviceContext) throws PortalException { if (_log.isDebugEnabled()) { _log.debug( StringBundler.concat( "Importing user with identifier ", subjectNameIdentifier, " of type ", subjectNameIdentifierType)); } Map<String, List<Serializable>> attributesMap = getAttributesMap( userResolverSAMLContext); User user = getUser( companyId, subjectNameIdentifier, subjectNameIdentifierType); if (user != null) { if (_log.isDebugEnabled()) { _log.debug("Found user " + user.toString()); } user = updateUser(companyId, user, attributesMap, serviceContext); } else { user = addUser( companyId, attributesMap, userResolverSAMLContext, serviceContext); if (_log.isDebugEnabled()) { _log.debug("Added user " + user.toString()); } } return user; }  @Override User resolveUser(
			UserResolverSAMLContext userResolverSAMLContext,
			ServiceContext serviceContext); @Reference(unbind = "-") void setCompanyLocalService(
		CompanyLocalService companyLocalService); @Reference(unbind = "-") void setMetadataManager(MetadataManager metadataManager); @Reference(unbind = "-") void setSamlProviderConfigurationHelper(
		SamlProviderConfigurationHelper samlProviderConfigurationHelper); @Reference(unbind = "-") void setSamlSpIdpConnectionLocalService(
		SamlSpIdpConnectionLocalService samlSpIdpConnectionLocalService); @Reference(unbind = "-") void setUserImporter(UserImporter userImporter); @Reference(unbind = "-") void setUserLocalService(UserLocalService userLocalService);  }
@Test public void testImportUserWithEmailAddress() throws Exception { when( _company.isStrangers() ).thenReturn( true ); when( _company.isStrangersWithMx() ).thenReturn( true ); User resolvedUser = _defaultUserResolver.importUser( 1, _SUBJECT_NAME_IDENTIFIER_EMAIL_ADDRESS, "emailAddress", new UserResolverSAMLContextImpl(_messageContext), new ServiceContext()); Assert.assertNotNull(resolvedUser); }
@Test(expected = SubjectException.class) public void testStrangersNotAllowedToCreateAccounts() throws Exception { when( _company.isStrangers() ).thenReturn( false ); _defaultUserResolver.importUser( 1, _SUBJECT_NAME_IDENTIFIER_EMAIL_ADDRESS, "emailAddress", new UserResolverSAMLContextImpl(_messageContext), new ServiceContext()); }
@Test(expected = UserEmailAddressException.MustNotUseCompanyMx.class) public void testStrangersNotAllowedToCreateAccountsWithCompanyMx() throws Exception { when( _company.isStrangers() ).thenReturn( true ); when( _company.isStrangersWithMx() ).thenReturn( false ); _defaultUserResolver.importUser( 1, _SUBJECT_NAME_IDENTIFIER_EMAIL_ADDRESS, "emailAddress", new UserResolverSAMLContextImpl(_messageContext), new ServiceContext()); }