Search in sources :

Example 1 with SessionDataStore

use of org.mx.dal.session.SessionDataStore in project main by JohnPeng739.

the class InitializeAdminAccountTask method invokeTask.

/**
 * {@inheritDoc}
 * <p>
 * 初始化系统数据的任务,包括:admin、user、guest角色,以及admin、guest账户。
 *
 * @see InitializeTask#invokeTask()
 */
@Override
public void invokeTask() {
    GeneralDictAccessor accessor = SpringContextHolder.getBean("generalDictAccessor", GeneralDictAccessor.class);
    SessionDataStore sessionDataStore = SpringContextHolder.getBean(SessionDataStore.class);
    sessionDataStore.setCurrentUserCode("system");
    // 创建相关的角色
    createRole(accessor, "admin", "系统管理员", "系统管理员角色");
    createRole(accessor, "user", "用户", "一般业务操作用户角色");
    createRole(accessor, "guest", "客人", "客人访问角色,只能不需要权限认证的功能");
    // 创建相关的账户
    createAccount(accessor, "admin", "系统管理员", "ds110119", "系统管理员账户", "admin");
    createAccount(accessor, "guest", "客人", "guest", "客人账户", "guest");
    sessionDataStore.removeCurrentUserCode();
}
Also used : GeneralDictAccessor(org.mx.dal.service.GeneralDictAccessor) SessionDataStore(org.mx.dal.session.SessionDataStore)

Example 2 with SessionDataStore

use of org.mx.dal.session.SessionDataStore in project main by JohnPeng739.

the class BaseTest method before.

@Before
public void before() {
    try {
        IMongodConfig config = new MongodConfigBuilder().version(Version.Main.PRODUCTION).net(new Net("localhost", 27017, Network.localhostIsIPv6())).build();
        mongodExecutable = MongodStarter.getDefaultInstance().prepare(config);
        mongod = mongodExecutable.start();
        context = new AnnotationConfigApplicationContext(CompsRbacMongodbConfig.class);
        SessionDataStore sessionDataStore = context.getBean(SessionDataStore.class);
        assertNotNull(sessionDataStore);
        sessionDataStore.setCurrentUserCode("admin");
    } catch (Exception ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
}
Also used : CompsRbacMongodbConfig(org.mx.comps.rbac.mongodb.config.CompsRbacMongodbConfig) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) IMongodConfig(de.flapdoodle.embed.mongo.config.IMongodConfig) Net(de.flapdoodle.embed.mongo.config.Net) MongodConfigBuilder(de.flapdoodle.embed.mongo.config.MongodConfigBuilder) SessionDataStore(org.mx.dal.session.SessionDataStore) Before(org.junit.Before)

Example 3 with SessionDataStore

use of org.mx.dal.session.SessionDataStore in project main by JohnPeng739.

the class BaseTest method before.

@Before
public void before() {
    CleanH2DatabaseFile.cleanDataFile("./h2/test");
    context = new AnnotationConfigApplicationContext(TestDalConfig.class);
    assertNotNull(context);
    SessionDataStore sessionDataStore = context.getBean(SessionDataStore.class);
    assertNotNull(sessionDataStore);
    sessionDataStore.setCurrentUserCode("admin");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) TestDalConfig(org.mx.test.config.TestDalConfig) SessionDataStore(org.mx.dal.session.SessionDataStore) Before(org.junit.Before)

Aggregations

SessionDataStore (org.mx.dal.session.SessionDataStore)3 Before (org.junit.Before)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 IMongodConfig (de.flapdoodle.embed.mongo.config.IMongodConfig)1 MongodConfigBuilder (de.flapdoodle.embed.mongo.config.MongodConfigBuilder)1 Net (de.flapdoodle.embed.mongo.config.Net)1 CompsRbacMongodbConfig (org.mx.comps.rbac.mongodb.config.CompsRbacMongodbConfig)1 GeneralDictAccessor (org.mx.dal.service.GeneralDictAccessor)1 TestDalConfig (org.mx.test.config.TestDalConfig)1