summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
Diffstat (limited to 'auth')
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Approval.java12
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java20
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NsAttrib.java85
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/UserRole.java20
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java1
-rw-r--r--auth/docker/aaf.sh2
-rwxr-xr-xauth/sample/bin/client.sh8
-rw-r--r--auth/sample/bin/service.sh10
8 files changed, 139 insertions, 19 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Approval.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Approval.java
index 8aee4f8a..ce19865a 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Approval.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Approval.java
@@ -231,18 +231,6 @@ public class Approval implements CacheChange.Data {
}
};
-// /**
-// * @return the lastNotified
-// */
-// public Date getLast_notified() {
-// return add.last_notified;
-// }
-// /**
-// * @param lastNotified the lastNotified to set
-// */
-// public void setLastNotified(Date last_notified) {
-// add.last_notified = last_notified;
-// }
/**
* @return the status
*/
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
index 55fe22ce..dbafdc04 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
@@ -28,9 +28,11 @@ import java.util.Map;
import java.util.TreeMap;
import org.onap.aaf.auth.dao.cass.NsDAO;
+import org.onap.aaf.cadi.util.CSV;
import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
import org.onap.aaf.misc.env.Trans;
+import org.onap.aaf.misc.env.util.Chrono;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
@@ -67,17 +69,29 @@ public class NS implements Comparable<NS> {
public static void load(Trans trans, Session session, Creator<NS> creator) {
load(trans,session,
"select name, description, parent, type, scope from authz.ns;"
- ,creator);
+ ,creator
+ , v -> data.put(v.ndd.name,v)
+ );
}
public static void loadOne(Trans trans, Session session, Creator<NS> creator, String ns) {
load(trans,session,
("select name, description, parent, type, scope from authz.ns WHERE name='"+ns+"';")
,creator
+ , v -> data.put(v.ndd.name,v)
);
}
- private static void load(Trans trans, Session session, String query, Creator<NS> creator) {
+ public static void load(Trans trans, Session session, Creator<NS> creator, Visitor<NS> visitor) {
+ load(trans,session,creator.query(null),creator, visitor);
+ }
+
+ public void row(final CSV.Writer csvw, String tag) {
+ csvw.row(tag,ndd.name,ndd.type,ndd.parent);
+ }
+
+
+ private static void load(Trans trans, Session session, String query, Creator<NS> creator, Visitor<NS> visitor) {
trans.info().log( "query: " + query );
ResultSet results;
TimeTaken tt;
@@ -99,7 +113,7 @@ public class NS implements Comparable<NS> {
while (iter.hasNext()) {
row = iter.next();
NS ns = creator.create(row);
- data.put(ns.ndd.name,ns);
+ visitor.visit(ns);
}
} finally {
tt.done();
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NsAttrib.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NsAttrib.java
new file mode 100644
index 00000000..f5e36fa1
--- /dev/null
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NsAttrib.java
@@ -0,0 +1,85 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.auth.batch.helpers;
+
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.TimeTaken;
+import org.onap.aaf.misc.env.Trans;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.SimpleStatement;
+import com.datastax.driver.core.Statement;
+
+public class NsAttrib {
+
+ public final String ns;
+ public final String key;
+ public final String value;
+
+
+ public NsAttrib(String ns, String key, String value) {
+ this.ns = ns;
+ this.key = key;
+ this.value = value;
+ }
+
+ public static Creator<NsAttrib> v2_0_11 = new Creator<NsAttrib>() {
+ @Override
+ public NsAttrib create(Row row) {
+ return new NsAttrib(row.getString(0), row.getString(1), row.getString(2));
+ }
+
+ @Override
+ public String select() {
+ return "select ns,key,value from authz.ns_attrib";
+ }
+ };
+
+ public static void load(Trans trans, Session session, Creator<NsAttrib> creator, Visitor<NsAttrib> visitor) {
+ trans.info().log( "query: " + creator.select() );
+ ResultSet results;
+ TimeTaken tt = trans.start("Load NsAttributes", Env.REMOTE);
+ try {
+ Statement stmt = new SimpleStatement(creator.select());
+ results = session.execute(stmt);
+ } finally {
+ tt.done();
+ }
+ int count = 0;
+ tt = trans.start("Process NsAttributes", Env.SUB);
+
+ try {
+ for (Row row : results.all()) {
+ ++count;
+ visitor.visit(creator.create(row));
+ }
+ } finally {
+ tt.done();
+ trans.info().log("Found",count,"NS Attributes");
+ }
+ }
+}
+
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/UserRole.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/UserRole.java
index b4e1a6d3..96169434 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/UserRole.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/UserRole.java
@@ -21,6 +21,7 @@
package org.onap.aaf.auth.batch.helpers;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Date;
@@ -32,6 +33,7 @@ import java.util.TreeMap;
import org.onap.aaf.auth.dao.cass.UserRoleDAO;
import org.onap.aaf.auth.dao.cass.UserRoleDAO.Data;
import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.util.CSV;
import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
@@ -124,6 +126,14 @@ public class UserRole implements Cloneable, CacheChange.Data {
load(trans,session,creator,"user='"+ user +'\'',visitor);
}
+ public static void load(Trans trans, CSV csv, Creator<UserRole> creator, Visitor<UserRole> visitor) throws IOException, CadiException {
+// public UserRole(String user, String role, String ns, String rname, Date expires) {
+ csv.visit( row -> {
+ visitor.visit(new UserRole(row.get(1),row.get(2),row.get(3),row.get(4),
+ new Date(Long.parseLong(row.get(6)))));
+ });
+ }
+
private static void load(Trans trans, Session session, Creator<UserRole> creator, String where, Visitor<UserRole> visitor) {
String query = creator.query(where);
trans.debug().log( "query: " + query );
@@ -330,6 +340,16 @@ public class UserRole implements Cloneable, CacheChange.Data {
sb.append("';\n");
}
+ public void batchExtend(StringBuilder sb, Date newDate) {
+ sb.append("UPDATE authz.user_role SET expires='");
+ sb.append(Chrono.dateTime(newDate));
+ sb.append("' WHERE user='");
+ sb.append(user());
+ sb.append("' AND role='");
+ sb.append(role());
+ sb.append("';\n");
+ }
+
public void batchUpdateExpires(StringBuilder sb) {
sb.append("UPDATE authz.user_role SET expires='");
sb.append(Chrono.dateTime(expires()));
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
index 026c5f41..7201958d 100644
--- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/hl/Question.java
@@ -144,7 +144,6 @@ public class Question {
public Question(AuthzTrans trans, Cluster cluster, String keyspace, boolean startClean) throws APIException, IOException {
PERMS = trans.slot("USER_PERMS");
- System.out.println(trans.init());
trans.init().log("Instantiating DAOs");
long expiresIn = Long.parseLong(trans.getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF));
historyDAO = new HistoryDAO(trans, cluster, keyspace);
diff --git a/auth/docker/aaf.sh b/auth/docker/aaf.sh
index 656ce56c..23822e52 100644
--- a/auth/docker/aaf.sh
+++ b/auth/docker/aaf.sh
@@ -23,7 +23,7 @@
DOCKER=${DOCKER:=docker}
# if something, may not want CASS attached all the tim
-LINKS="--link $CASSANDRA_DOCKER"
+#LINKS="--link $CASSANDRA_DOCKER"
function run_it() {
if [ -n "${DUSER}" ]; then
diff --git a/auth/sample/bin/client.sh b/auth/sample/bin/client.sh
index dbf08622..9e3b2fd7 100755
--- a/auth/sample/bin/client.sh
+++ b/auth/sample/bin/client.sh
@@ -114,7 +114,13 @@ if [ ! -e "$DOT_AAF/keyfile" ]; then
fi
echo "cat SSO"
cat ${SSO}
-echo "dog"
+
+# Should we clean up?
+if [ "${VERSION}" != "$(cat ${LOCAL}/VERSION)" ]; then
+ echo "Clean up directory ${LOCAL}"
+ rm -Rf ${LOCAL}/*
+fi
+echo "${VERSION}" > $LOCAL/VERSION
# Only initialize once, automatically...
if [ ! -e $LOCAL/${NS}.props ]; then
diff --git a/auth/sample/bin/service.sh b/auth/sample/bin/service.sh
index 1a289d35..a4d2aba1 100644
--- a/auth/sample/bin/service.sh
+++ b/auth/sample/bin/service.sh
@@ -105,7 +105,13 @@ if [ ! -e $FILE ]; then
fi
fi
-# echo "Check keyfile"
+# Should we clean up?
+if [ "${VERSION}" != "$(cat ${LOCAL}/VERSION)" ]; then
+ echo "Clean up directory ${LOCAL}"
+ rm -Rf ${LOCAL}/*
+fi
+echo "${VERSION}" > $LOCAL/VERSION
+
FILE="$LOCAL/org.osaaf.aaf.p12"
if [ ! -e $FILE ]; then
if [ -e $CONFIG/cert/org.osaaf.aaf.p12 ]; then
@@ -157,6 +163,8 @@ if [ ! -e $LOCAL/org.osaaf.aaf.props ]; then
$JAVA_AGENT config \
aaf@aaf.osaaf.org \
cadi_etc_dir=$LOCAL \
+ cadi_latitude=${cadi_latitude} \
+ cadi_longitude=${cadi_longitude} \
cadi_prop_files=$CONFIG/local/initialConfig.props:$CONFIG/local/aaf.props:${TMP}
rm ${TMP}