Search in sources :

Example 1 with MetadataEncryptor

use of org.alfresco.repo.node.encryption.MetadataEncryptor in project alfresco-repository by Alfresco.

the class IntegrityTest method setUp.

public void setUp() throws Exception {
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    // load the test model
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/integrity/IntegrityTest_model.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
    integrityChecker.setEnabled(true);
    integrityChecker.setFailOnViolation(true);
    integrityChecker.setTraceOn(true);
    // we want to count the correct number of errors
    integrityChecker.setMaxErrorsPerTransaction(100);
    MetadataEncryptor encryptor = (MetadataEncryptor) ctx.getBean("metadataEncryptor");
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    nodeService = serviceRegistry.getNodeService();
    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    // begin a transaction
    TransactionService transactionService = serviceRegistry.getTransactionService();
    txn = transactionService.getUserTransaction();
    txn.begin();
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
    if (!nodeService.exists(storeRef)) {
        nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
    }
    rootNodeRef = nodeService.getRootNode(storeRef);
    allProperties = new PropertyMap();
    allProperties.put(TEST_PROP_TEXT_A, "ABC");
    allProperties.put(TEST_PROP_TEXT_B, "DEF");
    allProperties.put(TEST_PROP_INT_A, "123");
    allProperties.put(TEST_PROP_INT_B, "456");
    allProperties.put(TEST_PROP_ENCRYPTED_A, "ABC");
    allProperties.put(TEST_PROP_ENCRYPTED_B, "DEF");
    allProperties = encryptor.encrypt(allProperties);
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) ApplicationContext(org.springframework.context.ApplicationContext) PropertyMap(org.alfresco.util.PropertyMap) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) TransactionService(org.alfresco.service.transaction.TransactionService) InputStream(java.io.InputStream) MetadataEncryptor(org.alfresco.repo.node.encryption.MetadataEncryptor) M2Model(org.alfresco.repo.dictionary.M2Model)

Aggregations

InputStream (java.io.InputStream)1 DictionaryDAO (org.alfresco.repo.dictionary.DictionaryDAO)1 M2Model (org.alfresco.repo.dictionary.M2Model)1 MetadataEncryptor (org.alfresco.repo.node.encryption.MetadataEncryptor)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 TransactionService (org.alfresco.service.transaction.TransactionService)1 PropertyMap (org.alfresco.util.PropertyMap)1 ApplicationContext (org.springframework.context.ApplicationContext)1