private void deleteCreds( UUID appId, EntityRef owner, String key ) throws Exception { EntityManager em = emf.getEntityManager( appId ); em.removeFromDictionary(owner, DICTIONARY_CREDENTIALS, key); }
/** currently only affects properties */ public void updateOrganization( OrganizationInfo organizationInfo ) throws Exception { Map<String, Object> properties = organizationInfo.getProperties(); if ( properties != null ) { EntityRef organizationEntity = new SimpleEntityRef( Group.ENTITY_TYPE, organizationInfo.getUuid() ); EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); for ( Map.Entry<String, Object> entry : properties.entrySet() ) { if ( "".equals( entry.getValue() ) ) { properties.remove( entry.getKey() ); em.removeFromDictionary( organizationEntity, ORGANIZATION_PROPERTIES_DICTIONARY, entry.getKey() ); } else { em.addToDictionary( organizationEntity, ORGANIZATION_PROPERTIES_DICTIONARY, entry.getKey(), entry.getValue() ); } } } }
@Override public void updateOrganizationConfig( OrganizationConfig organizationConfig ) throws Exception { // get only the overrides Map<String, Object> orgConfigProperties = organizationConfig.getOrgConfigOverridesMap(); if ( orgConfigProperties != null ) { EntityRef organizationEntity = new SimpleEntityRef( Group.ENTITY_TYPE, organizationConfig.getUuid() ); EntityManager em = emf.getEntityManager( smf.getManagementAppId() ); for ( Map.Entry<String, Object> entry : orgConfigProperties.entrySet() ) { if ( "".equals( entry.getValue() ) ) { em.removeFromDictionary( organizationEntity, ORGANIZATION_CONFIG_DICTIONARY, entry.getKey() ); } else { em.addToDictionary( organizationEntity, ORGANIZATION_CONFIG_DICTIONARY, entry.getKey(), entry.getValue() ); } } // evict cache for this key if it exists orgConfigByAppCache.invalidate( organizationConfig.getUuid() ); } }
UUIDUtils.sort( oldUUIDs ); for ( int i = 0; i < oldUUIDs.size() - passwordHistorySize; i++ ) { em.removeFromDictionary( user, CREDENTIALS_HISTORY, oldUUIDs.get( i ).toString() );
@Test public void testRemoveFromDictionary() throws Exception { logger.info( "EntityDictionaryIT.testRemoveFromDictionary" ); Application.OAuthProvider provider = new Application.OAuthProvider(); provider.setClientId( "123456789012.apps.googleusercontent.com" ); provider.setClientSecret( "abcdefghijklmnopqrstuvwx" ); provider.setRedirectUris( "https://www.example.com/oauth2callback" ); provider.setJavaScriptOrigins( "https://www.example.com" ); provider.setAuthorizationEndpointUrl( "https://accounts.google.com/o/oauth2/auth" ); provider.setAccessTokenEndpointUrl( "https://accounts.google.com/o/oauth2/token" ); provider.setVersion( "2.0" ); logger.info( "EntityDictionaryIT.testApplicationDictionaries" ); EntityManager em = app.getEntityManager(); assertNotNull( em ); em.addToDictionary( em.getApplicationRef(), "oauthproviders", "google", provider ); Object o = em.getDictionaryElementValue( em.getApplicationRef(), "oauthproviders", "google" ); assertNotNull( o ); em.removeFromDictionary( em.getApplicationRef(),"oauthproviders","google" ); o = em.getDictionaryElementValue( em.getApplicationRef(), "oauthproviders", "google" ); assertNull( o ); }