</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <!-- This bundle works with Karaf 3 and 4.0 -->
+ <Import-Package>
+ org.apache.karaf.shell.commands;version="[3.0.0,4.1)",
+ org.apache.karaf.shell.console;version="[3.0.0,4.1)",
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2015 Inocybe Technology All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.6.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.opendaylight.aaa</groupId>
- <artifactId>aaa-cli4</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>aaa-cert</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.aaa</groupId>
- <artifactId>aaa-authn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <version>${karaf4.version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <version>2.8.3</version>
- </dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.aaa.cli;
-
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-/**
- * @author mserngawy
- *
- */
-public abstract class AaaCliAbstractCommand extends OsgiCommandSupport {
-
- private volatile static String authUser = null;
- protected final IIDMStore identityStore;
-
- public AaaCliAbstractCommand(final IIDMStore identityStore) {
- this.identityStore = identityStore;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- final User currentUser = SessionsManager.getInstance().getCurrentUser(authUser);
- if (currentUser == null) {
- final String userName = CliUtils.readPassword(super.session, "Enter Username:");
- final String passwd = CliUtils.readPassword(super.session, "Enter Password:");
- final User usr = DataStoreUtils.isAdminUser(identityStore, userName, passwd);
- if(usr != null) {
- authUser = userName;
- SessionsManager.getInstance().addUserSession(userName, usr);
- }
- return usr;
- }
- return currentUser;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.Element;
-
-import org.opendaylight.aaa.api.model.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The SessionsManager class will keep the admin user credential vaild at the cache
- * for certain time instead of required the admin user to enter the username and pwd
- * with each aaa-cli command.
- *
- * @author mserngawy
- *
- */
-public class SessionsManager implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(SessionsManager.class);
-
- private static SessionsManager sessionMgr = null;
- private Cache authUsers;
- private final int maxCachedUsersInMemory = 1;
- private final int maxCachedUsersOnDisk = 1;
- private final long secondsToLive = 120;
- private final long secondsToIdle = 60;
- private final String CLI_CACHE_MANAGER = "org.opendaylight.aaa.cli";
- private final String CLI_CACHE = "users";
-
- public static SessionsManager getInstance() {
- if (sessionMgr == null) {
- sessionMgr = new SessionsManager();
- }
- return sessionMgr;
- }
-
- private SessionsManager() {
- CacheManager cm = CacheManager.newInstance();
- authUsers = new Cache( new CacheConfiguration(CLI_CACHE, maxCachedUsersInMemory)
- .maxEntriesLocalDisk(maxCachedUsersOnDisk)
- .timeToLiveSeconds(secondsToLive)
- .timeToIdleSeconds(secondsToIdle));
- cm.addCache(authUsers);
- cm.setName(CLI_CACHE_MANAGER);
- LOG.info("Initialized cli authorized users cache manager");
- }
-
- @Override
- public void close() throws Exception {
- LOG.info("Shutting down cli authorized users cache manager");
- CacheManager.getInstance().shutdown();
- }
-
- public void addUserSession(String userName, User usr) {
- authUsers.put(new Element(userName, usr));
- }
-
- public User getCurrentUser(String userName) {
- try {
- Element elem = authUsers.get(userName);
- if (elem != null) {
- return (User) elem.getObjectValue();
- }
- } catch (Exception e) {
- LOG.debug("Error while getting userName {} ", userName, e);
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.cert;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.cert.api.ICertificateManager;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "gen-cert-req", scope = "aaa", description = "generate a certificate request for the opendaylight controller.")
-
-/**
- * GenerateCertReq from the ODL key store to be signed by the Certificate Authority 'CA'
- *
- * @author mserngawy
- *
- */
-public class GenerateCertReq extends OsgiCommandSupport{
-
- protected ICertificateManager certProvider;
-
- public GenerateCertReq(final ICertificateManager aaaCertProvider) {
- this.certProvider = aaaCertProvider;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- final String pwd = CliUtils.readPassword(this.session, "Enter Keystore Password:");
- return certProvider.genODLKeyStoreCertificateReq(pwd, true);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.cert;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.cert.api.ICertificateManager;
-
-@Command(name = "get-cipher-suites", scope = "aaa", description = "Get the allowed cipher suites for TLS communication.")
-
-/**
- * GetCipherSuites get the allowed cipher suites for TLS communication.
- *
- * @author mserngawy
- *
- */
-public class GetCipherSuites extends OsgiCommandSupport {
-
- protected volatile ICertificateManager certProvider;
-
- public GetCipherSuites(final ICertificateManager aaaCertProvider) {
- this.certProvider = aaaCertProvider;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- return certProvider.getCipherSuites();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.cert;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.cert.api.ICertificateManager;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "get-odl-cert", scope = "aaa", description = "get self sign certificate for the opendaylight controller.")
-
-/**
- * GetODLSelfSignCert get the ODL key store self sign certificate.
- *
- * @author mserngawy
- *
- */
-public class GetODLSelfSignCert extends OsgiCommandSupport{
-
- protected ICertificateManager certProvider;
-
- public GetODLSelfSignCert(final ICertificateManager aaaCertProvider) {
- this.certProvider = aaaCertProvider;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- final String pwd = CliUtils.readPassword(this.session, "Enter Keystore Password:");
- return certProvider.getODLKeyStoreCertificate(pwd, true);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.cert;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.cert.api.ICertificateManager;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "get-node-cert", scope = "aaa", description = "get node certificate form the opendaylight trust keystore .")
-
-/**
- * GetTrustStoreCert get a certain certificate stored in the trust key store using the its alias
- *
- * @author mserngawy
- *
- */
-public class GetTrustStoreCert extends OsgiCommandSupport{
-
- protected ICertificateManager certProvider;
-
- @Option(name = "-alias",
- aliases = { "--alias" },
- description = "The alias.\n-alias / --should be the node certificate alias",
- required = true,
- multiValued = false)
- private String alias = "";
-
- public GetTrustStoreCert(final ICertificateManager aaaCertProvider) {
- this.certProvider = aaaCertProvider;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- final String pwd = CliUtils.readPassword(this.session, "Enter Keystore Password:");
- return certProvider.getCertificateTrustStore(pwd, alias, true);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.Domain;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Command(name = "add-domain", scope = "aaa", description = "Add domain.")
-
-/**
- * @author mserngawy
- *
- */
-public class AddDomain extends AaaCliAbstractCommand {
-
- private static final Logger LOG = LoggerFactory.getLogger(AddDomain.class);
-
- @Option(name = "-name",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- @Option(name = "-desc",
- aliases = { "--domainDescription" },
- description = "The domain Description",
- required = true,
- multiValued = false)
- private String domainDesc = "";
-
- public AddDomain(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- Domain domain = new Domain();
- domain.setDescription(domainDesc);
- domain.setEnabled(true);
- domain.setName(domainName);
- domain = identityStore.writeDomain(domain);
- if (domain != null) {
- return "Domain " + domainName + " has been created, Domain Id is " + domain.getDomainid();
- }
- return null;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.Grant;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "add-grant", scope = "aaa", description = "Add Grant.")
-
-/**
- * @author mserngawy
- *
- */
-public class AddGrant extends AaaCliAbstractCommand {
-
- @Option(name = "-uname",
- aliases = { "--userName" },
- description = "The user name",
- required = true,
- multiValued = false)
- private String userName = "";
-
- @Option(name = "-dname",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- @Option(name = "-rname",
- aliases = { "--roleName" },
- description = "The role name",
- required = false,
- multiValued = false)
- private String roleName = "";
-
-
- public AddGrant(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String domainId = DataStoreUtils.getDomainId(identityStore, domainName);
- if (domainId == null) {
- return "Domain does not exist";
- }
- final String roleId = DataStoreUtils.getRoleId(identityStore, roleName);
- if (roleId == null) {
- return "Role does not exist";
- }
- final String usrId = DataStoreUtils.getUserId(identityStore, userName);
- if (usrId == null) {
- return "User does not exist";
- }
- Grant grant = new Grant();
- grant.setDomainid(domainId);
- grant.setRoleid(roleId);
- grant.setUserid(usrId);
- grant = identityStore.writeGrant(grant);
- if (grant != null) {
- return "Grant has been created, Grant id is " + grant.getGrantid();
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.Role;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "add-role", scope = "aaa", description = "Add role.")
-
-/**
- * @author mserngawy
- *
- */
-public class AddRole extends AaaCliAbstractCommand {
-
- @Option(name = "-name",
- aliases = { "--roleName" },
- description = "The role name",
- required = true,
- multiValued = false)
- private String roleName = "";
-
- @Option(name = "-dname",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- @Option(name = "-desc",
- aliases = { "--roleDescription" },
- description = "The role Description",
- required = true,
- multiValued = false)
- private String roleDesc = "";
-
- public AddRole(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- Role role = new Role();
- role.setDescription(roleDesc);
- role.setName(roleName);
- final String domainId = DataStoreUtils.getDomainId(identityStore, domainName);
- if (domainId == null) {
- return "Domain does not exist";
- }
- role.setDomainid(domainId);
- role = identityStore.writeRole(role);
- if (role != null) {
- return "Role " + roleName + " has been created, Role Id is " + role.getRoleid();
- }
- return null;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.Grant;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "add-user", scope = "aaa", description = "Add user.")
-
-/**
- * @author mserngawy
- *
- */
-public class AddUser extends AaaCliAbstractCommand {
-
- @Option(name = "-name",
- aliases = { "--userName" },
- description = "The user name",
- required = true,
- multiValued = false)
- private String userName = "";
-
- @Option(name = "-dname",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- @Option(name = "-rname",
- aliases = { "--roleName" },
- description = "The role name",
- required = false,
- multiValued = false)
- private String roleName = "";
-
- @Option(name = "-desc",
- aliases = { "--userDescription" },
- description = "The user Description",
- required = false,
- multiValued = false)
- private String userDesc = "";
-
- @Option(name = "-email",
- aliases = { "--userEmail" },
- description = "The user Description",
- required = false,
- multiValued = false)
- private String userEmail = "";
-
- public AddUser(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String domainId = DataStoreUtils.getDomainId(identityStore, domainName);
- if (domainId == null) {
- return "Domain does not exist";
- }
- User usr = new User();
- usr.setDescription(userDesc);
- usr.setDomainid(domainId);
- usr.setEnabled(true);
- usr.setEmail(userEmail);
- final String pwd = CliUtils.readPassword(this.session, "Enter new user password: ");
- if (pwd == null || pwd.isEmpty() || pwd.length() < 6) {
- return "Password should be at least 6 characters";
- }
- usr.setPassword(pwd);
- usr.setName(userName);
- usr = identityStore.writeUser(usr);
- if (usr != null) {
- if (roleName != null && !roleName.isEmpty()) {
- final String roleId = DataStoreUtils.getRoleId(identityStore, roleName);
- if (roleId == null) {
- return "User " + userName + " has been created, User Id is " + usr.getUserid() + ", Role does not exist";
- }
- Grant grant = new Grant();
- grant.setDomainid(domainId);
- grant.setRoleid(roleId);
- grant.setUserid(usr.getUserid());
- grant = identityStore.writeGrant(grant);
- if (grant == null) {
- return "User " + usr.getName() + " has been created, User Id is " + usr.getUserid()
- + " but not granted to role " + roleName;
- }
- return "User " + usr.getName() + " has been created, User Id is " + usr.getUserid()
- + " and granted to role " + roleName;
- }
- return "User " + userName + " has been created, User Id is " + usr.getUserid();
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.SHA256Calculator;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.api.model.Users;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "change-user-pwd", scope = "aaa", description = "Change the user password.")
-
-/**
- * ChangeUserPassword change the user password.
- *
- * @author mserngawy
- *
- */
-public class ChangeUserPassword extends OsgiCommandSupport {
-
- protected IIDMStore identityStore;
-
- @Option(name = "-user",
- aliases = { "--userName" },
- description = "The user name",
- required = true,
- multiValued = false)
- private String userName = "";
-
- public ChangeUserPassword(final IIDMStore identityStore) {
- this.identityStore = identityStore;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (identityStore == null) {
- return "Failed to access the users data store";
- }
- final String currentPwd = CliUtils.readPassword(this.session, "Enter current password:");
- final String newPwd = CliUtils.readPassword(this.session, "Enter new password:");
- final Users users = identityStore.getUsers();
- for (User usr : users.getUsers()) {
- final String realPwd = SHA256Calculator.getSHA256(currentPwd, usr.getSalt());
- if (usr.getName().equals(userName) && usr.getPassword().equals(realPwd)) {
- usr.setPassword(newPwd);
- identityStore.updateUser(usr);
- return userName + "'s password has been changed";
- }
- }
- return CliUtils.LOGIN_FAILED_MESS;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "get-domains", scope = "aaa", description = "get list of ODL domains.")
-
-/**
- * ListODLDomains list the available domains at ODL aaa data store.
- *
- * @author mserngawy
- *
- */
-public class ListODLDomains extends AaaCliAbstractCommand {
-
- public ListODLDomains(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- return identityStore.getDomains().getDomains();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "get-roles", scope = "aaa", description = "get list of ODL roles.")
-
-/**
- * ListODLDomains list the available roles at ODL aaa data store.
- *
- * @author mserngawy
- *
- */
-public class ListODLRoles extends AaaCliAbstractCommand {
-
- public ListODLRoles(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- return identityStore.getRoles().getRoles();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-
-@Command(name = "get-users", scope = "aaa", description = "get list of ODL users.")
-
-/**
- * ListODLDomains list the available users at ODL aaa data store.
- *
- * @author mserngawy
- *
- */
-public class ListODLUsers extends AaaCliAbstractCommand {
-
- public ListODLUsers(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- return identityStore.getUsers().getUsers();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "remove-domain", scope = "aaa", description = "Remove domain.")
-
-/**
- * @author mserngawy
- *
- */
-public class RemoveDomain extends AaaCliAbstractCommand {
-
- @Option(name = "-name",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- public RemoveDomain(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String domainId = DataStoreUtils.getDomainId(identityStore, domainName);
- if (domainId == null) {
- return "User does not exist";
- }
- if (identityStore.deleteDomain(domainId) == null) {
- return "Failed to delete domain " + domainName;
- }
- return "Domain " + domainName + "has been deleted.";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "remove-grant", scope = "aaa", description = "Remove grant.")
-
-/**
- * @author mserngawy
- *
- */
-public class RemoveGrant extends AaaCliAbstractCommand {
-
- @Option(name = "-uname",
- aliases = { "--userName" },
- description = "The user name",
- required = true,
- multiValued = false)
- private String userName = "";
-
- @Option(name = "-dname",
- aliases = { "--domainName" },
- description = "The domain name",
- required = true,
- multiValued = false)
- private String domainName = "";
-
- @Option(name = "-rname",
- aliases = { "--roleName" },
- description = "The role name",
- required = false,
- multiValued = false)
- private String roleName = "";
-
- public RemoveGrant(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String grantid = DataStoreUtils.getGrantId(identityStore, domainName, roleName, userName);
- if (grantid == null) {
- return "Grant does not exist";
- }
- if (identityStore.deleteGrant(grantid) == null) {
- return "Failed to delete grant " + userName + " " + roleName + " " + domainName;
- }
- return "Grant has been deleted.";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "remove-role", scope = "aaa", description = "Remove role.")
-
-/**
- * @author mserngawy
- *
- */
-public class RemoveRole extends AaaCliAbstractCommand {
-
- @Option(name = "-name",
- aliases = { "--roleName" },
- description = "The role name",
- required = true,
- multiValued = false)
- private String roleName = "";
-
- public RemoveRole(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String roleId = DataStoreUtils.getRoleId(identityStore, roleName);
- if (roleId == null) {
- return "Role does not exist";
- }
- if (identityStore.deleteUser(roleId) == null) {
- return "Failed to delete role " + roleName;
- }
- return "Role " + roleName + "has been deleted.";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.dmstore;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.utils.CliUtils;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-
-@Command(name = "remove-user", scope = "aaa", description = "Remove user.")
-
-/**
- * @author mserngawy
- *
- */
-public class RemoveUser extends AaaCliAbstractCommand {
-
- @Option(name = "-name",
- aliases = { "--userName" },
- description = "The user name",
- required = true,
- multiValued = false)
- private String userName = "";
-
- public RemoveUser(final IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- if (super.doExecute() == null) {
- return CliUtils.LOGIN_FAILED_MESS;
- }
- final String usrId = DataStoreUtils.getUserId(identityStore, userName);
- if (usrId == null) {
- return "User does not exist";
- }
- if (identityStore.deleteUser(usrId) == null) {
- return "Failed to delete user " + userName;
- }
- return "User " + userName + "has been deleted.";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.aaa.cli.utils;
-
-import org.apache.felix.service.command.CommandSession;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * CliUtils has helper methods for CLI bundle.
- *
- * @author mserngawy
- *
- */
-public class CliUtils {
-
- public static final String LOGIN_FAILED_MESS = "User does not exist OR user name and passsword are not correct";
-
- /**
- * Retrieve the password from the user
- *
- * @param session command line session
- * @param pwdPrintStr label for enter password
- * @return the new written password
- * @throws Exception
- */
- public static String readPassword(final CommandSession session, final String pwdPrintStr) throws Exception {
- session.getConsole().println(pwdPrintStr);
- final InputStreamReader iStreamReader = new InputStreamReader(session.getKeyboard());
- final BufferedReader bReader = new BufferedReader(iStreamReader);
- final String pwd = bReader.readLine();
- return pwd;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.utils;
-
-import java.util.List;
-
-import org.opendaylight.aaa.api.IDMStoreException;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.SHA256Calculator;
-import org.opendaylight.aaa.api.model.Domain;
-import org.opendaylight.aaa.api.model.Domains;
-import org.opendaylight.aaa.api.model.Grant;
-import org.opendaylight.aaa.api.model.Role;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.api.model.Users;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataStoreUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger(DataStoreUtils.class);
- private static final String ADMIN_ROLE = "admin";
-
- public static final String getDomainId(IIDMStore identityStore, String domainName) throws IDMStoreException {
- Domains domains = identityStore.getDomains();
- if (domains != null) {
- for (Domain domain : domains.getDomains()) {
- if (domain.getName().equalsIgnoreCase(domainName)) {
- return domain.getDomainid();
- }
- }
- }
- return null;
- }
-
- public static final String getRoleId(IIDMStore identityStore, String roleName) throws IDMStoreException {
- List<Role> roles = identityStore.getRoles().getRoles();
- for (Role role : roles) {
- if (role.getName().equalsIgnoreCase(roleName)) {
- return role.getRoleid();
- }
- }
- return null;
- }
-
- public static final String getUserId(IIDMStore identityStore, String userName) throws IDMStoreException {
- List<User> users = identityStore.getUsers().getUsers();
- for (User usr : users) {
- if (usr.getName().equalsIgnoreCase(userName)) {
- return usr.getUserid();
- }
- }
- return null;
- }
-
- public static final String getGrantId(IIDMStore identityStore, String domainName, String roleName,
- String userName) throws IDMStoreException {
- final String domainId = getDomainId(identityStore, domainName);
- if (domainId == null) {
- return null;
- }
- final String usrId = getUserId(identityStore, userName);
- if (usrId == null) {
- return null;
- }
- List<Grant> grants = identityStore.getGrants(usrId).getGrants();
- if (grants == null || grants.isEmpty()) {
- return null;
- }
- final String roleId = getRoleId(identityStore, roleName);
- if (roleId == null) {
- return null;
- }
- for (Grant grant : grants) {
- if (grant.getRoleid().equals(roleId)) {
- return grant.getGrantid();
- }
- }
- return null;
- }
-
- public static User isAdminUser(IIDMStore identityStore, String userName, String password) throws IDMStoreException {
- final Users users = identityStore.getUsers();
- for (User usr : users.getUsers()) {
- final String realPwd = SHA256Calculator.getSHA256(password, usr.getSalt());
- if (usr.getName().equals(userName) && usr.getPassword().equals(realPwd)) {
- List<Grant> grants = identityStore.getGrants(usr.getUserid()).getGrants();
- if (grants != null && !grants.isEmpty()) {
- final String adminRoleId = getRoleId(identityStore, ADMIN_ROLE);
- for (Grant grant : grants) {
- if (grant.getRoleid().equals(adminRoleId)) {
- return usr;
- }
- }
- LOG.debug("user is not authorized for admin grant");
- }
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <reference id="KeyStoreConsoleProvider" availability="mandatory"
- activation="eager" interface="org.opendaylight.aaa.cert.api.ICertificateManager">
- </reference>
-
- <reference id="iIDMStore" interface="org.opendaylight.aaa.api.IIDMStore"
- availability="optional" timeout="30000">
- </reference>
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.ListODLUsers">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.ListODLDomains">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.ListODLRoles">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.ChangeUserPassword">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.cert.GetODLSelfSignCert">
- <argument ref="KeyStoreConsoleProvider" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.cert.GenerateCertReq">
- <argument ref="KeyStoreConsoleProvider" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.cert.GetTrustStoreCert">
- <argument ref="KeyStoreConsoleProvider" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.cert.GetCipherSuites">
- <argument ref="KeyStoreConsoleProvider" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.AddRole">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.AddDomain">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.AddUser">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.AddGrant">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.RemoveGrant">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.RemoveUser">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.RemoveRole">
- <argument ref="iIDMStore" />
- </action>
- </command>
- <command>
- <action class="org.opendaylight.aaa.cli.dmstore.RemoveDomain">
- <argument ref="iIDMStore" />
- </action>
- </command>
- </command-bundle>
-
-</blueprint>
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.aaa.cli.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
-import org.opendaylight.aaa.cli.SessionsManager;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.api.support.membermodification.MemberModifier;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-/**
- * @author mserngawy
- *
- */
-@RunWith(PowerMockRunner.class)
-public class AaaCliAbstractCommandTest {
-
- class TestAaaCliAbstractCommand extends AaaCliAbstractCommand {
-
- public TestAaaCliAbstractCommand(IIDMStore identityStore) {
- super(identityStore);
- }
-
- @Override
- protected Object doExecute() throws Exception {
- return super.doExecute();
- }
- }
-
- private static final String authUserName = "foo";
- final User usr = new User();
- @Mock private TestAaaCliAbstractCommand testCmd;
-
- @Before
- public void setUp() throws Exception {
- testCmd = PowerMockito.mock(TestAaaCliAbstractCommand.class, Mockito.CALLS_REAL_METHODS);
- MemberModifier.field(TestAaaCliAbstractCommand.class, "authUser").set(testCmd, authUserName);
- SessionsManager sessionMngr = SessionsManager.getInstance();
- final String usrName = "foo";
- usr.setName(usrName);
- usr.setDomainid("fooDomain");
- usr.setPassword("fooPwd");
- sessionMngr.addUserSession(usrName, usr);
- }
-
- @Test
- public void testDoExecute() throws Exception {
- User authUsr = (User) testCmd.doExecute();
- assertNotNull(authUsr);
- assertEquals(authUsr, usr);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.aaa.cli.test;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.opendaylight.aaa.api.IDMStoreException;
-import org.opendaylight.aaa.api.IIDMStore;
-import org.opendaylight.aaa.api.model.*;
-import org.opendaylight.aaa.cli.utils.DataStoreUtils;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-/**
- * @author mserngawy
- *
- */
-@RunWith(PowerMockRunner.class)
-public class DataStoreUtilsTest {
-
- @Mock private IIDMStore identityStore;
- private final String domainName = "Dfoo";
- private final String usrName = "Ufoo";
- private final String roleName = "Rfoo";
- private final String grantId = "Gfoo";
- private final String dummyId = "foo";
-
- @Before
- public void setUp() throws Exception {
- identityStore = PowerMockito.mock(IIDMStore.class, Mockito.CALLS_REAL_METHODS);
- Domains domains = new Domains();
- Domain domain = new Domain();
- domain.setName(domainName);
- domain.setDomainid(domainName);
- List<Domain> dList = new ArrayList<>();
- dList.add(domain);
- domains.setDomains(dList);
- when(identityStore.getDomains()).thenReturn(domains);
-
- Users users = new Users();
- User usr = new User();
- usr.setName(usrName);
- usr.setDomainid(domainName);
- usr.setUserid(usrName);
- List<User> uList = new ArrayList<>();
- uList.add(usr);
- users.setUsers(uList);
- when(identityStore.getUsers()).thenReturn(users);
-
- Roles roles = new Roles();
- Role role = new Role();
- role.setName(roleName);
- role.setDomainid(domainName);
- role.setRoleid(roleName);
- List<Role> rList = new ArrayList<>();
- rList.add(role);
- roles.setRoles(rList);
- when(identityStore.getRoles()).thenReturn(roles);
-
- Grants grants = new Grants();
- Grant grant = new Grant();
- grant.setDomainid(domainName);
- grant.setGrantid(grantId);
- grant.setRoleid(roleName);
- grant.setUserid(usrName);
- List<Grant> gList = new ArrayList<>();
- gList.add(grant);
- grants.setGrants(gList);
- when(identityStore.getGrants(usrName)).thenReturn(grants);
- }
-
- @Test
- public void testGetDomainId() throws IDMStoreException {
- final String domID = DataStoreUtils.getDomainId(identityStore, domainName);
- assertNotNull(domID);
- assertEquals(domID, domainName);
- assertNull(DataStoreUtils.getDomainId(identityStore, dummyId));
- }
-
- @Test
- public void testGetRoleId() throws IDMStoreException {
- final String roleID = DataStoreUtils.getRoleId(identityStore, roleName);
- assertNotNull(roleID);
- assertEquals(roleID, roleName);
- assertNull(DataStoreUtils.getRoleId(identityStore, dummyId));
- }
-
- @Test
- public void testGetUserId() throws IDMStoreException {
- final String usrID = DataStoreUtils.getUserId(identityStore, usrName);
- assertNotNull(usrID);
- assertEquals(usrID, usrName);
- assertNull(DataStoreUtils.getUserId(identityStore, dummyId));
- }
-
- @Test
- public void testGetGrantId() throws IDMStoreException {
- final String grantID = DataStoreUtils.getGrantId(identityStore, domainName, roleName, usrName);
- assertNotNull(grantID);
- assertEquals(grantID, grantId);
- assertNull(DataStoreUtils.getGrantId(identityStore, dummyId, dummyId, dummyId));
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Inocybe Technologies. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.aaa.cli.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.opendaylight.aaa.api.model.User;
-import org.opendaylight.aaa.cli.SessionsManager;
-
-/**
- * @author mserngawy
- *
- */
-public class SessionsManagerTest {
-
- @Test
- public void testSessionManager() {
- SessionsManager sessionMngr = SessionsManager.getInstance();
- assertNotNull(sessionMngr);
- final String usrName = "foo";
- final User usr = new User();
- usr.setName(usrName);
- usr.setDomainid("fooDomain");
- usr.setPassword("fooPwd");
- sessionMngr.addUserSession(usrName, usr);
- final User authUsr = sessionMngr.getCurrentUser(usrName);
- assertNotNull(authUsr);
- assertEquals(usr, authUsr);
- }
-
-}
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>aaa-cli4</artifactId>
+ <artifactId>aaa-cli</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<module>aaa-h2-store</module>
<module>aaa-cert</module>
<module>aaa-cli</module>
- <module>aaa-cli4</module>
<module>aaa-cli-jar</module>
<module>aaa-filterchain</module>
<module>artifacts</module>