当前位置: 首页>>代码示例>>Java>>正文


Java UserConfig类代码示例

本文整理汇总了Java中org.opendaylight.controller.usermanager.UserConfig的典型用法代码示例。如果您正苦于以下问题:Java UserConfig类的具体用法?Java UserConfig怎么用?Java UserConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserConfig类属于org.opendaylight.controller.usermanager包,在下文中一共展示了UserConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveLocalUserConfig

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@RequestMapping(value = "/users", method = RequestMethod.POST)
@ResponseBody
public String saveLocalUserConfig(
        @RequestParam(required = true) String json,
        @RequestParam(required = true) String action,
        HttpServletRequest request) {

    IUserManager userManager = (IUserManager) ServiceHelper
            .getGlobalInstance(IUserManager.class, this);
    if (userManager == null) {
        return "Internal Error";
    }

    if (!authorize(userManager, UserLevel.NETWORKADMIN, request)) {
        return "Operation not permitted";
    }

    Gson gson = new Gson();
    UserConfig config = gson.fromJson(json, UserConfig.class);

    Status result = (action.equals("add")) ? userManager
            .addLocalUser(config) : userManager.removeLocalUser(config);

    return result.getDescription();
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:26,代码来源:DaylightWebAdmin.java

示例2: changeLocalUserPassword

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@Override
public Status changeLocalUserPassword(String user, String curPassword,
        String newPassword) {
    UserConfig targetConfigEntry = null;

    // update configuration entry
    targetConfigEntry = localUserConfigList.get(user);
    if (targetConfigEntry == null) {
        return new Status(StatusCode.NOTFOUND, "User not found");
    }
    Status status = targetConfigEntry
            .update(curPassword, newPassword, null);
    if (!status.isSuccess()) {
        return status;
    }
    // Trigger cluster update
    localUserConfigList.put(user, targetConfigEntry);

    logger.info("Password changed for User \"{}\"", user);

    return status;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:UserManagerImpl.java

示例3: _umAddUser

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
public void _umAddUser(CommandInterpreter ci) {
    String userName = ci.nextArgument();
    String password = ci.nextArgument();
    String role = ci.nextArgument();

    List<String> roles = new ArrayList<String>();
    while (role != null) {
        if (!role.trim().isEmpty()) {
            roles.add(role);
        }
        role = ci.nextArgument();
    }

    if (userName == null || userName.trim().isEmpty() || password == null
            || password.trim().isEmpty() || roles == null
            || roles.isEmpty()) {
        ci.println("Invalid Arguments");
        ci.println("umAddUser <user_name> <password> <user_role>");
        return;
    }
    ci.print(this.addLocalUser(new UserConfig(userName, password, roles)));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:UserManagerImpl.java

示例4: testGetUserLevel

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@Test
public void testGetUserLevel() {
    List<String> roles = new ArrayList<String>(2);
    roles.add(UserLevel.SYSTEMADMIN.toString());
    roles.add("App1_supervisor");
    um.addLocalUser(new UserConfig("Jack", "password", roles));
    um.authenticate("Jack", "password");

    roles.clear();
    roles.add("App2Admin");
    roles.add(UserLevel.NETWORKOPERATOR.toString());
    um.addLocalUser(new UserConfig("John", "password", roles));

    // Run the check on authenticated user
    Assert.assertTrue(um.getUserLevel("Jack") == UserLevel.SYSTEMADMIN);
    // Run the check on configured users
    Assert.assertTrue(um.getUserLevel("John") == UserLevel.NETWORKOPERATOR);
    // Run the check on local authorized users
    Assert.assertTrue(um.getUserLevel("Andrew") == UserLevel.NETWORKOPERATOR);
    // Non locally known user
    Assert.assertTrue(um.getUserLevel("Tom") == UserLevel.NOUSER);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:UserManagerImplTest.java

示例5: getUsers

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@RequestMapping("/users")
@ResponseBody
public List<UserConfig> getUsers() {
    IUserManager userManager = (IUserManager) ServiceHelper
            .getGlobalInstance(IUserManager.class, this);
    if (userManager == null) {
        return null;
    }

    List<UserConfig> userConfList = userManager.getLocalUserList();

    return userConfList;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:14,代码来源:DaylightWebAdmin.java

示例6: checkDefaultNetworkAdmin

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
private void checkDefaultNetworkAdmin() {
    // If startup config is not there, it's old or it was deleted,
    // need to add Default Admin
    if (!localUserConfigList.containsKey(defaultAdmin)) {
        List<String> roles = new ArrayList<String>(1);
        roles.add(defaultAdminRole);
        localUserConfigList.put(defaultAdmin, new UserConfig(defaultAdmin,
                defaultAdminPassword, roles));
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:11,代码来源:UserManagerImpl.java

示例7: loadUserConfig

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void loadUserConfig() {
    ObjectReader objReader = new ObjectReader();
    ConcurrentMap<String, UserConfig> confList = (ConcurrentMap<String, UserConfig>) objReader
            .read(this, usersFileName);

    if (confList == null) {
        return;
    }

    for (UserConfig conf : confList.values()) {
        addLocalUser(conf);
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:UserManagerImpl.java

示例8: _umRemUser

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
public void _umRemUser(CommandInterpreter ci) {
    String userName = ci.nextArgument();

    if (userName == null || userName.trim().isEmpty()) {
        ci.println("Invalid Arguments");
        ci.println("umRemUser <user_name>");
        return;
    }
    UserConfig target = localUserConfigList.get(userName);
    if (target == null) {
        ci.println("User not found");
        return;
    }
    ci.println(this.removeLocalUser(target));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:16,代码来源:UserManagerImpl.java

示例9: testAuthenticateStringString

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#authenticate(java.lang.String, java.lang.String)}
 * .
 */
@Test
public void testAuthenticateStringString() {
    List<String> roles = new ArrayList<String>(1);
    roles.add(UserLevel.SYSTEMADMIN.toString());
    UserConfig uc = new UserConfig("administrator", "admin", roles);
    um.addLocalUser(uc);
    AuthResultEnum authResult = um.authenticate("administrator", "admin");
    assertEquals(authResult, AuthResultEnum.AUTH_ACCEPT_LOC);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:UserManagerImplTest.java

示例10: testAddRemoveLocalUser

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addRemoveLocalUser(org.opendaylight.controller.usermanager.org.opendaylight.controller.usermanager.internal.UserConfig, boolean)}
 * .
 */
@Test
public void testAddRemoveLocalUser() {
    List<String> roles = new ArrayList<String>(1);
    roles.add(UserLevel.SYSTEMADMIN.toString());
    UserConfig uc = new UserConfig("sysadmin", "7029,7455,8165,7029,7881",
            roles);
    um.addLocalUser(uc);
    assertTrue(um.getLocalUserList().contains(uc));
    um.removeLocalUser(uc);
    assertFalse(um.getLocalUserList().contains(uc));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:17,代码来源:UserManagerImplTest.java

示例11: retrieveCaches

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation" })
private void retrieveCaches() {
    if (clusterGlobalService == null) {
        logger.error("un-initialized clusterService, can't retrieve cache");
        return;
    }

    activeUsers = (ConcurrentMap<String, AuthenticatedUser>) clusterGlobalService
            .getCache("usermanager.activeUsers");
    if (activeUsers == null) {
        logger.error("Failed to get cache for activeUsers");
    }

    localUserConfigList = (ConcurrentMap<String, UserConfig>) clusterGlobalService
            .getCache("usermanager.localUserConfigList");
    if (localUserConfigList == null) {
        logger.error("Failed to get cache for localUserConfigList");
    }

    remoteServerConfigList = (ConcurrentMap<String, ServerConfig>) clusterGlobalService
            .getCache("usermanager.remoteServerConfigList");
    if (remoteServerConfigList == null) {
        logger.error("Failed to get cache for remoteServerConfigList");
    }

    authorizationConfList = (ConcurrentMap<String, AuthorizationConfig>) clusterGlobalService
            .getCache("usermanager.authorizationConfList");
    if (authorizationConfList == null) {
        logger.error("Failed to get cache for authorizationConfList");
    }

    localUserListSaveConfigEvent = (ConcurrentMap<Long, String>) clusterGlobalService
            .getCache("usermanager.localUserSaveConfigEvent");
    if (localUserListSaveConfigEvent == null) {
        logger.error("Failed to get cache for localUserSaveConfigEvent");
    }

    remoteServerSaveConfigEvent = (ConcurrentMap<Long, String>) clusterGlobalService
            .getCache("usermanager.remoteServerSaveConfigEvent");
    if (remoteServerSaveConfigEvent == null) {
        logger.error("Failed to get cache for remoteServerSaveConfigEvent");
    }

    authorizationSaveConfigEvent = (ConcurrentMap<Long, String>) clusterGlobalService
            .getCache("usermanager.authorizationSaveConfigEvent");
    if (authorizationSaveConfigEvent == null) {
        logger.error("Failed to get cache for authorizationSaveConfigEvent");
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:50,代码来源:UserManagerImpl.java

示例12: saveLocalUserListInternal

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
private Status saveLocalUserListInternal() {
    ObjectWriter objWriter = new ObjectWriter();
    return objWriter.write(new ConcurrentHashMap<String, UserConfig>(
            localUserConfigList), usersFileName);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:6,代码来源:UserManagerImpl.java

示例13: addLocalUser

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@Override
public Status addLocalUser(UserConfig AAAconf) {
    return addRemoveLocalUser(AAAconf, false);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:5,代码来源:UserManagerImpl.java

示例14: removeLocalUser

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@Override
public Status removeLocalUser(UserConfig AAAconf) {
    return addRemoveLocalUser(AAAconf, true);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:5,代码来源:UserManagerImpl.java

示例15: getLocalUserList

import org.opendaylight.controller.usermanager.UserConfig; //导入依赖的package包/类
@Override
public List<UserConfig> getLocalUserList() {
    return new ArrayList<UserConfig>(localUserConfigList.values());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:5,代码来源:UserManagerImpl.java


注:本文中的org.opendaylight.controller.usermanager.UserConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。