Karaf 4: remove aaa-cli4 80/51380/1
authorStephen Kitt <skitt@redhat.com>
Fri, 3 Feb 2017 09:09:30 +0000 (10:09 +0100)
committerStephen Kitt <skitt@redhat.com>
Fri, 3 Feb 2017 09:09:30 +0000 (10:09 +0100)
aaa-cli can be easily fixed to work with both Karaf 3 and 4; doing
this means we can drop the duplicated aaa-cli4 entirely.

Change-Id: I73fb4de50c9d5a71502e2125cf9f45a526474ca6
Signed-off-by: Stephen Kitt <skitt@redhat.com>
29 files changed:
aaa-cli/pom.xml
aaa-cli/src/main/resources/org/opendaylight/blueprint/commands.xml [moved from aaa-cli/src/main/resources/OSGI-INF/blueprint/commands.xml with 100% similarity]
aaa-cli4/pom.xml [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/AaaCliAbstractCommand.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/SessionsManager.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GenerateCertReq.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetCipherSuites.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetODLSelfSignCert.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetTrustStoreCert.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddDomain.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddGrant.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddRole.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddUser.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ChangeUserPassword.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLDomains.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLRoles.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLUsers.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveDomain.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveGrant.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveRole.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveUser.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/CliUtils.java [deleted file]
aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/DataStoreUtils.java [deleted file]
aaa-cli4/src/main/resources/org/opendaylight/blueprint/commands.xml [deleted file]
aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/AaaCliAbstractCommandTest.java [deleted file]
aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/DataStoreUtilsTest.java [deleted file]
aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/SessionsManagerTest.java [deleted file]
features/authn/odl-aaa-cli/pom.xml
pom.xml

index 5ae98bb5f24508ccc5c0d68f77c7786048a92892..c98922bcad60619c5971d689b44a69a0cbb2c6ce 100755 (executable)
@@ -62,4 +62,23 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     </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>
diff --git a/aaa-cli4/pom.xml b/aaa-cli4/pom.xml
deleted file mode 100755 (executable)
index 622e355..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?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>
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/AaaCliAbstractCommand.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/AaaCliAbstractCommand.java
deleted file mode 100644 (file)
index 3b81d39..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/SessionsManager.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/SessionsManager.java
deleted file mode 100644 (file)
index 611cae5..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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;
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GenerateCertReq.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GenerateCertReq.java
deleted file mode 100644 (file)
index 7caf774..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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);
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetCipherSuites.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetCipherSuites.java
deleted file mode 100644 (file)
index d8a3b60..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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();
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetODLSelfSignCert.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetODLSelfSignCert.java
deleted file mode 100644 (file)
index 6b6c8ab..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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);
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetTrustStoreCert.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/cert/GetTrustStoreCert.java
deleted file mode 100644 (file)
index a2d9343..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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);
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddDomain.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddDomain.java
deleted file mode 100644 (file)
index adf4583..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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;
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddGrant.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddGrant.java
deleted file mode 100644 (file)
index 30a977d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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;
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddRole.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddRole.java
deleted file mode 100644 (file)
index 3ae45f9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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;
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddUser.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/AddUser.java
deleted file mode 100644 (file)
index 858851b..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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;
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ChangeUserPassword.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ChangeUserPassword.java
deleted file mode 100644 (file)
index 44a233d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLDomains.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLDomains.java
deleted file mode 100644 (file)
index 0c23e36..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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();
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLRoles.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLRoles.java
deleted file mode 100644 (file)
index 066280b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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();
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLUsers.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/ListODLUsers.java
deleted file mode 100644 (file)
index 1062f39..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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();
-    }
-
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveDomain.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveDomain.java
deleted file mode 100644 (file)
index d02f3ab..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.";
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveGrant.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveGrant.java
deleted file mode 100644 (file)
index bfb5ae9..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.";
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveRole.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveRole.java
deleted file mode 100644 (file)
index 543b766..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.";
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveUser.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/dmstore/RemoveUser.java
deleted file mode 100644 (file)
index a32d3ff..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.";
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/CliUtils.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/CliUtils.java
deleted file mode 100644 (file)
index 76d9a8a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-    }
-}
diff --git a/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/DataStoreUtils.java b/aaa-cli4/src/main/java/org/opendaylight/aaa/cli/utils/DataStoreUtils.java
deleted file mode 100644 (file)
index 0e5f57c..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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;
-    }
-
-}
diff --git a/aaa-cli4/src/main/resources/org/opendaylight/blueprint/commands.xml b/aaa-cli4/src/main/resources/org/opendaylight/blueprint/commands.xml
deleted file mode 100644 (file)
index e236c5e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<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
diff --git a/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/AaaCliAbstractCommandTest.java b/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/AaaCliAbstractCommandTest.java
deleted file mode 100644 (file)
index 30757fb..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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);
-    }
-
-}
diff --git a/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/DataStoreUtilsTest.java b/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/DataStoreUtilsTest.java
deleted file mode 100644 (file)
index b1a16b5..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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));
-    }
-
-}
diff --git a/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/SessionsManagerTest.java b/aaa-cli4/src/test/java/org/opendaylight/aaa/cli/test/SessionsManagerTest.java
deleted file mode 100644 (file)
index 548eaff..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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);
-    }
-
-}
index f9337f0a5dd8d8290bdcfb6d02d369f34e06bd17..1f465e66aac43e8f39c6f1ee987a2e178a0b30ed 100644 (file)
@@ -71,7 +71,7 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>aaa-cli4</artifactId>
+            <artifactId>aaa-cli</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/pom.xml b/pom.xml
index 1c0019e0c85dc2162f7b9e4354fd59ba64b6f887..669a6c04481d88c285084332e22a5e8bdde8cd3e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,6 @@
     <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>