@Override public boolean newAppUsersNeedAdminApproval( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager(applicationId); Boolean registration_requires_admin_approval = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), REGISTRATION_REQUIRES_ADMIN_APPROVAL ); return registration_requires_admin_approval != null && registration_requires_admin_approval; }
@Override public boolean newAppUsersRequireConfirmation( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); Boolean registration_requires_email_confirmation = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), REGISTRATION_REQUIRES_EMAIL_CONFIRMATION ); return registration_requires_email_confirmation != null && registration_requires_email_confirmation; }
@Override public Group getOrganizationProps( UUID orgId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return em.get( orgId, Group.class ); }
private CredentialsInfo readCreds( UUID appId, UUID ownerId, String ownerType, String key ) throws Exception { EntityManager em = emf.getEntityManager( appId ); Entity owner = em.get( ownerId ); return ( CredentialsInfo ) em.getDictionaryElementValue( owner, DICTIONARY_CREDENTIALS, key ); }
@Override public User getAppUserByIdentifier( UUID applicationId, Identifier identifier ) throws Exception { EntityManager em = emf.getEntityManager(applicationId); return em.get( em.getUserByIdentifier( identifier ), User.class ); }
@Override public boolean isAdminUserConfirmed( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "confirmed" ) ); }
@Override public boolean isOrganizationEnabled( UUID organizationId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return !Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "disabled" ) ); }
@Override public void confirmAdminUser( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "confirmed", true ); }
@Override public void unconfirmAdminUser( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "confirmed", false ); }
public SignInAsProvider pingident( Application application ) { PingIdentityProvider pingIdentityProvider = new PingIdentityProvider( emf.getEntityManager( application.getUuid() ), managementService ); pingIdentityProvider.configure(); return pingIdentityProvider; } }
@Override public void deactivateOrganization( UUID organizationId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "activated", false ); }
@Override public void setOrganizationProps( UUID orgId, Map<String, Object> props ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); Group org = em.get( orgId, Group.class ); if ( org == null ) { throw new EntityNotFoundException( String.format( "Could not find organization with id %s", orgId.toString() ) ); } org.setProperties( props ); em.update(org); }
@Override public void countAdminUserAction( UserInfo user, String action ) throws Exception { EntityManager em = emf.getEntityManager(smf.getManagementAppId()); em.incrementAggregateCounters( user.getUuid(), null, null, "admin_logins", 1 ); }
/** * Returns the File Import Entity that stores all meta-data for the particular sub File import Job * * @return File Import Entity */ @Override public FileImport getFileImportEntity(final JobExecution jobExecution) throws Exception { UUID fileImportId = (UUID) jobExecution.getJobData().getProperty(FILE_IMPORT_ID); EntityManager em = emf.getEntityManager(emf.getManagementAppId()); return em.get(fileImportId, FileImport.class); }
/** * Returns the Import Entity that stores all meta-data for the particular import Job * * @param jobExecution the import job details * @return Import Entity */ @Override public Import getImportEntity(final JobExecution jobExecution) throws Exception { UUID importId = (UUID) jobExecution.getJobData().getProperty(IMPORT_ID); EntityManager importManager = emf.getEntityManager(emf.getManagementAppId()); return importManager.get(importId, Import.class); }
@Override public void disableAdminUser( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "disabled", true ); revokeAccessTokensForAdminUser(userId); }
@Override public JobStat getStatsForJob( String jobName, UUID jobId ) throws Exception { EntityManager em = emf.getEntityManager( emf.getManagementAppId() ); Query query = Query.fromQL( "select * where " + JOB_NAME + " = '" + jobName + "' AND " + JOB_ID + " = " + jobId ); Results r = em.searchCollection( em.getApplicationRef(), "job_stats", query ); if ( r.size() == 1 ) { return ( JobStat ) r.getEntity(); } return null; }
private void enableEmailConfirmation( UUID appId ) throws Exception { EntityManager em = setup.getEmf().getEntityManager( appId ); SimpleEntityRef ref = new SimpleEntityRef( Application.ENTITY_TYPE, appId ); em.setProperty( ref, ManagementServiceImpl.REGISTRATION_REQUIRES_EMAIL_CONFIRMATION, true ); }
@Test public void verifyConfigureOk() throws Exception { Application application = setup.getEmf().getEntityManager( applicationId ).getApplication(); Map fbProps = MapUtils.hashMap( "api_url", "localhost" ); FacebookProvider fp = ( FacebookProvider ) providerFactory.facebook( application ); assertNotNull( fp ); fp.saveToConfiguration( "facebookProvider", fbProps ); fp.configure(); Map map = fp.loadConfigurationFor( "facebookProvider" ); assertEquals( "localhost", map.get( "api_url" ) ); } }
@Test @Category(ExperimentalTest.class) public void verifyGetOrCreateOk() throws Exception { Application application = setup.getEmf().getEntityManager( applicationId ).getApplication(); Map fb_user = MapUtils.hashMap( "id", "12345678" ).map( "name", "Facebook User" ).map( "username", "fb.user" ); FacebookProvider facebookProvider = ( FacebookProvider ) providerFactory.facebook( application ); String fb_access_token = "CAAE...NJIZD"; User user1 = facebookProvider.createOrAuthenticate( fb_access_token ); assertNotNull( user1 ); }