protected void unregisterDeviceToUsers(UUID deviceId, EntityRef owner){ try { EntityRef device = new SimpleEntityRef("device",deviceId); deleteEntityConnection(device,owner); } catch (Exception e) { logger.error("Failed to delete connection for {}", deviceId.toString(), e); } } }
private Entity getApplicationInfoEntity(final EntityManager rootEm, final UUID applicationId) throws Exception { final Entity entity = rootEm.get(new SimpleEntityRef(CpNamingUtils.APPLICATION_INFO, applicationId)); if (entity == null) { throw new EntityNotFoundException("Cound not find application with id " + applicationId); } return entity; }
@Override public void setAppUserPin( UUID applicationId, UUID userId, String newPin ) throws Exception { if ( ( userId == null ) || ( newPin == null ) ) { return; } writeUserPin( applicationId, new SimpleEntityRef( User.ENTITY_TYPE, userId ), encryptionService.plainTextCredentials( newPin, userId, applicationId ) ); }
private Iterable<EntityRef> getEntityRefsForUniqueProperty( String collName, String propName, String alias ) throws Exception { final Id id = getIdForUniqueEntityField( collName, propName, alias ); if ( id == null ) { return Collections.emptyList(); } return Collections.<EntityRef>singleton( new SimpleEntityRef( id.getType(), id.getUuid() ) ); }
public boolean notifyAdminOfNewAppUsers( UUID applicationId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); Boolean notify_admin_of_new_users = ( Boolean ) em .getProperty( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), NOTIFY_ADMIN_OF_NEW_USERS ); return notify_admin_of_new_users != null && notify_admin_of_new_users; }
@Override public void activateAppUser( UUID applicationId, UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( applicationId ); em.setProperty(new SimpleEntityRef(User.ENTITY_TYPE, userId), "activated", true); }
@Override public Set<String> getUserPermissions( UUID userId ) throws Exception { return cast(getDictionaryAsSet( new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.DICTIONARY_PERMISSIONS ) ); }
@Override public boolean isAdminUserActivated( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "activated" ) ); }
@Override public boolean isAdminUserEnabled( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); return !Boolean.TRUE.equals( em.getProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "disabled" ) ); }
private EntityRef getRoleRef( String roleName ) throws Exception { Results results = this.searchCollection( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), Schema.defaultCollectionName( Role.ENTITY_TYPE ), Query.fromQL( "roleName = '" + roleName + "'" ) ); Iterator<Entity> iterator = results.iterator(); EntityRef roleRef = null; while ( iterator.hasNext() ) { roleRef = iterator.next(); } return roleRef; }
@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 disableOrganization( UUID organizationId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( Group.ENTITY_TYPE, organizationId ), "disabled", true ); }
protected Entity getOrganizationEntityForApplication( UUID applicationInfoId ) throws Exception { if ( applicationInfoId == null ) { return null; } final EntityManager em = emf.getEntityManager(smf.getManagementAppId()); Results r = em.getSourceEntities( new SimpleEntityRef(CpNamingUtils.APPLICATION_INFO, applicationInfoId), ORG_APP_RELATIONSHIP, Group.ENTITY_TYPE, Level.ALL_PROPERTIES); return r.getEntity(); }
@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 void activateAdminUser( UUID userId ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); em.setProperty( new SimpleEntityRef( User.ENTITY_TYPE, userId ), "activated", true ); invalidateManagementAppAuthCache(); }
@Override public ApplicationInfo getDeletedApplicationInfo(UUID applicationId) throws Exception { if ( applicationId == null ) { return null; } EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); final Entity entity = em.get( new SimpleEntityRef( CpNamingUtils.DELETED_APPLICATION_INFO, applicationId ) ); if ( entity != null ) { return new ApplicationInfo( applicationId, entity.getName() ); } return null; }
public String newSecretKey( AuthPrincipalType type, UUID id ) throws Exception { String secret = generateOAuthSecretKey( type ); writeUserToken( smf.getManagementAppId(), new SimpleEntityRef( type.getEntityType(), id ), encryptionService.plainTextCredentials( secret, id, smf.getManagementAppId() ) ); return secret; }
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 ); }
@Override public OrganizationInfo getOrganizationByUuid( UUID id ) throws Exception { EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); Entity entity = em.get( new SimpleEntityRef( Group.ENTITY_TYPE, id ) ); if ( entity == null ) { return null; } Map<Object, Object> properties = em.getDictionaryAsMap( entity, ORGANIZATION_PROPERTIES_DICTIONARY ); OrganizationInfo orgInfo = new OrganizationInfo( entity.getProperties() ); orgInfo.setProperties( properties ); return orgInfo; }
public Entity getEntityFromPrincipal( AuthPrincipalInfo principal ) throws Exception { EntityManager em = emf.getEntityManager( principal.getApplicationId() != null ? principal.getApplicationId() : smf.getManagementAppId() ); return em.get(new SimpleEntityRef( principal.getType().getEntityType(), principal.getUuid())); }