diff options
411 files changed, 15491 insertions, 16699 deletions
diff --git a/authz-batch/pom.xml b/authz-batch/pom.xml deleted file mode 100644 index 6f3d8d7a..00000000 --- a/authz-batch/pom.xml +++ /dev/null @@ -1,286 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - --> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.att.authz</groupId> - <artifactId>parent</artifactId> - <version>1.0.1-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>authz-batch</artifactId> - <name>Authz Batch</name> - <description>Batch Processing for Authz</description> - <packaging>jar</packaging> - <url>https://github.com/att/AAF</url> - - <developers> - <developer> - <name>Jonathan Gathman</name> - <email></email> - <organization>ATT</organization> - <organizationUrl></organizationUrl> - </developer> - </developers> - - <properties> - <maven.test.failure.ignore>false</maven.test.failure.ignore> - <project.swmVersion>1</project.swmVersion> - <project.interfaceVersion>1.0.0-SNAPSHOT</project.interfaceVersion> - <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion> - <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <skipTests>false</skipTests> - <project.dme2Version>3.1.200</project.dme2Version> - - <!-- SONAR --> - <jacoco.version>0.7.7.201606060606</jacoco.version> - <sonar.skip>true</sonar.skip> - <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> - <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> - <!-- Default Sonar configuration --> - <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath> - <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath> - <!-- Note: This list should match jacoco-maven-plugin's exclusion list below --> - <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions> - <nexusproxy>https://nexus.onap.org</nexusproxy> - <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath> - <releaseNexusPath>/content/repositories/releases/</releaseNexusPath> - <stagingNexusPath>/content/repositories/staging/</stagingNexusPath> - <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath> - </properties> - - <dependencies> - - <dependency> - <groupId>org.onap.aaf.inno</groupId> - <artifactId>env</artifactId> - <version>${project.innoVersion}</version> - </dependency> - - <dependency> - <groupId>org.onap.aaf.inno</groupId> - <artifactId>rosetta</artifactId> - <version>${project.innoVersion}</version> - </dependency> - - <dependency> - <groupId>org.onap.aaf.cadi</groupId> - <artifactId>cadi-core</artifactId> - <version>${project.cadiVersion}</version> - </dependency> - - <dependency> - <groupId>org.onap.aaf.cadi</groupId> - <artifactId>cadi-aaf</artifactId> - <version>${project.cadiVersion}</version> - </dependency> - - - <dependency> - <groupId>prg.onap.aaf.authz</groupId> - <artifactId>authz-cass</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.onap.aaf.cadi</groupId> - <artifactId>cadi-aaf</artifactId> - </exclusion> - <exclusion> - <groupId>org.onap.aaf.cadi</groupId> - <artifactId>cadi-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.onap.aaf.cadi</groupId> - <artifactId>cadi-client</artifactId> - </exclusion> - - </exclusions> - </dependency> - - <dependency> - <groupId>org.joda</groupId> - <artifactId>joda-time</artifactId> - <version>2.5</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - - </dependencies> - - <build> - <plugins> - - - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.4</version> - - <configuration> - <classifier>tests</classifier> - <archive> - <manifestEntries> - <Sealed>true</Sealed> - </manifestEntries> - </archive> - </configuration> - <executions> - <execution> - <id>depends</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <archive> - <manifest> - <mainClass>org.onap.aaf.authz.Batch</mainClass> - </manifest> - </archive> - </configuration> - </execution> - <execution> - <id>swm</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <finalName>authz-batch-${project.version}.${project.swmVersion}</finalName> - <descriptors> - <descriptor>../authz-service/src/main/assemble/swm.xml</descriptor> - </descriptors> - <archive> - </archive> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <failOnError>false</failOnError> - </configuration> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.2.1</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - -<plugin> - <groupId>org.sonatype.plugins</groupId> - <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.7</version> - <extensions>true</extensions> - <configuration> - <nexusUrl>${nexusproxy}</nexusUrl> - <stagingProfileId>176c31dfe190a</stagingProfileId> - <serverId>ecomp-staging</serverId> - </configuration> - </plugin> - - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>${jacoco.version}</version> - <configuration> - <excludes> - <exclude>**/gen/**</exclude> - <exclude>**/generated-sources/**</exclude> - <exclude>**/yang-gen/**</exclude> - <exclude>**/pax/**</exclude> - </excludes> - </configuration> - <executions> - - <execution> - <id>pre-unit-test</id> - <goals> - <goal>prepare-agent</goal> - </goals> - <configuration> - <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile> - <propertyName>surefireArgLine</propertyName> - </configuration> - </execution> - - - <execution> - <id>post-unit-test</id> - <phase>test</phase> - <goals> - <goal>report</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile> - <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> - </configuration> - </execution> - <execution> - <id>pre-integration-test</id> - <phase>pre-integration-test</phase> - <goals> - <goal>prepare-agent</goal> - </goals> - <configuration> - <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile> - - <propertyName>failsafeArgLine</propertyName> - </configuration> - </execution> - - - <execution> - <id>post-integration-test</id> - <phase>post-integration-test</phase> - <goals> - <goal>report</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile> - <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - - - - </plugins> - </build> -</project> diff --git a/authz-batch/src/main/config/authBatch.props b/authz-batch/src/main/config/authBatch.props deleted file mode 100644 index cfe75e32..00000000 --- a/authz-batch/src/main/config/authBatch.props +++ /dev/null @@ -1,36 +0,0 @@ -## -## AUTHZ Batch (authz-batch) Properties -## -## DISCOVERY (DME2) Parameters on the Command Line -AFT_LATITUDE=_AFT_LATITUDE_ -AFT_LONGITUDE=_AFT_LONGITUDE_ -AFT_ENVIRONMENT=_AFT_ENVIRONMENT_ -DEPLOYED_VERSION=_ARTIFACT_VERSION_ - - -DRY_RUN=false - -## Pull in common/security properties - -cadi_prop_files=_COMMON_DIR_/com.att.aaf.props;_COMMON_DIR_/com.att.aaf.common.props - - -## ------------------------------------- -## Batch specific Settings -## ------------------------------------- -SPECIAL_NAMES=testunused,testid,unknown - - -## ---------------------------------------------- -## Email Server settings -## ---------------------------------------------- -#Sender's email ID needs to be mentioned -mailFromUserId=DL-aaf-support@att.com -mailHost=smtp.it.att.com - -ALERT_TO_ADDRESS=DL-aaf-support@att.com - -PASSWORD_RESET_URL=_AUTHZ_GUI_URL_/gui/passwd -APPROVALS_URL=_AUTHZ_GUI_URL_/gui/approve - - diff --git a/authz-batch/src/main/config/log4j.properties b/authz-batch/src/main/config/log4j.properties deleted file mode 100644 index 169460c4..00000000 --- a/authz-batch/src/main/config/log4j.properties +++ /dev/null @@ -1,84 +0,0 @@ -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -log4j.rootLogger=INFO,FA -log4j.logger.aspr=INFO,aspr -log4j.additivity.aspr=false -log4j.logger.authz-batch=INFO,authz-batch -log4j.logger.sync=INFO,sync -log4j.additivity.sync=false -log4j.logger.jobchange=INFO,jobchange -log4j.additivity.jobchange=false -log4j.logger.validateuser=INFO,validateuser -log4j.additivity.validateuser=false - - -log4j.appender.FA=org.apache.log4j.RollingFileAppender -log4j.appender.FA.File=${LOG4J_FILENAME_authz-batch} -log4j.appender.FA.MaxFileSize=10000KB -log4j.appender.FA.MaxBackupIndex=7 -log4j.appender.FA.layout=org.apache.log4j.PatternLayout -log4j.appender.FA.layout.ConversionPattern=%d %p [%c] - %m %n - -log4j.appender.stderr=org.apache.log4j.ConsoleAppender -log4j.appender.stderr.layout=org.apache.log4j.PatternLayout -log4j.appender.stderr.layout.ConversionPattern=%d %p [%c] - %m %n -log4j.appender.stderr.Target=System.err - -log4j.appender.authz-batch=org.apache.log4j.DailyRollingFileAppender -log4j.appender.authz-batch.encoding=UTF-8 -log4j.appender.authz-batch.layout=org.apache.log4j.PatternLayout -log4j.appender.authz-batch.layout.ConversionPattern=%d [%p] %m %n -log4j.appender.authz-batch.File=${LOG4J_FILENAME_authz-batch} -log4j.appender.authz-batch.DatePattern='.'yyyy-MM - -log4j.appender.aspr=org.apache.log4j.DailyRollingFileAppender -log4j.appender.aspr.encoding=UTF-8 -log4j.appender.aspr.layout=org.apache.log4j.PatternLayout -log4j.appender.aspr.layout.ConversionPattern=%d [%p] %m %n -log4j.appender.aspr.File=${LOG4J_FILENAME_aspr} -log4j.appender.aspr.DatePattern='.'yyyy-MM - - -log4j.appender.jobchange=org.apache.log4j.RollingFileAppender -log4j.appender.jobchange.File=${LOG4J_FILENAME_jobchange} -log4j.appender.jobchange.MaxFileSize=10000KB -log4j.appender.jobchange.MaxBackupIndex=7 -log4j.appender.jobchange.layout=org.apache.log4j.PatternLayout -log4j.appender.jobchange.layout.ConversionPattern=%d %p [%c] - %m %n - -log4j.appender.validateuser=org.apache.log4j.RollingFileAppender -log4j.appender.validateuser.File=${LOG4J_FILENAME_validateuser} -log4j.appender.validateuser.MaxFileSize=10000KB -log4j.appender.validateuser.MaxBackupIndex=7 -log4j.appender.validateuser.layout=org.apache.log4j.PatternLayout -log4j.appender.validateuser.layout.ConversionPattern=%d %p [%c] - %m %n - -log4j.appender.sync=org.apache.log4j.DailyRollingFileAppender -log4j.appender.sync.encoding=UTF-8 -log4j.appender.sync.layout=org.apache.log4j.PatternLayout -log4j.appender.sync.layout.ConversionPattern=%d [%p] %m %n -log4j.appender.sync.File=${LOG4J_FILENAME_sync} -log4j.appender.sync.DatePattern='.'yyyy-MM - -# General Apache libraries -log4j.logger.org.apache=WARN - diff --git a/authz-batch/src/main/java/com/att/authz/Batch.java b/authz-batch/src/main/java/com/att/authz/Batch.java deleted file mode 100644 index a31d55f8..00000000 --- a/authz-batch/src/main/java/com/att/authz/Batch.java +++ /dev/null @@ -1,471 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.lang.reflect.Constructor; -import java.net.InetAddress; -import java.net.URL; -import java.net.UnknownHostException; -import java.nio.ByteBuffer; -import java.text.SimpleDateFormat; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.TimeZone; - -import org.apache.log4j.Logger; - -import com.att.authz.env.AuthzEnv; -import com.att.authz.env.AuthzTrans; -import com.att.authz.org.Organization; -import com.att.authz.org.OrganizationException; -import com.att.authz.org.OrganizationFactory; -import com.att.dao.CassAccess; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.StaticSlot; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.impl.Log4JLogTarget; -import org.onap.aaf.inno.env.log4j.LogFileNamer; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.Statement; - -public abstract class Batch { - private static StaticSlot ssargs; - - protected static final String STARS = "*****"; - - protected final Cluster cluster; - protected static AuthzEnv env; - protected static Session session; - protected static Logger aspr; - private static Set<String> specialNames = null; - protected static boolean dryRun; - protected static String batchEnv; - - public static final String CASS_ENV = "CASS_ENV"; - protected final static String PUNT="punt"; - protected final static String VERSION="VERSION"; - public final static String GUI_URL="GUI_URL"; - - protected final static String ORA_URL="ora_url"; - protected final static String ORA_PASSWORD="ora_password"; - - - - protected Batch(AuthzEnv env) throws APIException, IOException { - // TODO - Property Driven Organization -// try { -// // att = new ATT(env); -// } catch (OrganizationException e) { -// throw new APIException(e); -// } - - // Be able to change Environments - // load extra properties, i.e. - // PERF.cassandra.clusters=.... - batchEnv = env.getProperty(CASS_ENV); - if(batchEnv != null) { - batchEnv = batchEnv.trim(); - env.info().log("Redirecting to ",batchEnv,"environment"); - String str; - for(String key : new String[]{ - CassAccess.CASSANDRA_CLUSTERS, - CassAccess.CASSANDRA_CLUSTERS_PORT, - CassAccess.CASSANDRA_CLUSTERS_USER_NAME, - CassAccess.CASSANDRA_CLUSTERS_PASSWORD, - VERSION,GUI_URL,PUNT, - // TEMP - ORA_URL, ORA_PASSWORD - }) { - if((str = env.getProperty(batchEnv+'.'+key))!=null) { - env.setProperty(key, str); - } - } - } - - // Setup for Dry Run - cluster = CassAccess.cluster(env,batchEnv); - env.info().log("cluster name - ",cluster.getClusterName()); - String dryRunStr = env.getProperty( "DRY_RUN" ); - if ( dryRunStr == null || dryRunStr.equals("false") ) { - dryRun = false; - } else { - dryRun = true; - env.info().log("dryRun set to TRUE"); - } - - // Special names to allow behaviors beyond normal rules - String names = env.getProperty( "SPECIAL_NAMES" ); - if ( names != null ) - { - env.info().log("Loading SPECIAL_NAMES"); - specialNames = new HashSet<String>(); - for (String s :names.split(",") ) - { - env.info().log("\tspecial: " + s ); - specialNames.add( s.trim() ); - } - } - } - - protected abstract void run(AuthzTrans trans); - protected abstract void _close(AuthzTrans trans); - - public String[] args() { - return (String[])env.get(ssargs); - } - - public boolean isDryRun() - { - return( dryRun ); - } - - public boolean isSpecial(String user) { - if (specialNames != null && specialNames.contains(user)) { - env.info().log("specialName: " + user); - - return (true); - } else { - return (false); - } - } - - public boolean isMechID(String user) { - if (user.matches("m[0-9][0-9][0-9][0-9][0-9]")) { - return (true); - } else { - return (false); - } - } - - protected PrintStream fallout(PrintStream _fallout, String logType) - throws IOException { - PrintStream fallout = _fallout; - if (fallout == null) { - File dir = new File("logs"); - if (!dir.exists()) { - dir.mkdirs(); - } - - File f = null; - // String os = System.getProperty("os.name").toLowerCase(); - long uniq = System.currentTimeMillis(); - - f = new File(dir, getClass().getSimpleName() + "_" + logType + "_" - + uniq + ".log"); - - fallout = new PrintStream(new FileOutputStream(f, true)); - } - return fallout; - } - - public Organization getOrgFromID(AuthzTrans trans, String user) { - Organization org; - try { - org = OrganizationFactory.obtain(trans.env(),user.toLowerCase()); - } catch (OrganizationException e1) { - trans.error().log(e1); - org=null; - } - - if (org == null) { - PrintStream fallout = null; - - try { - fallout = fallout(fallout, "Fallout"); - fallout.print("INVALID_ID,"); - fallout.println(user); - } catch (Exception e) { - env.error().log("Could not write to Fallout File", e); - } - return (null); - } - - return (org); - } - - public static Row executeDeleteQuery(Statement stmt) { - Row row = null; - if (!dryRun) { - row = session.execute(stmt).one(); - } - - return (row); - - } - - public static int acquireRunLock(String className) { - Boolean testEnv = true; - String envStr = env.getProperty("AFT_ENVIRONMENT"); - - if (envStr != null) { - if (envStr.equals("AFTPRD")) { - testEnv = false; - } - } else { - env.fatal() - .log("AFT_ENVIRONMENT property is required and was not found. Exiting."); - System.exit(1); - } - - if (testEnv) { - env.info().log("TESTMODE: skipping RunLock"); - return (1); - } - - String hostname = null; - try { - hostname = InetAddress.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - e.printStackTrace(); - env.warn().log("Unable to get hostname"); - return (0); - } - - ResultSet existing = session.execute(String.format( - "select * from authz.run_lock where class = '%s'", className)); - - for (Row row : existing) { - long curr = System.currentTimeMillis(); - ByteBuffer lastRun = row.getBytesUnsafe(2); // Can I get this field - // by name? - - long interval = (1 * 60 * 1000); // @@ Create a value in props file - // for this - long prev = lastRun.getLong(); - - if ((curr - prev) <= interval) { - env.warn().log( - String.format("Too soon! Last run was %d minutes ago.", - ((curr - prev) / 1000) / 60)); - env.warn().log( - String.format("Min time between runs is %d minutes ", - (interval / 1000) / 60)); - env.warn().log( - String.format("Last ran on machine: %s at %s", - row.getString("host"), row.getDate("start"))); - return (0); - } else { - env.info().log("Delete old lock"); - deleteLock(className); - } - } - - GregorianCalendar current = new GregorianCalendar(); - - // We want our time in UTC, hence "+0000" - SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+0000"); - fmt.setTimeZone(TimeZone.getTimeZone("UTC")); - - String cql = String - .format("INSERT INTO authz.run_lock (class,host,start) VALUES ('%s','%s','%s') IF NOT EXISTS", - className, hostname, fmt.format(current.getTime())); - - env.info().log(cql); - - Row row = session.execute(cql).one(); - if (!row.getBool("[applied]")) { - env.warn().log("Lightweight Transaction failed to write lock."); - env.warn().log( - String.format("host with lock: %s, running at %s", - row.getString("host"), row.getDate("start"))); - return (0); - } - return (1); - } - - private static void deleteLock( String className) { - Row row = session.execute( String.format( "DELETE FROM authz.run_lock WHERE class = '%s' IF EXISTS", className ) ).one(); - if (! row.getBool("[applied]")) { - env.info().log( "delete failed" ); - } - } - - private static void transferVMProps(AuthzEnv env, String ... props) { - String value; - for(String key : props) { - if((value = System.getProperty(key))!=null) { - env.setProperty(key, value); - } - } - - } - - protected int count(String str, char c) { - int count=str==null||str.isEmpty()?0:1; - for(int i=str.indexOf(c);i>=0;i=str.indexOf(c,i+1)) { - ++count; - } - return count; - } - - public final void close(AuthzTrans trans) { - _close(trans); - cluster.close(); - } - - public static void main(String[] args) { - Properties props = new Properties(); - InputStream is=null; - String filename; - String propLoc; - try { - File f = new File("etc/authBatch.props"); - try { - if(f.exists()) { - filename = f.getCanonicalPath(); - is = new FileInputStream(f); - propLoc=f.getPath(); - } else { - URL rsrc = ClassLoader.getSystemResource("authBatch.props"); - filename = rsrc.toString(); - is = rsrc.openStream(); - propLoc=rsrc.getPath(); - } - props.load(is); - } finally { - if(is==null) { - System.err.println("authBatch.props must exist in etc dir, or in Classpath"); - System.exit(1); - } - is.close(); - } - - env = new AuthzEnv(props); - - transferVMProps(env,CASS_ENV,"DRY_RUN","NS","Organization"); - - // Flow all Env Logs to Log4j, with ENV - - LogFileNamer lfn; - if((batchEnv=env.getProperty(CASS_ENV))==null) { - lfn = new LogFileNamer("logs/").noPID(); - } else { - lfn = new LogFileNamer("logs/" + batchEnv+'/').noPID(); - } - - lfn.setAppender("authz-batch"); - lfn.setAppender("aspr|ASPR"); - lfn.setAppender("sync"); - lfn.setAppender("jobchange"); - lfn.setAppender("validateuser"); - aspr = Logger.getLogger("aspr"); - Log4JLogTarget.setLog4JEnv("authz-batch", env); - if(filename!=null) { - env.init().log("Instantiated properties from",filename); - } - - - // Log where Config found - env.info().log("Configuring from",propLoc); - propLoc=null; - - Batch batch = null; - // setup ATTUser and Organization Slots before starting this: - //TODO Property Driven Organization -// env.slot(ATT.ATT_USERSLOT); -// OrganizationFactory.setDefaultOrg(env, ATT.class.getName()); - AuthzTrans trans = env.newTrans(); - - TimeTaken tt = trans.start("Total Run", Env.SUB); - try { - int len = args.length; - if(len>0) { - String toolName = args[0]; - len-=1; - if(len<0)len=0; - String nargs[] = new String[len]; - if(len>0) { - System.arraycopy(args, 1, nargs, 0, len); - } - - env.put(ssargs=env.staticSlot("ARGS"), nargs); - - /* - * Add New Batch Programs (inherit from Batch) here - */ - - if( JobChange.class.getSimpleName().equals(toolName)) { - aspr.info( "Begin jobchange processing" ); - batch = new JobChange(trans); - } - //// else if( ValidateUsers.class.getSimpleName().equals(toolName)) { - //// aspr.info( "Begin ValidateUsers processing" ); - //// batch = new ValidateUsers(trans); - // } - else if( UserRoleDataGeneration.class.getSimpleName().equals(toolName)) { - // This job duplicates User Role add/delete History items - // so that we can search them by Role. Intended as a one-time - // script! but written as batch job because Java has better - // UUID support. Multiple runs will generate multiple copies of - // these history elements! - aspr.info( "Begin User Role Data Generation Processing "); - batch = new UserRoleDataGeneration(trans); - } else { // Might be a Report, Update or Temp Batch - Class<?> cls; - String classifier = ""; - try { - cls = ClassLoader.getSystemClassLoader().loadClass("com.att.authz.update."+toolName); - classifier = "Update:"; - } catch(ClassNotFoundException e) { - try { - cls = ClassLoader.getSystemClassLoader().loadClass("com.att.authz.reports."+toolName); - classifier = "Report:"; - } catch (ClassNotFoundException e2) { - try { - cls = ClassLoader.getSystemClassLoader().loadClass("com.att.authz.temp."+toolName); - classifier = "Temp Utility:"; - } catch (ClassNotFoundException e3) { - cls = null; - } - } - } - if(cls!=null) { - Constructor<?> cnst = cls.getConstructor(new Class[]{AuthzTrans.class}); - batch = (Batch)cnst.newInstance(trans); - env.info().log("Begin",classifier,toolName); - } - } - - if(batch==null) { - trans.error().log("No Batch named",toolName,"found"); - } - /* - * End New Batch Programs (inherit from Batch) here - */ - - } - if(batch!=null) { - batch.run(trans); - } - } finally { - tt.done(); - if(batch!=null) { - batch.close(trans); - } - StringBuilder sb = new StringBuilder("Task Times\n"); - trans.auditTrail(4, sb, AuthzTrans.REMOTE); - trans.info().log(sb); - } - } catch (Exception e) { - e.printStackTrace(System.err); - // Exceptions thrown by DB aren't stopping the whole process. - System.exit(1); - } - } - - -} - diff --git a/authz-batch/src/main/java/com/att/authz/BatchException.java b/authz-batch/src/main/java/com/att/authz/BatchException.java deleted file mode 100644 index 72475033..00000000 --- a/authz-batch/src/main/java/com/att/authz/BatchException.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz; - -public class BatchException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -3877245367723491192L; - - public BatchException() { - } - - public BatchException(String message) { - super(message); - } - - public BatchException(Throwable cause) { - super(cause); - } - - public BatchException(String message, Throwable cause) { - super(message, cause); - } - - public BatchException(String message, Throwable cause, - boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/CassBatch.java b/authz-batch/src/main/java/com/att/authz/CassBatch.java deleted file mode 100644 index f2515820..00000000 --- a/authz-batch/src/main/java/com/att/authz/CassBatch.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz; - -import java.io.IOException; - -import com.att.authz.env.AuthzTrans; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.impl.Log4JLogTarget; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.exceptions.InvalidQueryException; - -public abstract class CassBatch extends Batch { - - protected CassBatch(AuthzTrans trans, String log4JName) throws APIException, IOException { - super(trans.env()); - // Flow all Env Logs to Log4j - Log4JLogTarget.setLog4JEnv(log4JName, env); - - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - } - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - trans.info().log("Closed Session"); - } - - public ResultSet executeQuery(String cql) { - return executeQuery(cql,""); - } - - public ResultSet executeQuery(String cql, String extra) { - if(isDryRun() && !cql.startsWith("SELECT")) { - if(extra!=null)env.info().log("Would query" + extra + ": " + cql); - } else { - if(extra!=null)env.info().log("query" + extra + ": " + cql); - try { - return session.execute(cql); - } catch (InvalidQueryException e) { - if(extra==null) { - env.info().log("query: " + cql); - } - throw e; - } - } - return null; - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/FileCassBatch.java b/authz-batch/src/main/java/com/att/authz/FileCassBatch.java deleted file mode 100644 index 10440527..00000000 --- a/authz-batch/src/main/java/com/att/authz/FileCassBatch.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz; - -import java.io.File; -import java.io.IOException; -import java.nio.file.DirectoryIteratorException; -import java.nio.file.DirectoryStream; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import org.onap.aaf.inno.env.APIException; - -public abstract class FileCassBatch extends CassBatch { - - public FileCassBatch(AuthzTrans trans, String log4jName) throws APIException, IOException { - super(trans, log4jName); - } - - protected List<File> findAllFiles(String regex) { - List<File> files = new ArrayList<File>(); - FileSystem fileSystem = FileSystems.getDefault(); - PathMatcher pathMatcher = fileSystem.getPathMatcher("glob:" + regex); - Path path = Paths.get(System.getProperty("user.dir"), "data"); - - try { - DirectoryStream<Path> directoryStream = Files.newDirectoryStream( - path, regex); - for (Path file : directoryStream) { - if (pathMatcher.matches(file.getFileName())) { - files.add(file.toFile()); - } - } - } catch (IOException ex) { - ex.printStackTrace(); - } catch (DirectoryIteratorException ex) { - ex.printStackTrace(); - } - - return files; - } - - - -} diff --git a/authz-batch/src/main/java/com/att/authz/JobChange.java b/authz-batch/src/main/java/com/att/authz/JobChange.java deleted file mode 100644 index e5672e6f..00000000 --- a/authz-batch/src/main/java/com/att/authz/JobChange.java +++ /dev/null @@ -1,743 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -// test for case where I'm an admin - -package com.att.authz; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.org.Organization; -import com.att.authz.org.OrganizationFactory; -import org.onap.aaf.inno.env.APIException; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.SimpleStatement; -import com.datastax.driver.core.Statement; - -public class JobChange extends Batch -{ - private class UserRole - { - String user; - String role; - } - private class UserCred - { - String user; - String ns; - } - - private class NamespaceOwner - { - String user; - String ns; - boolean responsible; - int ownerCount; - } - - - private AuthzTrans myTrans; - - private Map<String, ArrayList<UserRole>> rolesMap = new HashMap<String, ArrayList<UserRole>>(); - private Map<String, ArrayList<NamespaceOwner>> ownersMap = new HashMap<String, ArrayList<NamespaceOwner>>(); - private Map<String, ArrayList<UserCred>> credsMap = new HashMap<String, ArrayList<UserCred>>(); - - - public static void createDirectory( String dir ) - { - File f = new File( dir ); - - if ( ! f.exists()) - { - env.info().log( "creating directory: " + dir ); - boolean result = false; - - try - { - f.mkdir(); - result = true; - } catch(SecurityException e){ - e.printStackTrace(); - } - if(result) { - System.out.println("DIR created"); - } - } - } - - public static String getJobChangeDataFile() - { - File outFile = null; - BufferedWriter writer = null; - BufferedReader reader = null; - String line; - boolean errorFlag = false; - - try - { - createDirectory( "etc" ); - - outFile = new File("etc/jobchange." + getCurrentDate() ); - if (!outFile.exists()) - { - outFile.createNewFile(); - } - else - { - return( "etc/jobchange." + getCurrentDate() ); - } - - env.info().log("Creating the local file with the webphone data"); - - - - writer = new BufferedWriter(new FileWriter( - outFile.getAbsoluteFile())); - - URL u = new URL( "ftp://thprod37.sbc.com/jobchange_Delta.dat" ); - reader = new BufferedReader(new InputStreamReader( - new BufferedInputStream(u.openStream()))); - while ((line = reader.readLine()) != null) { - writer.write(line + "\n"); - } - - writer.close(); - reader.close(); - - env.info().log("Finished fetching the data from the webphone ftp site."); - return( "etc/jobchange." + getCurrentDate() ); - - } catch (MalformedURLException e) { - env.error().log("Could not open the remote job change data file.", e); - errorFlag = true; - - } catch (IOException e) { - env.error().log( - "Error while opening or writing to the local data file.", e); - errorFlag = true; - - } catch (Exception e) { - env.error().log("Error while fetching the data file.", e); - errorFlag = true; - - } finally { - if (errorFlag) - outFile.delete(); - } - return null; - } - - public static String getCurrentDate() - { - SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); - Date now = new Date(); - String strDate = sdfDate.format(now); - return strDate; - } - - public void loadUsersFromCred() - { - String query = "select id,ns from authz.cred" ; - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - ResultSet results = session.execute(stmt); - - Iterator<Row> iter = results.iterator(); - while( iter.hasNext() ) - { - Row row = iter.next(); - String user = row.getString( "id" ); - String ns = row.getString( "ns" ); - String simpleUser = user.substring( 0, user.indexOf( "@" ) ); - - if ( isMechID( simpleUser ) ) - { - continue; - } - else if ( credsMap.get( simpleUser ) == null ) - { - credsMap.put( simpleUser, new ArrayList<UserCred>() ); - - UserCred newEntry = new UserCred(); - newEntry.user = user; - newEntry.ns = ns; - - credsMap.get( simpleUser ).add( newEntry ); - } - else - { - UserCred newEntry = new UserCred(); - newEntry.user = user; - newEntry.ns = ns; - - credsMap.get( simpleUser ).add( newEntry ); - } - - env.debug().log( String.format( "\tUser: %s NS: %s", user, ns ) ); - } - } - - public void loadUsersFromRoles() - { - String query = "select user,role from authz.user_role" ; - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - ResultSet results = session.execute(stmt); - int total=0, flagged=0; - - Iterator<Row> iter = results.iterator(); - while( iter.hasNext() ) - { - Row row = iter.next(); - String user = row.getString( "user" ); - String role = row.getString( "role" ); - String simpleUser = user.substring( 0, user.indexOf( "@" ) ); - - if ( isMechID( simpleUser ) ) - { - continue; - } - else if ( rolesMap.get( simpleUser ) == null ) - { - rolesMap.put( simpleUser, new ArrayList<UserRole>() ); - - UserRole newEntry = new UserRole(); - newEntry.user = user; - newEntry.role = role; - - rolesMap.get( simpleUser ).add( newEntry ); - } - else - { - UserRole newEntry = new UserRole(); - newEntry.user = user; - newEntry.role = role; - - rolesMap.get( simpleUser ).add( newEntry ); - } - - env.debug().log( String.format( "\tUser: %s Role: %s", user, role ) ); - - ++total; - } - env.info().log( String.format( "rows read: %d expiring: %d", total, flagged ) ); - } - - public void loadOwnersFromNS() - { - String query = "select name,admin,responsible from authz.ns" ; - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - ResultSet results = session.execute(stmt); - - Iterator<Row> iter = results.iterator(); - while( iter.hasNext() ) - { - Row row = iter.next(); - Set<String> responsibles = row.getSet( "responsible", String.class ); - - for ( String user : responsibles ) - { - env.info().log( String.format( "Found responsible %s", user ) ); - String simpleUser = user.substring( 0, user.indexOf( "@" ) ); - - if ( isMechID( simpleUser ) ) - { - continue; - } - else if ( ownersMap.get( simpleUser ) == null ) - { - ownersMap.put( simpleUser, new ArrayList<NamespaceOwner>() ); - - NamespaceOwner newEntry = new NamespaceOwner(); - newEntry.user = user; - newEntry.ns = row.getString( "name" ); - newEntry.ownerCount = responsibles.size(); - newEntry.responsible = true; - ownersMap.get( simpleUser ).add( newEntry ); - } - else - { - NamespaceOwner newEntry = new NamespaceOwner(); - newEntry.user = user; - newEntry.ns = row.getString( "name" ); - newEntry.ownerCount = responsibles.size(); - newEntry.responsible = true; - ownersMap.get( simpleUser ).add( newEntry ); - } - } - Set<String> admins = row.getSet( "admin", String.class ); - - for ( String user : admins ) - { - env.info().log( String.format( "Found admin %s", user ) ); - String simpleUser = user.substring( 0, user.indexOf( "@" ) ); - - if ( isMechID( simpleUser ) ) - { - continue; - } - else if ( ownersMap.get( simpleUser ) == null ) - { - ownersMap.put( simpleUser, new ArrayList<NamespaceOwner>() ); - - NamespaceOwner newEntry = new NamespaceOwner(); - newEntry.user = user; - newEntry.ns = row.getString( "name" ); - newEntry.responsible = false; - newEntry.ownerCount = -1; // - ownersMap.get( simpleUser ).add( newEntry ); - } - else - { - NamespaceOwner newEntry = new NamespaceOwner(); - newEntry.user = user; - newEntry.ns = row.getString( "name" ); - newEntry.responsible = false; - newEntry.ownerCount = -1; // - ownersMap.get( simpleUser ).add( newEntry ); - } - } - - } - } - - /** - * Processes the specified JobChange data file obtained from Webphone. Each line is - * read and processed and any fallout is written to the specified fallout file. - * If fallout file already exists it is deleted and a new one is created. A - * comparison of the supervisor id in the job data file is done against the one returned - * by the authz service and if the supervisor Id has changed then the record is updated - * using the authz service. An email is sent to the new supervisor to approve the roles - * assigned to the user. - * - * @param fileName - name of the file to process including its path - * @param falloutFileName - the file where the fallout entries have to be written - * @param validDate - the valid effective date when the user had moved to the new supervisor - * @throws Exception - */ - public void processJobChangeDataFile(String fileName, - String falloutFileName, Date validDate) throws Exception - { - - BufferedWriter writer = null; - - try { - - env.info().log("Reading file: " + fileName ); - - FileInputStream fstream = new FileInputStream(fileName); - BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); - - String strLine; - - while ((strLine = br.readLine()) != null) { - processLine( strLine, writer ); - } - - br.close(); - - - } catch (IOException e) { - env.error().log( "Error while reading from the input data file: " + e ); - throw e; - } - } - - public void handleAdminChange( String user ) - { - ArrayList<NamespaceOwner> val = ownersMap.get( user ); - - for ( NamespaceOwner r : val ) - { - env.info().log( "handleAdminChange: " + user ); - AuthzTrans trans = env.newTransNoAvg(); - - - if ( r.responsible ) - { - env.info().log( String.format( "delete from NS owner: %s, NS: %s, count: %s", - r.user, r.ns, r.ownerCount ) ); - - aspr.info( String.format( "action=DELETE_NS_OWNER, user=%s, ns=%s", - r.user, r.ns ) ); - if ( r.ownerCount < 2 ) - { - // send warning email to aaf-support, after this deletion, no owner for NS - ArrayList<String> toAddress = new ArrayList<String>(); - toAddress.add( "XXX_EMAIL" ); - - env.warn().log( "removing last owner from namespace" ); - - Organization org = null; - org = getOrgFromID( myTrans, org, toAddress.get(0) ); - - env.info().log( "calling getOrgFromID with " + toAddress.get(0) ); - - if ( org != null ) - { - try - { - aspr.info( String.format( "action=EMAIL_NO_OWNER_NS to=%s, user=%s, ns=%s", - toAddress.get(0), r.user, r.ns ) ); - org.sendEmail( trans, toAddress, - new ArrayList<String>(), - String.format( "WARNING: no owners for AAF namespace '%s'", r.ns ), // subject: - String.format( "AAF recieved a jobchange notification for user %s who was the owner of the '%s' namespace. Please identify a new owner for this namespace and update AAF.", r.user, r.ns ), // body of msg - true ); - } catch (Exception e) { - env.error().log("calling sendEmail()"); - - e.printStackTrace(); - } - } - else - { - env.error().log( "Failed getOrgFromID" ); - } - } - } - else - { - env.info().log( String.format( "delete from NS admin: %s, NS: %s", - r.user, r.ns ) ); - - aspr.info( String.format( "action=DELETE_NS_ADMIN, user=%s, ns=%s", - r.user, r.ns ) ); - } - - String field = (r.responsible == true) ? "responsible" : "admin"; - - String query = String.format( "update authz.ns set %s = %s - {'%s'} where name = '%s'", - field, field, r.user, r.ns ) ; - env.info().log( "query: " + query ); - Statement stmt = new SimpleStatement( query ); - /*Row row = */session.execute(stmt).one(); - - String attribQuery = String.format( "delete from authz.ns_attrib where ns = '%s' AND type='%s' AND name='%s'", - r.ns, field, r.user); - env.info().log( "ns_attrib query: " + attribQuery); - Statement attribStmt = new SimpleStatement( attribQuery ); - /*Row attribRow = */session.execute(attribStmt).one(); - - } - } - - public void handleRoleChange( String user ) - { - ArrayList<UserRole> val = rolesMap.get( user ); - - for ( UserRole r : val ) - { - env.info().log( "handleRoleChange: " + user ); - - env.info().log( String.format( "delete from %s from user_role: %s", - r.user, r.role ) ); - - aspr.info( String.format( "action=DELETE_FROM_ROLE, user=%s, role=%s", - r.user, r.role ) ); - - - String query = String.format( "delete from authz.user_role where user = '%s' and role = '%s'", - r.user, r.role ); - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - /* Row row = */ session.execute(stmt).one(); - - } - } - - public void handleCredChange( String user ) - { - ArrayList<UserCred> val = credsMap.get( user ); - - for ( UserCred r : val ) - { - env.info().log( "handleCredChange: " + user ); - - env.info().log( String.format( "delete user %s cred from ns: %s", - r.user, r.ns ) ); - - aspr.info( String.format( "action=DELETE_FROM_CRED, user=%s, ns=%s", - r.user, r.ns ) ); - - String query = String.format( "delete from authz.cred where id = '%s'", - r.user ); - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - /*Row row = */session.execute(stmt).one(); - - } - - } - - public boolean processLine(String line, BufferedWriter writer) throws IOException - { - SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd"); - boolean errorFlag = false; - String errorMsg = ""; - - try - { - String[] phoneInfo = line.split( "\\|" ); - - if ((phoneInfo != null) && (phoneInfo.length >= 8) - && (!phoneInfo[0].startsWith("#"))) - { - String user = phoneInfo[0]; - String newSupervisor = phoneInfo[7]; - Date effectiveDate = sdfDate.parse(phoneInfo[8].trim()); - - env.debug().log( String.format( "checking user: %s, newSupervisor: %s, date: %s", - user, newSupervisor, effectiveDate ) ); - - // Most important case, user is owner of a namespace - // - if ( ownersMap.get( user ) != null ) - { - env.info().log( String.format( "Found %s as a namespace admin/owner", user ) ); - handleAdminChange( user ); - } - - if ( credsMap.get( user ) != null ) - { - env.info().log( String.format( "Found %s in cred table", user ) ); - handleCredChange( user ); - } - - if ( rolesMap.get( user ) != null ) - { - env.info().log( String.format( "Found %s in a role ", user ) ); - handleRoleChange( user ); - } - } - - else if (phoneInfo[0].startsWith("#")) - { - return true; - } - else - { - env.warn().log("Can't parse. Skipping the line." + line); - errorFlag = true; - } - } catch (Exception e) { - errorFlag = true; - errorMsg = e.getMessage(); - env.error().log( "Error while processing line:" + line + e ); - e.printStackTrace(); - } finally { - if (errorFlag) { - env.info().log( "Fallout enrty being written for line:" + line ); - writer.write(line + "|Failed to update supervisor for user:" + errorMsg + "\n"); - } - } - return true; - } - - - public JobChange(AuthzTrans trans) throws APIException, IOException { - super( trans.env() ); - myTrans = trans; - session = cluster.connect(); - } - - public Organization getOrgFromID( AuthzTrans trans, Organization _org, String user ) { - Organization org = _org; - if ( org == null || ! user.endsWith( org.getRealm() ) ) { - int idx = user.lastIndexOf('.'); - if ( idx > 0 ) - idx = user.lastIndexOf( '.', idx-1 ); - - org = null; - if ( idx > 0 ) { - try { - org = OrganizationFactory.obtain( trans.env(), user.substring( idx+1 ) ); - } catch (Exception e) { - trans.error().log(e,"Failure Obtaining Organization"); - } - } - - if ( org == null ) { - PrintStream fallout = null; - - try { - fallout= fallout(fallout, "Fallout"); - fallout.print("INVALID_ID,"); - fallout.println(user); - } catch (Exception e) { - env.error().log("Could not write to Fallout File",e); - } - return( null ); - } - } - return( org ); - } - - public void dumpOwnersMap() - { - for ( Map.Entry<String, ArrayList<NamespaceOwner>> e : ownersMap.entrySet() ) - { - String key = e.getKey(); - ArrayList<NamespaceOwner> values = e.getValue(); - - env.info().log( "ns user: " + key ); - - for ( NamespaceOwner r : values ) - { - env.info().log( String.format( "\tNS-user: %s, NS-name: %s, ownerCount: %d", - r.user, r.ns, r.ownerCount ) ); - - } - } - } - - public void dumpRolesMap() - { - for ( Map.Entry<String, ArrayList<UserRole>> e : rolesMap.entrySet() ) - { - String key = e.getKey(); - ArrayList<UserRole> values = e.getValue(); - - env.info().log( "user: " + key ); - - for ( UserRole r : values ) - { - env.info().log( String.format( "\trole-user: %s, role-name: %s", - r.user, r.role ) ); - } - } - } - public void dumpCredMap() - { - for ( Map.Entry<String, ArrayList<UserCred>> e : credsMap.entrySet() ) - { - String key = e.getKey(); - ArrayList<UserCred> values = e.getValue(); - - env.info().log( "user: " + key ); - - for ( UserCred r : values ) - { - env.info().log( String.format( "\tcred-user: %s, ns: %s", - r.user, r.ns ) ); - } - - } - } - - @Override - protected void run (AuthzTrans trans) - { - if ( acquireRunLock( this.getClass().getName() ) != 1 ) { - env.warn().log( "Cannot acquire run lock, exiting" ); - System.exit( 1 ); - } - - try { -// Map<String,EmailMsg> email = new HashMap<String,EmailMsg>(); - - try - { - String workingDir = System.getProperty("user.dir"); - env.info().log( "Process jobchange file. PWD is " + workingDir ); - - loadUsersFromRoles(); - loadOwnersFromNS(); - loadUsersFromCred(); - - dumpRolesMap(); - dumpOwnersMap(); - dumpCredMap(); - - String fname = getJobChangeDataFile(); - - if ( fname == null ) - { - env.warn().log("getJobChangedatafile returned null"); - } - else - { - env.info().log("done with FTP"); - } - processJobChangeDataFile( fname, "fallout", null ); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -/* - private class EmailMsg { - private boolean urgent = false; - public String url; - public Organization org; - public String summary; - - public EmailMsg() { - org = null; - summary = ""; - } - - public boolean getUrgent() { - return( this.urgent ); - } - - public void setUrgent( boolean val ) { - this.urgent = val; - } - public void setOrg( Organization newOrg ) { - this.org = newOrg; - } - public Organization getOrg() { - return( this.org ); - } - } -*/ - @Override - protected void _close(AuthzTrans trans) { - session.close(); - } -} - - diff --git a/authz-batch/src/main/java/com/att/authz/UserRoleDataGeneration.java b/authz-batch/src/main/java/com/att/authz/UserRoleDataGeneration.java deleted file mode 100644 index df537c20..00000000 --- a/authz-batch/src/main/java/com/att/authz/UserRoleDataGeneration.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz; - -import java.io.IOException; -import java.util.Iterator; -import java.util.Random; -import java.util.UUID; - -import com.att.authz.env.AuthzTrans; -import org.onap.aaf.inno.env.APIException; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.SimpleStatement; -import com.datastax.driver.core.Statement; - -public class UserRoleDataGeneration extends Batch { - - protected UserRoleDataGeneration(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - session = cluster.connect(); - - } - - @Override - protected void run(AuthzTrans trans) { - - String query = "select * from authz.history" ; - - env.info().log( "query: " + query ); - - Statement stmt = new SimpleStatement( query ); - ResultSet results = session.execute(stmt); - int total=0; - - Iterator<Row> iter = results.iterator(); - - Random rand = new Random(); - - int min = 1; - int max = 32; - - while( iter.hasNext() ) { - Row row = iter.next(); - if (row.getString("target").equals("user_role")) { - int randomNum = rand.nextInt((max - min) + 1) + min; - - String newId = modifiedTimeuid(row.getUUID("id").toString(), randomNum); - String subject = row.getString("subject"); - String newSubject = subject.split("\\|")[1]; - - String newInsert = insertStmt(row, newId, "role", newSubject); - Statement statement = new SimpleStatement(newInsert); - session.executeAsync(statement); - - total++; - } - } - - env.info().log(total+ " history elements inserted for user roles"); - - } - - private String insertStmt(Row row, String newId, String newTarget, String newSubject) { - StringBuilder sb = new StringBuilder(); - sb.append("INSERT INTO authz.history (id,action,memo,reconstruct,subject,target,user,yr_mon) VALUES ("); - sb.append(newId+","); - sb.append("'"+row.getString("action")+"',"); - sb.append("'"+row.getString("memo")+"',"); - sb.append("null,"); - sb.append("'"+newSubject+"',"); - sb.append("'"+newTarget+"',"); - sb.append("'"+row.getString("user")+"',"); - sb.append(row.getInt("yr_mon")); - sb.append(")"); - - return sb.toString(); - } - - private String modifiedTimeuid(String origTimeuuid, int rand) { - UUID uuid = UUID.fromString(origTimeuuid); - - long bottomBits = uuid.getLeastSignificantBits(); - long newBottomBits = bottomBits + (1 << rand); - if (newBottomBits - bottomBits == 0) - env.info().log("Duplicate!\t"+uuid + " not duplicated for role history function."); - - UUID newUuid = new UUID(uuid.getMostSignificantBits(),newBottomBits); - return newUuid.toString(); - } - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info( "End UserRoleDataGeneration processing" ); - - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/Action.java b/authz-batch/src/main/java/com/att/authz/actions/Action.java deleted file mode 100644 index f69bb22a..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/Action.java +++ /dev/null @@ -1,11 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; - -public interface Action<T,RV> { - public Result<RV> exec(AuthzTrans trans, T ur); -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/ActionDAO.java b/authz-batch/src/main/java/com/att/authz/actions/ActionDAO.java deleted file mode 100644 index f0d10a8d..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/ActionDAO.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; - -import com.att.authz.env.AuthzTrans; -import com.att.dao.CassAccess; -import com.att.dao.aaf.hl.Function; -import com.att.dao.aaf.hl.Question; -import org.onap.aaf.inno.env.APIException; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; - -public abstract class ActionDAO<T,RV> implements Action<T,RV> { - protected final Question q; - protected final Function f; - private boolean clean; - - public ActionDAO(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - q = new Question(trans, cluster, CassAccess.KEYSPACE, false); - f = new Function(trans,q); - clean = true; - } - - public ActionDAO(AuthzTrans trans, ActionDAO<?,?> predecessor) { - q = predecessor.q; - f = new Function(trans,q); - clean = false; - } - - public Session getSession(AuthzTrans trans) throws APIException, IOException { - return q.historyDAO.getSession(trans); - } - - public void close(AuthzTrans trans) { - if(clean) { - q.close(trans); - } - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/ActionPuntDAO.java b/authz-batch/src/main/java/com/att/authz/actions/ActionPuntDAO.java deleted file mode 100644 index 3f521f17..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/ActionPuntDAO.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; -import java.security.SecureRandom; -import java.util.Date; -import java.util.GregorianCalendar; - -import com.att.authz.env.AuthzTrans; -import org.onap.aaf.inno.env.APIException; -import com.datastax.driver.core.Cluster; - -public abstract class ActionPuntDAO<T, RV> extends ActionDAO<T, RV> { - private static final SecureRandom random = new SecureRandom(); - private int months, range; - protected static final Date now = new Date(); - - public ActionPuntDAO(AuthzTrans trans, Cluster cluster, int months, int range) throws APIException, IOException { - super(trans, cluster); - this.months = months; - this.range = range; - } - - public ActionPuntDAO(AuthzTrans trans, ActionDAO<?, ?> predecessor, int months, int range) { - super(trans, predecessor); - this.months = months; - this.range = range; - } - - - protected Date puntDate() { - GregorianCalendar temp = new GregorianCalendar(); - temp.setTime(now); - if(range>0) { - int forward = months+Math.abs(random.nextInt()%range); - temp.add(GregorianCalendar.MONTH, forward); - temp.add(GregorianCalendar.DAY_OF_MONTH, (random.nextInt()%30)-15); - } - return temp.getTime(); - - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/CredDelete.java b/authz-batch/src/main/java/com/att/authz/actions/CredDelete.java deleted file mode 100644 index 80c6755c..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/CredDelete.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.CredDAO; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class CredDelete extends ActionDAO<CredDAO.Data,Void> { - - public CredDelete(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - super(trans, cluster); - } - - public CredDelete(AuthzTrans trans, ActionDAO<?,?> adao) { - super(trans, adao); - } - - @Override - public Result<Void> exec(AuthzTrans trans, CredDAO.Data cred) { - Result<Void> rv = q.credDAO.delete(trans, cred, true); // need to read for undelete - trans.info().log("Deleted:",cred.id,CredPrint.type(cred.type),Chrono.dateOnlyStamp(cred.expires)); - return rv; - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/CredPrint.java b/authz-batch/src/main/java/com/att/authz/actions/CredPrint.java deleted file mode 100644 index 3e8c294a..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/CredPrint.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.CredDAO; -import org.onap.aaf.inno.env.util.Chrono; - -public class CredPrint implements Action<CredDAO.Data,Void> { - private String text; - - public CredPrint(String text) { - this.text = text; - } - - @Override - public Result<Void> exec(AuthzTrans trans, CredDAO.Data cred) { - trans.info().log(text,cred.id,type(cred.type),Chrono.dateOnlyStamp(cred.expires)); - return Result.ok(); - } - - - public static String type(int type) { - switch(type) { - case CredDAO.BASIC_AUTH: // 1 - return "OLD"; - case CredDAO.BASIC_AUTH_SHA256: // 2 - return "U/P"; - case CredDAO.CERT_SHA256_RSA: // 200 - return "Cert"; - default: - return "Unknown"; - } - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/CredPunt.java b/authz-batch/src/main/java/com/att/authz/actions/CredPunt.java deleted file mode 100644 index 0805e9b7..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/CredPunt.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; -import java.util.Date; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.CredDAO; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class CredPunt extends ActionPuntDAO<CredDAO.Data,Void> { - - public CredPunt(AuthzTrans trans, Cluster cluster, int months, int range) throws IOException, APIException { - super(trans,cluster,months,range); - } - - public CredPunt(AuthzTrans trans, ActionDAO<?,?> adao, int months, int range) throws IOException { - super(trans, adao, months,range); - } - - public Result<Void> exec(AuthzTrans trans, CredDAO.Data cdd) { - Result<Void> rv = null; - Result<List<CredDAO.Data>> read = q.credDAO.read(trans, cdd); - if(read.isOKhasData()) { - for(CredDAO.Data data : read.value) { - Date from = data.expires; - data.expires = puntDate(); - if(data.expires.before(from)) { - trans.error().printf("Error: %s is before %s", Chrono.dateOnlyStamp(data.expires), Chrono.dateOnlyStamp(from)); - } else { - rv = q.credDAO.update(trans, data); - trans.info().log("Updated Cred",cdd.id, CredPrint.type(cdd.type), "from",Chrono.dateOnlyStamp(from),"to",Chrono.dateOnlyStamp(data.expires)); - } - } - } - if(rv==null) { - rv=Result.err(read); - } - return rv; - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/Email.java b/authz-batch/src/main/java/com/att/authz/actions/Email.java deleted file mode 100644 index df491df3..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/Email.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization; - -public class Email implements Action<Organization,Void>{ - protected final List<String> toList; - protected final List<String> ccList; - private final String[] defaultCC; - protected String subject; - private String preamble; - private Message msg; - private String sig; - protected String lineIndent=" "; - - - public Email(String ... defaultCC) { - toList = new ArrayList<String>(); - this.defaultCC = defaultCC; - ccList = new ArrayList<String>(); - clear(); - } - - public Email clear() { - toList.clear(); - ccList.clear(); - for(String s: defaultCC) { - ccList.add(s); - } - return this; - } - - - public void indent(String indent) { - lineIndent = indent; - } - - public void preamble(String format, Object ... args) { - preamble = String.format(format, args); - } - - public Email addTo(Collection<String> users) { - toList.addAll(users); - return this; - } - - public Email addTo(String email) { - toList.add(email); - return this; - } - - - public Email subject(String format, Object ... args) { - subject = String.format(format, args); - return this; - } - - - public Email signature(String format, Object ... args) { - sig = String.format(format, args); - return this; - } - - public void msg(Message msg) { - this.msg = msg; - } - - @Override - public Result<Void> exec(AuthzTrans trans, Organization org) { - StringBuilder sb = new StringBuilder(); - if(preamble!=null) { - sb.append(lineIndent); - sb.append(preamble); - sb.append("\n\n"); - } - - if(msg!=null) { - msg.msg(sb,lineIndent); - sb.append("\n"); - } - - if(sig!=null) { - sb.append(sig); - sb.append("\n"); - } - - return exec(trans,org,sb); - } - - protected Result<Void> exec(AuthzTrans trans, Organization org, StringBuilder sb) { - try { - /* int status = */ - org.sendEmail(trans, - toList, - ccList, - subject, - sb.toString(), - false); - } catch (Exception e) { - return Result.err(Result.ERR_ActionNotCompleted,e.getMessage()); - } - return Result.ok(); - - } -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/EmailPrint.java b/authz-batch/src/main/java/com/att/authz/actions/EmailPrint.java deleted file mode 100644 index 5b356ce1..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/EmailPrint.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.PrintStream; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization; - -public class EmailPrint extends Email { - - public EmailPrint(String... defaultCC) { - super(defaultCC); - } - - /* (non-Javadoc) - * @see com.att.authz.actions.Email#exec(com.att.authz.org.Organization, java.lang.StringBuilder) - */ - @Override - protected Result<Void> exec(AuthzTrans trans, Organization org, StringBuilder msg) { - PrintStream out = System.out; - boolean first = true; - out.print("To: "); - for(String s: toList) { - if(first) {first = false;} - else {out.print(',');} - out.print(s); - } - out.println(); - - first = true; - out.print("CC: "); - for(String s: ccList) { - if(first) {first = false;} - else {out.print(',');} - out.print(s); - } - out.println(); - - out.print("Subject: "); - out.println(subject); - out.println(); - - out.println(msg); - return Result.ok(); - - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/FADelete.java b/authz-batch/src/main/java/com/att/authz/actions/FADelete.java deleted file mode 100644 index b61ac7dc..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/FADelete.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Future; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.ApprovalDAO; -import com.att.dao.aaf.cass.FutureDAO; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class FADelete extends ActionDAO<Future,Void> { - public FADelete(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - super(trans, cluster); - } - - public FADelete(AuthzTrans trans, ActionDAO<?,?> adao) { - super(trans, adao); - } - - @Override - public Result<Void> exec(AuthzTrans trans, Future f) { - FutureDAO.Data fdd = new FutureDAO.Data(); - fdd.id=f.id; - Result<Void> rv = q.futureDAO.delete(trans, fdd, true); // need to read for undelete - if(rv.isOK()) { - trans.info().log("Deleted:",f.id,f.memo,"expiring on",Chrono.dateOnlyStamp(f.expires)); - } else { - trans.info().log("Failed to Delete Approval"); - } - - Result<List<ApprovalDAO.Data>> ral = q.approvalDAO.readByTicket(trans, f.id); - if(ral.isOKhasData()) { - for(ApprovalDAO.Data add : ral.value) { - rv = q.approvalDAO.delete(trans, add, false); - if(rv.isOK()) { - trans.info().log("Deleted: Approval",add.id,"on ticket",add.ticket,"for",add.approver); - } else { - trans.info().log("Failed to Delete Approval"); - } - } - } - return rv; - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/FAPrint.java b/authz-batch/src/main/java/com/att/authz/actions/FAPrint.java deleted file mode 100644 index c2ec50ae..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/FAPrint.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Future; -import com.att.authz.layer.Result; -import org.onap.aaf.inno.env.util.Chrono; - -public class FAPrint implements Action<Future,Void> { - private String text; - - public FAPrint(String text) { - this.text = text; - } - - @Override - public Result<Void> exec(AuthzTrans trans, Future f) { - trans.info().log(text,f.id,f.memo,"expiring on",Chrono.dateOnlyStamp(f.expires)); - return Result.ok(); - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/Key.java b/authz-batch/src/main/java/com/att/authz/actions/Key.java deleted file mode 100644 index 89b7c6f8..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/Key.java +++ /dev/null @@ -1,8 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -public interface Key<HELPER> { - public String key(HELPER H); -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/Message.java b/authz-batch/src/main/java/com/att/authz/actions/Message.java deleted file mode 100644 index 2aca4eac..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/Message.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.util.ArrayList; -import java.util.List; - -public class Message { - public final List<String> lines; - - public Message() { - lines = new ArrayList<String>(); - } - - public void clear() { - lines.clear(); - } - - public void line(String format, Object ... args) { - lines.add(String.format(format, args)); - } - - public void msg(StringBuilder sb, String lineIndent) { - if(lines.size()>0) { - for(String line : lines) { - sb.append(lineIndent); - sb.append(line); - sb.append('\n'); - } - } - } -} diff --git a/authz-batch/src/main/java/com/att/authz/actions/URAdd.java b/authz-batch/src/main/java/com/att/authz/actions/URAdd.java deleted file mode 100644 index fd3962f8..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URAdd.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.UserRoleDAO; -import com.att.dao.aaf.cass.UserRoleDAO.Data; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class URAdd extends ActionDAO<UserRole,UserRoleDAO.Data> { - public URAdd(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - super(trans, cluster); - } - - public URAdd(AuthzTrans trans, ActionDAO<?,?> adao) { - super(trans, adao); - } - - @Override - public Result<Data> exec(AuthzTrans trans, UserRole ur) { - UserRoleDAO.Data urd = new UserRoleDAO.Data(); - urd.user = ur.user; - urd.role = ur.role; - urd.ns=ur.ns; - urd.rname = ur.rname; - urd.expires = ur.expires; - Result<Data> rv = q.userRoleDAO.create(trans, urd); - trans.info().log("Added:",ur.role,ur.user,"on",Chrono.dateOnlyStamp(ur.expires)); - return rv; - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/URDelete.java b/authz-batch/src/main/java/com/att/authz/actions/URDelete.java deleted file mode 100644 index e3bd40ac..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URDelete.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.UserRoleDAO; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class URDelete extends ActionDAO<UserRole,Void> { - public URDelete(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - super(trans, cluster); - } - - public URDelete(AuthzTrans trans, ActionDAO<?,?> adao) { - super(trans, adao); - } - - @Override - public Result<Void> exec(AuthzTrans trans, UserRole ur) { - UserRoleDAO.Data urd = new UserRoleDAO.Data(); - urd.user = ur.user; - urd.role = ur.role; - Result<Void> rv = q.userRoleDAO.delete(trans, urd, true); // need to read for undelete - trans.info().log("Deleted:",ur.role,ur.user,"on",Chrono.dateOnlyStamp(ur.expires)); - return rv; - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/URFutureApprove.java b/authz-batch/src/main/java/com/att/authz/actions/URFutureApprove.java deleted file mode 100644 index 6af3e12a..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URFutureApprove.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization.Expiration; -import com.att.authz.org.Organization.Identity; -import com.att.dao.aaf.cass.FutureDAO; -import com.att.dao.aaf.cass.NsDAO; -import com.att.dao.aaf.hl.Function; -import com.att.dao.aaf.hl.Question; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class URFutureApprove extends ActionDAO<UserRole, List<Identity>> implements Action<UserRole,List<Identity>>, Key<UserRole> { - private final Date start, expires; - - public URFutureApprove(AuthzTrans trans, Cluster cluster) throws APIException, IOException { - super(trans,cluster); - GregorianCalendar gc = new GregorianCalendar(); - start = gc.getTime(); - expires = trans.org().expiration(gc, Expiration.Future).getTime(); - } - - public URFutureApprove(AuthzTrans trans, ActionDAO<?,?> adao) { - super(trans, adao); - GregorianCalendar gc = new GregorianCalendar(); - start = gc.getTime(); - expires = trans.org().expiration(gc, Expiration.Future).getTime(); - } - - @Override - public Result<List<Identity>> exec(AuthzTrans trans, UserRole ur) { - Result<NsDAO.Data> rns = q.deriveNs(trans, ur.ns); - if(rns.isOK()) { - - FutureDAO.Data data = new FutureDAO.Data(); - data.id=null; // let Create function assign UUID - data.target=Function.FOP_USER_ROLE; - - data.memo = key(ur); - data.start = start; - data.expires = expires; - try { - data.construct = ur.to().bytify(); - } catch (IOException e) { - return Result.err(e); - } - Result<List<Identity>> rapprovers = f.createFuture(trans, data, Function.FOP_USER_ROLE, ur.user, rns.value, "U"); - return rapprovers; - } else { - return Result.err(rns); - } - } - - @Override - public String key(UserRole ur) { - String expire; - if(expires.before(start)) { - expire = "' - EXPIRED "; - } else { - expire = "' - expiring "; - } - - if(Question.OWNER.equals(ur.rname)) { - return "Re-Validate Ownership for AAF Namespace '" + ur.ns + expire + Chrono.dateOnlyStamp(ur.expires); - } else if(Question.ADMIN.equals(ur.rname)) { - return "Re-Validate as Administrator for AAF Namespace '" + ur.ns + expire + Chrono.dateOnlyStamp(ur.expires); - } else { - return "Re-Approval in Role '" + ur.role + expire + Chrono.dateOnlyStamp(ur.expires); - } - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/URFuturePrint.java b/authz-batch/src/main/java/com/att/authz/actions/URFuturePrint.java deleted file mode 100644 index ea5a8bf0..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URFuturePrint.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.util.ArrayList; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization.Identity; -import org.onap.aaf.inno.env.util.Chrono; - - -public class URFuturePrint implements Action<UserRole,List<Identity>> { - private String text; - private final static List<Identity> rv = new ArrayList<Identity>(); - - public URFuturePrint(String text) { - this.text = text; - } - - @Override - public Result<List<Identity>> exec(AuthzTrans trans, UserRole ur) { - trans.info().log(text,ur.user,"to",ur.role,"on",Chrono.dateOnlyStamp(ur.expires)); - return Result.ok(rv); - }}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/URPrint.java b/authz-batch/src/main/java/com/att/authz/actions/URPrint.java deleted file mode 100644 index 80925672..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URPrint.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import org.onap.aaf.inno.env.util.Chrono; - -public class URPrint implements Action<UserRole,Void> { - private String text; - - public URPrint(String text) { - this.text = text; - } - - @Override - public Result<Void> exec(AuthzTrans trans, UserRole ur) { - trans.info().log(text,ur.user,"to",ur.role,"expiring on",Chrono.dateOnlyStamp(ur.expires)); - return Result.ok(); - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/actions/URPunt.java b/authz-batch/src/main/java/com/att/authz/actions/URPunt.java deleted file mode 100644 index e76852f0..00000000 --- a/authz-batch/src/main/java/com/att/authz/actions/URPunt.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.actions; - -import java.io.IOException; -import java.util.Date; -import java.util.List; - -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.dao.aaf.cass.UserRoleDAO; -import com.att.dao.aaf.cass.UserRoleDAO.Data; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.util.Chrono; -import com.datastax.driver.core.Cluster; - -public class URPunt extends ActionPuntDAO<UserRole,Void> { - public URPunt(AuthzTrans trans, Cluster cluster, int months, int range) throws APIException, IOException { - super(trans,cluster, months, range); - } - - public URPunt(AuthzTrans trans, ActionDAO<?,?> adao, int months, int range) { - super(trans, adao, months, range); - } - - public Result<Void> exec(AuthzTrans trans, UserRole ur) { - Result<List<Data>> read = q.userRoleDAO.read(trans, ur.user, ur.role); - if(read.isOK()) { - for(UserRoleDAO.Data data : read.value) { - Date from = data.expires; - data.expires = puntDate(); - if(data.expires.before(from)) { - trans.error().printf("Error: %s is before %s", Chrono.dateOnlyStamp(data.expires), Chrono.dateOnlyStamp(from)); - } else { - q.userRoleDAO.update(trans, data); - trans.info().log("Updated User",ur.user,"and Role", ur.role, "from",Chrono.dateOnlyStamp(from),"to",Chrono.dateOnlyStamp(data.expires)); - } - } - return Result.ok(); - } else { - return Result.err(read); - } - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/AafEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/AafEntryConverter.java deleted file mode 100644 index 4f05f203..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/AafEntryConverter.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import java.util.Set; - -public abstract class AafEntryConverter { - - protected String formatSet(Set<String> set) { - if (set==null || set.isEmpty()) return ""; - StringBuilder sb = new StringBuilder(); - int curr = 0; - sb.append("{"); - for (String s : set) { - sb.append("'"); - sb.append(s); - sb.append("'"); - if (set.size() != curr + 1) { - sb.append(","); - } - curr++; - } - sb.append("}"); - return sb.toString(); - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/CredEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/CredEntryConverter.java deleted file mode 100644 index 96c88122..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/CredEntryConverter.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; - -import com.att.dao.aaf.cass.CredDAO; -import com.datastax.driver.core.utils.Bytes; -import com.googlecode.jcsv.writer.CSVEntryConverter; - -public class CredEntryConverter extends AafEntryConverter implements CSVEntryConverter<CredDAO.Data> { - private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ssZ"; - - @Override - public String[] convertEntry(CredDAO.Data cd) { - String[] columns = new String[5]; - - columns[0] = cd.id; - columns[1] = String.valueOf(cd.type); - DateFormat df = new SimpleDateFormat(DATE_FORMAT); - columns[2] = df.format(cd.expires); - columns[3] = Bytes.toHexString(cd.cred); - columns[4] = (cd.ns==null)?"":cd.ns; - - return columns; - } -} diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/NsEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/NsEntryConverter.java deleted file mode 100644 index e9cd91c4..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/NsEntryConverter.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import com.att.dao.aaf.cass.NsDAO; -import com.googlecode.jcsv.writer.CSVEntryConverter; - -public class NsEntryConverter extends AafEntryConverter implements CSVEntryConverter<NsDAO.Data> { - - @Override - public String[] convertEntry(NsDAO.Data nsd) { - String[] columns = new String[5]; - - columns[0] = nsd.name; - // JG changed from "scope" to "type" - columns[1] = String.valueOf(nsd.type); - //TODO Chris: need to look at this -// columns[2] = formatSet(nsd.admin); -// columns[3] = formatSet(nsd.responsible); -// columns[4] = nsd.description==null?"":nsd.description; - columns[5] = nsd.description==null?"":nsd.description; - - return columns; - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/PermEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/PermEntryConverter.java deleted file mode 100644 index afabdfdf..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/PermEntryConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import com.att.dao.aaf.cass.PermDAO; -import com.googlecode.jcsv.writer.CSVEntryConverter; - -public class PermEntryConverter extends AafEntryConverter implements CSVEntryConverter<PermDAO.Data> { - - @Override - public String[] convertEntry(PermDAO.Data pd) { - String[] columns = new String[6]; - - columns[0] = pd.ns; - columns[1] = pd.type; - columns[2] = pd.instance; - columns[3] = pd.action; - columns[4] = formatSet(pd.roles); - columns[5] = pd.description==null?"":pd.description; - - return columns; - } -} diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/RoleEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/RoleEntryConverter.java deleted file mode 100644 index 51389bd3..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/RoleEntryConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import com.att.dao.aaf.cass.RoleDAO; -import com.googlecode.jcsv.writer.CSVEntryConverter; - -public class RoleEntryConverter extends AafEntryConverter implements CSVEntryConverter<RoleDAO.Data> { - - @Override - public String[] convertEntry(RoleDAO.Data rd) { - String[] columns = new String[4]; - - columns[0] = rd.ns; - columns[1] = rd.name; - columns[2] = formatSet(rd.perms); - columns[3] = rd.description==null?"":rd.description; - - return columns; - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/entryConverters/UserRoleEntryConverter.java b/authz-batch/src/main/java/com/att/authz/entryConverters/UserRoleEntryConverter.java deleted file mode 100644 index 0b2a956e..00000000 --- a/authz-batch/src/main/java/com/att/authz/entryConverters/UserRoleEntryConverter.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.entryConverters; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; - -import com.att.dao.aaf.cass.UserRoleDAO; -import com.googlecode.jcsv.writer.CSVEntryConverter; - -public class UserRoleEntryConverter extends AafEntryConverter implements CSVEntryConverter<UserRoleDAO.Data> { - private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ssZ"; - - @Override - public String[] convertEntry(UserRoleDAO.Data urd) { - String[] columns = new String[3]; - - columns[0] = urd.user; - columns[1] = urd.role; - DateFormat df = new SimpleDateFormat(DATE_FORMAT); - columns[2] = df.format(urd.expires); - - return columns; - } -} diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Approver.java b/authz-batch/src/main/java/com/att/authz/helpers/Approver.java deleted file mode 100644 index 0cac97bc..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Approver.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.HashMap; -import java.util.Map; - -import com.att.authz.actions.Message; -import com.att.authz.org.Organization; - -public class Approver { - public String name; - public Organization org; - public Map<String, Integer> userRequests; - - public Approver(String approver, Organization org) { - this.name = approver; - this.org = org; - userRequests = new HashMap<String, Integer>(); - } - - public void addRequest(String user) { - if (userRequests.get(user) == null) { - userRequests.put(user, 1); - } else { - Integer curCount = userRequests.remove(user); - userRequests.put(user, curCount+1); - } - } - - /** - * @param sb - * @return - */ - public void build(Message msg) { - msg.clear(); - msg.line("You have %d total pending approvals from the following users:", userRequests.size()); - for (Map.Entry<String, Integer> entry : userRequests.entrySet()) { - msg.line(" %s (%d)",entry.getKey(),entry.getValue()); - } - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Creator.java b/authz-batch/src/main/java/com/att/authz/helpers/Creator.java deleted file mode 100644 index 1fe513e8..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Creator.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import com.datastax.driver.core.Row; - -public abstract class Creator<T> { - public abstract T create(Row row); - public abstract String select(); - - public String query(String where) { - StringBuilder sb = new StringBuilder(select()); - if(where!=null) { - sb.append(" WHERE "); - sb.append(where); - } - sb.append(';'); - return sb.toString(); - } - - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Cred.java b/authz-batch/src/main/java/com/att/authz/helpers/Cred.java deleted file mode 100644 index a7717ae0..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Cred.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.TreeMap; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 Cred { - public static final TreeMap<String,Cred> data = new TreeMap<String,Cred>(); - - public final String id; - public final List<Instance> instances; - - public Cred(String id) { - this.id = id; - instances = new ArrayList<Instance>(); - } - - public static class Instance { - public final int type; - public final Date expires; - public final Integer other; - - public Instance(int type, Date expires, Integer other) { - this.type = type; - this.expires = expires; - this.other = other; - } - } - - public Date last(final int type) { - Date last = null; - for(Instance i : instances) { - if(i.type==type && (last==null || i.expires.after(last))) { - last = i.expires; - } - } - return last; - } - - - public Set<Integer> types() { - Set<Integer> types = new HashSet<Integer>(); - for(Instance i : instances) { - types.add(i.type); - } - return types; - } - - public static void load(Trans trans, Session session ) { - load(trans, session,"select id, type, expires, other from authz.cred;"); - - } - - public static void loadOneNS(Trans trans, Session session, String ns ) { - load(trans, session,"select id, type, expires, other from authz.cred WHERE ns='" + ns + "';"); - } - - private static void load(Trans trans, Session session, String query) { - - trans.info().log( "query: " + query ); - TimeTaken tt = trans.start("Read Creds", Env.REMOTE); - - ResultSet results; - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - int count = 0; - try { - Iterator<Row> iter = results.iterator(); - Row row; - tt = trans.start("Load Roles", Env.SUB); - try { - while(iter.hasNext()) { - ++count; - row = iter.next(); - String id = row.getString(0); - Cred cred = data.get(id); - if(cred==null) { - cred = new Cred(id); - data.put(id, cred); - } - cred.instances.add(new Instance(row.getInt(1), row.getDate(2), row.getInt(3))); - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",count,"creds"); - } - - - } - public String toString() { - StringBuilder sb = new StringBuilder(id); - sb.append('['); - for(Instance i : instances) { - sb.append('{'); - sb.append(i.type); - sb.append(",\""); - sb.append(i.expires); - sb.append("\"}"); - } - sb.append(']'); - return sb.toString(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return id.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return id.equals(obj); - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Future.java b/authz-batch/src/main/java/com/att/authz/helpers/Future.java deleted file mode 100644 index d658535c..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Future.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.TreeMap; -import java.util.UUID; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 Future { - public static final List<Future> data = new ArrayList<Future>(); - public static final TreeMap<String,List<Future>> byMemo = new TreeMap<String,List<Future>>(); - - public final UUID id; - public final String memo, target; - public final Date start, expires; - public Future(UUID id, String memo, String target, Date start, Date expires) { - this.id = id; - this.memo = memo; - this.target = target; - this.start = start; - this.expires = expires; - } - - public static void load(Trans trans, Session session, Creator<Future> creator) { - trans.info().log( "query: " + creator.select() ); - ResultSet results; - TimeTaken tt = trans.start("Load Futures", Env.REMOTE); - try { - Statement stmt = new SimpleStatement(creator.select()); - results = session.execute(stmt); - } finally { - tt.done(); - } - - int count = 0; - tt = trans.start("Process Futures", Env.SUB); - try { - for(Row row : results.all()) { - ++count; - Future f = creator.create(row); - data.add(f); - - List<Future> lf = byMemo.get(f.memo); - if(lf == null) { - lf = new ArrayList<Future>(); - byMemo.put(f.memo, lf); - } - lf.add(f); - - } - } finally { - trans.info().log("Found",count,"Futures"); - } - } - - public static Creator<Future> v2_0_15 = new Creator<Future>() { - @Override - public Future create(Row row) { - return new Future(row.getUUID(0),row.getString(1),row.getString(2), - row.getDate(3),row.getDate(4)); - } - - @Override - public String select() { - return "select id,memo,target,start,expires from authz.future"; - } - }; - - public static void delete(List<Future> fl) { - if(fl==null || fl.isEmpty()) { - return; - } - for(Future f : fl) { - data.remove(f); - } - // Faster to start over, then look for entries. - byMemo.clear(); - for(Future f : data) { - List<Future> lf = byMemo.get(f.memo); - if(lf == null) { - lf = new ArrayList<Future>(); - byMemo.put(f.memo, lf); - } - lf.add(f); - } - } -} diff --git a/authz-batch/src/main/java/com/att/authz/helpers/InputIterator.java b/authz-batch/src/main/java/com/att/authz/helpers/InputIterator.java deleted file mode 100644 index 02fdc166..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/InputIterator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.PrintStream; -import java.util.Iterator; - -public class InputIterator implements Iterable<String> { - private BufferedReader in; - private final PrintStream out; - private final String prompt, instructions; - - public InputIterator(BufferedReader in, PrintStream out, String prompt, String instructions) { - this.in = in; - this.out = out; - this.prompt = prompt; - this.instructions = instructions; - } - - @Override - public Iterator<String> iterator() { - out.println(instructions); - return new Iterator<String>() { - String input; - @Override - public boolean hasNext() { - out.append(prompt); - try { - input = in.readLine(); - } catch (IOException e) { - input = null; - return false; - } - return input.length()>0; - } - - @Override - public String next() { - return input; - } - - @Override - public void remove() { - } - }; - } -} - diff --git a/authz-batch/src/main/java/com/att/authz/helpers/MiscID.java b/authz-batch/src/main/java/com/att/authz/helpers/MiscID.java deleted file mode 100644 index b553009d..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/MiscID.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.Map; -import java.util.TreeMap; - -import com.att.authz.BatchException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 MiscID { - public static final TreeMap<String,MiscID> data = new TreeMap<String,MiscID>(); - /* - Sample Record - aad890|mj9030|20040902|20120207 - - **** Field Definitions **** - MISCID - AT&T Miscellaneous ID - Non-User ID (Types: Internal Mechanized ID, External Mechanized ID, Datagate ID, Customer ID, Vendor ID, Exchange Mail ID, CLEC ID, Specialized ID, Training ID) - SPONSOR_ATTUID - ATTUID of MiscID Sponsor (Owner) - CREATE_DATE - Date when MiscID was created - LAST_RENEWAL_DATE - Date when MiscID Sponsorship was last renewed - */ - public String id,sponsor,created,renewal; - - private static final String fieldString = "id,created,sponsor,renewal"; - - /** - * Load a Row of Strings (from CSV file). - * - * Be CAREFUL that the Row lists match the Fields above!!! If this changes, change - * 1) This Object - * 2) DB "suits.cql" - * 3) Alter existing Tables - * @param row - * @throws BatchException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - public void set(String row []) throws BatchException { - if(row.length<4) {throw new BatchException("Row of MiscID_XRef is too short");} - id = row[0]; - sponsor = row[1]; - created = row[2]; - renewal = row[3]; - } - - public void set(Row row) { - id = row.getString(0); - sponsor = row.getString(1); - created = row.getString(2); - renewal = row.getString(3); - } - - - public static void load(Trans trans, Session session ) { - load(trans, session,"SELECT " + fieldString + " FROM authz.miscid;",data); - } - - public static void load(Trans trans, Session session, Map<String,MiscID> map ) { - load(trans, session,"SELECT " + fieldString + " FROM authz.miscid;",map); - } - - public static void loadOne(Trans trans, Session session, String id ) { - load(trans, session,"SELECT " + fieldString + " FROM authz.miscid WHERE id ='" + id + "';", data); - } - - public static void load(Trans trans, Session session, String query, Map<String,MiscID> map) { - trans.info().log( "query: " + query ); - TimeTaken tt = trans.start("Read MiscID", Env.REMOTE); - - ResultSet results; - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - int count = 0; - try { - tt = trans.start("Load Map", Env.SUB); - try { - for( Row row : results.all()) { - MiscID miscID = new MiscID(); - miscID.set(row); - data.put(miscID.id,miscID); - ++count; - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",count,"miscID records"); - } - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return id.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if(obj!=null && obj instanceof MiscID) { - return id.equals(((MiscID)obj).id); - } - return false; - } - - public StringBuilder insertStmt() throws IllegalArgumentException, IllegalAccessException { - StringBuilder sb = new StringBuilder("INSERT INTO authz.miscid ("); - sb.append(fieldString); - sb.append(") VALUES ('"); - sb.append(id); - sb.append("','"); - sb.append(sponsor); - sb.append("','"); - sb.append(created); - sb.append("','"); - sb.append(renewal); - sb.append("')"); - return sb; - } - - public StringBuilder updateStmt(MiscID source) { - StringBuilder sb = null; - if(id.equals(source.id)) { - sb = addField(sb,"sponser",sponsor,source.sponsor); - sb = addField(sb,"created",created,source.created); - sb = addField(sb,"renewal",renewal,source.renewal); - } - if(sb!=null) { - sb.append(" WHERE id='"); - sb.append(id); - sb.append('\''); - } - return sb; - } - - private StringBuilder addField(StringBuilder sb, String name, String a, String b) { - if(!a.equals(b)) { - if(sb==null) { - sb = new StringBuilder("UPDATE authz.miscid SET "); - } else { - sb.append(','); - } - sb.append(name); - sb.append("='"); - sb.append(b); - sb.append('\''); - } - return sb; - } - - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/NS.java b/authz-batch/src/main/java/com/att/authz/helpers/NS.java deleted file mode 100644 index f8c59750..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/NS.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 NS implements Comparable<NS> { - public final static Map<String,NS> data = new TreeMap<String,NS>(); - - public final String name, description, parent; - public final int scope,type; - - public NS(String name, String description, String parent, int type, int scope) { - this.name = name; - this.description = description; - this.parent = parent; - this.scope = scope; - this.type = type; - } - - public static void load(Trans trans, Session session, Creator<NS> creator) { - load(trans,session, - "select name, description, parent, type, scope from authz.ns;" - ,creator); - } - - 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 - ); - } - - private static void load(Trans trans, Session session, String query, Creator<NS> creator) { - trans.info().log( "query: " + query ); - ResultSet results; - TimeTaken tt; - - tt = trans.start("Read Namespaces", Env.REMOTE); - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - - - try { - Iterator<Row> iter = results.iterator(); - Row row; - tt = trans.start("Load Namespaces", Env.SUB); - try { - while(iter.hasNext()) { - row = iter.next(); - NS ns = creator.create(row); - data.put(ns.name,ns); - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",data.size(),"Namespaces"); - } - - } - - public String toString() { - return name; - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return name.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return name.equals(obj); - } - - @Override - public int compareTo(NS o) { - return name.compareTo(o.name); - } - - public static class NSSplit { - public String ns; - public String other; - public NSSplit(String s, int dot) { - ns = s.substring(0,dot); - other = s.substring(dot+1); - } - } - public static NSSplit deriveParent(String dotted) { - if(dotted==null)return null; - for(int idx = dotted.lastIndexOf('.');idx>=0; idx=dotted.lastIndexOf('.',idx-1)) { - if(data.get(dotted.substring(0, idx))!=null) { - return new NSSplit(dotted,idx); - } - } - return null; - } - - public static Creator<NS> v2_0_11 = new Creator<NS> () { - @Override - public NS create(Row row) { - return new NS(row.getString(0),row.getString(1), row.getString(2),row.getInt(3),row.getInt(4)); - } - - @Override - public String select() { - return "SELECT name, description, parent, type, scope FROM authz.ns "; - } - }; - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Notification.java b/authz-batch/src/main/java/com/att/authz/helpers/Notification.java deleted file mode 100644 index 501edfa0..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Notification.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.TreeMap; - -import com.att.authz.actions.Message; -import com.att.authz.env.AuthzTrans; -import com.att.authz.org.EmailWarnings; -import com.att.authz.org.Organization; -import com.att.authz.org.Organization.Notify; -import com.att.authz.org.Organization.Identity; -import com.att.authz.org.OrganizationException; -import com.att.authz.org.OrganizationFactory; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.util.Chrono; -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 Notification { - - public static final TreeMap<String,List<Notification>> data = new TreeMap<String,List<Notification>>(); - public static final long now = System.currentTimeMillis(); - - public final String user; - public final Notify type; - public final Date last; - public final int checksum; - public Message msg; - private int current; - public Organization org; - public int count; - private long graceEnds,lastdays; - - private Notification(String user, int type, Date last, int checksum) { - this.user = user; - this.type = Notify.from(type); - this.last = last; - this.checksum = checksum; - current = 0; - count = 0; - } - - private Notification(String user, Notify type, Date last, int checksum) { - this.user = user; - this.type = type; - this.last = last; - this.checksum = checksum; - current = 0; - count = 0; - } - - public static void load(Trans trans, Session session, Creator<Notification> creator ) { - trans.info().log( "query: " + creator.select() ); - TimeTaken tt = trans.start("Load Notify", Env.REMOTE); - - ResultSet results; - try { - Statement stmt = new SimpleStatement(creator.select()); - results = session.execute(stmt); - } finally { - tt.done(); - } - int count = 0; - tt = trans.start("Process Notify", Env.SUB); - - try { - for(Row row : results.all()) { - ++count; - try { - Notification not = creator.create(row); - List<Notification> ln = data.get(not.user); - if(ln==null) { - ln = new ArrayList<Notification>(); - data.put(not.user, ln); - } - ln.add(not); - } finally { - tt.done(); - } - } - } finally { - tt.done(); - trans.info().log("Found",count,"Notify Records"); - } - } - - public static Notification get(String user, Notify type) { - List<Notification> ln = data.get(user); - if(ln!=null) { - for(Notification n : ln) { - if(type.equals(n.type)) { - return n; - } - } - } - return null; - } - - private static Notification getOrCreate(String user, Notify type) { - List<Notification> ln = data.get(user); - Notification n = null; - if(ln==null) { - ln = new ArrayList<Notification>(); - data.put(user, ln); - } else { - for(Notification n2 : ln) { - if(type.equals(n2.type)) { - n=n2; - break; - } - } - } - if(n==null) { - n = new Notification(user, type, new Date(), 0); - ln.add(n); - } - return n; - } - - public static Notification add(AuthzTrans trans, UserRole ur) { - Notification n = getOrCreate(ur.user,Notify.RoleExpiration); - if(n.org==null) { - try { - n.org = OrganizationFactory.obtain(trans.env(), ur.ns); - } catch (OrganizationException e) { - trans.error().log(ur.ns, " does not have a Namespace"); - } - } - - if(n.count==0) { - EmailWarnings ew = n.org.emailWarningPolicy(); - n.graceEnds = ew.roleEmailInterval(); - n.lastdays = ew.emailUrgentWarning(); - } - ++n.count; - - /* - StringBuilder sb = new StringBuilder(); - sb.append("ID: "); - sb.append(ur.user); - User ouser; - try { - ouser = n.org.getUser(trans, ur.user); - if(ouser!=null) { - sb.append(" ("); - sb.append(ouser.fullName()); - sb.append(')'); - } - } catch (Exception e) { - } - sb.append(" Role: "); - sb.append(ur.role); - sb.append(" Expire"); - if(now<ur.expires.getTime()) { - sb.append("s: "); - } else { - sb.append("d: "); - } - sb.append(Chrono.dateOnlyStamp(ur.expires)); - sb.append("\n If you wish to extend, type\n"); - sb.append("\trole user extend "); - sb.append(ur.role); - sb.append(' '); - sb.append(ur.user); - sb.append("\n If you wish to delete, type\n"); - sb.append("\trole user del "); - sb.append(ur.role); - sb.append(' '); - sb.append(ur.user); - sb.append('\n'); - n.msg.add(sb.toString()); - n.current=0; - */ - return n; - } - - public static Notification addApproval(AuthzTrans trans, Identity ou) { - Notification n = getOrCreate(ou.id(),Notify.Approval); - if(n.org==null) { - n.org = ou.org(); - } - if(n.count==0) { // first time. - EmailWarnings ew = n.org.emailWarningPolicy(); - n.graceEnds = ew.apprEmailInterval(); - n.lastdays = ew.emailUrgentWarning(); - } - ++n.count; - return n; - } - - public static Creator<Notification> v2_0_14 = new Creator<Notification>() { - @Override - public Notification create(Row row) { - return new Notification(row.getString(0), row.getInt(1), row.getDate(2),row.getInt(3)); - } - - @Override - public String select() { - return "select user,type,last,checksum from authz.notify"; - } - }; - - public void set(Message msg) { - this.msg = msg; - } - - public int checksum() { - if(current==0) { - for(String l : msg.lines) { - for(byte b : l.getBytes()) { - current+=b; - } - } - } - return current; - } - - public boolean update(AuthzTrans trans, Session session, boolean dryRun) { - String update = update(); - if(update!=null) { - if(dryRun) { - trans.info().log(update); - } else { - session.execute(update); - } - return true; // Updated info, expect to notify - } - return false; - } - - /** - * Returns an Update String for CQL if there is data. - * - * Returns null if nothing to update - * @return - */ - private String update() { - // If this has been done before, there is no change in checkSum and the last time notified is within GracePeriod - if(checksum!=0 && checksum()==checksum && now < last.getTime()+graceEnds && now > last.getTime()+lastdays) { - return null; - } else { - return "UPDATE authz.notify SET last = '" + - Chrono.dateOnlyStamp(last) + - "', checksum=" + - current + - " WHERE user='" + - user + - "' AND type=" + - type.getValue() + - ";"; - } - } - -// public void text(Email email) { -// for(String s : msg) { -// email.line(s); -// } -// } -// - public String toString() { - return "\"" + user + "\",\"" + type.name() + "\",\"" + Chrono.dateOnlyStamp(last); - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/NsAttrib.java b/authz-batch/src/main/java/com/att/authz/helpers/NsAttrib.java deleted file mode 100644 index fa0bd284..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/NsAttrib.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 static final List<NsAttrib> data = new ArrayList<NsAttrib>(); - public static final TreeMap<String,List<NsAttrib>> byKey = new TreeMap<String,List<NsAttrib>>(); - public static final TreeMap<String,List<NsAttrib>> byNS = new TreeMap<String,List<NsAttrib>>(); - - public final String ns,key,value; - - public NsAttrib(String ns, String key, String value) { - this.ns = ns; - this.key = key; - this.value = value; - } - - public static void load(Trans trans, Session session, Creator<NsAttrib> creator ) { - 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; - NsAttrib ur = creator.create(row); - data.add(ur); - - List<NsAttrib> lna = byKey.get(ur.key); - if(lna==null) { - lna = new ArrayList<NsAttrib>(); - byKey.put(ur.key, lna); - } - lna.add(ur); - - lna = byNS.get(ur.ns); - if(lna==null) { - lna = new ArrayList<NsAttrib>(); - byNS.put(ur.ns, lna); - } - lna.add(ur); - } - } finally { - tt.done(); - trans.info().log("Found",count,"NS Attributes"); - } - } - - 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 String toString() { - return "\"" + ns + "\",\"" + key + "\",\"" + value; - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Perm.java b/authz-batch/src/main/java/com/att/authz/helpers/Perm.java deleted file mode 100644 index 41c41a85..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Perm.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.Iterator; -import java.util.Set; -import java.util.TreeMap; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 Perm implements Comparable<Perm> { - public static final TreeMap<Perm,Set<String>> data = new TreeMap<Perm,Set<String>>(); - public static final TreeMap<String,Perm> keys = new TreeMap<String,Perm>(); - - public final String ns, type, instance, action,description; - private String fullType = null, fullPerm = null, encode = null; - public final Set<String> roles; - - public String encode() { - if(encode == null) { - encode = ns + '|' + type + '|' + instance + '|' + action; - } - return encode; - } - - public String fullType() { - if(fullType==null) { - fullType = ns + '.' + type; - } - return fullType; - } - - public String fullPerm() { - if(fullPerm==null) { - fullPerm = ns + '.' + type + '|' + instance + '|' + action; - } - return fullPerm; - } - - public Perm(String ns, String type, String instance, String action, String description, Set<String> roles) { - this.ns = ns; - this.type = type; - this.instance = instance; - this.action = action; - this.description = description; - // 2.0.11 -// this.full = encode();//ns+'.'+type+'|'+instance+'|'+action; - this.roles = roles; - } - - public static void load(Trans trans, Session session) { - load(trans, session, "select ns, type, instance, action, description, roles from authz.perm;"); - } - - public static void loadOneNS(Trans trans, Session session, String ns) { - load(trans, session, "select ns, type, instance, action, description, roles from authz.perm WHERE ns='" + ns + "';"); - - } - - private static void load(Trans trans, Session session, String query) { - // - trans.info().log( "query: " + query ); - TimeTaken tt = trans.start("Read Perms", Env.REMOTE); - ResultSet results; - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - - try { - Iterator<Row> iter = results.iterator(); - Row row; - tt = trans.start("Load Perms", Env.SUB); - try { - while(iter.hasNext()) { - row = iter.next(); - Perm pk = new Perm(row.getString(0),row.getString(1),row.getString(2),row.getString(3), row.getString(4), row.getSet(5,String.class)); - keys.put(pk.encode(), pk); - data.put(pk,pk.roles); - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",data.size(),"perms"); - } - } - - public String toString() { - return encode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return encode().hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return encode().equals(obj); - } - - @Override - public int compareTo(Perm o) { - return encode().compareTo(o.encode()); - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Role.java b/authz-batch/src/main/java/com/att/authz/helpers/Role.java deleted file mode 100644 index fd57f5c1..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/Role.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeMap; - -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.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 Role implements Comparable<Role> { - public static final TreeMap<Role,Set<String>> data = new TreeMap<Role,Set<String>>(); - public static final TreeMap<String,Role> keys = new TreeMap<String,Role>(); - - public final String ns, name, description; - private String full, encode; - public final Set<String> perms; - - public Role(String full) { - ns = name = description = ""; - this.full = full; - perms = new HashSet<String>(); - } - - public Role(String ns, String name, String description,Set<String> perms) { - this.ns = ns; - this.name = name; - this.description = description; - this.full = null; - this.encode = null; - this.perms = perms; - } - - public String encode() { - if(encode==null) { - encode = ns + '|' + name; - } - return encode; - } - - public String fullName() { - if(full==null) { - full = ns + '.' + name; - } - return full; - } - - public static void load(Trans trans, Session session ) { - load(trans,session,"select ns, name, description, perms from authz.role;"); - } - - public static void loadOneNS(Trans trans, Session session, String ns ) { - load(trans,session,"select ns, name, description, perms from authz.role WHERE ns='" + ns + "';"); - } - - private static void load(Trans trans, Session session, String query) { - trans.info().log( "query: " + query ); - TimeTaken tt = trans.start("Read Roles", Env.REMOTE); - - ResultSet results; - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - - try { - Iterator<Row> iter = results.iterator(); - Row row; - tt = trans.start("Load Roles", Env.SUB); - try { - while(iter.hasNext()) { - row = iter.next(); - Role rk =new Role(row.getString(0),row.getString(1), row.getString(2),row.getSet(3,String.class)); - keys.put(rk.encode(), rk); - data.put(rk,rk.perms); - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",data.size(),"roles"); - } - - - } - public String toString() { - return encode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return encode().hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return encode().equals(obj); - } - - @Override - public int compareTo(Role o) { - return encode().compareTo(o.encode()); - } - - public static String fullName(String role) { - return role.replace('|', '.'); - } -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/helpers/UserRole.java b/authz-batch/src/main/java/com/att/authz/helpers/UserRole.java deleted file mode 100644 index fa23d13a..00000000 --- a/authz-batch/src/main/java/com/att/authz/helpers/UserRole.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.helpers; - -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.TreeMap; - -import com.att.dao.aaf.cass.UserRoleDAO; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.Trans; -import org.onap.aaf.inno.env.util.Chrono; -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 UserRole implements Cloneable { - public static final List<UserRole> data = new ArrayList<UserRole>(); - public static final TreeMap<String,List<UserRole>> byUser = new TreeMap<String,List<UserRole>>(); - public static final TreeMap<String,List<UserRole>> byRole = new TreeMap<String,List<UserRole>>(); - - public final String user, role, ns, rname; - public final Date expires; - - public UserRole(String user, String ns, String rname, Date expires) { - this.user = user; - this.role = ns + '.' + rname; - this.ns = ns; - this.rname = rname; - this.expires = expires; - } - - public UserRole(String user, String role, String ns, String rname, Date expires) { - this.user = user; - this.role = role; - this.ns = ns; - this.rname = rname; - this.expires = expires; - } - - public static void load(Trans trans, Session session, Creator<UserRole> creator ) { - load(trans,session,creator,null); - } - - public static void loadOneRole(Trans trans, Session session, Creator<UserRole> creator, String role) { - load(trans,session,creator,"role='" + role +"' ALLOW FILTERING;"); - } - - public static void loadOneUser(Trans trans, Session session, Creator<UserRole> creator, String user ) { - load(trans,session,creator,"role='"+ user +"';"); - } - - private static void load(Trans trans, Session session, Creator<UserRole> creator, String where) { - String query = creator.query(where); - trans.info().log( "query: " + query ); - TimeTaken tt = trans.start("Read UserRoles", Env.REMOTE); - - ResultSet results; - try { - Statement stmt = new SimpleStatement( query ); - results = session.execute(stmt); - } finally { - tt.done(); - } - int count = 0; - try { - Iterator<Row> iter = results.iterator(); - Row row; - tt = trans.start("Load UserRole", Env.SUB); - try { - while(iter.hasNext()) { - ++count; - row = iter.next(); - UserRole ur = creator.create(row); - data.add(ur); - - List<UserRole> lur = byUser.get(ur.user); - if(lur==null) { - lur = new ArrayList<UserRole>(); - byUser.put(ur.user, lur); - } - lur.add(ur); - - lur = byRole.get(ur.role); - if(lur==null) { - lur = new ArrayList<UserRole>(); - byRole.put(ur.role, lur); - } - lur.add(ur); - } - } finally { - tt.done(); - } - } finally { - trans.info().log("Found",count,"UserRoles"); - } - - - } - - public static Creator<UserRole> v2_0_11 = new Creator<UserRole>() { - @Override - public UserRole create(Row row) { - return new UserRole(row.getString(0), row.getString(1), row.getString(2),row.getString(3),row.getDate(4)); - } - - @Override - public String select() { - return "select user,role,ns,rname,expires from authz.user_role"; - } - }; - - public UserRoleDAO.Data to() { - UserRoleDAO.Data urd = new UserRoleDAO.Data(); - urd.user = user; - urd.role = role; - urd.ns = ns; - urd.rname = rname; - urd.expires = expires; - return urd; - } - - public String toString() { - return "\"" + user + "\",\"" + role + "\",\"" + ns + "\",\"" + rname + "\",\""+ Chrono.dateOnlyStamp(expires); - } - -}
\ No newline at end of file diff --git a/authz-batch/src/main/java/com/att/authz/reports/ApprNotify.java b/authz-batch/src/main/java/com/att/authz/reports/ApprNotify.java deleted file mode 100644 index 79bdb5b8..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/ApprNotify.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import com.att.authz.Batch; -import com.att.authz.actions.Email; -import com.att.authz.actions.Message; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Approver; -import com.att.authz.helpers.Notification; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization; -import com.att.authz.org.Organization.Identity; -import com.att.authz.org.OrganizationException; -import com.att.authz.org.OrganizationFactory; -import com.att.dao.CassAccess; -import com.att.dao.aaf.cass.ApprovalDAO; -import com.att.dao.aaf.cass.ApprovalDAO.Data; -import org.onap.aaf.inno.env.APIException; - -public class ApprNotify extends Batch { - private final ApprovalDAO apprDAO; - private Result<List<Data>> rladd; - private Email email; - - public ApprNotify(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - apprDAO = new ApprovalDAO(trans, cluster, CassAccess.KEYSPACE); - session = apprDAO.getSession(trans); - rladd = apprDAO.readByStatus(trans,"pending"); - if(isDryRun()) { - email = new Email();//EmailPrint(); - } else { - email = new Email(); - } - email.subject("AAF Approval Notification (ENV: %s)",batchEnv); - email.preamble("AAF is the AT&T System for Fine-Grained Authorizations. " - + "You are being asked to Approve in the %s environment before AAF Actions can be taken. \n\n" - + " Please follow this link:\n\n\t%s/approve" - ,batchEnv,env.getProperty(GUI_URL)); - - Notification.load(trans, session, Notification.v2_0_14); - } - - @Override - protected void run(AuthzTrans trans) { - if(rladd.isOK()) { - if(rladd.isEmpty()) { - trans.warn().log("No Pending Approvals to Process"); - } else { - Organization org=null; - //Map<String,Organization> users = new HashMap<String,Organization>(); - Map<String,Approver> users = new TreeMap<String,Approver>(); - - for(Data data : rladd.value) { - // We've already seen this approver. Simply add the new request to him. - try { - Approver approver = users.get(data.approver); - if(approver==null) { - org = OrganizationFactory.obtain(trans.env(), data.approver); - approver = new Approver(data.approver, org); - users.put(data.approver, approver); - } - approver.addRequest(data.user); - } catch (OrganizationException e) { - trans.error().log(e); - } - } - - // Notify - Message msg = new Message(); - for(Approver approver : users.values()) { - try { - Notification n = Notification.addApproval(trans, org.getIdentity(trans, approver.name)); - approver.build(msg); - n.set(msg); - if(n.update(trans, session, isDryRun())) { - Identity user = n.org.getIdentity(trans, approver.name); - email.clear(); - email.addTo(user.email()); - email.msg(msg); - email.exec(trans, n.org); - } - } catch (OrganizationException e) { - trans.error().log(e); - } - } - } - } else { - trans.error().log('[',rladd.status,']',rladd.details); - } - } - - @Override - protected void _close(AuthzTrans trans) { - apprDAO.close(trans); - } - - - -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/CheckCred.java b/authz-batch/src/main/java/com/att/authz/reports/CheckCred.java deleted file mode 100644 index 58cc0743..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/CheckCred.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; - -import com.att.authz.Batch; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Cred; -import com.att.authz.helpers.Cred.Instance; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.util.Chrono; - -public class CheckCred extends Batch{ - - public CheckCred(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - - Cred.load(trans, session); - } - - @Override - protected void run(AuthzTrans trans) { - String query; - for(Cred cred : Cred.data.values()) { - for(Instance inst : cred.instances) { - if(inst.other==0) { - if(dryRun) { - trans.warn().log("Ensuring 'other' is numeric"); - } else { - query = "UPDATE authz.cred SET other=0 WHERE " - + "id='" + cred.id - + "' AND type=" + inst.type - + " AND expires='" + Chrono.dateStamp(inst.expires) - + "';"; - session.execute(query); - trans.warn().log("resetting 'other'",query); - } - } - } - } - - } - /* - /// Evaluate - for(UserRole urKey : UserRole.data) { - NSSplit nss = NS.deriveParent(urKey.role); - if(nss==null && NS.data.size()>0 ) { // there is no Namespace for this UserRole - if(dryRun) { - trans.warn().printf("Would delete %s %s, which has no corresponding Namespace",urKey.user,urKey.role); - } else { - query = "DELETE FROM authz.user_role WHERE " - + "user='" + urKey.user - + "' AND role='" + urKey.role - + "';"; - session.execute(query); - trans.warn().printf("Deleting %s %s, which has no corresponding Namespace",urKey.user,urKey.role); - } - } else if(urKey.ns == null || urKey.rname == null || !urKey.role.equals(urKey.ns+'.'+urKey.rname)) { - if(dryRun) { - trans.warn().log(urKey,"needs to be split and added to Record (", urKey.ns, urKey.rname,")"); - } else { - query = "UPDATE authz.user_role SET ns='" + nss.ns - + "', rname='" + nss.other - + "' WHERE " - + "user='" + urKey.user - + "' AND role='" + urKey.role - + "';"; - session.execute(query); - trans.warn().log("Setting ns and rname",query); - } - } - } - } - */ - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - } -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/CheckNS.java b/authz-batch/src/main/java/com/att/authz/reports/CheckNS.java deleted file mode 100644 index b4572b4f..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/CheckNS.java +++ /dev/null @@ -1,425 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; -import java.util.List; - -import com.att.authz.Batch; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.NS; -import com.att.authz.helpers.NsAttrib; -import com.att.authz.helpers.Perm; -import com.att.authz.helpers.Role; -import com.att.dao.aaf.cass.NsType; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; - -public class CheckNS extends Batch{ - - public CheckNS(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - NS.load(trans, session,NS.v2_0_11); - Role.load(trans, session); - Perm.load(trans, session); - NsAttrib.load(trans, session, NsAttrib.v2_0_11); - } - - @Override - protected void run(AuthzTrans trans) { - - String msg; - String query; - trans.info().log(STARS, msg = "Checking for NS type mis-match", STARS); - TimeTaken tt = trans.start(msg, Env.SUB); - try { - for(NS ns : NS.data.values()) { - if(ns.description==null) { - trans.warn().log("Namepace description is null. Changing to empty string."); - if(dryRun) { - trans.warn().log("Namepace description is null. Changing to empty string"); - } else { - query = "UPDATE authz.ns SET description='' WHERE name='" + ns.name +"';"; - session.execute(query); - } - } - int scope = count(ns.name,'.'); - NsType nt; - switch(scope) { - case 0: - nt = NsType.DOT; - break; - case 1: - nt = NsType.ROOT; - break; - case 2: - nt = NsType.COMPANY; - break; - default: - nt = NsType.APP; - break; - } - if(ns.type!=nt.type || ns.scope !=scope) { - if(dryRun) { - trans.warn().log("Namepace",ns.name,"has no type. Should change to ",nt.name()); - } else { - query = "UPDATE authz.ns SET type=" + nt.type + ", scope=" + scope + " WHERE name='" + ns.name +"';"; - trans.warn().log("Namepace",ns.name,"changing to",nt.name()+":",query); - session.execute(query); - } - } - } - } finally { - tt.done(); - } - - - trans.info().log(STARS, msg = "Checking for NS admin/owner mis-match", STARS); - tt = trans.start(msg, Env.SUB); - try { - /// Evaluate - for(NS nk : NS.data.values()) { - //String name; - String roleAdmin = nk.name+"|admin"; - String roleAdminPrev = nk.name+".admin"; - String roleOwner = nk.name+"|owner"; - String roleOwnerPrev = nk.name+".owner"; - String permAll = nk.name+"|access|*|*"; - String permAllPrev = nk.name+".access|*|*"; - String permRead = nk.name+"|access|*|read"; - String permReadPrev = nk.name+".access|*|read"; - // Admins - - Role rk = Role.keys.get(roleAdmin); // accomodate new role key - // Role Admin should exist - if(rk==null) { - if(dryRun) { - trans.warn().log(nk.name + " is missing role: " + roleAdmin); - } else { - query = "INSERT INTO authz.role(ns, name, description, perms) VALUES ('" - + nk.name - + "','admin','Automatic Administration'," - + "{'" + nk.name + "|access|*|*'});"; - session.execute(query); - env.info().log(query); - - - if(Role.keys.get(roleAdminPrev)!=null) { - query = "UPDATE authz.role set perms = perms + " - + "{'" + roleAdminPrev + "'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='admin'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - } else { - // Role Admin should be linked to Perm All - if(!rk.perms.contains(permAll)) { - if(dryRun) { - trans.warn().log(roleAdmin,"is not linked to",permAll); - } else { - query = "UPDATE authz.role set perms = perms + " - + "{'" + nk.name + "|access|*|*'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='admin'" - + ";"; - session.execute(query); - env.info().log(query); - - if(rk.perms.contains(permAllPrev)) { - query = "UPDATE authz.role set perms = perms - " - + "{'" + nk.name + ".access|*|*'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='admin'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - } - // Role Admin should not be linked to Perm Read - if(rk.perms.contains(permRead)) { - if(dryRun) { - trans.warn().log(roleAdmin,"should not be linked to",permRead); - } else { - query = "UPDATE authz.role set perms = perms - " - + "{'" + nk.name + "|access|*|read'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='admin'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - } - - Perm pk = Perm.keys.get(permAll); - if(pk==null) { - trans.warn().log(nk.name + " is missing perm: " + permAll); - if(!dryRun) { - query = "INSERT INTO authz.perm(ns, type,instance,action,description, roles) VALUES ('" - + nk.name - + "','access','*','*','Namespace Write'," - + "{'" + nk.name + "|admin'});"; - session.execute(query); - env.info().log(query); - - } - } else { - // PermALL should be linked to Role Admin - if(!pk.roles.contains(roleAdmin)) { - trans.warn().log(permAll,"is not linked to",roleAdmin); - if(!dryRun) { - query = "UPDATE authz.perm set roles = roles + " - + "{'" + nk.name + "|admin'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='*'" - + ";"; - session.execute(query); - env.info().log(query); - - if(pk.roles.contains(roleAdminPrev)) { - query = "UPDATE authz.perm set roles = roles - " - + "{'" + nk.name + ".admin'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='*'" - + ";"; - session.execute(query); - env.info().log(query); - - } - } - } - - // PermALL should be not linked to Role Owner - if(pk.roles.contains(roleOwner)) { - trans.warn().log(permAll,"should not be linked to",roleOwner); - if(!dryRun) { - query = "UPDATE authz.perm set roles = roles - " - + "{'" + nk.name + "|owner'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='*'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - - } - - - - // Owner - rk = Role.keys.get(roleOwner); - if(rk==null) { - trans.warn().log(nk.name + " is missing role: " + roleOwner); - if(!dryRun) { - query = "INSERT INTO authz.role(ns, name, description, perms) VALUES('" - + nk.name - + "','owner','Automatic Owners'," - + "{'" + nk.name + "|access|*|read'});"; - session.execute(query); - env.info().log(query); - - } - } else { - // Role Owner should be linked to permRead - if(!rk.perms.contains(permRead)) { - trans.warn().log(roleOwner,"is not linked to",permRead); - if(!dryRun) { - query = "UPDATE authz.role set perms = perms + " - + "{'" + nk.name + "|access|*|read'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='owner'" - + ";"; - session.execute(query); - env.info().log(query); - - if(rk.perms.contains(permReadPrev)) { - query = "UPDATE authz.role set perms = perms - " - + "{'" + nk.name + ".access|*|read'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='owner'" - + ";"; - session.execute(query); - env.info().log(query); - - } - } - } - // Role Owner should not be linked to PermAll - if(rk.perms.contains(permAll)) { - trans.warn().log(roleAdmin,"should not be linked to",permAll); - if(!dryRun) { - query = "UPDATE authz.role set perms = perms - " - + "{'" + nk.name + "|access|*|*'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='admin'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - - } - - pk = Perm.keys.get(permRead); - if(pk==null) { - trans.warn().log(nk.name + " is missing perm: " + permRead); - if(!dryRun) { - query = "INSERT INTO authz.perm(ns, type,instance,action,description, roles) VALUES ('" - + nk.name - + "','access','*','read','Namespace Read'," - + "{'" + nk.name + "|owner'});"; - session.execute(query); - env.info().log(query); - } - } else { - // PermRead should be linked to roleOwner - if(!pk.roles.contains(roleOwner)) { - trans.warn().log(permRead, "is not linked to", roleOwner); - if(!dryRun) { - query = "UPDATE authz.perm set roles = roles + " - + "{'" + nk.name + "|owner'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='read'" - + ";"; - session.execute(query); - env.info().log(query); - - if(pk.roles.contains(roleOwnerPrev)) { - query = "UPDATE authz.perm set roles = roles - " - + "{'" + nk.name + ".owner'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='read'" - + ";"; - session.execute(query); - env.info().log(query); - - } - } - } - // PermRead should be not linked to RoleAdmin - if(pk.roles.contains(roleAdmin)) { - if(dryRun) { - trans.warn().log(permRead,"should not be linked to",roleAdmin); - } else { - query = "UPDATE authz.perm set roles = roles - " - + "{'" + nk.name + "|admin'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='read'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - } - - - int dot = nk.name.lastIndexOf('.'); - String parent; - if(dot<0) { - parent = "."; - } else { - parent = nk.name.substring(0, dot); - } - - if(!parent.equals(nk.parent)) { - if(dryRun) { - trans.warn().log(nk.name + " is missing namespace data"); - } else { - query = "UPDATE authz.ns SET parent='"+parent+"'" + - " WHERE name='" + nk.name + "';"; - session.execute(query); - env.info().log(query); - } - } - - // During Migration: - List<NsAttrib> swm = NsAttrib.byNS.get(nk.name); - boolean hasSwmV1 = false; - if(swm!=null) {for(NsAttrib na : swm) { - if("swm".equals(na.key) && "v1".equals(na.value)) { - hasSwmV1=true; - break; - } - }} - String roleMem = nk.name+"|member"; - Role rm = Role.keys.get(roleMem); // Accommodate new role key - if(rm==null && hasSwmV1) { - query = "INSERT INTO authz.role(ns, name, description, perms) VALUES ('" - + nk.name - + "','member','Member'," - + "{'" + nk.name + "|access|*|read'});"; - session.execute(query); - query = "UPDATE authz.role set perms = perms + " - + "{'" + nk.name + "|access|*|read'} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='member'" - + ";"; - session.execute(query); - env.info().log(query); - } - if(rm!=null) { - if(!rm.perms.contains(permRead)) { - if(isDryRun()) { - env.info().log(nk.name+"|member needs " + nk.name + "|access|*|read"); - } else { - query = "UPDATE authz.perm set roles = roles + " - + "{'" + nk.name + "|member'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='access' AND instance='*' and action='read'" - + ";"; - session.execute(query); - env.info().log(query); - query = "UPDATE authz.role set perms = perms + " - + "{'" + nk.name + "|access|*|read'" - + (hasSwmV1?",'"+nk.name+"|swm.star|*|*'":"") - + "} " - + "WHERE ns='"+ nk.name + "' AND " - + "name='member'" - + ";"; - session.execute(query); - env.info().log(query); - if(hasSwmV1) { - query = "UPDATE authz.perm set roles = roles + " - + "{'" + nk.name + "|member'} WHERE " - + "ns='"+ pk.ns + "' AND " - + "type='swm.star' AND instance='*' and action='*'" - + ";"; - session.execute(query); - env.info().log(query); - } - } - } - } - - - - // Best Guess Owner - -// owner = Role.keys.get(ns.) - } - } finally { - tt.done(); - } - - } - - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - } -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/CheckRolePerm.java b/authz-batch/src/main/java/com/att/authz/reports/CheckRolePerm.java deleted file mode 100644 index 2df123de..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/CheckRolePerm.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; -import java.util.Set; - -import com.att.authz.Batch; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.NS; -import com.att.authz.helpers.Perm; -import com.att.authz.helpers.Role; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; -import org.onap.aaf.inno.env.util.Split; - -public class CheckRolePerm extends Batch{ - - public CheckRolePerm(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - NS.load(trans,session,NS.v2_0_11); - Role.load(trans, session); - Perm.load(trans, session); - } - - @Override - protected void run(AuthzTrans trans) { - // Run for Roles - trans.info().log("Checking for Role/Perm mis-match"); - - String query; - /// Evaluate from Role side - for(Role roleKey : Role.data.keySet()) { - for(String perm : Role.data.get(roleKey)) { - Perm pk = Perm.keys.get(perm); - if(pk==null) { - NS ns=null; - String msg = perm + " in role " + roleKey.fullName() + " does not exist"; - String newPerm; - String[] s = Split.split('|', perm); - if(s.length==3) { - int i; - String find = s[0]; - for(i=find.lastIndexOf('.');ns==null && i>=0;i=find.lastIndexOf('.', i-1)) { - ns = NS.data.get(find.substring(0,i)); - } - if(ns==null) { - newPerm = perm; - } else { - newPerm = ns.name + '|' + s[0].substring(i+1) + '|' + s[1] + '|' + s[2]; - } - } else { - newPerm = perm; - } - if(dryRun) { - if(ns==null) { - trans.warn().log(msg, "- would remove role from perm;"); - } else { - trans.warn().log(msg, "- would update role in perm;"); - } - } else { - if(ns!=null) { - query = "UPDATE authz.role SET perms = perms + {'" + - newPerm + "'}" - + (roleKey.description==null?", description='clean'":"") - + " WHERE " - + "ns='" + roleKey.ns - + "' AND name='" + roleKey.name + "';"; - trans.warn().log("Fixing role in perm",query); - session.execute(query); - } - - query = "UPDATE authz.role SET perms = perms - {'" - + perm.replace("'", "''") + "'}" - + (roleKey.description==null?", description='clean'":"") - + " WHERE " - + "ns='" + roleKey.ns - + "' AND name='" + roleKey.name + "';"; - session.execute(query); - trans.warn().log(msg, "- removing role from perm"); -// env.info().log( "query: " + query ); - } - } else { - Set<String> p_roles = Perm.data.get(pk); - if(p_roles!=null && !p_roles.contains(roleKey.encode())) { - String msg = perm + " does not have role: " + roleKey; - if(dryRun) { - trans.warn().log(msg,"- should add this role to this perm;"); - } else { - query = "update authz.perm set roles = roles + {'" - + roleKey.encode() + "'}" - + (pk.description==null?", description=''":"") - + " WHERE " - + "ns='" + pk.ns - + "' AND type='" + pk.type - + "' AND instance='" + pk.instance - + "' AND action='" + pk.action - + "';"; - session.execute(query); - trans.warn().log(msg,"- adding perm to role"); - } - - } - } - } - } - - for(Perm permKey : Perm.data.keySet()) { - for(String role : Perm.data.get(permKey)) { - Role rk = Role.keys.get(role); - if(rk==null) { - String s = role + " in perm " + permKey.encode() + " does not exist"; - if(dryRun) { - trans.warn().log(s,"- would remove perm from role;"); - } else { - query = "update authz.perm set roles = roles - {'" - + role.replace("'","''") + "'}" - + (permKey.description==null?", description='clean'":"") - + " WHERE " - + "ns='" + permKey.ns - + "' AND type='" + permKey.type - + "' AND instance='" + permKey.instance - + "' AND action='" + permKey.action + "';"; - session.execute(query); - trans.warn().log(s,"- removing role from perm"); - } - } else { - Set<String> r_perms = Role.data.get(rk); - if(r_perms!=null && !r_perms.contains(permKey.encode())) { - String s ="Role '" + role + "' does not have perm: '" + permKey + '\''; - if(dryRun) { - trans.warn().log(s,"- should add this perm to this role;"); - } else { - query = "update authz.role set perms = perms + {'" - + permKey.encode() + "'}" - + (rk.description==null?", description=''":"") - + " WHERE " - + "ns='" + rk.ns - + "' AND name='" + rk.name + "';"; - session.execute(query); - trans.warn().log(s,"- adding role to perm"); - } - } - } - } - } - - } - - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - } -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/CheckUR.java b/authz-batch/src/main/java/com/att/authz/reports/CheckUR.java deleted file mode 100644 index 5064140c..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/CheckUR.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; - -import com.att.authz.Batch; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.NS; -import com.att.authz.helpers.NS.NSSplit; -import com.att.authz.helpers.UserRole; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; - -public class CheckUR extends Batch{ - - public CheckUR(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - NS.load(trans, session,NS.v2_0_11); - UserRole.load(trans, session,UserRole.v2_0_11); - } - - @Override - protected void run(AuthzTrans trans) { - trans.info().log("Get All Namespaces"); - - - String query; - - /// Evaluate - for(UserRole urKey : UserRole.data) { - NSSplit nss = NS.deriveParent(urKey.role); - if(nss==null && NS.data.size()>0 ) { // there is no Namespace for this UserRole - if(dryRun) { - trans.warn().printf("Would delete %s %s, which has no corresponding Namespace",urKey.user,urKey.role); - } else { - query = "DELETE FROM authz.user_role WHERE " - + "user='" + urKey.user - + "' AND role='" + urKey.role - + "';"; - session.execute(query); - trans.warn().printf("Deleting %s %s, which has no corresponding Namespace",urKey.user,urKey.role); - } - } else if(urKey.ns == null || urKey.rname == null || !urKey.role.equals(urKey.ns+'.'+urKey.rname)) { - if(dryRun) { - trans.warn().log(urKey,"needs to be split and added to Record (", urKey.ns, urKey.rname,")"); - } else { - query = "UPDATE authz.user_role SET ns='" + nss.ns - + "', rname='" + nss.other - + "' WHERE " - + "user='" + urKey.user - + "' AND role='" + urKey.role - + "';"; - session.execute(query); - trans.warn().log("Setting ns and rname",query); - } - } - } - } - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - } -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/Expiring.java b/authz-batch/src/main/java/com/att/authz/reports/Expiring.java deleted file mode 100644 index 79f37598..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/Expiring.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - -import com.att.authz.Batch; -import com.att.authz.actions.Action; -import com.att.authz.actions.ActionDAO; -import com.att.authz.actions.CredDelete; -import com.att.authz.actions.CredPrint; -import com.att.authz.actions.FADelete; -import com.att.authz.actions.FAPrint; -import com.att.authz.actions.Key; -import com.att.authz.actions.URDelete; -import com.att.authz.actions.URFutureApprove; -import com.att.authz.actions.URFuturePrint; -import com.att.authz.actions.URPrint; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Cred; -import com.att.authz.helpers.Cred.Instance; -import com.att.authz.helpers.Future; -import com.att.authz.helpers.Notification; -import com.att.authz.helpers.UserRole; -import com.att.authz.layer.Result; -import com.att.authz.org.Organization.Identity; -import com.att.dao.aaf.cass.CredDAO; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; - -public class Expiring extends Batch { - - private final Action<UserRole,Void> urDelete,urPrint; - private final Action<UserRole,List<Identity>> urFutureApprove; - private final Action<CredDAO.Data,Void> crDelete,crPrint; - private final Action<Future,Void> faDelete; -// private final Email email; - private final Key<UserRole> memoKey; - - public Expiring(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - trans.info().log("Starting Connection Process"); - TimeTaken tt0 = trans.start("Cassandra Initialization", Env.SUB); - try { - urPrint = new URPrint("Expired:"); - crPrint = new CredPrint("Expired:"); - - URFutureApprove ufr = new URFutureApprove(trans,cluster); - memoKey = ufr; - - if(isDryRun()) { - urDelete = new URPrint("Would Delete:"); - // While Testing -// urFutureApprove = ufr; - urFutureApprove = new URFuturePrint("Would setup Future/Approvals"); - crDelete = new CredPrint("Would Delete:"); - faDelete = new FAPrint("Would Delete:"); -// email = new EmailPrint(); - - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - - } else { - TimeTaken tt = trans.start("Connect to Cluster with DAOs", Env.REMOTE); - try { - ActionDAO<UserRole,Void> adao; - urDelete = adao = new URDelete(trans, cluster); - urFutureApprove = new URFutureApprove(trans,adao); - faDelete = new FADelete(trans, adao); - - crDelete = new CredDelete(trans, adao); -// email = new Email(); - TimeTaken tt2 = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = adao.getSession(trans); - } finally { - tt2.done(); - } - } finally { - tt.done(); - } - } - - UserRole.load(trans, session, UserRole.v2_0_11); - Cred.load(trans, session); - Notification.load(trans, session, Notification.v2_0_14); - Future.load(trans,session,Future.v2_0_15); - } finally { - tt0.done(); - } - } - - @Override - protected void run(AuthzTrans trans) { - // Setup Date boundaries - Date now = new Date(); - GregorianCalendar gc = new GregorianCalendar(); - gc.setTime(now); - gc.add(GregorianCalendar.MONTH, 1); - Date future = gc.getTime(); - gc.setTime(now); - gc.add(GregorianCalendar.MONTH, -1); - Date tooLate = gc.getTime(); - int count = 0, deleted=0; - -// List<Notification> ln = new ArrayList<Notification>(); - TimeTaken tt; - - // Run for Expired Futures - trans.info().log("Checking for Expired Futures"); - tt = trans.start("Delete old Futures", Env.REMOTE); - try { - List<Future> delf = new ArrayList<Future>(); - for(Future f : Future.data) { - AuthzTrans localTrans = env.newTransNoAvg(); - if(f.expires.before(now)) { - faDelete.exec(localTrans, f); - delf.add(f); - } - } - Future.delete(delf); - } finally { - tt.done(); - } - - // Run for Roles - trans.info().log("Checking for Expired Roles"); - try { - for(UserRole ur : UserRole.data) { - AuthzTrans localTrans = env.newTransNoAvg(); - if(ur.expires.before(tooLate)) { - if("owner".equals(ur.rname)) { // don't delete Owners, even if Expired - urPrint.exec(localTrans,ur); - } else { - urDelete.exec(localTrans,ur); - ++deleted; - trans.logAuditTrail(trans.info()); - } - ++count; - } else if(ur.expires.before(future)) { - List<Future> fbm = Future.byMemo.get(memoKey.key(ur)); - if(fbm==null || fbm.isEmpty()) { - Result<List<Identity>> rapprovers = urFutureApprove.exec(localTrans, ur); - if(rapprovers.isOK()) { - for(Identity ou : rapprovers.value) { -// Notification n = Notification.addApproval(localTrans,ou); -// if(n.org==null) { -// n.org = getOrgFromID(localTrans, ur.user); -// } -// ln.add(n); - urPrint.exec(localTrans,ur); - if(isDryRun()) { - trans.logAuditTrail(trans.info()); - } - } - } - } - ++count; - } - } - } finally { - env.info().log("Found",count,"roles expiring before",future); - env.info().log("deleting",deleted,"roles expiring before",tooLate); - } - -// // Email Approval Notification -// email.subject("AAF Role Expiration Warning (ENV: %s)", batchEnv); -// email.indent(""); -// for(Notification n: ln) { -// if(n.org==null) { -// trans.error().log("No Organization for Notification"); -// } else if(n.update(trans, session, isDryRun())) { -// email.clear(); -// email.addTo(n.user); -// email.line(n.text(new StringBuilder()).toString()); -// email.exec(trans,n.org); -// } -// } - // Run for Creds - trans.info().log("Checking for Expired Credentials"); - System.out.flush(); - count = 0; - try { - CredDAO.Data crd = new CredDAO.Data(); - Date last = null; - for( Cred creds : Cred.data.values()) { - AuthzTrans localTrans = env.newTransNoAvg(); - crd.id = creds.id; - for(int type : creds.types()) { - crd.type = type; - for( Instance inst : creds.instances) { - if(inst.expires.before(tooLate)) { - crd.expires = inst.expires; - crDelete.exec(localTrans, crd); - } else if(last==null || inst.expires.after(last)) { - last = inst.expires; - } - } - if(last!=null) { - if(last.before(future)) { - crd.expires = last; - crPrint.exec(localTrans, crd); - ++count; - } - } - } - } - } finally { - env.info().log("Found",count,"current creds expiring before",future); - } - - } - - @Override - protected void _close(AuthzTrans trans) { - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - for(Action<?,?> action : new Action<?,?>[] {urDelete,crDelete}) { - if(action instanceof ActionDAO) { - ((ActionDAO<?,?>)action).close(trans); - } - } - session.close(); - } - -} diff --git a/authz-batch/src/main/java/com/att/authz/reports/NSDump.java b/authz-batch/src/main/java/com/att/authz/reports/NSDump.java deleted file mode 100644 index a15fc242..00000000 --- a/authz-batch/src/main/java/com/att/authz/reports/NSDump.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. - *******************************************************************************/ -package com.att.authz.reports; - -import java.io.IOException; -import java.io.PrintStream; -import java.util.Date; -import java.util.List; - -import com.att.authz.Batch; -import com.att.authz.env.AuthzTrans; -import com.att.authz.helpers.Cred; -import com.att.authz.helpers.NS; -import com.att.authz.helpers.Perm; -import com.att.authz.helpers.Role; -import com.att.authz.helpers.UserRole; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Env; -import org.onap.aaf.inno.env.TimeTaken; - -public class NSDump extends Batch{ - private PrintStream out = System.out; - private final String ns, admin, owner; - - public NSDump(AuthzTrans trans) throws APIException, IOException { - super(trans.env()); - if(args().length>0) { - ns = args()[0]; - } else { - throw new APIException("NSDump requires \"NS\" parameter"); - } - admin = ns + "|admin"; - owner = ns + "|owner"; - - TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE); - try { - session = cluster.connect(); - } finally { - tt.done(); - } - - NS.loadOne(trans, session,NS.v2_0_11,ns); - Role.loadOneNS(trans, session, ns); - if(Role.data.keySet().size()>5) { - UserRole.load(trans, session,UserRole.v2_0_11); - } else { - for(Role r : Role.data.keySet()) { - UserRole.loadOneRole(trans, session, UserRole.v2_0_11, r.fullName()); - } - } - Perm.loadOneNS(trans,session,ns); - Cred.loadOneNS(trans, session, ns); - } - - @Override - protected void run(AuthzTrans trans) { - Date now = new Date(); - for(NS ns : NS.data.values()) { - out.format("# Data for Namespace [%s] - %s\n",ns.name,ns.description); - out.format("ns create %s",ns); - boolean first = true; - List<UserRole> owners = UserRole.byRole.get(owner); - if(owners!=null)for(UserRole ur : owners) { - if(first) { - out.append(' '); - first = false; - } else { - out.append(','); - } - out.append(ur.user); - } - first = true; - List<UserRole> admins = UserRole.byRole.get(admin); - if(admins!=null)for(UserRole ur : admins) { - if(first) { - out.append(' '); - first = false; - } else { - out.append(','); - } - out.append(ur.user); - } - out.println(); - - // Load Creds - Date last; - for(Cred c : Cred.data.values()) { - for(int i : c.types()) { - last = c.last(i); - if(last!=null && now.before(last)) { - switch(i) { - case 1: - out.format(" user cred add %s %s\n", c.id,"new2you!"); - break; - case 200: - out.format(" # CERT needs registering for %s\n", c.id); - break; - default: - out.format(" # Unknown Type for %s\n", c.id); - } - } - } - } - - // Load Roles - for(Role r : Role.data.keySet()) { - if(!"admin".equals(r.name) && !"owner".equals(r.name)) { - out.format(" role create %s\n",r.fullName()); - List<UserRole> lur = UserRole.byRole.get(r.fullName()); - if(lur!=null)for(UserRole ur : lur) { - if(ur.expires.after(now)) { - out.format(" request role user add %s %s\n", ur.role,ur.user); - } - } - } - } - - // Load Perms - for(Perm r : Perm.data.keySet()) { - out.format(" perm create %s.%s %s %s\n",r.ns,r.type,r.instance,r.action); - for(String role : r.roles) { - out.format(" request perm grant %s.%s %s %s %s\n", r.ns,r.type,r.instance,r.action,Role.fullName(role)); - } - } - - } - } - - @Override - protected void _close(AuthzTrans trans) { - session.close(); - aspr.info("End " + this.getClass().getSimpleName() + " processing" ); - } - -} diff --git a/authz-batch/src/main/scripts/SyncV1V2 b/authz-batch/src/main/scripts/SyncV1V2 deleted file mode 100644 index c3a9115a..00000000 --- a/authz-batch/src/main/scripts/SyncV1V2 +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ - -cd $ROOT_DIR - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="SyncV1V2" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog diff --git a/authz-batch/src/main/scripts/SyncV1V2daily b/authz-batch/src/main/scripts/SyncV1V2daily deleted file mode 100644 index 5c89d04d..00000000 --- a/authz-batch/src/main/scripts/SyncV1V2daily +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ - -cd $ROOT_DIR - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="SyncV1V2 v1 v2" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog diff --git a/authz-batch/src/main/scripts/SyncV2V1 b/authz-batch/src/main/scripts/SyncV2V1 deleted file mode 100644 index e766218f..00000000 --- a/authz-batch/src/main/scripts/SyncV2V1 +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ - -cd $ROOT_DIR - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="SyncV2V1" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog
\ No newline at end of file diff --git a/authz-batch/src/main/scripts/SyncV2V1daily b/authz-batch/src/main/scripts/SyncV2V1daily deleted file mode 100644 index 8a676928..00000000 --- a/authz-batch/src/main/scripts/SyncV2V1daily +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ - -cd $ROOT_DIR - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="SyncV2V1 v2 v1" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog
\ No newline at end of file diff --git a/authz-batch/src/main/scripts/V1daily b/authz-batch/src/main/scripts/V1daily deleted file mode 100644 index 9f6c4ca9..00000000 --- a/authz-batch/src/main/scripts/V1daily +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ -ENV_CONTEXT=_ENV_CONTEXT_ - -cd $ROOT_DIR - -if [ ! -e "$ROOT_DIR/data/stage" ]; then - mkdir -p $ROOT_DIR/data/stage -fi - -if [ ! -e "$ROOT_DIR/data/$ENV_CONTEXT/stage" ]; then - mkdir -p $ROOT_DIR/data/$ENV_CONTEXT - ln -s $ROOT_DIR/data/stage $ROOT_DIR/data/$ENV_CONTEXT/stage -fi - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="V1DataFile all" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog - -cd $ROOT_DIR/data/stage -LATEST=`ls -tr v1*.dat | tail -1` -if [ "$LATEST" != "" ]; then - > ../v1.lock - cp -p $LATEST ../v1.dat - rm ../v1.lock -fi - -LATEST=`ls -tr v1*.skip | tail -1` -if [ "$LATEST" != "" ]; then - cp -p $LATEST ../v1.skip -fi - -for FILE in `ls v1* | grep -v .gz`; do - gzip $FILE -done - - diff --git a/authz-batch/src/main/scripts/V2daily b/authz-batch/src/main/scripts/V2daily deleted file mode 100644 index c547a949..00000000 --- a/authz-batch/src/main/scripts/V2daily +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ -ENV_CONTEXT=_ENV_CONTEXT_ - -cd $ROOT_DIR - -if [ ! -e "$ROOT_DIR/data/stage" ]; then - mkdir -p $ROOT_DIR/data/stage -fi - -if [ ! -e "$ROOT_DIR/data/$ENV_CONTEXT/stage" ]; then - mkdir -p $ROOT_DIR/data/$ENV_CONTEXT - ln -s $ROOT_DIR/data/stage $ROOT_DIR/data/$ENV_CONTEXT/stage -fi - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -CMD="V2DataFile all" -echo $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP com.att.authz.Batch $CMD >> $ROOT_DIR/cronlog -date >> $ROOT_DIR/cronlog - -cd $ROOT_DIR/data/stage -LATEST=`ls -tr v2*.dat | tail -1` -if [ "$LATEST" != "" ]; then - > ../v2.lock - cp -p $LATEST ../v2.dat - rm ../v2.lock -fi - -LATEST=`ls -tr v2*.skip | tail -1` -if [ "$LATEST" != "" ]; then - cp -p $LATEST ../v2.skip -fi - -for FILE in `ls v2* | grep -v .gz`; do - gzip $FILE -done - - diff --git a/authz-batch/src/main/scripts/aafbch b/authz-batch/src/main/scripts/aafbch deleted file mode 100644 index fdeb22ea..00000000 --- a/authz-batch/src/main/scripts/aafbch +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -JAVA_HOME=_JAVA_HOME_ -PATH=${PATH}:${JAVA_HOME}/bin -ROOT_DIR=_ROOT_DIR_ -cd $ROOT_DIR - -if [ "$1" = "InnerConsistency" ]; then - CLS=com.att.authz.temp.InnerConsistency - shift -else - CLS=com.att.authz.Batch -fi - -CP=${ROOT_DIR}/etc -for FILE in `ls $ROOT_DIR/lib/*.jar`; do - CP=$CP:$FILE -done - -date -$JAVA_HOME/bin/java -Xmx2048m -classpath $CP $CLS $* -date diff --git a/authz-batch/src/main/scripts/run_batch b/authz-batch/src/main/scripts/run_batch deleted file mode 100644 index c09ea0a3..00000000 --- a/authz-batch/src/main/scripts/run_batch +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/env bash - -if [[ $# < 1 ]]; then - echo "USAGE: run_batch ExpiryNotification|ApprNotify|JobChange|RoleExpiration|ValidateUsers" - exit 1; -fi - -JAVA_HOME=_JAVA_HOME_ -AAF_CP="_ROOT_DIR_/etc" -for JAR in `find _ROOT_DIR_/lib -name *.jar` ; do - AAF_CP="$AAF_CP:$JAR" -done - -$JAVA_HOME/bin/java -cp $AAF_CP com.att.authz.Batch $* - - diff --git a/authz-test/TestSuite/Instructions_for_MTCs/MTC_Appr_README.txt b/authz-test/TestSuite/Instructions_for_MTCs/MTC_Appr_README.txt deleted file mode 100644 index d7ecee45..00000000 --- a/authz-test/TestSuite/Instructions_for_MTCs/MTC_Appr_README.txt +++ /dev/null @@ -1,101 +0,0 @@ -#-------------------------------------------------------------------------------
-# ============LICENSE_START====================================================
-# * org.onap.aaf
-# * ===========================================================================
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# * ===========================================================================
-# * 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====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-NOTE: You may find slight differences between this readme doc and your actual output in places such as <YOUR_ATTUID>, times, or other such fields that vary for each run.
-
-Do NOT replace anything inside square brackets such as [user.name] Some commands listed here use this notation, but they are set up to work by just copying & pasting the entire command.
-
-run command: sh ./tc MTC_Appr1
-you should see: MTC_Appr1
- SUCCESS! [MTC_Appr1.2014-11-03_11-26-26]
-
-
-open a broswer and goto the gui for the machine you're on. For example, this is the home page on test machine zltv1492:
-https://zltv1492.vci.att.com:8085/gui/home
-
-click on My Approvals
-
-click the submit button at the bottom of the form with no approve or deny buttons selected
-
-you should see: No Approvals have been sent. Try again
-
-click "Try again" link
-
-you should see: The Approval Request page
-
-NOTE: a radio button is a (filled or unfilled) circle under approve or deny
-click the select all link for approve
-
-you should see: all radio buttons under approve should be selected
-
-click the select all link for deny
-
-you should see: all radio buttons under deny should be selected
-
-click the reset button at the bottom of the form
-
-you should see: NO radio buttons should be selected
-
-Try to select both approve and deny for a single entry
-
-you should: not be able to
-
-approve or deny entries as you like, then click submit
-
-after you have submitted all approvals, go back to My Approvals page
-
-you should see: No Approvals to process at this time
-
-in your command line,
-run command: aafcli ns list name com.test.appr.@[user.name].myProject
-
-NOTE: what you see here will depend on which entries you approved and denied. Included are 2 examples of what you can see:
-
-1) If you approve everything
-
-List Namespaces by Name[com.test.appr.<YOUR_ATTUID>.myProject]
---------------------------------------------------------------------------------
-com.test.appr.<YOUR_ATTUID>.myProject
- Administrators
- <YOUR_ATTUID>@csp.att.com
- Responsible Parties
- <YOUR_ATTUID>@csp.att.com
-
-
-2) If you deny everything
-
-List Namespaces by Name[com.test.appr.<YOUR_ATTUID>.myProject]
---------------------------------------------------------------------------------
-
-
-run command: sh ./tc MTC_Appr2 dryrun
-you should see: a lot of output. It's fine if you see errors for this command.
-
-run command: aafcli ns list name com.test.appr
-you should see: List Namespaces by Name[com.test.appr]
---------------------------------------------------------------------------------
-
-
-run command: aafcli ns list name com.test.appr.@[user.name]
-you should see: List Namespaces by Name[com.test.appr.<YOUR_ATTUID>]
---------------------------------------------------------------------------------
-
diff --git a/authz-test/TestSuite/JU_Lur2_0/10_init b/authz-test/TestSuite/JU_Lur2_0/10_init deleted file mode 100644 index a38e94bf..00000000 --- a/authz-test/TestSuite/JU_Lur2_0/10_init +++ /dev/null @@ -1,34 +0,0 @@ -as testid@aaf.att.com:<pass> -# JU_Lur2_0.10.0.POS List NS to prove ok -expect 201,409 -ns create com.test.JU_Lur2_0Call @[user.name] testid@aaf.att.com - -# JU_Lur2_0.10.2.POS Create Role in Namespace -role create com.test.JU_Lur2_0Call.role - -# JU_Lur2_0.10.10.POS Create MyInstance Perms -perm create com.test.JU_Lur2_0Call.service myInstance write -perm create com.test.JU_Lur2_0Call.service myInstance read -perm create com.test.JU_Lur2_0Call.service myInstance * - -# JU_Lur2_0.10.11.POS Create kumquat Perms -perm create com.test.JU_Lur2_0Call.service kumquat write -perm create com.test.JU_Lur2_0Call.service kumquat read -perm create com.test.JU_Lur2_0Call.service kumquat * -perm create com.test.JU_Lur2_0Call.service kum.quat read - -# JU_Lur2_0.10.11.POS Create key delimited Perms -perm create com.test.JU_Lur2_0Call.service :myCluster write -perm create com.test.JU_Lur2_0Call.service :myCluster:myKeyspace write -perm create com.test.JU_Lur2_0Call.service :myCluster:myKeyspace:myCF write -perm create com.test.JU_Lur2_0Call.service :myCluster:*:myCF write -perm create com.test.JU_Lur2_0Call.service :myCluster:myKeyspace:* write - -# JU_Lur2_0.10.20.POS Grant Some Perms to Role -perm grant com.test.JU_Lur2_0Call.service myInstance * com.test.JU_Lur2_0Call.role -perm grant com.test.JU_Lur2_0Call.service kumquat read com.test.JU_Lur2_0Call.role -perm grant com.test.JU_Lur2_0Call.service kum.quat read com.test.JU_Lur2_0Call.role -perm grant com.test.JU_Lur2_0Call.service :myCluster:*:myCF write com.test.JU_Lur2_0Call.role - -# JU_Lur2_0.30.1.POS Add User to ROle -user role add testid@aaf.att.com com.test.JU_Lur2_0Call.role diff --git a/authz-test/TestSuite/JU_Lur2_0/Description b/authz-test/TestSuite/JU_Lur2_0/Description deleted file mode 100644 index 748dc675..00000000 --- a/authz-test/TestSuite/JU_Lur2_0/Description +++ /dev/null @@ -1,2 +0,0 @@ -Load Data for CADI Test: JU_Lur2_0Call.java - diff --git a/authz-test/TestSuite/MTC_Appr1/00_ids b/authz-test/TestSuite/MTC_Appr1/00_ids deleted file mode 100644 index e5c040ea..00000000 --- a/authz-test/TestSuite/MTC_Appr1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set XX@NS=<pass> -set testunused@aaf.att.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/MTC_Appr1/10_init b/authz-test/TestSuite/MTC_Appr1/10_init deleted file mode 100644 index f1c61cec..00000000 --- a/authz-test/TestSuite/MTC_Appr1/10_init +++ /dev/null @@ -1,29 +0,0 @@ - -as testid@aaf.att.com - -# TC_Appr1.10.0.POS List NS to prove ok -expect 200 -ns list name com.test.appr -ns list name com.test.appr.@[user.name] - -# TC_Appr1.10.1.POS Create Personalized Namespace to add Approvals -expect 201 -ns create com.test.appr.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Appr1.10.2.POS Create General Namespace to add Approvals -ns create com.test.appr @[user.name] testid@aaf.att.com - -# TC_Appr1.10.10.POS Create Roles in Namespace -role create com.test.appr.@[user.name].addToUserRole -role create com.test.appr.@[user.name].grantToPerm -role create com.test.appr.@[user.name].ungrantFromPerm -role create com.test.appr.@[user.name].grantFirstPerm -role create com.test.appr.@[user.name].grantSecondPerm - -# TC_Appr1.10.12.POS Create Permissions in Namespace -perm create com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm -perm create com.test.appr.@[user.name].grantToRole myInstance myAction -force perm create com.test.appr.@[user.name].deleteThisPerm myInstance myAction com.test.appr.@[user.name].grantedRole -perm create com.test.appr.@[user.name].grantTwoRoles myInstance myAction -perm create com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm - diff --git a/authz-test/TestSuite/MTC_Appr1/15_create b/authz-test/TestSuite/MTC_Appr1/15_create deleted file mode 100644 index 8791a3b5..00000000 --- a/authz-test/TestSuite/MTC_Appr1/15_create +++ /dev/null @@ -1,40 +0,0 @@ -expect 403 -as testunused@aaf.att.com - -# TC_Appr1.15.01.NEG Create Future and Approvals with non-admin request -user role add @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].addToUserRole - -# TC_Appr1.15.02.NEG Create Approval for NS create -ns create com.test.appr.@[user.name].myProject @[user.name] - -# TC_Appr1.15.03.NEG Generate Approval for granting permission to role -perm grant com.test.appr.@[user.name].grantToRole myInstance myAction com.test.appr.@[user.name].grantToPerm - -# TC_Appr1.15.04.NEG Generate Approval for ungranting permission from role -perm ungrant com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm - -# TC_Appr1.15.05.NEG Generate Approval for granting permission to role -perm grant com.test.appr.@[user.name].grantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm - -# TC_Appr1.15.06.NEG Generate Approval for ungranting permission from role -perm ungrant com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm - -expect 202 -# TC_Appr1.15.51.POS Create Future and Approvals with non-admin request -set request=true user role add @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].addToUserRole - -# TC_Appr1.15.52.POS Create Approval for NS create -set request=true ns create com.test.appr.@[user.name].myProject @[user.name] - -# TC_Appr1.15.53.POS Generate Approval for granting permission to role -set request=true perm grant com.test.appr.@[user.name].grantToRole myInstance myAction com.test.appr.@[user.name].grantToPerm - -# TC_Appr1.15.54.POS Generate Approval for ungranting permission from role -request perm ungrant com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm - -# TC_Appr1.15.55.POS Generate Approval for granting permission to role -request perm grant com.test.appr.@[user.name].grantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm - -# TC_Appr1.15.56.POS Generate Approval for ungranting permission from role -request perm ungrant com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm - diff --git a/authz-test/TestSuite/MTC_Appr1/Description b/authz-test/TestSuite/MTC_Appr1/Description deleted file mode 100644 index 59af5e1d..00000000 --- a/authz-test/TestSuite/MTC_Appr1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user addCred :user :password - user delCred :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/MTC_Appr2/00_ids b/authz-test/TestSuite/MTC_Appr2/00_ids deleted file mode 100644 index e5c040ea..00000000 --- a/authz-test/TestSuite/MTC_Appr2/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set XX@NS=<pass> -set testunused@aaf.att.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/MTC_Appr2/99_cleanup b/authz-test/TestSuite/MTC_Appr2/99_cleanup deleted file mode 100644 index 4d6fa758..00000000 --- a/authz-test/TestSuite/MTC_Appr2/99_cleanup +++ /dev/null @@ -1,35 +0,0 @@ - -as testid@aaf.att.com - -expect 200,404 - -# TC_Appr2.99.10.POS Delete UserRoles if exists -user role del @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].deleteThisRole -user role del @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].addToUserRole - -# TC_Appr2.10.11.POS Delete Roles if exists -set force=true role delete com.test.appr.@[user.name].addToUserRole -set force=true role delete com.test.appr.@[user.name].grantToPerm -set force=true role delete com.test.appr.@[user.name].ungrantFromPerm -role delete com.test.appr.@[user.name].grantedRole -role delete com.test.appr.@[user.name].approvedRole -role delete com.test.appr.@[user.name].approvedRole2 -role delete com.test.appr.@[user.name].grantFirstPerm -role delete com.test.appr.@[user.name].grantSecondPerm - -# TC_Appr2.10.12.POS Delete Permissions if exists -perm delete com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].grantedRole -perm delete com.test.appr.@[user.name].grantToRole myInstance myAction -perm delete com.test.appr.@[user.name].deleteThisPerm myInstance myAction com.test.appr.@[user.name].grantedRole -perm delete com.test.appr.@[user.name].approvedPerm myInstance myAction -perm delete com.test.appr.@[user.name].approvedPerm * * -perm delete com.test.appr.@[user.name].approvedPerm2 myInstance myAction -perm delete com.test.appr.@[user.name].grantTwoRoles myInstance myAction -perm delete com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction - - -# TC_Appr2.99.80.POS Delete Namespaces for TestSuite if exists -ns delete com.test.appr.@[user.name].myProject -set force=true ns delete com.test.appr.@[user.name] -set force=true ns delete com.test.appr - diff --git a/authz-test/TestSuite/MTC_Appr2/Description b/authz-test/TestSuite/MTC_Appr2/Description deleted file mode 100644 index 59af5e1d..00000000 --- a/authz-test/TestSuite/MTC_Appr2/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user addCred :user :password - user delCred :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/TC_Cred1/00_ids b/authz-test/TestSuite/TC_Cred1/00_ids deleted file mode 100644 index 9f6ad902..00000000 --- a/authz-test/TestSuite/TC_Cred1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus=boguspass -set XX@NS=<pass> - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Cred1/10_init b/authz-test/TestSuite/TC_Cred1/10_init deleted file mode 100644 index 18231c0d..00000000 --- a/authz-test/TestSuite/TC_Cred1/10_init +++ /dev/null @@ -1,36 +0,0 @@ -as testid@aaf.att.com -# TC_Cred1.10.0.POS List NS to prove ok -expect 200 -ns list name com.test.TC_Cred1.@[user.name] - -# TC_Cred1.10.1.POS Create Personalized Namespace to add Credentials -expect 201 -ns create com.test.TC_Cred1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Cred1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_Cred1.@[user.name].cred_admin testid@aaf.att.com -role create com.test.TC_Cred1.@[user.name].pw_reset - -# TC_Cred1.10.11.POS Assign roles to perms -as XX@NS -expect 201 -perm create com.att.aaf.password com.test reset com.test.TC_Cred1.@[user.name].pw_reset -perm create com.att.aaf.mechid com.test create com.test.TC_Cred1.@[user.name].cred_admin -perm grant com.att.aaf.mechid com.att create com.test.TC_Cred1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_Cred1.10.30.POS Assign user for creating creds -expect 201 -user cred add m99999@@[user.name].TC_Cred1.test.com password123 -set m99999@@[user.name].TC_Cred1.test.com=password123 - - -# TC_Cred1.10.31.POS Credential used to similate non-admin Tier1 user with reset and create permissions -expect 201 -user role add m99999@@[user.name].TC_Cred1.test.com com.test.TC_Cred1.@[user.name].pw_reset,com.test.TC_Cred1.@[user.name].cred_admin - -# TC_Cred1.10.32.POS Remove create rights for testing -expect 200 -user role del testid@aaf.att.com com.test.TC_Cred1.@[user.name].cred_admin - diff --git a/authz-test/TestSuite/TC_Cred1/15_create b/authz-test/TestSuite/TC_Cred1/15_create deleted file mode 100644 index c862d980..00000000 --- a/authz-test/TestSuite/TC_Cred1/15_create +++ /dev/null @@ -1,33 +0,0 @@ -# TC_Cred1.15.1.NEG Non-Admin, no permission user cannot create mechID -as testunused@aaf.att.com -expect 403 -user cred add m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.15.3.POS Non-Admin, with create permission user can create mechID -as m99999@@[user.name].TC_Cred1.test.com -expect 201 -user cred add m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.15.10.NEG Non-Admin, no reset permission cannot reset mechID -as testunused@aaf.att.com -expect 403 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.15.11.POS Non-Admin, with reset permission can reset mechID -as m99999@@[user.name].TC_Cred1.test.com:password123 -expect 200 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.15.12.POS Admin, without reset permission can reset Password -as testid@aaf.att.com -expect 200 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.15.15.POS Admin, without reset permission can reset mechID -expect 200 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 1 - -# TC_Cred1.15.20.POS Admin, delete -expect 200 -user cred del m99990@@[user.name].TC_Cred1.test.com password123 1 - diff --git a/authz-test/TestSuite/TC_Cred1/30_multiple_creds b/authz-test/TestSuite/TC_Cred1/30_multiple_creds deleted file mode 100644 index 689225e2..00000000 --- a/authz-test/TestSuite/TC_Cred1/30_multiple_creds +++ /dev/null @@ -1,69 +0,0 @@ -# TC_Cred1.30.1.NEG Multiple options available to delete -as XX@NS -expect 201 -user cred add m99990@@[user.name].TC_Cred1.test.com pass23Word - -as testid@aaf.att.com -expect 201 -user cred add m99990@@[user.name].TC_Cred1.test.com pass23worD - -# TC_Cred1.30.2.POS Succeeds when we choose last option -expect 200 -user cred del m99990@@[user.name].TC_Cred1.test.com 2 - -# TC_Cred1.30.10.POS Add another credential -expect 201 -user cred add m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.30.11.NEG Multiple options available to reset -expect 300 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 - -# TC_Cred1.30.12.NEG Fails when we choose a bad option -expect 406 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 0 - -# TC_Cred1.30.13.POS Succeeds when we choose last option -expect 200 -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 2 - -#TC_Cred1.30.30.NEG Fails when we don't have specific property -expect 403 -user cred extend m99990@@[user.name].TC_Cred1.test.com - -#### EXTENDS behavior #### -#TC_Cred1.30.32.POS Setup Temp Role for Extend Permission -expect 201 -as XX@NS -role create com.test.TC_Cred1.@[user.name].extendTemp - -#TC_Cred1.30.33.POS Grant Extends Permission to Role -expect 201 -perm grant com.att.aaf.password com.att extend com.test.TC_Cred1.@[user.name].extendTemp - -#TC_Cred1.30.35.POS Add current User to Temp Role for Extend Permission -expect 201 -role user add com.test.TC_Cred1.@[user.name].extendTemp XX@NS - -#TC_Cred1.30.36.POS Extend Password, expecting Single Response -expect 200 -user cred extend m99990@@[user.name].TC_Cred1.test.com 1 - -#TC_Cred1.30.39.POS Remove Role -expect 200 -set force=true -role delete com.test.TC_Cred1.@[user.name].extendTemp - -#### MULTI CLEANUP ##### -expect 200 -role list user m99990@@[user.name].TC_Cred1.test.com - -# TC_Cred1.30.80.POS Delete all entries for this cred -expect 200 -set force=true -user cred del m99990@@[user.name].TC_Cred1.test.com - -# TC_Cred1.30.99.POS List ns shows no creds attached -expect 200 -ns list name com.test.TC_Cred1.@[user.name] - diff --git a/authz-test/TestSuite/TC_Cred1/99_cleanup b/authz-test/TestSuite/TC_Cred1/99_cleanup deleted file mode 100644 index 3af41749..00000000 --- a/authz-test/TestSuite/TC_Cred1/99_cleanup +++ /dev/null @@ -1,29 +0,0 @@ -as testid@aaf.att.com -# TC_Cred1.99.1.POS Delete credentials -expect 200,404 -force user cred del m99990@@[user.name].TC_Cred1.test.com - -#TC_Cred1.99.2.POS Ensure Remove Role -expect 200,404 -set force=true -role delete com.test.TC_Cred1.@[user.name].extendTemp - -# TC_Cred1.99.10.POS Remove ability to create creds -force user role del testid@aaf.att.com com.test.TC_Cred1.@[user.name].cred_admin - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Cred1.@[user.name].cred_admin -force perm delete com.att.aaf.password com.test reset -force perm delete com.att.aaf.mechid com.test create - -as testid@aaf.att.com -force role delete com.test.TC_Cred1.@[user.name].cred_admin -force role delete com.test.TC_Cred1.@[user.name].pw_reset - -# TC_Cred1.99.99.POS Delete Namespace for TestSuite -set force=true ns delete com.test.TC_Cred1.@[user.name] - -as XX@NS -force ns delete com.test.TC_Cred1.@[user.name] -force ns delete com.test.TC_Cred1 - diff --git a/authz-test/TestSuite/TC_Cred1/Description b/authz-test/TestSuite/TC_Cred1/Description deleted file mode 100644 index 59af5e1d..00000000 --- a/authz-test/TestSuite/TC_Cred1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user addCred :user :password - user delCred :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/TC_DELG1/00_ids b/authz-test/TestSuite/TC_DELG1/00_ids deleted file mode 100644 index 0f77e593..00000000 --- a/authz-test/TestSuite/TC_DELG1/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set m99999@@[user.name].delg.test.com=password123 -set bogus@aaf.att.com=boguspass - -#delay 10 -set NFR=0 - diff --git a/authz-test/TestSuite/TC_DELG1/10_init b/authz-test/TestSuite/TC_DELG1/10_init deleted file mode 100644 index 558effe0..00000000 --- a/authz-test/TestSuite/TC_DELG1/10_init +++ /dev/null @@ -1,55 +0,0 @@ -# TC_DELG1.10.1.POS Check For Existing Data -as testid@aaf.att.com -expect 200 -ns list name com.test.delg.@[user.name] - -as XX@NS -expect 201,409 -perm create com.att.aaf.delg com.att * com.att.admin - -expect 404 -user list delegates delegate @[user.name]@csp.att.com - -as testid@aaf.att.com -# TC_DELG1.10.2.POS Create Namespace to add IDs -expect 201 -ns create com.test.delg.@[user.name] @[user.name] testid@aaf.att.com - -as XX@NS -# TC_DELG1.10.10.POS Grant ability to change delegates -expect 404 -force perm grant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg - -# TC_DELG1.10.11.POS Grant ability to change delegates -expect 201 -role create com.test.delg.@[user.name].change_delg - -# TC_DELG1.10.12.POS Grant ability to change delegates -expect 201 -force perm grant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg - -# TC_DELG1.10.14.POS Create user role to change delegates -expect 201 -user role add testid@aaf.att.com com.test.delg.@[user.name].change_delg - -# TC_DELG1.10.15.POS Grant ability to create cred -expect 201 -perm grant com.att.aaf.delg com.att create com.test.delg.@[user.name].change_delg - -as testid@aaf.att.com -# TC_DELG1.10.30.POS Create cred that will change his own delg -expect 201 -user cred add m99999@@[user.name].delg.test.com password123 - -as XX@NS - TC_DELG1.10.31.POS ungrant ability to create cred -expect 200 -perm ungrant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg - -as testid@aaf.att.com -# TC_DELG1.10.99.POS Check for Data as Correct -expect 200 -ns list name com.test.delg.@[user.name] - - - diff --git a/authz-test/TestSuite/TC_DELG1/20_create b/authz-test/TestSuite/TC_DELG1/20_create deleted file mode 100644 index 2dec8bf3..00000000 --- a/authz-test/TestSuite/TC_DELG1/20_create +++ /dev/null @@ -1,55 +0,0 @@ -# TC_DELG1.20.10.NEG Cannot create delegate with unknown user ID -expect 404 -user delegate add aa111q@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -# TC_DELG1.20.11.NEG Cannot Create Delegate with unknown delegate -expect 404 -user delegate add @[user.name]@csp.att.com aa111q@csp.att.com '2099-12-31 06:00' - -# TC_DELG1.20.20.NEG May not change user, no delegate permission -as m99999@@[user.name].delg.test.com -expect 403 -force user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -as testid@aaf.att.com -# TC_DELG1.20.21.NEG Fail to Update Delegate that doesnt exist -expect 404 -user delegate upd @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -# TC_DELG1.20.22.NEG May not create delegate for self. -expect 406 -user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -# TC_DELG1.20.23.POS May create delegate for self for tests by forcing. -expect 201 -force user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -as XX@NS -# TC_DELG1.20.30.POS Expect Delegates for User -expect 200 -user list delegates user @[user.name]@csp.att.com - -as testid@aaf.att.com -# TC_DELG1.20.35.NEG Fail Create when exists -expect 409 -user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' - -as XX@NS -# TC_DELG1.20.40.POS Expect Delegates for User -expect 200 -user list delegates user @[user.name]@csp.att.com - -as testid@aaf.att.com -# TC_DELG1.20.46.POS Update Delegate with new Date -expect 200 -user delegate upd @[user.name]@csp.att.com @[user.name]@csp.att.com '2999-01-01 06:00' - -as XX@NS -# TC_DELG1.20.82.POS Expect Delegates for User -expect 200 -user list delegates user @[user.name]@csp.att.com - -# TC_DELG1.20.83.POS Expect Delegate to show up in list -expect 200 -user list delegates delegate @[user.name]@csp.att.com - diff --git a/authz-test/TestSuite/TC_DELG1/99_cleanup b/authz-test/TestSuite/TC_DELG1/99_cleanup deleted file mode 100644 index 81dfd74e..00000000 --- a/authz-test/TestSuite/TC_DELG1/99_cleanup +++ /dev/null @@ -1,17 +0,0 @@ -expect 200,404 -as XX@NS -# TC_DELG1.99.0.POS Check for Data as Correct -ns list name com.test.delg.@[user.name] - -# TC_DELG1.99.10.POS Delete Delegates -user delegate del @[user.name]@csp.att.com - -# TC_DELG1.99.30.POS Delete Namespace com.att.test.id -force ns delete com.test.delg.@[user.name] - -# TC_DELG1.99.98.POS Check for Delegate Data as Correct -user list delegates user @[user.name]@csp.att.com - -# TC_DELG1.99.99.POS Check for NS Data as Correct -ns list name com.test.delg.@[user.name] - diff --git a/authz-test/TestSuite/TC_DELG1/Description b/authz-test/TestSuite/TC_DELG1/Description deleted file mode 100644 index 59af5e1d..00000000 --- a/authz-test/TestSuite/TC_DELG1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user addCred :user :password - user delCred :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/TC_Link/00_ids b/authz-test/TestSuite/TC_Link/00_ids deleted file mode 100644 index 0e7a40aa..00000000 --- a/authz-test/TestSuite/TC_Link/00_ids +++ /dev/null @@ -1,9 +0,0 @@ -expect 0 -set testid=<pass> -set testid@aaf.att.com=<pass> -set XX@NS=<pass> -set testunused=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Link/05_print b/authz-test/TestSuite/TC_Link/05_print deleted file mode 100644 index 62d8e256..00000000 --- a/authz-test/TestSuite/TC_Link/05_print +++ /dev/null @@ -1,6 +0,0 @@ -expect 200,404 -# TC_05 -ns list name com.test.TC_Link_1.@[user.name] -ns list name com.test.TC_Link_2.@[user.name] -perm list role com.test.TC_Link_1.@[user.name].myRole -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction diff --git a/authz-test/TestSuite/TC_Link/10_init b/authz-test/TestSuite/TC_Link/10_init deleted file mode 100644 index 0f8a4431..00000000 --- a/authz-test/TestSuite/TC_Link/10_init +++ /dev/null @@ -1,13 +0,0 @@ -expect 201 -# TC_10 -as XX@NS -ns create com.test.TC_Link_1.@[user.name] @[user.name] XX@NS -ns create com.test.TC_Link_2.@[user.name] @[user.name] XX@NS - -role create com.test.TC_Link_1.@[user.name].myRole - -perm create com.test.TC_Link_2.@[user.name].myPerm myInstance myAction - -perm grant com.test.TC_Link_2.@[user.name].myPerm myInstance myAction com.test.TC_Link_1.@[user.name].myRole - - diff --git a/authz-test/TestSuite/TC_Link/15_print b/authz-test/TestSuite/TC_Link/15_print deleted file mode 100644 index ac60ddcc..00000000 --- a/authz-test/TestSuite/TC_Link/15_print +++ /dev/null @@ -1,6 +0,0 @@ -# 15_print -expect 200 -ns list name com.test.TC_Link_1.@[user.name] -ns list name com.test.TC_Link_2.@[user.name] -perm list role com.test.TC_Link_1.@[user.name].myRole -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction diff --git a/authz-test/TestSuite/TC_Link/20_del b/authz-test/TestSuite/TC_Link/20_del deleted file mode 100644 index 35a01d39..00000000 --- a/authz-test/TestSuite/TC_Link/20_del +++ /dev/null @@ -1,3 +0,0 @@ -expect 200 -role delete com.test.TC_Link_1.@[user.name].myRole - diff --git a/authz-test/TestSuite/TC_Link/25_print b/authz-test/TestSuite/TC_Link/25_print deleted file mode 100644 index ac60ddcc..00000000 --- a/authz-test/TestSuite/TC_Link/25_print +++ /dev/null @@ -1,6 +0,0 @@ -# 15_print -expect 200 -ns list name com.test.TC_Link_1.@[user.name] -ns list name com.test.TC_Link_2.@[user.name] -perm list role com.test.TC_Link_1.@[user.name].myRole -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction diff --git a/authz-test/TestSuite/TC_Link/30_readd b/authz-test/TestSuite/TC_Link/30_readd deleted file mode 100644 index 69bfb22a..00000000 --- a/authz-test/TestSuite/TC_Link/30_readd +++ /dev/null @@ -1,5 +0,0 @@ -expect 201 -role create com.test.TC_Link_1.@[user.name].myRole - -perm grant com.test.TC_Link_2.@[user.name].myPerm myInstance myAction com.test.TC_Link_1.@[user.name].myRole - diff --git a/authz-test/TestSuite/TC_Link/35_print b/authz-test/TestSuite/TC_Link/35_print deleted file mode 100644 index ac60ddcc..00000000 --- a/authz-test/TestSuite/TC_Link/35_print +++ /dev/null @@ -1,6 +0,0 @@ -# 15_print -expect 200 -ns list name com.test.TC_Link_1.@[user.name] -ns list name com.test.TC_Link_2.@[user.name] -perm list role com.test.TC_Link_1.@[user.name].myRole -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction diff --git a/authz-test/TestSuite/TC_Link/99_delete b/authz-test/TestSuite/TC_Link/99_delete deleted file mode 100644 index 8dfcd17b..00000000 --- a/authz-test/TestSuite/TC_Link/99_delete +++ /dev/null @@ -1,5 +0,0 @@ -as XX@NS:<pass> - -expect 200,404 -force ns delete com.test.TC_Link_2.@[user.name] -force ns delete com.test.TC_Link_1.@[user.name] diff --git a/authz-test/TestSuite/TC_Link/Description b/authz-test/TestSuite/TC_Link/Description deleted file mode 100644 index 3abdcad3..00000000 --- a/authz-test/TestSuite/TC_Link/Description +++ /dev/null @@ -1,9 +0,0 @@ -This Testcase Tests the essentials of Grants - -APIs: - - -CLI: - Target - Ancillary - diff --git a/authz-test/TestSuite/TC_NS1/00_ids b/authz-test/TestSuite/TC_NS1/00_ids deleted file mode 100644 index 26c5db24..00000000 --- a/authz-test/TestSuite/TC_NS1/00_ids +++ /dev/null @@ -1,9 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus@aaf.att.com=boguspass - -#delay 10 -set NFR=0 - - diff --git a/authz-test/TestSuite/TC_NS1/01_ERR_BadData b/authz-test/TestSuite/TC_NS1/01_ERR_BadData deleted file mode 100644 index 09b3b949..00000000 --- a/authz-test/TestSuite/TC_NS1/01_ERR_BadData +++ /dev/null @@ -1,14 +0,0 @@ - -as testid@aaf.att.com -# TC_NS1.01.0.POS Expect Clean Namespace to start -expect 200 -ns list name com.test.TC_NS1.@[user.name] - -# TC_NS1.01.1.NEG Create Namespace with mechID as Responsible Party -expect 403 -ns create com.test.TC_NS1.@[user.name] testunused@aaf.att.com testid@aaf.att.com,XX@NS - -# TC_NS1.01.2.NEG Create Namespace with Bad ID for Admin -expect 403 -ns create com.test.TC_NS1.@[user.name] @[user.name] bogus@aaf.att.com,XX@NS - diff --git a/authz-test/TestSuite/TC_NS1/10_init b/authz-test/TestSuite/TC_NS1/10_init deleted file mode 100644 index b05be769..00000000 --- a/authz-test/TestSuite/TC_NS1/10_init +++ /dev/null @@ -1,30 +0,0 @@ - -as testid@aaf.att.com -# TC_NS1.10.0.POS Check for Existing Data -expect 200 -ns list name com.test.TC_NS1.@[user.name] - -# TC_NS1.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_NS1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_NS1.10.40.POS Expect Namespace to be created -expect 200 -ns list name com.test.TC_NS1.@[user.name] - -# TC_NS1.10.41.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS1.@[user.name].admin - -# TC_NS1.10.42.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS1.@[user.name].owner - -# TC_NS1.10.43.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS1.@[user.name].access * * - -# TC_NS1.10.44.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS1.@[user.name].access * read - diff --git a/authz-test/TestSuite/TC_NS1/11_ERR_Namespace_Exists b/authz-test/TestSuite/TC_NS1/11_ERR_Namespace_Exists deleted file mode 100644 index b6aa5080..00000000 --- a/authz-test/TestSuite/TC_NS1/11_ERR_Namespace_Exists +++ /dev/null @@ -1,4 +0,0 @@ -# TC_NS1.11.1.NEG Create Namespace when exists -expect 409 -ns create com.test.TC_NS1.@[user.name] @[user.name] testid@aaf.att.com - diff --git a/authz-test/TestSuite/TC_NS1/20_Commands b/authz-test/TestSuite/TC_NS1/20_Commands deleted file mode 100644 index b53750a1..00000000 --- a/authz-test/TestSuite/TC_NS1/20_Commands +++ /dev/null @@ -1,7 +0,0 @@ -# TC_NS1.20.1.NEG Too Few Args for Create 1 -expect Exception -ns create - -# TC_NS1.20.2.NEG Too Few Args for Create 2 -expect Exception -ns create bogus diff --git a/authz-test/TestSuite/TC_NS1/30_add_data b/authz-test/TestSuite/TC_NS1/30_add_data deleted file mode 100644 index 830b9658..00000000 --- a/authz-test/TestSuite/TC_NS1/30_add_data +++ /dev/null @@ -1,14 +0,0 @@ -# TC_NS1.30.10.NEG Non-admins can't change description -expect 403 -as testunused@aaf.att.com -ns describe com.test.TC_NS1.@[user.name] Description for my Namespace - -# TC_NS1.30.11.NEG Namespace must exist to change description -expect 404 -as testid@aaf.att.com -ns describe com.test.TC_NS1.@[user.name].project1 Description for my project - -# TC_NS1.30.12.POS Admin can change description -expect 200 -ns describe com.test.TC_NS1.@[user.name] Description for my Namespace - diff --git a/authz-test/TestSuite/TC_NS1/50_Admin b/authz-test/TestSuite/TC_NS1/50_Admin deleted file mode 100644 index 78df9cc8..00000000 --- a/authz-test/TestSuite/TC_NS1/50_Admin +++ /dev/null @@ -1,49 +0,0 @@ -# TC_NS1.50.1.NEG Adding a Bogus ID -expect 403 -ns admin add com.test.TC_NS1.@[user.name] bogus - -# TC_NS1.50.2.NEG Adding a Bogus ID, full Domain -expect 403 -ns admin add com.test.TC_NS1.@[user.name] bogus@csp.att.com - -# TC_NS1.50.3.NEG Adding an OK ID, bad domain -expect 403 -ns admin add com.test.TC_NS1.@[user.name] xz9914@bogus.test.com - -# TC_NS1.50.4.NEG Deleting an OK ID, but not an admin -expect 404 -ns admin del com.test.TC_NS1.@[user.name] XX@NS - -sleep @[NFR] -# TC_NS1.50.10.POS Adding an OK ID -expect 201 -ns admin add com.test.TC_NS1.@[user.name] XX@NS - -# TC_NS1.50.11.POS Deleting One of Two -expect 200 -ns admin del com.test.TC_NS1.@[user.name] testid@aaf.att.com - -# TC_NS1.50.12.NEG testid@aaf.att.com no longer Admin -expect 404 -ns admin del com.test.TC_NS1.@[user.name] testid@aaf.att.com - -# TC_NS1.50.13.POS Add ID back in -expect 201 -ns admin add com.test.TC_NS1.@[user.name] testid@aaf.att.com - -# TC_NS1.50.14.POS Deleting original -expect 200 -ns admin del com.test.TC_NS1.@[user.name] XX@NS - -# TC_NS1.50.15.NEG Can't remove twice -expect 404 -ns admin del com.test.TC_NS1.@[user.name] XX@NS - -# TC_NS1.50.20.NEG User Role Add should obey same "addAdmin" restrictions -expect 403 -role user add com.test.TC_NS1.@[user.name].admin m88888@i.have.no.domain - -# TC_NS1.50.21.NEG Role User Add should obey same "addAdmin" restrictions -expect 403 -user role add m88888@i.have.no.domain com.test.TC_NS1.@[user.name].admin - diff --git a/authz-test/TestSuite/TC_NS1/60_Responsible b/authz-test/TestSuite/TC_NS1/60_Responsible deleted file mode 100644 index c6fc0261..00000000 --- a/authz-test/TestSuite/TC_NS1/60_Responsible +++ /dev/null @@ -1,43 +0,0 @@ -# TC_NS1.60.1.NEG Adding a Bogus ID -expect 403 -ns responsible add com.test.TC_NS1.@[user.name] bogus - -# TC_NS1.60.2.NEG Adding a Bogus ID, full Domain -expect 403 -ns responsible add com.test.TC_NS1.@[user.name] bogus@csp.att.com - -# TC_NS1.60.3.NEG Adding an OK ID, bad domain -expect 403 -ns responsible add com.test.TC_NS1.@[user.name] xz9914@bogus.test.com - -# TC_NS1.60.4.NEG Deleting an OK ID, short, but not existent -expect 404 -ns responsible del com.test.TC_NS1.@[user.name] testid - -# TC_NS1.60.5.NEG Deleting an OK ID, long, but not existent -expect 404 -ns responsible del com.test.TC_NS1.@[user.name] testid@aaf.att.com - -sleep @[NFR] -# TC_NS1.60.10.POS Adding an OK ID -# Note: mw9749 used because we must have employee as responsible -expect 201 -ns responsible add com.test.TC_NS1.@[user.name] mw9749 - -# TC_NS1.60.11.POS Deleting One of Two -expect 200 -ns responsible del com.test.TC_NS1.@[user.name] mw9749 - -# TC_NS1.60.12.NEG mw9749 no longer Admin -expect 404 -ns responsible del com.test.TC_NS1.@[user.name] mw9749 - -# TC_NS1.60.20.NEG User Role Add should obey same "addResponsible" restrictions -expect 403 -role user add com.test.TC_NS1.@[user.name].owner m88888@i.have.no.domain - -# TC_NS1.60.21.NEG Role User Add should obey same "addResponsible" restrictions -expect 403 -user role add m88888@i.have.no.domain com.test.TC_NS1.@[user.name].owner - - diff --git a/authz-test/TestSuite/TC_NS1/80_CheckData b/authz-test/TestSuite/TC_NS1/80_CheckData deleted file mode 100644 index 207c75f0..00000000 --- a/authz-test/TestSuite/TC_NS1/80_CheckData +++ /dev/null @@ -1,15 +0,0 @@ -sleep @[NFR] -# TC_NS1.80.1.POS List Data on Empty NS -as testid@aaf.att.com - -expect 200 -ns list name com.test.TC_NS1.@[user.name] - -# TC_NS1.80.2.POS Add Roles to NS for Listing -expect 201 -role create com.test.TC_NS1.@[user.name].r.A -role create com.test.TC_NS1.@[user.name].r.B - -# TC_NS1.80.3.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_NS1.@[user.name] diff --git a/authz-test/TestSuite/TC_NS1/90_ERR_Delete b/authz-test/TestSuite/TC_NS1/90_ERR_Delete deleted file mode 100644 index 324e829d..00000000 --- a/authz-test/TestSuite/TC_NS1/90_ERR_Delete +++ /dev/null @@ -1,7 +0,0 @@ -# TC_NS1.90.1.NEG Non Namespace Admin Delete Namespace -expect 403 -as testunused@aaf.att.com -ns delete com.test.TC_NS1.@[user.name] - -sleep @[NFR] - diff --git a/authz-test/TestSuite/TC_NS1/99_cleanup b/authz-test/TestSuite/TC_NS1/99_cleanup deleted file mode 100644 index 36d5512d..00000000 --- a/authz-test/TestSuite/TC_NS1/99_cleanup +++ /dev/null @@ -1,15 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_NS1.99.1.POS Namespace Admin can delete Namepace defined Roles -role delete com.test.TC_NS1.@[user.name].r.A -role delete com.test.TC_NS1.@[user.name].r.B - -# TC_NS1.99.2.POS Namespace Admin can delete Namespace -ns delete com.test.TC_NS1.@[user.name] - -sleep @[NFR] - -# TC_NS1.99.99.POS Check Clean Namespace -ns list name com.test.TC_NS1.@[user.name] - diff --git a/authz-test/TestSuite/TC_NS1/Description b/authz-test/TestSuite/TC_NS1/Description deleted file mode 100644 index 0cde49ed..00000000 --- a/authz-test/TestSuite/TC_NS1/Description +++ /dev/null @@ -1,15 +0,0 @@ -This Testcase Tests the essentials of the Namespace, and the NS Commands - -APIs: POST /authz/ns - DELETE /authz/ns/:ns - GET /authz/roles/:role (where Role is NS + "*") - -CLI: - Target - ns create :ns :responsibleParty :admins - ns delete :ns - ns list :ns - Ancillary - role create :role - role list name :role.* - diff --git a/authz-test/TestSuite/TC_NS2/00_ids b/authz-test/TestSuite/TC_NS2/00_ids deleted file mode 100644 index 450818e0..00000000 --- a/authz-test/TestSuite/TC_NS2/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus@aaf.att.com=boguspass - -#delay 10 -set NFR=0 - - diff --git a/authz-test/TestSuite/TC_NS2/10_init b/authz-test/TestSuite/TC_NS2/10_init deleted file mode 100644 index 73b2cc78..00000000 --- a/authz-test/TestSuite/TC_NS2/10_init +++ /dev/null @@ -1,71 +0,0 @@ - -as testid@aaf.att.com -# TC_NS2.10.0.POS Check for Existing Data -expect 200 -ns list name com.test.TC_NS2.@[user.name] - -# TC_NS2.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_NS2.@[user.name] @[user.name] testid@aaf.att.com -ns create com.test.TC_NS2.@[user.name].project @[user.name] testunused@aaf.att.com - -# TC_NS2.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_NS2.@[user.name].cred_admin testid@aaf.att.com - -as XX@NS:<pass> -# TC_NS2.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_NS2.@[user.name].cred_admin - - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -expect 200 -ns list name com.test.TC_NS2.@[user.name] - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS2.@[user.name].admin - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS2.@[user.name].owner - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS2.@[user.name].access * * - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS2.@[user.name].access * read - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -expect 200 -ns list name com.test.TC_NS2.@[user.name].project - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS2.@[user.name].project.admin - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -expect 200 -perm list role com.test.TC_NS2.@[user.name].project.owner - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS2.@[user.name].project.access * * - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -expect 200 -role list perm com.test.TC_NS2.@[user.name].project.access * read - diff --git a/authz-test/TestSuite/TC_NS2/20_add_data b/authz-test/TestSuite/TC_NS2/20_add_data deleted file mode 100644 index ef5e11ea..00000000 --- a/authz-test/TestSuite/TC_NS2/20_add_data +++ /dev/null @@ -1,18 +0,0 @@ -as testid@aaf.att.com -# TC_NS2.20.1.POS Create roles -expect 201 -role create com.test.TC_NS2.@[user.name].watcher -role create com.test.TC_NS2.@[user.name].myRole - -# TC_NS2.20.2.POS Create permissions -perm create com.test.TC_NS2.@[user.name].myType myInstance myAction -perm create com.test.TC_NS2.@[user.name].myType * * - -# TC_NS2.20.3.POS Create mechid -user cred add m99990@@[user.name].TC_NS2.test.com password123 - -as XX@NS -# TC_NS2.20.10.POS Grant view perms to watcher role -expect 201 -perm create com.att.aaf.ns :com.test.TC_NS2.@[user.name]:ns read com.test.TC_NS2.@[user.name].watcher - diff --git a/authz-test/TestSuite/TC_NS2/40_viewByName b/authz-test/TestSuite/TC_NS2/40_viewByName deleted file mode 100644 index 6539acc7..00000000 --- a/authz-test/TestSuite/TC_NS2/40_viewByName +++ /dev/null @@ -1,31 +0,0 @@ - -as testunused@aaf.att.com -# TC_NS2.40.1.NEG Non-admin, not granted user should not view -expect 403 -ns list name com.test.TC_NS2.@[user.name] - -as testid@aaf.att.com -# Tens test user granted to permission -# TC_NS2.40.10.POS Add user to watcher role -expect 201 -user role add testunused@aaf.att.com com.test.TC_NS2.@[user.name].watcher - -as testunused@aaf.att.com -# TC_NS2.40.11.POS Non-admin, granted user should view -expect 200 -ns list name com.test.TC_NS2.@[user.name] - -as testid@aaf.att.com -# TC_NS2.40.19.POS Remove user from watcher role -expect 200 -user role del testunused@aaf.att.com com.test.TC_NS2.@[user.name].watcher - -# Thirties test admin user -# TC_NS2.40.20.POS Admin should be able to view -expect 200 -ns list name com.test.TC_NS2.@[user.name] - -# TC_NS2.40.21.POS Admin of parent NS should be able to view -expect 200 -ns list name com.test.TC_NS2.@[user.name].project - diff --git a/authz-test/TestSuite/TC_NS2/41_viewByAdmin b/authz-test/TestSuite/TC_NS2/41_viewByAdmin deleted file mode 100644 index ad15e9d9..00000000 --- a/authz-test/TestSuite/TC_NS2/41_viewByAdmin +++ /dev/null @@ -1,20 +0,0 @@ -# TC_NS2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -expect 200 -ns list admin testunused@aaf.att.com - -# TC_NS2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -expect 200 -ns list admin testunused@aaf.att.com - -# TC_NS2.41.20.POS List by User when not same as Caller, but parent owner of Namespace -as XX@NS -expect 200 -ns list admin testunused@aaf.att.com - -# TC_NS2.41.80.NEG List by User when not Caller nor associated to Namespace -as testunused@aaf.att.com -expect 200 -ns list admin XX@NS - diff --git a/authz-test/TestSuite/TC_NS2/99_cleanup b/authz-test/TestSuite/TC_NS2/99_cleanup deleted file mode 100644 index 24d16d3a..00000000 --- a/authz-test/TestSuite/TC_NS2/99_cleanup +++ /dev/null @@ -1,27 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_NS2.99.1.POS Namespace Admin can delete Namepace defined Roles & Perms -role delete com.test.TC_NS2.@[user.name].myRole -role delete com.test.TC_NS2.@[user.name].watcher -perm delete com.test.TC_NS2.@[user.name].myType myInstance myAction -perm delete com.test.TC_NS2.@[user.name].myType * * -user cred del m99990@@[user.name].TC_NS2.test.com - -as XX@NS -force perm delete com.att.aaf.ns :com.test.TC_NS2.@[user.name]:ns read - -# TC_NS2.99.15.POS Remove ability to create creds -perm ungrant com.att.aaf.mechid com.att create com.test.TC_NS2.@[user.name].cred_admin - -as testid@aaf.att.com:<pass> -force role delete com.test.TC_NS2.@[user.name].cred_admin - -# TC_NS2.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_NS2.@[user.name].project -force ns delete com.test.TC_NS2.@[user.name] -sleep @[NFR] - -# TC_NS2.99.99.POS Check Clean Namespace -ns list name com.test.TC_NS2.@[user.name] - diff --git a/authz-test/TestSuite/TC_NS2/Description b/authz-test/TestSuite/TC_NS2/Description deleted file mode 100644 index 40f2b6c4..00000000 --- a/authz-test/TestSuite/TC_NS2/Description +++ /dev/null @@ -1,7 +0,0 @@ -This Testcase Tests the viewability of different ns commands - -APIs: - -CLI: - - diff --git a/authz-test/TestSuite/TC_NS3/00_ids b/authz-test/TestSuite/TC_NS3/00_ids deleted file mode 100644 index ad09d774..00000000 --- a/authz-test/TestSuite/TC_NS3/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set testid_1@test.com=<pass> -set testid_2@test.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_NS3/10_init b/authz-test/TestSuite/TC_NS3/10_init deleted file mode 100644 index b13dcefa..00000000 --- a/authz-test/TestSuite/TC_NS3/10_init +++ /dev/null @@ -1,8 +0,0 @@ -as XX@NS -expect 200 -ns list name com.test.TC_NS3.@[user.name] - -# TC_NS3.10.1.POS Create Namespace with User ID -expect 201 -ns create com.test.TC_NS3.@[user.name]_1 @[user.name] testid_1@test.com - diff --git a/authz-test/TestSuite/TC_NS3/20_add b/authz-test/TestSuite/TC_NS3/20_add deleted file mode 100644 index 46ca091e..00000000 --- a/authz-test/TestSuite/TC_NS3/20_add +++ /dev/null @@ -1,56 +0,0 @@ -as testid_1@test.com -expect Exception -# TC_NS3.20.0.NEG Too short -ns attrib - -# TC_NS3.20.1.NEG Wrong command -ns attrib xyz - -# TC_NS3.20.2.NEG Too Short after Command -ns attrib add - -# TC_NS3.20.3.NEG Too Short after Namespace -ns attrib add com.test.TC_NS3.@[user.name] - -# TC_NS3.20.4.NEG Too Short after Key -ns attrib add com.test.TC_NS3.@[user.name] TC_NS3_swm - -# TC_NS3.20.5.NEG No Permission -expect 403 -ns attrib add com.test.TC_NS3.@[user.name]_1 TC_NS3_swm v1 - -# TC_NS3.20.6.POS Create Permission to write Attrib -expect 201 -as XX@NS -perm create com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin - -# TC_NS3.20.6.POS Create Permission -expect 201 -perm create com.att.aaf.attrib :com.att.*:* read com.test.TC_NS3.@[user.name]_1.admin - -# TC_NS3.20.10.POS Attribute added -as testid_1@test.com -expect 201 -ns attrib add com.test.TC_NS3.@[user.name]_1 TC_NS3_swm v1 - -# TC_NS3.20.30.POS List NS by Attrib -expect 200 -ns list keys TC_NS3_swm - -# TC_NS3.20.40.POS List NS (shows Attrib) -ns list name com.test.TC_NS3.@[user.name]_1 - -# TC_NS3.20.42.POS Change Attrib -ns attrib upd com.test.TC_NS3.@[user.name]_1 TC_NS3_swm Version1 - -# TC_NS3.20.49.POS List NS (shows new Attrib) -ns list name com.test.TC_NS3.@[user.name]_1 - -# TC_NS3.20.80.POS Remove write Permission -expect 200 -perm ungrant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin - -# TC_NS3.20.83.POS Remove read Permission -expect 200 -perm ungrant com.att.aaf.attrib :com.att.*:* read com.test.TC_NS3.@[user.name]_1.admin - diff --git a/authz-test/TestSuite/TC_NS3/50_delete b/authz-test/TestSuite/TC_NS3/50_delete deleted file mode 100644 index 9612a1d3..00000000 --- a/authz-test/TestSuite/TC_NS3/50_delete +++ /dev/null @@ -1,27 +0,0 @@ -as testid_1@test.com -expect Exception -# TC_NS3.50.2.NEG Too Short after Command -ns attrib del - -# TC_NS3.50.3.NEG Too Short after Namespace -ns attrib del com.test.TC_NS3.@[user.name] - -# TC_NS3.50.5.NEG No Permission -expect 403 -ns attrib del com.test.TC_NS3.@[user.name]_1 TC_NS3_swm - -# TC_NS3.50.6.POS Create Permission -as XX@NS -expect 201 -perm grant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin - -# TC_NS3.50.7.POS Attribute added -as testid_1@test.com -expect 200 -ns attrib del com.test.TC_NS3.@[user.name]_1 TC_NS3_swm - -# TC_NS3.50.8.POS Remove Permission -as XX@NS -expect 200 -perm ungrant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin - diff --git a/authz-test/TestSuite/TC_NS3/99_cleanup b/authz-test/TestSuite/TC_NS3/99_cleanup deleted file mode 100644 index 104831d7..00000000 --- a/authz-test/TestSuite/TC_NS3/99_cleanup +++ /dev/null @@ -1,14 +0,0 @@ -expect 200,404 -as testid_1@test.com -# TC_NS3.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_NS3.@[user.name]_1 - -# TC_NS3.99.3.POS Print Namespaces -ns list name com.test.TC_NS3.@[user.name]_1 - -# TC_NS3.99.10.POS Remove Special Permissions -as XX@NS -force perm delete com.att.aaf.attrib :com.att.*:TC_NS3_swm write - -force perm delete com.att.aaf.attrib :com.att.*:* read - diff --git a/authz-test/TestSuite/TC_NS3/Description b/authz-test/TestSuite/TC_NS3/Description deleted file mode 100644 index 2283774d..00000000 --- a/authz-test/TestSuite/TC_NS3/Description +++ /dev/null @@ -1,10 +0,0 @@ -This is a TEMPLATE testcase, to make creating new Test Cases easier. - -APIs: - - -CLI: -ns create -ns delete -as - diff --git a/authz-test/TestSuite/TC_NSdelete1/00_ids b/authz-test/TestSuite/TC_NSdelete1/00_ids deleted file mode 100644 index 450818e0..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus@aaf.att.com=boguspass - -#delay 10 -set NFR=0 - - diff --git a/authz-test/TestSuite/TC_NSdelete1/10_init b/authz-test/TestSuite/TC_NSdelete1/10_init deleted file mode 100644 index 7be6981c..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/10_init +++ /dev/null @@ -1,35 +0,0 @@ -as testid@aaf.att.com -# TC_NSdelete1.10.0.POS Check for Existing Data -expect 200 -ns list name com.test.TC_NSdelete1.@[user.name].app -ns list name com.test.force.@[user.name] -ns list name com.@[user.name] - -as XX@NS -# TC_NSdelete1.10.1.POS Create Namespaces with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_NSdelete1.@[user.name].app @[user.name] testid@aaf.att.com -ns create com.@[user.name] @[user.name] testid@aaf.att.com -ns create com.test.force.@[user.name] @[user.name] testid@aaf.att.com -ns create com.test.TC_NSdelete1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_NSdelete1.10.2.POS Expect Namespace to be created -expect 200 -ns list name com.test.TC_NSdelete1.@[user.name].app -ns list name com.test.TC_NSdelete1.@[user.name] -ns list name com.@[user.name] -ns list name com.test.force.@[user.name] - -# TC_NSdelete1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_NSdelete1.@[user.name].cred_admin - -# TC_NSdelete1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_NSdelete1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_NSdelete1.10.12.POS Assign user for creating creds -expect 201 -user role add testid@aaf.att.com com.test.TC_NSdelete1.@[user.name].cred_admin - diff --git a/authz-test/TestSuite/TC_NSdelete1/20_DeleteApp b/authz-test/TestSuite/TC_NSdelete1/20_DeleteApp deleted file mode 100644 index 519e135f..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/20_DeleteApp +++ /dev/null @@ -1,30 +0,0 @@ -as testid@aaf.att.com -# TC_NSdelete1.20.1.POS Create valid Role in my Namespace -expect 201 -role create com.test.TC_NSdelete1.@[user.name].app.r.A - -# TC_NSdelete1.20.2.POS Create valid permission -expect 201 -perm create com.test.TC_NSdelete1.@[user.name].app.p.A myInstance myAction - -# TC_NSdelete1.20.3.POS Add credential to my namespace -expect 201 -user cred add m99990@app.@[user.name].TC_NSdelete1.test.com password123 - -# TC_NSdelete1.20.10.NEG Delete Program Should fail because of attached credential -expect 424 -ns delete com.test.TC_NSdelete1.@[user.name].app - -# TC_NSdelete1.20.11.POS Delete Credential -expect 200 -set force=true -user cred del m99990@app.@[user.name].TC_NSdelete1.test.com - -# TC_NSdelete1.20.12.NEG Delete Program with role and permission attached -expect 424 -ns delete com.test.TC_NSdelete1.@[user.name].app - -# TC_NSdelete1.20.20.POS Expect role and permission to move to parent ns -expect 200 -set force=move ns list name com.test.TC_NSdelete1.@[user.name] - diff --git a/authz-test/TestSuite/TC_NSdelete1/30_DeleteCompany b/authz-test/TestSuite/TC_NSdelete1/30_DeleteCompany deleted file mode 100644 index 6c69bb20..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/30_DeleteCompany +++ /dev/null @@ -1,42 +0,0 @@ -as testid@aaf.att.com -# TC_NSdelete1.30.1.POS Create valid Role in my Namespace -expect 201 -role create com.@[user.name].r.A - -# TC_NSdelete1.30.2.NEG Delete Company with role attached -expect 424 -ns delete com.@[user.name] - -# TC_NSdelete1.30.3.POS Namespace Admin can delete Namepace defined Roles -expect 200 -role delete com.@[user.name].r.A - -# TC_NSdelete1.30.10.POS Create valid permission -expect 201 -perm create com.@[user.name].p.A myInstance myAction - -# TC_NSdelete1.30.11.NEG Delete Company with permission attached -expect 424 -ns delete com.@[user.name] - -# TC_NSdelete1.30.12.POS Namespace Admin can delete Namepace defined Perms -expect 200 -perm delete com.@[user.name].p.A myInstance myAction - -# TC_NSdelete1.30.20.POS Create valid Credential in my namespace -expect 201 -user cred add m99990@@[user.name].com password123 - -# TC_NSdelete1.30.21.NEG Delete Company with credential attached -expect 424 -ns delete com.@[user.name] - -# TC_NSdelete1.30.22.POS Namespace admin can remove Cred -expect 200 -set force=true -user cred del m99990@@[user.name].com - -# TC_NSdelete1.30.30.POS Delete Company with no roles or perms attached -expect 200 -ns delete com.@[user.name] - diff --git a/authz-test/TestSuite/TC_NSdelete1/40_ForceDelete b/authz-test/TestSuite/TC_NSdelete1/40_ForceDelete deleted file mode 100644 index c4ae2bb7..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/40_ForceDelete +++ /dev/null @@ -1,26 +0,0 @@ -# TC_NSdelete1.40.1.POS Create valid Role in my Namespace
-expect 201
-role create com.test.force.@[user.name].r.A
-
-# TC_NSdelete1.40.2.POS Create valid permission in my Namespace
-expect 201
-perm create com.test.force.@[user.name].p.A myInstance myAction
-
-# TC_NSdelete1.40.3.POS Add credential to my namespace
-expect 201
-user cred add m99990@@[user.name].force.test.com password123
-
-# TC_NSdelete1.40.10.POS Delete Program in my Namespace
-expect 200
-set force=true ns delete com.test.force.@[user.name]
-
-sleep @[NFR]
-# TC_NSdelete1.40.20.NEG Role and permission should not exist
-expect 200,404
-ns list name com.test.force.@[user.name]
-
-# TC_NSdelete1.40.22.NEG Credential should not exist
-expect 404
-set force=true
-user cred del m99990@@[user.name].force.test.com
-
diff --git a/authz-test/TestSuite/TC_NSdelete1/99_cleanup b/authz-test/TestSuite/TC_NSdelete1/99_cleanup deleted file mode 100644 index cb97bc03..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/99_cleanup +++ /dev/null @@ -1,36 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_NSdelete1.99.1.POS Namespace Admin can delete Namepace defined Roles -role delete com.test.TC_NSdelete1.@[user.name].app.r.A - -# TC_NSdelete1.99.2.POS Namespace Admin can delete Namepace defined Roles -perm delete com.test.TC_NSdelete1.@[user.name].app.p.A myInstance myAction - -# TC_NSdelete1.99.3.POS Namespace Admin can remove Namepace defined Credentials -set force=true user cred del m99990@@app.[user.name].TC_NSdelete1.test.com - -# TC_NSdelete1.99.10.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_NSdelete1.@[user.name].cred_admin - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_NSdelete1.@[user.name].cred_admin - -as testid@aaf.att.com -set force=true role delete com.test.TC_NSdelete1.@[user.name].cred_admin - -# TC_NSdelete1.99.97.POS Clean Namespace -set force=true ns delete com.test.TC_NSdelete1.@[user.name].app -set force=true ns delete com.test.TC_NSdelete1.@[user.name] -set force=true ns delete com.test.force.@[user.name] - -# TC_NSdelete1.99.98.POS Check Clean Namespace -ns list name com.test.TC_NSdelete1.@[user.name].app -ns list name com.test.TC_NSdelete1.@[user.name] -ns list name com.test.force.@[user.name] - -# TC_NSdelete1.99.99.POS Clean and check Company Namespace -as XX@NS -set force=true ns delete com.@[user.name] -ns list name com.@[user.name] - diff --git a/authz-test/TestSuite/TC_NSdelete1/Description b/authz-test/TestSuite/TC_NSdelete1/Description deleted file mode 100644 index be99e94f..00000000 --- a/authz-test/TestSuite/TC_NSdelete1/Description +++ /dev/null @@ -1,15 +0,0 @@ -This Testcase Tests the deletion of a Namespace with attached roles and permissions - -APIs: POST /authz/ns - DELETE /authz/ns/:ns - GET /authz/roles/:role (where Role is NS + "*") - -CLI: - Target - ns create :ns :responsibleParty :admins - ns delete :ns - ns list :ns - Ancillary - role create :role - role list name :role.* - diff --git a/authz-test/TestSuite/TC_PW1/00_ids b/authz-test/TestSuite/TC_PW1/00_ids deleted file mode 100644 index 7fb0e054..00000000 --- a/authz-test/TestSuite/TC_PW1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_PW1/10_init b/authz-test/TestSuite/TC_PW1/10_init deleted file mode 100644 index 7614fc4a..00000000 --- a/authz-test/TestSuite/TC_PW1/10_init +++ /dev/null @@ -1,24 +0,0 @@ - -as testid@aaf.att.com - -# TC_PW1.10.0.POS Validate no NS -expect 200,404 -ns list name com.test.TC_PW1.@[user.name] - -# TC_PW1.10.1.POS Create Namespace to add IDs -expect 201 -ns create com.test.TC_PW1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_PW1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_PW1.@[user.name].cred_admin - -as XX@NS -# TC_PW1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_PW1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_PW1.10.12.POS Assign user for creating creds -expect 201 -user role add testid@aaf.att.com com.test.TC_PW1.@[user.name].cred_admin diff --git a/authz-test/TestSuite/TC_PW1/20_length b/authz-test/TestSuite/TC_PW1/20_length deleted file mode 100644 index 233683a8..00000000 --- a/authz-test/TestSuite/TC_PW1/20_length +++ /dev/null @@ -1,10 +0,0 @@ -# TC_PW1.20.1.NEG ASPR 1010 Passwords must be at least 8 characters in length -expect 406 -user cred add m12345@TC_PW1.test.com 12 - -# TC_PW1.20.2.NEG ASPR 1010 Passwords must be at least 8 characters in length -user cred add m12345@TC_PW1.test.com 1 - -# TC_PW1.20.3.NEG ASPR 1010 Passwords must be at least 8 characters in length -user cred add m12345@TC_PW1.test.com 1234567 - diff --git a/authz-test/TestSuite/TC_PW1/21_groups b/authz-test/TestSuite/TC_PW1/21_groups deleted file mode 100644 index 0d853484..00000000 --- a/authz-test/TestSuite/TC_PW1/21_groups +++ /dev/null @@ -1,40 +0,0 @@ -# TC_PW1.21.1.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 406 -user cred add m12345@@[user.name].TC_PW1.test.com 12345678 - -# TC_PW1.21.2.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 406 -user cred add m12345@@[user.name].TC_PW1.test.com abcdefgh - -# TC_PW1.21.3.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 406 -user cred add m12345@@[user.name].TC_PW1.test.com "!@#%^()*" - -# TC_PW1.21.4.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 201 -user cred add m12345@@[user.name].TC_PW1.test.com "!@#a%^()*" - -sleep @[NFR] -expect 200 -user cred del m12345@@[user.name].TC_PW1.test.com - -# TC_PW1.21.5.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 201 -user cred add m12345@@[user.name].TC_PW1.test.com "!@#2%^()*" - -sleep @[NFR] -expect 200 -user cred del m12345@@[user.name].TC_PW1.test.com - -# TC_PW1.21.6.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -expect 201 -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sd" - -sleep @[NFR] -expect 200 -user cred del m12345@@[user.name].TC_PW1.test.com - -# TC_PW1.21.10.NEG ASPR 1010 Passwords cannot be the same as the User ID -expect 406 -user cred add m12345@@[user.name].TC_PW1.test.com m12345 - diff --git a/authz-test/TestSuite/TC_PW1/23_commands b/authz-test/TestSuite/TC_PW1/23_commands deleted file mode 100644 index 91502251..00000000 --- a/authz-test/TestSuite/TC_PW1/23_commands +++ /dev/null @@ -1,6 +0,0 @@ -# TC_PW1.23.1.NEG Too Few Args for User Cred 1 -expect Exception -user cred - -# TC_PW1.23.2.NEG Too Few Args for User Cred add -user cred add diff --git a/authz-test/TestSuite/TC_PW1/30_reset b/authz-test/TestSuite/TC_PW1/30_reset deleted file mode 100644 index ac058eba..00000000 --- a/authz-test/TestSuite/TC_PW1/30_reset +++ /dev/null @@ -1,15 +0,0 @@ -# TC_PW1.30.1.POS Create a Credential, with Temporary Time -expect 201 -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sd" - -# TC_PW1.30.3.NEG Credential Exists -expect 409 -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sf" - -# TC_PW1.30.8.POS Reset this Password -expect 200 -user cred reset m12345@@[user.name].TC_PW1.test.com "ABC123SD" 1 - -# TC_PW1.30.9.POS Delete a Credential -user cred del m12345@@[user.name].TC_PW1.test.com 1 - diff --git a/authz-test/TestSuite/TC_PW1/99_cleanup b/authz-test/TestSuite/TC_PW1/99_cleanup deleted file mode 100644 index 9de26368..00000000 --- a/authz-test/TestSuite/TC_PW1/99_cleanup +++ /dev/null @@ -1,21 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_PW1.99.1.NEG Delete ID m12345@@[user.name].TC_PW1.test.com -set force=true -user cred del m12345@@[user.name].TC_PW1.test.com - -# TC_PW1.99.2.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_PW1.@[user.name].cred_admin - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_PW1.@[user.name].cred_admin - -as testid@aaf.att.com -role delete com.test.TC_PW1.@[user.name].cred_admin - -# TC_PW1.99.98.POS Delete Namespace com..test.TC_PW1 -ns delete com.test.TC_PW1.@[user.name] - -# TC_PW1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_PW1.@[user.name] diff --git a/authz-test/TestSuite/TC_PW1/Description b/authz-test/TestSuite/TC_PW1/Description deleted file mode 100644 index 24180f49..00000000 --- a/authz-test/TestSuite/TC_PW1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user cred add :user :password - user cred del :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/TC_Perm1/00_ids b/authz-test/TestSuite/TC_Perm1/00_ids deleted file mode 100644 index 0e7a40aa..00000000 --- a/authz-test/TestSuite/TC_Perm1/00_ids +++ /dev/null @@ -1,9 +0,0 @@ -expect 0 -set testid=<pass> -set testid@aaf.att.com=<pass> -set XX@NS=<pass> -set testunused=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Perm1/10_init b/authz-test/TestSuite/TC_Perm1/10_init deleted file mode 100644 index 08a9d171..00000000 --- a/authz-test/TestSuite/TC_Perm1/10_init +++ /dev/null @@ -1,23 +0,0 @@ -# TC_Perm1.10.0.POS Validate Namespace is empty first -as testid@aaf.att.com -expect 200 -ns list name com.test.TC_Perm1.@[user.name] - -# TC_Perm1.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_Perm1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Perm1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_Perm1.@[user.name].cred_admin - -as XX@NS -# TC_Perm1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_Perm1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_Perm1.10.12.POS Assign user for creating creds -expect 201 -user role add XX@NS com.test.TC_Perm1.@[user.name].cred_admin - diff --git a/authz-test/TestSuite/TC_Perm1/20_add_data b/authz-test/TestSuite/TC_Perm1/20_add_data deleted file mode 100644 index 308170f8..00000000 --- a/authz-test/TestSuite/TC_Perm1/20_add_data +++ /dev/null @@ -1,38 +0,0 @@ -# TC_Perm1.20.1.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Perm1.@[user.name] - -# TC_Perm1.20.2.POS Add Perm -expect 201 -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction - -# TC_Perm1.20.3.NEG Already Added Perm -expect 409 -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction - -# TC_Perm1.20.4.POS Add Perm with non-existent Roles as well -expect 201 -force perm create com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].r.A,com.test.TC_Perm1.@[user.name].r.B - -# TC_Perm1.20.8.POS Print Info for Validation -expect 200 -ns list name com.test.TC_Perm1.@[user.name] - -# TC_Perm1.20.9.NEG Already Added Perm with some Roles as well -expect 409 -perm create com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].r.A,com.test.TC_Perm1.@[user.name].r.B - -# TC_Perm1.20.10.NEG Non-admins can't change description -expect 403 -as testunused -perm describe com.test.TC_Perm1.@[user.name].p.A myInstance myAction Description for A - -# TC_Perm1.20.11.NEG Permission must exist to change description -expect 404 -as testid -perm describe com.test.TC_Perm1.@[user.name].p.C myInstance myAction Description for C - -# TC_Perm1.20.12.POS Admin can change description -expect 200 -perm describe com.test.TC_Perm1.@[user.name].p.A myInstance myAction Description for A - diff --git a/authz-test/TestSuite/TC_Perm1/22_rename b/authz-test/TestSuite/TC_Perm1/22_rename deleted file mode 100644 index e2495608..00000000 --- a/authz-test/TestSuite/TC_Perm1/22_rename +++ /dev/null @@ -1,52 +0,0 @@ -# TC_Perm1.22.1.NEG Try to rename permission without changing anything
-expect 409
-perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].p.B myInstance myAction
-
-# TC_Perm1.22.2.NEG Try to rename parent ns
-expect 403
-perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.att.TC_Perm1.@[user.name].p.C myInstance myAction
-
-# TC_Perm1.22.10.POS View permission in original state
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-# TC_Perm1.22.11.POS Rename permission instance
-expect 200
-perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].p.B yourInstance myAction
-
-# TC_Perm1.22.12.POS Verify change in permission instance
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-# TC_Perm1.22.13.POS Rename permission action
-expect 200
-perm rename com.test.TC_Perm1.@[user.name].p.B yourInstance myAction com.test.TC_Perm1.@[user.name].p.B yourInstance yourAction
-
-# TC_Perm1.22.14.POS Verify change in permission action
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-# TC_Perm1.22.15.POS Rename permission type
-expect 200
-perm rename com.test.TC_Perm1.@[user.name].p.B yourInstance yourAction com.test.TC_Perm1.@[user.name].p.yourB yourInstance yourAction
-
-# TC_Perm1.22.16.POS Verify change in permission type
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-# TC_Perm1.22.20.POS See permission is attached to this role
-expect 200
-role list role com.test.TC_Perm1.@[user.name].r.A
-
-# TC_Perm1.22.21.POS Rename permission type, instance and action
-expect 200
-perm rename com.test.TC_Perm1.@[user.name].p.yourB yourInstance yourAction com.test.TC_Perm1.@[user.name].p.B myInstance myAction
-
-# TC_Perm1.22.22.POS See permission stays attached after rename
-expect 200
-role list role com.test.TC_Perm1.@[user.name].r.A
-
-# TC_Perm1.22.23.POS Verify permission is back to original state
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
diff --git a/authz-test/TestSuite/TC_Perm1/25_grant_owned b/authz-test/TestSuite/TC_Perm1/25_grant_owned deleted file mode 100644 index 3085ace7..00000000 --- a/authz-test/TestSuite/TC_Perm1/25_grant_owned +++ /dev/null @@ -1,40 +0,0 @@ -# TC_Perm1.25.1.POS Create another Role in This namespace -expect 201 -role create com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.2.POS Create another Perm in This namespace -expect 201 -perm create com.test.TC_Perm1.@[user.name].p.C myInstance myAction - -# TC_Perm1.25.3.NEG Permission must Exist to Add to Role -expect 404 -perm grant com.test.TC_Perm1.@[user.name].p.NO myInstance myAction com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.4.POS Grant individual new Perm to new Role -expect 201 -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.5.NEG Already Granted Perm -expect 409 -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.6.POS Print Info for Validation -expect 200 -ns list name com.test.TC_Perm1.@[user.name] - -# TC_Perm1.25.10.POS UnGrant individual new Perm to new Role -expect 200 -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.11.NEG Already UnGranted Perm -expect 404 -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C - -# TC_Perm1.25.20.POS Reset roles attached to permision with setTo -expect 200 -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C,com.test.TC_Perm1.@[user.name].r.A - -# TC_Perm1.25.21.POS Owner of permission can reset roles -expect 200 -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction - diff --git a/authz-test/TestSuite/TC_Perm1/26_grant_unowned b/authz-test/TestSuite/TC_Perm1/26_grant_unowned deleted file mode 100644 index 4449624f..00000000 --- a/authz-test/TestSuite/TC_Perm1/26_grant_unowned +++ /dev/null @@ -1,175 +0,0 @@ -# TC_Perm1.26.1.POS Create another Namespace, not owned by testid, one in company, one not
-as XX@NS
-expect 201
-ns create com.test2.TC_Perm1.@[user.name] @[user.name] XX@NS
-ns create com.test.TC_Perm1.@[user.name]_2 @[user.name] XX@NS
-
-# TC_Perm1.26.2.POS Create ID in other Namespace
-expect 201
-user cred add m99990@@[user.name].TC_Perm1.test2.com aRealPass7
-
-# TC_Perm1.26.3.POS Create a Role in other Namespaces, not owned by testid
-expect 201
-role create com.test2.TC_Perm1.@[user.name].r.C
-role create com.test2.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.11.NEG Grant Perm to Role in Other Namespace, when Role ID
-expect 403
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.11a.NEG Grant Perm to Role in Other Namespace, when Role ID
-expect 202
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-set request=true
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.12.NEG Grant Perm to Role in Other Namespace, when Perm ID, but different Company
-as testid@aaf.att.com
-expect 403
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.13.NEG Fail Grant Perm to Role in Other Namespace, when Perm ID, but same Company
-as testid@aaf.att.com
-expect 404
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.14.POS Create Role
-as testid@aaf.att.com
-expect 201
-role create com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.15.POS Fail Create/Grant Perm to Role in Other Namespace, when Perm ID, but same Company
-expect 201
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.16.POS Print Info for Validation
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-# TC_Perm1.26.17.POS Grant individual new Perm to new Role
-expect 201
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.18.NEG Already Granted Perm
-expect 409
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.19.POS UnGrant Perm from Role in Other Namespace, when Perm ID
-expect 200
-perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.21.NEG No Permission to Grant Perm to Role with Unrelated ID
-expect 403
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.22.NEG No Permission to Grant Perm to Role with Unrelated ID
-expect 202
-set request=true
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.25.NEG No Permission to UnGrant with Unrelated ID
-expect 403
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.B
-
-# TC_Perm1.26.26.NEG No Permission to UnGrant with Unrelated ID
-expect 202
-set request=true
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.B
-
-
-# TC_Perm1.26.30.POS Add ID to Role
-as XX@NS:<pass>
-expect 201
-ns admin add com.test2.TC_Perm1.@[user.name] m99990@@[user.name].TC_Perm1.test2.com
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-sleep @[NFR]
-
-# TC_Perm1.26.31.NEG No Permission Grant Perm to Role if not Perm Owner
-expect 403
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.31.NEG No Permission Grant Perm to Role if not Perm Owner
-expect 202
-set request=true
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C
-
-
-# TC_Perm1.26.32.POS Grant individual new Perm to Role in Other Namespace
-expect 201
-as testid@aaf.att.com
-perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.34.POS Print Info for Validation
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-
-as XX@NS
-# TC_Perm1.26.35.POS Print Info for Validation
-expect 200
-ns list name com.test2.TC_Perm1.@[user.name]
-
-as testid@aaf.att.com
-# TC_Perm1.26.36.POS UnGrant individual new Perm to new Role
-as testid@aaf.att.com
-expect 200
-perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.37.NEG Already UnGranted Perm
-expect 404
-perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C
-
-# TC_Perm1.26.40.POS Reset roles attached to permision with setTo
-expect 200
-perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C,com.test.TC_Perm1.@[user.name].r.A
-
-# TC_Perm1.26.41.NEG Non-owner of permission cannot reset roles
-expect 403
-as m99990@@[user.name].TC_Perm1.test2.com:aRealPass7
-perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction
-
-# TC_Perm1.26.42.NEG Non-owner of permission cannot ungrant
-expect 403
-perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C
-
-# TC_Perm1.26.43.NEG Non-owner of permission cannot delete
-expect 403
-perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction
-
-# TC_Perm1.26.45.POS Owner of permission can reset roles
-as testid@aaf.att.com
-expect 200
-perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction
-
-as XX@NS
-# TC_Perm1.26.97.POS List the Namespaces
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-ns list name com.test2.TC_Perm1.@[user.name]
-
-as testid@aaf.att.com
-# TC_Perm1.26.98.POS Cleanup
-expect 200
-role delete com.test.TC_Perm1.@[user.name].r.A
-role delete com.test.TC_Perm1.@[user.name].r.B
-role delete com.test.TC_Perm1.@[user.name].r.C
-role delete com.test.TC_Perm1.@[user.name]_2.r.C
-as XX@NS
-role delete com.test2.TC_Perm1.@[user.name]_2.r.C
-role delete com.test2.TC_Perm1.@[user.name].r.C
-as testid@aaf.att.com
-perm delete com.test.TC_Perm1.@[user.name].p.A myInstance myAction
-perm delete com.test.TC_Perm1.@[user.name].p.B myInstance myAction
-perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction
-force ns delete com.test.TC_Perm1.@[user.name]_2
-as XX@NS
-set force=true user cred del m99990@@[user.name].TC_Perm1.test2.com
-ns delete com.test2.TC_Perm1.@[user.name]
-
-# TC_Perm1.26.99.POS List the Now Empty Namespaces
-expect 200
-ns list name com.test.TC_Perm1.@[user.name]
-ns list name com.test2.TC_Perm1.@[user.name]
-
diff --git a/authz-test/TestSuite/TC_Perm1/27_grant_force b/authz-test/TestSuite/TC_Perm1/27_grant_force deleted file mode 100644 index 12ee9839..00000000 --- a/authz-test/TestSuite/TC_Perm1/27_grant_force +++ /dev/null @@ -1,29 +0,0 @@ -# TC_Perm1.27.1.POS Create Permission -expect 201 -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction - -# TC_Perm1.27.2.POS Create Role -expect 201 -role create com.test.TC_Perm1.@[user.name].r.A - -# TC_Perm1.27.10.NEG Role must Exist to Add to Role without force -expect 404 -perm grant com.test.TC_Perm1.@[user.name].p.A myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown - -# TC_Perm1.27.11.POS Role is created with force -expect 201 -force perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown - -# TC_Perm1.27.12.NEG Perm must Exist to Grant without force -expect 404 -perm grant com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction com.test.TC_Perm1.@[user.name].r.A - -# TC_Perm1.27.13.POS Perm is created with force -expect 201 -force perm grant com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction com.test.TC_Perm1.@[user.name].r.A - -# TC_Perm1.27.14.POS Role and perm are created with force -expect 201 -force perm create com.test.TC_Perm1.@[user.name].p.unknown2 myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown2 - - diff --git a/authz-test/TestSuite/TC_Perm1/30_change_ns b/authz-test/TestSuite/TC_Perm1/30_change_ns deleted file mode 100644 index a92562a6..00000000 --- a/authz-test/TestSuite/TC_Perm1/30_change_ns +++ /dev/null @@ -1,14 +0,0 @@ -# TC_Perm1.30.1.POS List Data on non-Empty NS -as testid -expect 200 -ns list name com.test.TC_Perm1.@[user.name] - -# TC_Perm1.30.2.POS Create Sub-ns when Roles that exist -expect 201 -ns create com.test.TC_Perm1.@[user.name].r @[user.name] testid@aaf.att.com - -# TC_Perm1.30.3.POS List Data on NS with sub-roles -expect 200 -ns list name com.test.TC_Perm1.@[user.name] -ns list name com.test.TC_Perm1.@[user.name].r - diff --git a/authz-test/TestSuite/TC_Perm1/99_cleanup b/authz-test/TestSuite/TC_Perm1/99_cleanup deleted file mode 100644 index 222e2a4c..00000000 --- a/authz-test/TestSuite/TC_Perm1/99_cleanup +++ /dev/null @@ -1,42 +0,0 @@ -as XX@NS:<pass> -expect 200,404 - -# TC_Perm1.99.1.POS Namespace Admin can delete Namepace defined Roles -set force=true perm delete com.test.TC_Perm1.@[user.name].p.A myInstance myAction -set force=true perm delete com.test.TC_Perm1.@[user.name].p.B myInstance myAction -set force=true perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction -set force=true perm delete com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction -set force=true perm delete com.test.TC_Perm1.@[user.name].p.unknown2 myInstance myAction -role delete com.test.TC_Perm1.@[user.name].r.A -role delete com.test.TC_Perm1.@[user.name].r.B -role delete com.test.TC_Perm1.@[user.name].r.C -role delete com.test.TC_Perm1.@[user.name].r.unknown -role delete com.test.TC_Perm1.@[user.name].r.unknown2 -role delete com.test2.TC_Perm1.@[user.name].r.C -role delete com.test.TC_Perm1.@[user.name]_2.r.C -role delete com.test2.TC_Perm1.@[user.name]_2.r.C - -# TC_Perm1.99.2.POS Remove ability to create creds -user role del XX@NS com.test.TC_Perm1.@[user.name].cred_admin - -as XX@NS:<pass> -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Perm1.@[user.name].cred_admin - -as testid@aaf.att.com:<pass> -role delete com.test.TC_Perm1.@[user.name].cred_admin - -sleep @[NFR] -as XX@NS:<pass> -# TC_Perm1.99.98.POS Namespace Admin can delete Namespace -set force=true ns delete com.test2.TC_Perm1.@[user.name] -as testid:<pass> -force ns delete com.test.TC_Perm1.@[user.name].r -force ns delete com.test.TC_Perm1.@[user.name]_2 -force ns delete com.test.TC_Perm1.@[user.name] -force ns delete com.test2.TC_Perm1.@[user.name] - -# TC_Perm1.99.99.POS List to prove removed -ns list name com.test.TC_Perm1.@[user.name] -ns list name com.test.TC_Perm1.@[user.name].r -ns list name com.test.TC_Perm1.@[user.name]_2 -ns list name com.test2.TC_Perm1.@[user.name] diff --git a/authz-test/TestSuite/TC_Perm1/Description b/authz-test/TestSuite/TC_Perm1/Description deleted file mode 100644 index 012a12b1..00000000 --- a/authz-test/TestSuite/TC_Perm1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of the Namespace, and the NS Commands - -APIs: - - - -CLI: - Target - role create :role - role delete - ns delete :ns - ns list :ns - Ancillary - role create :role - role list name :role.* - diff --git a/authz-test/TestSuite/TC_Perm2/00_ids b/authz-test/TestSuite/TC_Perm2/00_ids deleted file mode 100644 index f7196fc8..00000000 --- a/authz-test/TestSuite/TC_Perm2/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Perm2/10_init b/authz-test/TestSuite/TC_Perm2/10_init deleted file mode 100644 index dbda5edc..00000000 --- a/authz-test/TestSuite/TC_Perm2/10_init +++ /dev/null @@ -1,8 +0,0 @@ -as testid@aaf.att.com -# TC_Perm2.10.0.POS Print NS to prove ok -expect 200 -ns list name com.test.TC_Perm2.@[user.name] - -# TC_Perm2.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_Perm2.@[user.name] @[user.name] testid@aaf.att.com diff --git a/authz-test/TestSuite/TC_Perm2/20_add_data b/authz-test/TestSuite/TC_Perm2/20_add_data deleted file mode 100644 index dfcff2fc..00000000 --- a/authz-test/TestSuite/TC_Perm2/20_add_data +++ /dev/null @@ -1,44 +0,0 @@ -as testid@aaf.att.com:<pass> -# TC_Perm2.20.1.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Perm2.@[user.name] - -# TC_Perm2.20.10.POS Add Perms with specific Instance and Action -expect 201 -perm create com.test.TC_Perm2.@[user.name].p.A myInstance myAction - -# TC_Perm2.20.11.POS Add Perms with specific Instance and Star -expect 201 -perm create com.test.TC_Perm2.@[user.name].p.A myInstance * - -# TC_Perm2.20.12.POS Add Perms with Stars for Instance and Action -expect 201 -perm create com.test.TC_Perm2.@[user.name].p.A * * -perm create com.test.TC_Perm2.@[user.name].p.phoneCalls * spy - -# TC_Perm2.20.20.POS Create role -expect 201 -role create com.test.TC_Perm2.@[user.name].p.superUser -role create com.test.TC_Perm2.@[user.name].p.secret - -# TC_Perm2.20.21.POS Grant sub-NS perms to role -expect 201 -perm grant com.test.TC_Perm2.@[user.name].p.A myInstance myAction com.test.TC_Perm2.@[user.name].p.superUser -perm grant com.test.TC_Perm2.@[user.name].p.A myInstance * com.test.TC_Perm2.@[user.name].p.superUser -perm grant com.test.TC_Perm2.@[user.name].p.A * * com.test.TC_Perm2.@[user.name].p.superUser -perm grant com.test.TC_Perm2.@[user.name].p.phoneCalls * spy com.test.TC_Perm2.@[user.name].p.secret - -# TC_Perm2.20.30.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Perm2.@[user.name] - -# TC_Perm2.20.40.POS Create role -expect 201 -role create com.test.TC_Perm2.@[user.name].p.watcher - -as XX@NS -# TC_Perm2.20.50.POS Grant view perms to watcher role -expect 201 -perm create com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:myInstance:myAction view com.test.TC_Perm2.@[user.name].p.watcher -perm create com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view com.test.TC_Perm2.@[user.name].p.watcher - diff --git a/authz-test/TestSuite/TC_Perm2/30_change_ns b/authz-test/TestSuite/TC_Perm2/30_change_ns deleted file mode 100644 index b69f9e8d..00000000 --- a/authz-test/TestSuite/TC_Perm2/30_change_ns +++ /dev/null @@ -1,14 +0,0 @@ -as testid@aaf.att.com -# TC_Perm2.30.1.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Perm2.@[user.name] - -# TC_Perm2.30.2.POS Create Sub-ns when Roles that exist -expect 201 -ns create com.test.TC_Perm2.@[user.name].p @[user.name] testid@aaf.att.com - -# TC_Perm2.30.3.POS List Data on NS with sub-roles -expect 200 -ns list name com.test.TC_Perm2.@[user.name] -ns list name com.test.TC_Perm2.@[user.name].p - diff --git a/authz-test/TestSuite/TC_Perm2/40_viewByType b/authz-test/TestSuite/TC_Perm2/40_viewByType deleted file mode 100644 index cef41b05..00000000 --- a/authz-test/TestSuite/TC_Perm2/40_viewByType +++ /dev/null @@ -1,82 +0,0 @@ - -as testunused@aaf.att.com -# TC_Perm2.40.1.NEG Non-admin, not granted user should not view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -as testid@aaf.att.com -# Tens test user granted to permission -# TC_Perm2.40.10.POS Add user to superUser role -expect 201 -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser - -as testunused@aaf.att.com -# TC_Perm2.40.11.POS Non-admin, granted user should view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -as testid@aaf.att.com -# TC_Perm2.40.12.POS Ungrant perm with wildcards -expect 200 -perm ungrant com.test.TC_Perm2.@[user.name].p.A * * com.test.TC_Perm2.@[user.name].p.superUser - -as testunused@aaf.att.com -# TC_Perm2.40.13.POS Non-admin, granted user should view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -as testid@aaf.att.com -# TC_Perm2.40.19.POS Remove user from superUser role -expect 200 -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser - -# Twenties test user granted explicit view permission -# TC_Perm2.40.20.POS Add user to watcher role -expect 201 -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher - -as testunused@aaf.att.com -# TC_Perm2.40.21.NEG Non-admin, granted explicit view perm user should view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -as XX@NS -# TC_Perm2.40.22.POS Ungrant perm with wildcards -expect 200 -perm ungrant com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view com.test.TC_Perm2.@[user.name].p.watcher - -as testunused@aaf.att.com -# TC_Perm2.40.23.POS Non-admin, granted user should view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -as testid@aaf.att.com -# TC_Perm2.40.29.POS Remove user from watcher role -expect 200 -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher - -# Thirties test admin user -# TC_Perm2.40.30.POS Admin should be able to view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -# TC_Perm2.40.31.POS Add new admin for sub-NS -expect 201 -ns admin add com.test.TC_Perm2.@[user.name].p testunused@aaf.att.com - -# TC_Perm2.40.32.POS Remove admin from sub-NS -expect 200 -ns admin del com.test.TC_Perm2.@[user.name].p testid@aaf.att.com - -# TC_Perm2.40.34.POS Admin of parent NS should be able to view -expect 200 -perm list name com.test.TC_Perm2.@[user.name].p.A - -# TC_Perm2.40.80.POS Add new admin for sub-NS -expect 201 -ns admin add com.test.TC_Perm2.@[user.name].p testid@aaf.att.com - -# TC_Perm2.40.81.POS Remove admin from sub-NS -expect 200 -ns admin del com.test.TC_Perm2.@[user.name].p testunused@aaf.att.com - diff --git a/authz-test/TestSuite/TC_Perm2/41_viewByUser b/authz-test/TestSuite/TC_Perm2/41_viewByUser deleted file mode 100644 index 51c2ecb4..00000000 --- a/authz-test/TestSuite/TC_Perm2/41_viewByUser +++ /dev/null @@ -1,34 +0,0 @@ -# TC_Perm2.41.1.POS Add user to some roles with perms attached -as testid@aaf.att.com -expect 201 -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -user role add XX@NS com.test.TC_Perm2.@[user.name].p.secret - -# TC_Perm2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -expect 200 -perm list user testunused@aaf.att.com - -# TC_NS2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -expect 200 -perm list user testunused@aaf.att.com - -# TC_Perm2.41.20.POS List by User when not same as Caller, but parent owner/admin of Namespace -as XX@NS -expect 200 -perm list user testunused@aaf.att.com - -# TC_Perm2.41.80.NEG List by User when not Caller nor associated to Namespace (nothing should be shown) -as testunused@aaf.att.com -expect 200 -perm list user XX@NS - -# TC_Perm2.41.99.POS Remove users from roles for later test -as testid@aaf.att.com -expect 200 -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -user role del XX@NS com.test.TC_Perm2.@[user.name].p.secret - diff --git a/authz-test/TestSuite/TC_Perm2/42_viewByNS b/authz-test/TestSuite/TC_Perm2/42_viewByNS deleted file mode 100644 index 69f4ed63..00000000 --- a/authz-test/TestSuite/TC_Perm2/42_viewByNS +++ /dev/null @@ -1,10 +0,0 @@ -# TC_Perm2.42.10.POS List Roles from NS when not allowed to see NS -as testid@aaf.att.com -expect 200 -perm list ns com.test.TC_Perm2.@[user.name].p - -# TC_Perm2.42.20.NEG Don't List Roles from NS when not allowed to see NS -as testunused@aaf.att.com -expect 403 -perm list ns com.test.TC_Perm2.@[user.name].p - diff --git a/authz-test/TestSuite/TC_Perm2/43_viewByRole b/authz-test/TestSuite/TC_Perm2/43_viewByRole deleted file mode 100644 index 29585b47..00000000 --- a/authz-test/TestSuite/TC_Perm2/43_viewByRole +++ /dev/null @@ -1,15 +0,0 @@ -# TC_Perm2.43.10.POS List perms when allowed to see Role -as testid@aaf.att.com -expect 200 -perm list role com.test.TC_Perm2.@[user.name].p.superUser -perm list role com.test.TC_Perm2.@[user.name].p.watcher -perm list role com.test.TC_Perm2.@[user.name].p.secret - -# TC_Perm2.43.20.NEG Don't List perms when not allowed to see Role -as testunused@aaf.att.com -expect 403 -perm list role com.test.TC_Perm2.@[user.name].p.superUser -perm list role com.test.TC_Perm2.@[user.name].p.watcher -perm list role com.test.TC_Perm2.@[user.name].p.secret - - diff --git a/authz-test/TestSuite/TC_Perm2/99_cleanup b/authz-test/TestSuite/TC_Perm2/99_cleanup deleted file mode 100644 index 2d853869..00000000 --- a/authz-test/TestSuite/TC_Perm2/99_cleanup +++ /dev/null @@ -1,24 +0,0 @@ -as testid@aaf.att.com -# TC_Perm2.99.1.POS Namespace Admin can delete Namepace defined Roles -expect 200,404 - -force perm delete com.test.TC_Perm2.@[user.name].p.A myInstance myAction -force perm delete com.test.TC_Perm2.@[user.name].p.A myInstance * -force perm delete com.test.TC_Perm2.@[user.name].p.A * * -force perm delete com.test.TC_Perm2.@[user.name].p.phoneCalls * spy -force role delete com.test.TC_Perm2.@[user.name].p.watcher -force role delete com.test.TC_Perm2.@[user.name].p.superUser -force role delete com.test.TC_Perm2.@[user.name].p.secret - -as XX@NS -force perm delete com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view -force perm delete com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:myInstance:myAction view - -# TC_Perm2.99.2.POS Namespace Admin can delete Namespace -expect 200,404 -force ns delete com.test.TC_Perm2.@[user.name].p -force ns delete com.test.TC_Perm2.@[user.name] - -# TC_Perm2.99.3.POS Print Namespaces -ns list name com.test.TC_Perm2.@[user.name].p -ns list name com.test.TC_Perm2.@[user.name] diff --git a/authz-test/TestSuite/TC_Perm2/Description b/authz-test/TestSuite/TC_Perm2/Description deleted file mode 100644 index 96cb3708..00000000 --- a/authz-test/TestSuite/TC_Perm2/Description +++ /dev/null @@ -1,9 +0,0 @@ -This Testcase Tests the viewability of different perm commands - -APIs: - - - -CLI: - - diff --git a/authz-test/TestSuite/TC_Perm3/00_ids b/authz-test/TestSuite/TC_Perm3/00_ids deleted file mode 100644 index ad09d774..00000000 --- a/authz-test/TestSuite/TC_Perm3/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set testid_1@test.com=<pass> -set testid_2@test.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Perm3/10_init b/authz-test/TestSuite/TC_Perm3/10_init deleted file mode 100644 index f8e2ebf1..00000000 --- a/authz-test/TestSuite/TC_Perm3/10_init +++ /dev/null @@ -1,16 +0,0 @@ -as XX@NS -# TC_Perm3.10.0.POS Print NS to prove ok -expect 200 -ns list name com.test.TC_Perm3.@[user.name] - -# TC_Perm3.10.1.POS Create Namespace with User ID -expect 201 -ns create com.test.TC_Perm3.@[user.name]_1 @[user.name] testid_1@test.com - -# TC_Perm3.10.2.POS Create Namespace with Different ID -expect 201 -ns create com.test.TC_Perm3.@[user.name]_2 @[user.name] testid_2@test.com - -# TC_Perm3.10.3.POS Create Namespace in Different Company -expect 201 -ns create com.att.TC_Perm3.@[user.name] @[user.name] testunused@aaf.att.com diff --git a/authz-test/TestSuite/TC_Perm3/20_innerGrants b/authz-test/TestSuite/TC_Perm3/20_innerGrants deleted file mode 100644 index 4f6482cd..00000000 --- a/authz-test/TestSuite/TC_Perm3/20_innerGrants +++ /dev/null @@ -1,29 +0,0 @@ -as testid_1@test.com - -# TC_Perm3.20.0.POS User1 Create a Perm -expect 201 -perm create com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction - -# TC_Perm3.20.5.NEG User1 should not be able to create Role in other group -expect 403 -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_a - -# TC_Perm3.20.6.POS User2 should be able to create Role in own group -as testid_2@test.com -expect 201 -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_a - -# TC_Perm3.20.7.NEG User2 should not be able to grant Perm to own Role -expect 403 -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a - -# TC_Perm3.20.8.NEG User2 cannot create Role in NS 2 -as testid_2@test.com -expect 403 -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a - -# TC_Perm3.20.9.POS Role created, but can't grant... has to be testid_1 -expect 201 -as testid_1@test.com -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a - diff --git a/authz-test/TestSuite/TC_Perm3/30_outerGrants b/authz-test/TestSuite/TC_Perm3/30_outerGrants deleted file mode 100644 index ca2f7c53..00000000 --- a/authz-test/TestSuite/TC_Perm3/30_outerGrants +++ /dev/null @@ -1,23 +0,0 @@ -# TC_Perm3.30.0.POS User1 Create a Perm -as testid_1@test.com -expect 201 -perm create com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction - -# TC_Perm3.30.5.NEG User1 should not be able to create Role in other group -expect 403 -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_b - -# TC_Perm3.30.6.POS User2 should be able to create Role in own group -as testunused@aaf.att.com -expect 201 -role create com.att.TC_Perm3.@[user.name].dev.myRole_b - -# TC_Perm3.30.7.NEG User2 should not be able to grant Perm to own Role -expect 403 -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction com.att.TC_Perm3.@[user.name].dev.myRole_b - -# TC_Perm3.30.8.POS User should be able to grant cross company only Double Perm -as testid_1@test.com -expect 403 -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction com.att.TC_Perm3.@[user.name].dev.myRole_b - diff --git a/authz-test/TestSuite/TC_Perm3/99_cleanup b/authz-test/TestSuite/TC_Perm3/99_cleanup deleted file mode 100644 index 89b20783..00000000 --- a/authz-test/TestSuite/TC_Perm3/99_cleanup +++ /dev/null @@ -1,22 +0,0 @@ -expect 200,404 -as testid_1@test.com -# TC_Perm3.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Perm3.@[user.name]_1 - -# TC_Perm3.99.3.POS Print Namespaces -ns list name com.test.TC_Perm3.@[user.name]_1 - -as testid_2@test.com -# TC_Perm3.99.4.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Perm3.@[user.name]_2 - -# TC_Perm3.99.5.POS Print Namespaces -ns list name com.test.TC_Perm3.@[user.name]_2 - - -as testunused@aaf.att.com -# TC_Perm3.99.6.POS Remove Namespace from other company -force ns delete com.att.TC_Perm3.@[user.name] - -# TC_Perm3.99.7.POS Print Namespace from other company -ns list name com.att.TC_Perm3.@[user.name] diff --git a/authz-test/TestSuite/TC_Perm3/Description b/authz-test/TestSuite/TC_Perm3/Description deleted file mode 100644 index 9f572aa2..00000000 --- a/authz-test/TestSuite/TC_Perm3/Description +++ /dev/null @@ -1,13 +0,0 @@ -This is a targeted Test Case specifically to cover Inner and Outer Granting. - -APIs: - - -CLI: -ns create -ns delete -perm create -perm grant -role create -as - diff --git a/authz-test/TestSuite/TC_Realm1/00_ids b/authz-test/TestSuite/TC_Realm1/00_ids deleted file mode 100644 index 7fb0e054..00000000 --- a/authz-test/TestSuite/TC_Realm1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Realm1/10_init b/authz-test/TestSuite/TC_Realm1/10_init deleted file mode 100644 index 6fee8d9f..00000000 --- a/authz-test/TestSuite/TC_Realm1/10_init +++ /dev/null @@ -1,20 +0,0 @@ - -as testid@aaf.att.com - -# TC_Realm1.10.0.POS Validate no NS -expect 200,404 -ns list name com.test.TC_Realm1.@[user.name] - -# TC_Realm1.10.1.POS Create Namespace to add IDs -expect 201 -ns create com.test.TC_Realm1.@[user.name] @[user.name] testid@aaf.att.com - -as XX@NS -# TC_Realm1.10.10.POS Grant ability to change delegates -expect 201 -force perm create com.att.aaf.delg com.att create com.test.TC_Realm1.@[user.name].change_delg - -# TC_Realm1.10.11.POS Create user role to change delegates -expect 201 -user role add testid@aaf.att.com com.test.TC_Realm1.@[user.name].change_delg - diff --git a/authz-test/TestSuite/TC_Realm1/20_ns b/authz-test/TestSuite/TC_Realm1/20_ns deleted file mode 100644 index b090d96d..00000000 --- a/authz-test/TestSuite/TC_Realm1/20_ns +++ /dev/null @@ -1,26 +0,0 @@ - -as testid@aaf.att.com -# TC_Realm1.20.1.NEG Fail to create - default domain wrong -expect 403 -ns create com.test.TC_Realm1.@[user.name].project1 testunused - -# TC_Realm1.20.2.POS Create - default domain appended -expect 201 -ns create com.test.TC_Realm1.@[user.name].project1 @[user.name] @[user.name] - -# TC_Realm1.20.3.NEG Fail to create - default domain wrong -expect 403 -ns admin add com.test.TC_Realm1.@[user.name].project1 testunused - -# TC_Realm1.20.4.POS Create - full domain given -expect 201 -ns admin add com.test.TC_Realm1.@[user.name].project1 testid@aaf.att.com - -# TC_Realm1.20.5.POS Delete - default domain appended -expect 200 -ns admin del com.test.TC_Realm1.@[user.name].project1 @[user.name] - -# TC_Realm1.20.6.POS Add admin - default domain appended -expect 201 -ns admin add com.test.TC_Realm1.@[user.name].project1 @[user.name] - diff --git a/authz-test/TestSuite/TC_Realm1/30_role b/authz-test/TestSuite/TC_Realm1/30_role deleted file mode 100644 index ea99bc25..00000000 --- a/authz-test/TestSuite/TC_Realm1/30_role +++ /dev/null @@ -1,20 +0,0 @@ -# TC_Realm1.30.1.POS Create role to add to users -expect 201 -role create com.test.TC_Realm1.@[user.name].role1 - -# TC_Realm1.30.2.NEG Add user, but default domain wrong -expect 403 -role user add com.test.TC_Realm1.@[user.name].role1 testunused - -# TC_Realm1.30.3.POS Add user, with default domain appended -expect 201 -role user add com.test.TC_Realm1.@[user.name].role1 @[user.name] - -# TC_Realm1.30.10.POS Role list, with default domain added -expect 200 -role list user testunused - -# TC_Realm1.30.80.POS Delete user, with default domain appended -expect 200 -role user del com.test.TC_Realm1.@[user.name].role1 @[user.name] - diff --git a/authz-test/TestSuite/TC_Realm1/40_user b/authz-test/TestSuite/TC_Realm1/40_user deleted file mode 100644 index 629251ea..00000000 --- a/authz-test/TestSuite/TC_Realm1/40_user +++ /dev/null @@ -1,42 +0,0 @@ -# TC_Realm1.40.1.POS Create role to add to users -expect 201 -role create com.test.TC_Realm1.@[user.name].role2 - -# TC_Realm1.40.2.NEG Add user, but default domain wrong -expect 403 -user role add testunused com.test.TC_Realm1.@[user.name].role2 - -# TC_Realm1.40.3.POS Add user, with default domain appended -expect 201 -user role add @[user.name] com.test.TC_Realm1.@[user.name].role2 - -# TC_Realm1.40.10.NEG Add delegate, but default domain wrong -expect 404 -user delegate add testunused testid 2099-01-01 - -# TC_Realm1.40.11.POS Add delegate, with default domain appended -expect 201 -force user delegate add @[user.name] @[user.name] 2099-01-01 - -# TC_Realm1.40.12.POS Update delegate, with default domain appended -expect 200 -user delegate upd @[user.name] @[user.name] 2099-01-01 - -as XX@NS -# TC_Realm1.40.20.POS List delegate, with default domain appended -expect 200 -user list delegates user @[user.name] - -# TC_Realm1.40.21.POS List delegate, with default domain appended -expect 200 -user list delegates delegate @[user.name] - -as testid@aaf.att.com -# TC_Realm1.40.80.POS Delete user, with default domain appended -expect 200 -user role del @[user.name] com.test.TC_Realm1.@[user.name].role2 - -# TC_Realm1.40.81.POS Delete delegate, with default domain appended -expect 200 -user delegate del @[user.name] - diff --git a/authz-test/TestSuite/TC_Realm1/99_cleanup b/authz-test/TestSuite/TC_Realm1/99_cleanup deleted file mode 100644 index cf8c3a90..00000000 --- a/authz-test/TestSuite/TC_Realm1/99_cleanup +++ /dev/null @@ -1,28 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_Realm1.99.1.POS Delete delgates -user delegate del @[user.name] - -# TC_Realm1.99.2.POS Delete user roles -role user del com.test.TC_Realm1.@[user.name].role1 @[user.name] -user role del @[user.name] com.test.TC_Realm1.@[user.name].role2 - -# TC_Realm1.99.3.POS Delete roles -role delete com.test.TC_Realm1.@[user.name].role1 -role delete com.test.TC_Realm1.@[user.name].role2 - -as XX@NS -# TC_Realm1.99.10.POS UnGrant ability to change delegates -perm ungrant com.att.aaf.delg com.att change com.test.TC_Realm1.@[user.name].change_delg - -as testid@aaf.att.com -# TC_Realm1.99.11.POS Delete role to change delegates -set force=true role delete com.test.TC_Realm1.@[user.name].change_delg - -# TC_Realm1.99.98.POS Delete Namespaces -ns delete com.test.TC_Realm1.@[user.name] -ns delete com.test.TC_Realm1.@[user.name].project1 - -# TC_Realm1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_Realm1.@[user.name] diff --git a/authz-test/TestSuite/TC_Realm1/Description b/authz-test/TestSuite/TC_Realm1/Description deleted file mode 100644 index edd16859..00000000 --- a/authz-test/TestSuite/TC_Realm1/Description +++ /dev/null @@ -1,2 +0,0 @@ -This Testcase tests that the default domain is appended before being sent to the server - diff --git a/authz-test/TestSuite/TC_Role1/00_ids b/authz-test/TestSuite/TC_Role1/00_ids deleted file mode 100644 index 7fb0e054..00000000 --- a/authz-test/TestSuite/TC_Role1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Role1/10_init b/authz-test/TestSuite/TC_Role1/10_init deleted file mode 100644 index 4af50879..00000000 --- a/authz-test/TestSuite/TC_Role1/10_init +++ /dev/null @@ -1,23 +0,0 @@ -as testid@aaf.att.com - -# TC_Role1.10.0.POS Validate NS ok -expect 200 -ns list name com.test.TC_Role1.@[user.name] - -# TC_Role1.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_Role1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Role1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_Role1.@[user.name].cred_admin - -as XX@NS -# TC_Role1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_Role1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_Role1.10.12.POS Assign user for creating creds -expect 201 -user role add testid@aaf.att.com com.test.TC_Role1.@[user.name].cred_admin diff --git a/authz-test/TestSuite/TC_Role1/20_add_data b/authz-test/TestSuite/TC_Role1/20_add_data deleted file mode 100644 index 43c97d92..00000000 --- a/authz-test/TestSuite/TC_Role1/20_add_data +++ /dev/null @@ -1,40 +0,0 @@ -# TC_Role1.20.1.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Role1.@[user.name] - -# TC_Role1.20.2.POS Add Roles -expect 201 -role create com.test.TC_Role1.@[user.name].r.A -role create com.test.TC_Role1.@[user.name].r.B - -# TC_Role1.20.3.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Role1.@[user.name] - -# TC_Role1.20.4.NEG Don't write over Role -expect 409 -role create com.test.TC_Role1.@[user.name].r.A - -# TC_Role1.20.5.NEG Don't allow non-user to create -expect 401 -as bogus -role create com.test.TC_Role1.@[user.name].r.No - -# TC_Role1.20.6.NEG Don't allow non-user to create without Approval -expect 403 -as testunused@aaf.att.com -role create com.test.TC_Role1.@[user.name].r.No - -# TC_Role1.20.10.NEG Non-admins can't change description -expect 403 -as testunused@aaf.att.com -role describe com.test.TC_Role1.@[user.name].r.A Description A - -# TC_Role1.20.11.NEG Role must exist to change description -expect 404 -as testid@aaf.att.com -role describe com.test.TC_Role1.@[user.name].r.C Description C - -# TC_Role1.20.12.POS Admin can change description -expect 200 -role describe com.test.TC_Role1.@[user.name].r.A Description A diff --git a/authz-test/TestSuite/TC_Role1/30_change_ns b/authz-test/TestSuite/TC_Role1/30_change_ns deleted file mode 100644 index 4d32f656..00000000 --- a/authz-test/TestSuite/TC_Role1/30_change_ns +++ /dev/null @@ -1,14 +0,0 @@ -# TC_Role1.30.1.POS List Data on non-Empty NS -as testid@aaf.att.com -expect 200 -ns list name com.test.TC_Role1.@[user.name] - -# TC_Role1.30.2.POS Create Sub-ns when Roles that exist -expect 201 -ns create com.test.TC_Role1.@[user.name].r @[user.name] testid@aaf.att.com - -# TC_Role1.30.3.POS List Data on NS with sub-roles -expect 200 -ns list name com.test.TC_Role1.@[user.name] -ns list name com.test.TC_Role1.@[user.name].r - diff --git a/authz-test/TestSuite/TC_Role1/40_reports b/authz-test/TestSuite/TC_Role1/40_reports deleted file mode 100644 index 657d1c7c..00000000 --- a/authz-test/TestSuite/TC_Role1/40_reports +++ /dev/null @@ -1,24 +0,0 @@ -# TC_Role1.40.01.POS List Data on non-Empty NS -expect 200 -role list role com.test.TC_Role1.@[user.name].r.A - -# TC_Role1.40.20.POS Create a Perm, and add to Role -expect 201 -perm create com.test.TC_Role1.@[user.name].samplePerm1 some.long(involved).text SELECT com.test.TC_Role1.@[user.name].r.A - -# TC_Role1.40.25.POS List -expect 200 -role list role com.test.TC_Role1.@[user.name].r.A - -# TC_Role1.40.30.POS Create a Perm -expect 201 -perm create com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case - -# TC_Role1.40.32.POS Separately Grant Perm -expect 201 -perm grant com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case com.test.TC_Role1.@[user.name].r.A - -# TC_Role1.40.35.POS List -expect 200 -role list role com.test.TC_Role1.@[user.name].r.A - diff --git a/authz-test/TestSuite/TC_Role1/50_force_delete b/authz-test/TestSuite/TC_Role1/50_force_delete deleted file mode 100644 index ef334b24..00000000 --- a/authz-test/TestSuite/TC_Role1/50_force_delete +++ /dev/null @@ -1,28 +0,0 @@ -# TC_Role1.50.1.POS Create user to attach to role
-expect 201
-user cred add m00001@@[user.name].TC_Role1.test.com password123
-
-# TC_Role1.50.2.POS Create new role
-expect 201
-role create com.test.TC_Role1.@[user.name].r.C
-
-# TC_Role1.50.3.POS Attach user to role
-expect 201
-user role add m00001@@[user.name].TC_Role1.test.com com.test.TC_Role1.@[user.name].r.C
-
-# TC_Role1.50.4.POS Create permission and attach to role
-expect 201
-perm create com.test.TC_Role1.@[user.name].p.C myInstance myAction com.test.TC_Role1.@[user.name].r.C
-
-# TC_Role1.50.20.NEG Delete role with permission and user attached should fail
-expect 424
-role delete com.test.TC_Role1.@[user.name].r.C
-
-# TC_Role1.50.21.POS Force delete role should work
-expect 200
-set force=true role delete com.test.TC_Role1.@[user.name].r.C
-
-# TC_Role1.50.30.POS List Data on non-Empty NS
-expect 200
-ns list name com.test.TC_Role1.@[user.name]
-
diff --git a/authz-test/TestSuite/TC_Role1/90_wait b/authz-test/TestSuite/TC_Role1/90_wait deleted file mode 100644 index 91d890f0..00000000 --- a/authz-test/TestSuite/TC_Role1/90_wait +++ /dev/null @@ -1,2 +0,0 @@ -# Need to let DB catch up on deletes -sleep @[NFR] diff --git a/authz-test/TestSuite/TC_Role1/99_cleanup b/authz-test/TestSuite/TC_Role1/99_cleanup deleted file mode 100644 index 63e240eb..00000000 --- a/authz-test/TestSuite/TC_Role1/99_cleanup +++ /dev/null @@ -1,34 +0,0 @@ -as testid@aaf.att.com -expect 200,404 - -# TC_Role1.99.05.POS Remove Permissions from "40_reports" -set force=true perm delete com.test.TC_Role1.@[user.name].samplePerm1 some.long(involved).text SELECT -set force=true perm delete com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case - -# TC_Role1.99.10.POS Namespace Admin can delete Namepace defined Roles -force role delete com.test.TC_Role1.@[user.name].r.A -force role delete com.test.TC_Role1.@[user.name].r.B -force role delete com.test.TC_Role1.@[user.name].r.C - -# TC_Role1.99.15.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_Role1.@[user.name].cred_admin - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Role1.@[user.name].cred_admin - -as testid@aaf.att.com -role delete com.test.TC_Role1.@[user.name].cred_admin - -# TC_Role1.99.20.POS Namespace Admin can delete permissions and credentials -perm delete com.test.TC_Role1.@[user.name].p.C myInstance myAction -set force=true -user cred del m00001@@[user.name].TC_Role1.test.com - -# TC_Role1.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Role1.@[user.name].r -force ns delete com.test.TC_Role1.@[user.name] - -# TC_Role1.99.99.POS List to prove clean Namespaces -ns list name com.test.TC_Role1.@[user.name].r -ns list name com.test.TC_Role1.@[user.name] - diff --git a/authz-test/TestSuite/TC_Role1/Description b/authz-test/TestSuite/TC_Role1/Description deleted file mode 100644 index 012a12b1..00000000 --- a/authz-test/TestSuite/TC_Role1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of the Namespace, and the NS Commands - -APIs: - - - -CLI: - Target - role create :role - role delete - ns delete :ns - ns list :ns - Ancillary - role create :role - role list name :role.* - diff --git a/authz-test/TestSuite/TC_Role2/00_ids b/authz-test/TestSuite/TC_Role2/00_ids deleted file mode 100644 index f7196fc8..00000000 --- a/authz-test/TestSuite/TC_Role2/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Role2/10_init b/authz-test/TestSuite/TC_Role2/10_init deleted file mode 100644 index dbe7b858..00000000 --- a/authz-test/TestSuite/TC_Role2/10_init +++ /dev/null @@ -1,8 +0,0 @@ -as testid@aaf.att.com -# TC_Role2.10.0.POS Print NS to prove ok -expect 200 -ns list name com.test.TC_Role2.@[user.name] - -# TC_Role2.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_Role2.@[user.name] @[user.name] testid@aaf.att.com diff --git a/authz-test/TestSuite/TC_Role2/20_add_data b/authz-test/TestSuite/TC_Role2/20_add_data deleted file mode 100644 index 6b85dea1..00000000 --- a/authz-test/TestSuite/TC_Role2/20_add_data +++ /dev/null @@ -1,39 +0,0 @@ -############## -# Testing Model -# We are making a Testing model based loosely on George Orwell's Animal Farm -# In Animal Farm, Animals did all the work but didn't get any priviledges. -# In our test, the animals can't see anything but their own role, etc -# Dogs were supervisors, and ostensibly did something, though mostly laid around -# In our test, they have Implicit Permissions by being Admins -# Pigs were the Elite. They did nothing, but watch everyone and eat the produce -# In our test, they have Explicit Permissions to see everything they want -############## -as testid@aaf.att.com:<pass> -# TC_Role2.20.1.POS List Data on non-Empty NS -expect 200 -ns list name com.test.TC_Role2.@[user.name] - -# TC_Role2.20.10.POS Create Orwellian Roles -expect 201 -role create com.test.TC_Role2.@[user.name].r.animals -role create com.test.TC_Role2.@[user.name].r.dogs -role create com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.20.20.POS Create and Grant Perms to Dog Roles -expect 201 -perm create com.test.TC_Role2.@[user.name].r.A garbage eat com.test.TC_Role2.@[user.name].r.animals -perm create com.test.TC_Role2.@[user.name].r.A grain eat com.test.TC_Role2.@[user.name].r.dogs -perm create com.test.TC_Role2.@[user.name].r.A grain * com.test.TC_Role2.@[user.name].r.dogs -perm create com.test.TC_Role2.@[user.name].r.A * * com.test.TC_Role2.@[user.name].r.dogs - -# TC_Role2.20.25.POS Create and Grant Animal Farm Priviledges to Pigs -expect 201 -as XX@NS:<pass> -perm create com.att.aaf.role com.test.TC_Role2.@[user.name].r.animals view com.test.TC_Role2.@[user.name].r.pigs -perm create com.att.aaf.role com.test.TC_Role2.@[user.name].r.dogs view com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.20.60.POS List Data on non-Empty NS -expect 200 -as testid@aaf.att.com:<pass> -ns list name com.test.TC_Role2.@[user.name] - diff --git a/authz-test/TestSuite/TC_Role2/40_viewByName b/authz-test/TestSuite/TC_Role2/40_viewByName deleted file mode 100644 index a6ec33c5..00000000 --- a/authz-test/TestSuite/TC_Role2/40_viewByName +++ /dev/null @@ -1,45 +0,0 @@ -as XX@NS -# TC_Role2.40.1.POS List Data on Role -expect 200 -role list role com.test.TC_Role2.@[user.name].r.animals -role list role com.test.TC_Role2.@[user.name].r.dogs -role list role com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.40.10.POS Add testunused to animals -expect 201 -as testid@aaf.att.com -user role add testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.animals - -# TC_Role2.40.11.POS List by Name when part of role -as testunused@aaf.att.com -expect 200 -role list role com.test.TC_Role2.@[user.name].r.animals - -# TC_Role2.40.12.NEG List by Name when not part of Role -expect 403 -role list role com.test.TC_Role2.@[user.name].r.dogs -role list role com.test.TC_Role2.@[user.name].r.pigs - - -# TC_Role2.40.30.POS Read various Roles based on being Admin in Namespace -as testid@aaf.att.com -expect 200 -role list role com.test.TC_Role2.@[user.name].r.animals -role list role com.test.TC_Role2.@[user.name].r.dogs -role list role com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.40.50.POS Change testunused to Pigs -as testid@aaf.att.com -expect 200 -user role del testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.animals -expect 201 -user role add testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.40.51.POS Read various Roles based on having Explicit Permissions -as testunused@aaf.att.com -expect 403 -role list role com.test.TC_Role2.@[user.name].r.animals -role list role com.test.TC_Role2.@[user.name].r.dogs -expect 200 -role list role com.test.TC_Role2.@[user.name].r.pigs - diff --git a/authz-test/TestSuite/TC_Role2/41_viewByUser b/authz-test/TestSuite/TC_Role2/41_viewByUser deleted file mode 100644 index 684d9ba1..00000000 --- a/authz-test/TestSuite/TC_Role2/41_viewByUser +++ /dev/null @@ -1,20 +0,0 @@ -# TC_Role2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -expect 200 -role list user testunused@aaf.att.com - -# TC_Role2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -expect 200 -role list user testunused@aaf.att.com - -# TC_Role2.41.20.POS List by User when not same as Caller, but parent owner of Namespace -as XX@NS -expect 200 -role list user testunused@aaf.att.com - -# TC_Role2.41.80.NEG List by User when not Caller nor associated to Namespace (nothing should be shown) -as testunused@aaf.att.com -expect 200 -role list user XX@NS - diff --git a/authz-test/TestSuite/TC_Role2/42_viewByNS b/authz-test/TestSuite/TC_Role2/42_viewByNS deleted file mode 100644 index 8f184943..00000000 --- a/authz-test/TestSuite/TC_Role2/42_viewByNS +++ /dev/null @@ -1,10 +0,0 @@ -# TC_Role2.42.10.POS List Roles from NS when not allowed to see NS -as testid@aaf.att.com -expect 200 -role list ns com.test.TC_Role2.@[user.name] - -# TC_Role2.42.20.NEG Don't List Roles from NS when not allowed to see NS -as testunused@aaf.att.com -expect 403 -role list ns com.test.TC_Role2.@[user.name] - diff --git a/authz-test/TestSuite/TC_Role2/43_viewByPerm b/authz-test/TestSuite/TC_Role2/43_viewByPerm deleted file mode 100644 index 53a1e3d4..00000000 --- a/authz-test/TestSuite/TC_Role2/43_viewByPerm +++ /dev/null @@ -1,15 +0,0 @@ -# TC_Role2.43.10.POS List Roles when allowed to see Perm -as testid@aaf.att.com -expect 200 -role list perm com.test.TC_Role2.@[user.name].r.A grain eat -role list perm com.test.TC_Role2.@[user.name].r.A grain * -role list perm com.test.TC_Role2.@[user.name].r.A * * - -# TC_Role2.43.15.NEG Don't List Roles when not allowed to see Perm -as testunused@aaf.att.com -expect 403 -role list perm com.test.TC_Role2.@[user.name].r.A grain eat -role list perm com.test.TC_Role2.@[user.name].r.A grain * -role list perm com.test.TC_Role2.@[user.name].r.A * * - - diff --git a/authz-test/TestSuite/TC_Role2/99_cleanup b/authz-test/TestSuite/TC_Role2/99_cleanup deleted file mode 100644 index df344b2d..00000000 --- a/authz-test/TestSuite/TC_Role2/99_cleanup +++ /dev/null @@ -1,22 +0,0 @@ -as XX@NS -expect 200,404 - -# TC_Role2.99.1.POS Delete Roles -force role delete com.test.TC_Role2.@[user.name].r.animals -force role delete com.test.TC_Role2.@[user.name].r.dogs -force role delete com.test.TC_Role2.@[user.name].r.pigs - -# TC_Role2.99.2.POS Delete Perms -force perm delete com.test.TC_Role2.@[user.name].r.A garbage eat -force perm delete com.test.TC_Role2.@[user.name].r.A grain eat -force perm delete com.test.TC_Role2.@[user.name].r.A grain * -force perm delete com.test.TC_Role2.@[user.name].r.A * * -force perm delete com.att.aaf.role com.test.TC_Role2.@[user.name].r.animals view -force perm delete com.att.aaf.role com.test.TC_Role2.@[user.name].r.dogs view - - -# TC_Role2.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Role2.@[user.name] - -# TC_Role2.99.3.POS Print Namespaces -ns list name com.test.TC_Role2.@[user.name] diff --git a/authz-test/TestSuite/TC_Role2/Description b/authz-test/TestSuite/TC_Role2/Description deleted file mode 100644 index ea741a81..00000000 --- a/authz-test/TestSuite/TC_Role2/Description +++ /dev/null @@ -1,9 +0,0 @@ -This Testcase Tests the viewability of different role commands - -APIs: - - - -CLI: - - diff --git a/authz-test/TestSuite/TC_UR1/00_ids b/authz-test/TestSuite/TC_UR1/00_ids deleted file mode 100644 index 7fb0e054..00000000 --- a/authz-test/TestSuite/TC_UR1/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_UR1/10_init b/authz-test/TestSuite/TC_UR1/10_init deleted file mode 100644 index 3709b5be..00000000 --- a/authz-test/TestSuite/TC_UR1/10_init +++ /dev/null @@ -1,31 +0,0 @@ -as testid@aaf.att.com -# TC_UR1.10.0.POS Validate no NS -expect 200 -ns list name com.test.TC_UR1.@[user.name] - -# TC_UR1.10.1.POS Create Namespace to add IDs -expect 201 -ns create com.test.TC_UR1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Role1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_UR1.@[user.name].cred_admin - -as XX@NS -# TC_Role1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_UR1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_Role1.10.12.POS Assign user for creating creds -expect 201 -user role add testid@aaf.att.com com.test.TC_UR1.@[user.name].cred_admin - -# TC_UR1.10.20.POS Create two Credentials -user cred add m00001@@[user.name].TC_UR1.test.com "abc123sd" -user cred add m00002@@[user.name].TC_UR1.test.com "abc123sd" - -# TC_UR1.10.21.POS Create two Roles -role create com.test.TC_UR1.@[user.name].r1 -role create com.test.TC_UR1.@[user.name].r2 - diff --git a/authz-test/TestSuite/TC_UR1/23_commands b/authz-test/TestSuite/TC_UR1/23_commands deleted file mode 100644 index b5345714..00000000 --- a/authz-test/TestSuite/TC_UR1/23_commands +++ /dev/null @@ -1,10 +0,0 @@ -# TC_UR1.23.1.NEG Too Few Args for User Role 1 -expect 0 -user - -# TC_UR1.23.2.NEG Too Few Args for user role -expect Exception -user role - -# TC_UR1.23.3.NEG Too Few Args for user role add -user role add diff --git a/authz-test/TestSuite/TC_UR1/30_userrole b/authz-test/TestSuite/TC_UR1/30_userrole deleted file mode 100644 index f4c514e5..00000000 --- a/authz-test/TestSuite/TC_UR1/30_userrole +++ /dev/null @@ -1,53 +0,0 @@ -# TC_UR1.30.10.POS Create a UserRole -expect 201 -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 - -# TC_UR1.30.11.NEG Created UserRole Exists -expect 409 -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 - -# TC_UR1.30.13.POS Delete UserRole -sleep @[NFR] -expect 200 -user role del m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 - - -# TC_UR1.30.20.POS Create multiple UserRoles -expect 201 -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 - -# TC_UR1.30.21.NEG Created UserRole Exists -expect 409 -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 - -# TC_UR1.30.23.POS Delete UserRole -sleep @[NFR] -expect 200 -user role del m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 - -# TC_UR1.30.30.POS Create a Role User -expect 201 -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com - -# TC_UR1.30.31.NEG Created Role User Exists -expect 409 -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com - -# TC_UR1.30.33.POS Delete Role User -sleep @[NFR] -expect 200 -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com - -# TC_UR1.30.40.POS Create multiple Role Users -expect 201 -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com - -# TC_UR1.30.41.NEG Created Role User Exists -expect 409 -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com - -# TC_UR1.30.43.POS Delete Role Users -sleep @[NFR] -expect 200 -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com - diff --git a/authz-test/TestSuite/TC_UR1/40_reset b/authz-test/TestSuite/TC_UR1/40_reset deleted file mode 100644 index 66f8c172..00000000 --- a/authz-test/TestSuite/TC_UR1/40_reset +++ /dev/null @@ -1,40 +0,0 @@ -# TC_UR1.40.10.POS Create multiple UserRoles
-expect 200
-user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2
-
-# TC_UR1.40.11.POS Reset userrole for a user
-expect 200
-user role setTo m00001@@[user.name].TC_UR1.test.com
-
-# TC_UR1.40.12.NEG Create userrole where Role doesn't exist
-expect 404
-user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r5
-
-# TC_UR1.40.13.NEG Create userrole where User doesn't exist
-expect 403
-user role setTo m99999@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1
-
-as testunused@aaf.att.com
-# TC_UR1.40.19.NEG User without permission tries to add userrole
-expect 403
-user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1
-
-# TC_UR1.40.20.NEG User without permission tries to add userrole
-expect 403
-role user setTo com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com
-
-as testid@aaf.att.com
-# TC_UR1.40.22.POS Reset userrole for a user
-expect 200
-role user setTo com.test.TC_UR1.@[user.name].r1
-
-sleep @[NFR]
-# TC_UR1.40.23.NEG Create UserRole where Role doesn't exist
-expect 404
-role user setTo com.test.TC_UR1.@[user.name].r5 m00001@@[user.name].TC_UR1.test.com
-
-sleep @[NFR]
-# TC_UR1.40.24.NEG Create UserRole where User doesn't exist
-expect 403
-role user setTo com.test.TC_UR1.@[user.name].r1 m99999@@[user.name].TC_UR1.test.com
-
diff --git a/authz-test/TestSuite/TC_UR1/90_wait b/authz-test/TestSuite/TC_UR1/90_wait deleted file mode 100644 index 91d890f0..00000000 --- a/authz-test/TestSuite/TC_UR1/90_wait +++ /dev/null @@ -1,2 +0,0 @@ -# Need to let DB catch up on deletes -sleep @[NFR] diff --git a/authz-test/TestSuite/TC_UR1/99_cleanup b/authz-test/TestSuite/TC_UR1/99_cleanup deleted file mode 100644 index c5e1caf5..00000000 --- a/authz-test/TestSuite/TC_UR1/99_cleanup +++ /dev/null @@ -1,32 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_UR1.99.1.POS Remove User from Role -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -role user del com.test.TC_UR1.@[user.name].r2 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -role user setTo com.test.TC_UR1.@[user.name].r1 - -# TC_UR1.99.2.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_UR1.@[user.name].cred_admin - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_UR1.@[user.name].cred_admin - -as testid@aaf.att.com -role delete com.test.TC_UR1.@[user.name].cred_admin - -# TC_UR1.99.3.POS Delete Creds -set force=true -user cred del m00001@@[user.name].TC_UR1.test.com -set force=true -user cred del m00002@@[user.name].TC_UR1.test.com - -# TC_UR1.99.4.POS Delete Roles -set force=true role delete com.test.TC_UR1.@[user.name].r1 -set force=true role delete com.test.TC_UR1.@[user.name].r2 - -# TC_UR1.99.5.POS Delete Namespace -set force=true ns delete com.test.TC_UR1.@[user.name] - -# TC_UR1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_UR1.@[user.name] diff --git a/authz-test/TestSuite/TC_UR1/Description b/authz-test/TestSuite/TC_UR1/Description deleted file mode 100644 index 24180f49..00000000 --- a/authz-test/TestSuite/TC_UR1/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of User Credentials - -APIs: - POST /auth/cred - PUT /auth/cred - DELETE /auth/cred - - -CLI: - Target - user cred add :user :password - user cred del :user - Ancillary - ns create - ns delete - diff --git a/authz-test/TestSuite/TC_User1/00_ids b/authz-test/TestSuite/TC_User1/00_ids deleted file mode 100644 index b989aa3b..00000000 --- a/authz-test/TestSuite/TC_User1/00_ids +++ /dev/null @@ -1,12 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set bogus@aaf.att.com=boguspass -set m99990@@[user.name].TC_User1.test.com=password123 -set m99995@@[user.name].TC_User1.test.com=password123 - -#delay 10 -set NFR=0 - - diff --git a/authz-test/TestSuite/TC_User1/10_init b/authz-test/TestSuite/TC_User1/10_init deleted file mode 100644 index 0cad5595..00000000 --- a/authz-test/TestSuite/TC_User1/10_init +++ /dev/null @@ -1,25 +0,0 @@ - -as testid@aaf.att.com -# TC_User1.10.0.POS Check for Existing Data -expect 200 -ns list name com.test.TC_User1.@[user.name] - -# TC_User1.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.test.TC_User1.@[user.name] @[user.name] testid@aaf.att.com - -# TC_User1.10.10.POS Create role to assign mechid perm to -expect 201 -role create com.test.TC_User1.@[user.name].cred_admin testid@aaf.att.com - -as XX@NS:<pass> -# TC_User1.10.11.POS Assign role to mechid perm -expect 201 -perm grant com.att.aaf.mechid com.att create com.test.TC_User1.@[user.name].cred_admin -perm grant com.att.aaf.delg com.att change com.test.TC_User1.@[user.name].cred_admin - -as testid@aaf.att.com -# TC_User1.01.99.POS Expect Namespace to be created -expect 200 -ns list name com.test.TC_User1.@[user.name] - diff --git a/authz-test/TestSuite/TC_User1/20_add_data b/authz-test/TestSuite/TC_User1/20_add_data deleted file mode 100644 index 9a9acec5..00000000 --- a/authz-test/TestSuite/TC_User1/20_add_data +++ /dev/null @@ -1,26 +0,0 @@ -as testid@aaf.att.com -# TC_User1.20.1.POS Create roles -expect 201 -role create com.test.TC_User1.@[user.name].manager -role create com.test.TC_User1.@[user.name].worker - -# TC_User1.20.2.POS Create permissions -perm create com.test.TC_User1.@[user.name].supplies * move com.test.TC_User1.@[user.name].worker -perm create com.test.TC_User1.@[user.name].supplies * stock com.test.TC_User1.@[user.name].worker -perm create com.test.TC_User1.@[user.name].schedule worker create com.test.TC_User1.@[user.name].manager -perm create com.test.TC_User1.@[user.name].worker * annoy com.test.TC_User1.@[user.name].manager - -# TC_User1.20.3.POS Create mechid -user cred add m99990@@[user.name].TC_User1.test.com password123 -user cred add m99995@@[user.name].TC_User1.test.com password123 - -as XX@NS -# TC_User1.20.10.POS Add users to roles -expect 201 -user role add @[user.name] com.test.TC_User1.@[user.name].manager -user role add m99990@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker - -# TC_User1.20.20.POS Add Delegate -as XX@NS -# TC_User1.20.20.POS Create delegates -force user delegate add @[user.name] @[user.name] diff --git a/authz-test/TestSuite/TC_User1/40_viewByRole b/authz-test/TestSuite/TC_User1/40_viewByRole deleted file mode 100644 index 824f01e2..00000000 --- a/authz-test/TestSuite/TC_User1/40_viewByRole +++ /dev/null @@ -1,23 +0,0 @@ - -# TC_User1.40.1.NEG Non-admin, user not in role should not view -expect 403 -as testunused@aaf.att.com -user list role com.test.TC_User1.@[user.name].manager -user list role com.test.TC_User1.@[user.name].worker - -as m99990@@[user.name].TC_User1.test.com -# TC_User1.40.2.NEG Non-admin, user in role should not view -expect 403 -user list role com.test.TC_User1.@[user.name].manager - -sleep @[NFR] -# TC_User1.40.3.POS Non-admin, user in role can view himself -expect 200 -user list role com.test.TC_User1.@[user.name].worker - -as testid@aaf.att.com -# TC_User1.40.10.POS admin should view -expect 200 -user list role com.test.TC_User1.@[user.name].manager -user list role com.test.TC_User1.@[user.name].worker - diff --git a/authz-test/TestSuite/TC_User1/41_viewByPerm b/authz-test/TestSuite/TC_User1/41_viewByPerm deleted file mode 100644 index 6813cb15..00000000 --- a/authz-test/TestSuite/TC_User1/41_viewByPerm +++ /dev/null @@ -1,29 +0,0 @@ -as testunused@aaf.att.com -# TC_User1.41.1.NEG Non-admin, user not in perm should not view -expect 200 -user list perm com.test.TC_User1.@[user.name].supplies * move -user list perm com.test.TC_User1.@[user.name].supplies * stock -user list perm com.test.TC_User1.@[user.name].schedule worker create -user list perm com.test.TC_User1.@[user.name].worker * annoy - -as m99990@@[user.name].TC_User1.test.com -# TC_User1.41.2.POS Non-admin, user in perm can view himself -expect 200 -user list perm com.test.TC_User1.@[user.name].supplies * move -user list perm com.test.TC_User1.@[user.name].supplies * stock - -as m99990@@[user.name].TC_User1.test.com -# TC_User1.41.3.NEG Non-admin, user in perm should not view -expect 200 -user list perm com.test.TC_User1.@[user.name].schedule worker create -user list perm com.test.TC_User1.@[user.name].worker * annoy - -as testid@aaf.att.com -# TC_User1.41.10.POS admin should view -expect 200 -user list perm com.test.TC_User1.@[user.name].supplies * move -user list perm com.test.TC_User1.@[user.name].supplies * stock -user list perm com.test.TC_User1.@[user.name].schedule worker create -user list perm com.test.TC_User1.@[user.name].worker * annoy - - diff --git a/authz-test/TestSuite/TC_User1/42_viewByDelegates b/authz-test/TestSuite/TC_User1/42_viewByDelegates deleted file mode 100644 index 7d16cb3c..00000000 --- a/authz-test/TestSuite/TC_User1/42_viewByDelegates +++ /dev/null @@ -1,12 +0,0 @@ -as testunused@aaf.att.com -# TC_User1.42.1.NEG Unrelated user can't view delegates -expect 403 -user list delegates user m99990@@[user.name].TC_User1.test.com -user list delegates delegate m99995@@[user.name].TC_User1.test.com - -as XX@NS -# TC_User1.42.10.POS Admin of domain NS can view -expect 200 -user list delegates user @[user.name] -user list delegates delegate @[user.name] - diff --git a/authz-test/TestSuite/TC_User1/43_viewsExplicitiPerm b/authz-test/TestSuite/TC_User1/43_viewsExplicitiPerm deleted file mode 100644 index 8f4ffd05..00000000 --- a/authz-test/TestSuite/TC_User1/43_viewsExplicitiPerm +++ /dev/null @@ -1,27 +0,0 @@ - -as testid@aaf.att.com -# TC_User1.43.1.POS Add another user to worker role -expect 201 -user role add m99995@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker - - -as m99990@@[user.name].TC_User1.test.com -# TC_User1.43.2.POS User should only see himself here -expect 200 -user list role com.test.TC_User1.@[user.name].worker -user list perm com.test.TC_User1.@[user.name].supplies * move -user list perm com.test.TC_User1.@[user.name].supplies * stock - - -as XX@NS -# TC_User1.43.10.POS Grant explicit user perm to user -expect 201 -perm create com.att.aaf.user :com.test.TC_User1.@[user.name] view com.test.TC_User1.@[user.name].worker - -as m99990@@[user.name].TC_User1.test.com -# TC_User1.43.11.POS User should see all users of test domain now -expect 200 -user list role com.test.TC_User1.@[user.name].worker -user list perm com.test.TC_User1.@[user.name].supplies * move -user list perm com.test.TC_User1.@[user.name].supplies * stock - diff --git a/authz-test/TestSuite/TC_User1/99_cleanup b/authz-test/TestSuite/TC_User1/99_cleanup deleted file mode 100644 index f6e9724e..00000000 --- a/authz-test/TestSuite/TC_User1/99_cleanup +++ /dev/null @@ -1,37 +0,0 @@ -expect 200,404 -as testid@aaf.att.com - -# TC_User1.99.0.POS Remove user roles -user role del @[user.name] com.test.TC_User1.@[user.name].manager -user role del m99990@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker -user role del m99995@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker - -# TC_User1.99.1.POS Namespace Admin can delete Namepace defined Roles & Perms -force perm delete com.test.TC_User1.@[user.name].supplies * move -force perm delete com.test.TC_User1.@[user.name].supplies * stock -force perm delete com.test.TC_User1.@[user.name].schedule worker create -force perm delete com.test.TC_User1.@[user.name].worker * annoy -force role delete com.test.TC_User1.@[user.name].manager -force role delete com.test.TC_User1.@[user.name].worker - -# TC_User1.99.10.POS Creds and delegate -user delegate del @[user.name] -user cred del m99990@@[user.name].TC_User1.test.com -user cred del m99995@@[user.name].TC_User1.test.com - -as XX@NS -# TC_User1.99.15.POS Remove ability to create creds -perm ungrant com.att.aaf.mechid com.att create com.test.TC_User1.@[user.name].cred_admin -perm ungrant com.att.aaf.delg com.att change com.test.TC_User1.@[user.name].cred_admin -perm delete com.att.aaf.user :com.test.TC_User1.@[user.name] view - -as testid@aaf.att.com:<pass> -force role delete com.test.TC_User1.@[user.name].cred_admin - -# TC_User1.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_User1.@[user.name] -sleep @[NFR] - -# TC_User1.99.99.POS Check Clean Namespace -ns list name com.test.TC_User1.@[user.name] - diff --git a/authz-test/TestSuite/TC_User1/Description b/authz-test/TestSuite/TC_User1/Description deleted file mode 100644 index 9f74081d..00000000 --- a/authz-test/TestSuite/TC_User1/Description +++ /dev/null @@ -1,6 +0,0 @@ -This Testcase Tests the viewability of different user commands - -APIs: - -CLI: - diff --git a/authz-test/TestSuite/TC_Wild/00_ids b/authz-test/TestSuite/TC_Wild/00_ids deleted file mode 100644 index 7fb0e054..00000000 --- a/authz-test/TestSuite/TC_Wild/00_ids +++ /dev/null @@ -1,8 +0,0 @@ -expect 0 -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set XX@NS=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TC_Wild/10_init b/authz-test/TestSuite/TC_Wild/10_init deleted file mode 100644 index c411f930..00000000 --- a/authz-test/TestSuite/TC_Wild/10_init +++ /dev/null @@ -1,18 +0,0 @@ -as XX@NS -# TC_Wild.10.0.POS Validate NS ok -expect 200 -ns list name com.att.test.TC_Wild.@[user.name] - -# TC_Wild.10.1.POS Create Namespace with valid IDs and Responsible Parties -expect 201 -ns create com.att.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com - -# TC_Wild.10.10.POS Create a clean MechID -expect 201 -user cred add m99999@@[user.name].TC_Wild.att.com aNewPass8 -set m99999@@[user.name].TC_Wild.att.com=aNewPass8 - -as XX@NS -# TC_Wild.10.11.POS Create role and assign MechID to -expect 201 -role create com.att.TC_Wild.@[user.name].service m99999@@[user.name].TC_Wild.att.com diff --git a/authz-test/TestSuite/TC_Wild/20_perm b/authz-test/TestSuite/TC_Wild/20_perm deleted file mode 100644 index 2110cbe5..00000000 --- a/authz-test/TestSuite/TC_Wild/20_perm +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.20.1.NEG Fail to create a perm in NS -expect 403 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.20.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.TC_Wild.@[user.name].access :perm:myType:*:myAction write com.att.TC_Wild.@[user.name].service - -# TC_Wild.20.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.20.7.POS Now able to create a perm in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.20.8.POS Print Perms -as XX@NS -expect 200 -perm list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.20.10.POS Delete Perms Created -expect 200 -force perm delete com.att.TC_Wild.@[user.name].access :perm:myType:*:myAction write -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction - diff --git a/authz-test/TestSuite/TC_Wild/21_perm b/authz-test/TestSuite/TC_Wild/21_perm deleted file mode 100644 index 772eea9d..00000000 --- a/authz-test/TestSuite/TC_Wild/21_perm +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.21.1.NEG Fail to create a perm in NS -expect 403 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.21.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.TC_Wild.@[user.name].access :perm:myType:*:* write com.att.TC_Wild.@[user.name].service - -# TC_Wild.21.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.21.7.POS Now able to create a perm in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.21.8.POS Print Perms -as XX@NS -expect 200 -perm list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.21.10.POS Delete Perms Created -expect 200 -force perm delete com.att.TC_Wild.@[user.name].access :perm:myType:*:* write -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction - diff --git a/authz-test/TestSuite/TC_Wild/30_role b/authz-test/TestSuite/TC_Wild/30_role deleted file mode 100644 index 6d680c7e..00000000 --- a/authz-test/TestSuite/TC_Wild/30_role +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.30.1.NEG Fail to create a role in NS -expect 403 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.30.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.TC_Wild.@[user.name].access :role:tool.* write com.att.TC_Wild.@[user.name].service - -# TC_Wild.30.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.30.7.POS Now able to create a role in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.30.8.POS Print Perms -as XX@NS -expect 200 -role list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.30.10.POS Delete Perms Created -expect 200 -force perm delete com.att.TC_Wild.@[user.name].access :role:tool.* write -force role delete com.att.TC_Wild.@[user.name].tool.myRole - diff --git a/authz-test/TestSuite/TC_Wild/31_role b/authz-test/TestSuite/TC_Wild/31_role deleted file mode 100644 index e29f308c..00000000 --- a/authz-test/TestSuite/TC_Wild/31_role +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.31.1.NEG Fail to create a role in NS -expect 403 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.31.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.TC_Wild.@[user.name].access :role:* write com.att.TC_Wild.@[user.name].service - -# TC_Wild.31.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.31.7.POS Now able to create a role in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.31.8.POS Print Perms -as XX@NS -expect 200 -role list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.31.10.POS Delete Perms Created -expect 200 -force perm delete com.att.TC_Wild.@[user.name].access :role:* write -force role delete com.att.TC_Wild.@[user.name].tool.myRole - diff --git a/authz-test/TestSuite/TC_Wild/32_role b/authz-test/TestSuite/TC_Wild/32_role deleted file mode 100644 index ccbe866a..00000000 --- a/authz-test/TestSuite/TC_Wild/32_role +++ /dev/null @@ -1,30 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.32.1.NEG Fail to create a role in NS -expect 403 -role create com.att.TC_Wild.@[user.name].tool.myRole - -# TC_Wild.32.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.TC_Wild.@[user.name].access :role:* * com.att.TC_Wild.@[user.name].service - -# TC_Wild.32.5.POS Print Perms -as m99999@@[user.name].TC_Wild.att.com -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.32.7.POS Now able to create a role in NS -expect 201 -role create com.att.TC_Wild.@[user.name].tool.myRole - -# TC_Wild.32.8.POS May Print Role -expect 200 -role list role com.att.TC_Wild.@[user.name].tool.myRole - -as XX@NS -# TC_Wild.32.10.POS Delete Perms Created -expect 200 -force perm delete com.att.TC_Wild.@[user.name].access :role:* * -force role delete com.att.TC_Wild.@[user.name].tool.myRole - diff --git a/authz-test/TestSuite/TC_Wild/50_global_perm b/authz-test/TestSuite/TC_Wild/50_global_perm deleted file mode 100644 index df5f5426..00000000 --- a/authz-test/TestSuite/TC_Wild/50_global_perm +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.50.1.NEG Fail to create a perm in NS -expect 403 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.50.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.aaf.ns :com.att.*:perm:myType:*:* write com.att.TC_Wild.@[user.name].service - -# TC_Wild.50.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.50.7.POS Now able to create a perm in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction - - -# TC_Wild.50.8.POS Print Perms -as XX@NS -expect 200 -perm list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.50.10.POS Delete Perms Created -expect 200 -force perm delete com.att.aaf.ns :com.att.*:perm:myType:*:* write -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction - diff --git a/authz-test/TestSuite/TC_Wild/51_global_role b/authz-test/TestSuite/TC_Wild/51_global_role deleted file mode 100644 index 1e86e916..00000000 --- a/authz-test/TestSuite/TC_Wild/51_global_role +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.51.1.NEG Fail to create a role in NS -expect 403 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.51.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.aaf.ns :com.att.*:role:tool.* write com.att.TC_Wild.@[user.name].service - -# TC_Wild.51.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.51.7.POS Now able to create a role in NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -role create com.att.TC_Wild.@[user.name].tool.myRole - - -# TC_Wild.51.8.POS Print Perms -as XX@NS -expect 200 -role list ns com.att.TC_Wild.@[user.name] - -# TC_Wild.51.10.POS Delete Perms Created -expect 200 -force perm delete com.att.aaf.ns :com.att.*:role:tool.* write -force role delete com.att.TC_Wild.@[user.name].tool.myRole - diff --git a/authz-test/TestSuite/TC_Wild/52_global_ns b/authz-test/TestSuite/TC_Wild/52_global_ns deleted file mode 100644 index b1e45ad3..00000000 --- a/authz-test/TestSuite/TC_Wild/52_global_ns +++ /dev/null @@ -1,33 +0,0 @@ -as m99999@@[user.name].TC_Wild.att.com - -# TC_Wild.52.1.NEG Fail to create a NS -expect 403 -ns create com.test.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com - - -# TC_Wild.52.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -expect 201 -perm create com.att.aaf.ns :com.test:ns write com.att.TC_Wild.@[user.name].service - -# TC_Wild.52.5.POS Print Perms -expect 200 -perm list user m99999@@[user.name].TC_Wild.att.com - - -# TC_Wild.52.7.POS Now able to create an NS -as m99999@@[user.name].TC_Wild.att.com -expect 201 -ns create com.test.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com - - -# TC_Wild.52.8.POS Print Perms -as XX@NS -expect 200 -ns list name com.test.TC_Wild.@[user.name] - -# TC_Wild.52.10.POS Delete Perms Created -expect 200 -force perm delete com.att.aaf.ns :com.test:ns write -force ns delete com.test.TC_Wild.@[user.name] - diff --git a/authz-test/TestSuite/TC_Wild/99_cleanup b/authz-test/TestSuite/TC_Wild/99_cleanup deleted file mode 100644 index d6abfd90..00000000 --- a/authz-test/TestSuite/TC_Wild/99_cleanup +++ /dev/null @@ -1,25 +0,0 @@ -as XX@NS -expect 200,404 - -# TC_Wild.99.80.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:perm:*:* write - -# TC_Wild.99.81.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:perm:*:* * - -# TC_Wild.99.82.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:role:* write - -# TC_Wild.99.83.POS Cleanup -force perm delete com.att.aaf.ns :com.test:ns write - -# TC_Wild.99.90.POS Cleanup -force ns delete com.test.TC_Wild.@[user.name] - -# TC_Wild.99.91.POS Cleanup -force ns delete com.att.TC_Wild.@[user.name] - -# TC_Wild.99.99.POS List to prove clean Namespaces -ns list name com.att.TC_Wild.@[user.name] -ns list name com.test.TC_Wild.@[user.name] - diff --git a/authz-test/TestSuite/TC_Wild/Description b/authz-test/TestSuite/TC_Wild/Description deleted file mode 100644 index 012a12b1..00000000 --- a/authz-test/TestSuite/TC_Wild/Description +++ /dev/null @@ -1,16 +0,0 @@ -This Testcase Tests the essentials of the Namespace, and the NS Commands - -APIs: - - - -CLI: - Target - role create :role - role delete - ns delete :ns - ns list :ns - Ancillary - role create :role - role list name :role.* - diff --git a/authz-test/TestSuite/TEMPLATE_TC/00_ids b/authz-test/TestSuite/TEMPLATE_TC/00_ids deleted file mode 100644 index ad09d774..00000000 --- a/authz-test/TestSuite/TEMPLATE_TC/00_ids +++ /dev/null @@ -1,10 +0,0 @@ -expect 0 -set XX@NS=<pass> -set testid@aaf.att.com=<pass> -set testunused@aaf.att.com=<pass> -set testid_1@test.com=<pass> -set testid_2@test.com=<pass> -set bogus=boguspass - -#delay 10 -set NFR=0 diff --git a/authz-test/TestSuite/TEMPLATE_TC/10_init b/authz-test/TestSuite/TEMPLATE_TC/10_init deleted file mode 100644 index ebdaaae5..00000000 --- a/authz-test/TestSuite/TEMPLATE_TC/10_init +++ /dev/null @@ -1,24 +0,0 @@ -as XX@NS -# TEMPLATE_TC.10.0.POS Print NS to prove ok -expect 200 -ns list name com.test.TEMPLATE_TC.@[user.name] - -# TEMPLATE_TC.10.1.POS Create Namespace with User ID -expect 201 -ns create com.test.TEMPLATE_TC.@[user.name]_1 @[user.name] testid_1@test.com - -# TEMPLATE_TC.10.4.POS Print NS to prove ok -expect 200 -ns list name com.test.TEMPLATE_TC.@[user.name]_2 - -# TEMPLATE_TC.10.5.POS Create Namespace with Different ID -expect 201 -ns create com.test.TEMPLATE_TC.@[user.name]_2 @[user.name] testid_2@test.com - -# TEMPLATE_TC.10.8.POS Print NS to prove ok -expect 200 -ns list name com.att.TEMPLATE_TC.@[user.name] - -# TEMPLATE_TC.10.9.POS Create Namespace in Different Company -expect 201 -ns create com.att.TEMPLATE_TC.@[user.name] @[user.name] testunused@aaf.att.com diff --git a/authz-test/TestSuite/TEMPLATE_TC/99_cleanup b/authz-test/TestSuite/TEMPLATE_TC/99_cleanup deleted file mode 100644 index a2080461..00000000 --- a/authz-test/TestSuite/TEMPLATE_TC/99_cleanup +++ /dev/null @@ -1,22 +0,0 @@ -expect 200,404 -as testid_1@test.com -# TEMPLATE_TC.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TEMPLATE_TC.@[user.name]_1 - -# TEMPLATE_TC.99.3.POS Print Namespaces -ns list name com.test.TEMPLATE_TC.@[user.name]_1 - -as testid_2@test.com -# TEMPLATE_TC.99.4.POS Namespace Admin can delete Namespace -force ns delete com.test.TEMPLATE_TC.@[user.name]_2 - -# TEMPLATE_TC.99.5.POS Print Namespaces -ns list name com.test.TEMPLATE_TC.@[user.name]_2 - - -as testunused@aaf.att.com -# TEMPLATE_TC.99.6.POS Remove Namespace from other company -force ns delete com.att.TEMPLATE_TC.@[user.name] - -# TEMPLATE_TC.99.7.POS Print Namespace from other company -ns list name com.att.TEMPLATE_TC.@[user.name] diff --git a/authz-test/TestSuite/TEMPLATE_TC/Description b/authz-test/TestSuite/TEMPLATE_TC/Description deleted file mode 100644 index 2283774d..00000000 --- a/authz-test/TestSuite/TEMPLATE_TC/Description +++ /dev/null @@ -1,10 +0,0 @@ -This is a TEMPLATE testcase, to make creating new Test Cases easier. - -APIs: - - -CLI: -ns create -ns delete -as - diff --git a/authz-test/TestSuite/cmds b/authz-test/TestSuite/cmds deleted file mode 100644 index 4d3c6ab4..00000000 --- a/authz-test/TestSuite/cmds +++ /dev/null @@ -1,21 +0,0 @@ -# /bin/bash -. ~/.bashrc -function failed { - echo "FAILED TEST! " $* - exit 1 -} - -if [ "$1" == "" ] ; then - DIRS=`find . -name "TC_*" -maxdepth 1`" "`find . -name "MTC_*" -maxdepth 1` -else - DIRS="$1" -fi - - for DIR in $DIRS; do - for FILE in $DIR/[0-9]*; do - echo "*** "$FILE" ***" - cat $FILE - echo - done - done -exit 0 diff --git a/authz-test/TestSuite/copy b/authz-test/TestSuite/copy deleted file mode 100644 index 27d57cb6..00000000 --- a/authz-test/TestSuite/copy +++ /dev/null @@ -1,17 +0,0 @@ -# /bin/bash -if [ "$2" != "" ] ; then - if [ -e $2 ]; then - echo "$2 exists, copy aborted" - exit 1 - fi - mkdir -p $2 - for FILE in $1/*; do - FILE2=`echo $FILE | sed -e "s/$1/$2/"` - echo $FILE2 - sed -e "s/$1/$2/g" $FILE > $FILE2 - done -else - echo 'Usage: copy <Source TestCase> <Target TestCase>' -fi - -exit 0 diff --git a/authz-test/TestSuite/csv b/authz-test/TestSuite/csv deleted file mode 100644 index a6a0b305..00000000 --- a/authz-test/TestSuite/csv +++ /dev/null @@ -1,13 +0,0 @@ -# /bin/bash -if [ "$1" == "" ]; then - DIRS=`ls -d TC*` -else - DIRS=$1 -fi - -echo '"Test Case","Description"' -for DIR in $DIRS; do - grep -h "^# $DIR" $DIR/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ /,"/' -e 's/$/"/' -done -cd .. -exit 0 diff --git a/authz-test/TestSuite/expected/MTC_Appr1.expected b/authz-test/TestSuite/expected/MTC_Appr1.expected deleted file mode 100644 index 269f7317..00000000 --- a/authz-test/TestSuite/expected/MTC_Appr1.expected +++ /dev/null @@ -1,144 +0,0 @@ -set testid@aaf.att.com <pass> -set XX@NS <pass> -set testunused@aaf.att.com <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Appr1.10.0.POS List NS to prove ok -ns list name com.test.appr -** Expect 200 ** - -List Namespaces by Name[com.test.appr] --------------------------------------------------------------------------------- - -ns list name com.test.appr.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.appr.@[THE_USER]] --------------------------------------------------------------------------------- - -# TC_Appr1.10.1.POS Create Personalized Namespace to add Approvals -ns create com.test.appr.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Appr1.10.2.POS Create General Namespace to add Approvals -ns create com.test.appr @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Appr1.10.10.POS Create Roles in Namespace -role create com.test.appr.@[user.name].addToUserRole -** Expect 201 ** -Created Role - -role create com.test.appr.@[user.name].grantToPerm -** Expect 201 ** -Created Role - -role create com.test.appr.@[user.name].ungrantFromPerm -** Expect 201 ** -Created Role - -role create com.test.appr.@[user.name].grantFirstPerm -** Expect 201 ** -Created Role - -role create com.test.appr.@[user.name].grantSecondPerm -** Expect 201 ** -Created Role - -# TC_Appr1.10.12.POS Create Permissions in Namespace -perm create com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm -** Expect 201 ** -Created Permission -Granted Permission [com.test.appr.@[THE_USER].ungrantFromRole|myInstance|myAction] to Role [com.test.appr.@[THE_USER].ungrantFromPerm] - -perm create com.test.appr.@[user.name].grantToRole myInstance myAction -** Expect 201 ** -Created Permission - -force perm create com.test.appr.@[user.name].deleteThisPerm myInstance myAction com.test.appr.@[user.name].grantedRole -** Expect 201 ** -Created Permission -Granted Permission [com.test.appr.@[THE_USER].deleteThisPerm|myInstance|myAction] to Role [com.test.appr.@[THE_USER].grantedRole] (Created) - -perm create com.test.appr.@[user.name].grantTwoRoles myInstance myAction -** Expect 201 ** -Created Permission - -perm create com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm -** Expect 201 ** -Created Permission -Granted Permission [com.test.appr.@[THE_USER].ungrantTwoRoles|myInstance|myAction] to Role [com.test.appr.@[THE_USER].grantFirstPerm] -Granted Permission [com.test.appr.@[THE_USER].ungrantTwoRoles|myInstance|myAction] to Role [com.test.appr.@[THE_USER].grantSecondPerm] - -as testunused@aaf.att.com -# TC_Appr1.15.01.NEG Create Future and Approvals with non-admin request -user role add @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].addToUserRole -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.02.NEG Create Approval for NS create -ns create com.test.appr.@[user.name].myProject @[user.name] -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.03.NEG Generate Approval for granting permission to role -perm grant com.test.appr.@[user.name].grantToRole myInstance myAction com.test.appr.@[user.name].grantToPerm -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.04.NEG Generate Approval for ungranting permission from role -perm ungrant com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.05.NEG Generate Approval for granting permission to role -perm grant com.test.appr.@[user.name].grantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.06.NEG Generate Approval for ungranting permission from role -perm ungrant com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm -** Expect 403 ** -Failed [SVC2403]: Approvals required, but not requested by Client -Failed [SVC2403]: Approvals required, but not requested by Client - -# TC_Appr1.15.51.POS Create Future and Approvals with non-admin request -set request true -set request=true user role add @[user.name]@@[user.name].appr.test.com com.test.appr.@[user.name].addToUserRole -** Expect 202 ** -UserRole Creation Accepted, but requires Approvals before actualizing - -# TC_Appr1.15.52.POS Create Approval for NS create -set request true -set request=true ns create com.test.appr.@[user.name].myProject @[user.name] -** Expect 202 ** -Namespace Creation Accepted, but requires Approvals before actualizing - -# TC_Appr1.15.53.POS Generate Approval for granting permission to role -set request true -set request=true perm grant com.test.appr.@[user.name].grantToRole myInstance myAction com.test.appr.@[user.name].grantToPerm -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Appr1.15.54.POS Generate Approval for ungranting permission from role -request perm ungrant com.test.appr.@[user.name].ungrantFromRole myInstance myAction com.test.appr.@[user.name].ungrantFromPerm -** Expect 202 ** -Permission Role Ungranted Accepted, but requires Approvals before actualizing - -# TC_Appr1.15.55.POS Generate Approval for granting permission to role -request perm grant com.test.appr.@[user.name].grantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Appr1.15.56.POS Generate Approval for ungranting permission from role -request perm ungrant com.test.appr.@[user.name].ungrantTwoRoles myInstance myAction com.test.appr.@[user.name].grantFirstPerm,com.test.appr.@[user.name].grantSecondPerm -** Expect 202 ** -Permission Role Ungranted Accepted, but requires Approvals before actualizing -Permission Role Ungranted Accepted, but requires Approvals before actualizing - diff --git a/authz-test/TestSuite/expected/MTC_Appr2.expected b/authz-test/TestSuite/expected/MTC_Appr2.expected deleted file mode 100644 index 7191a044..00000000 --- a/authz-test/TestSuite/expected/MTC_Appr2.expected +++ /dev/null @@ -1,24 +0,0 @@ -# TC_Appr2.99.1.POS Delete User Role, if exists -user role del testunused@aaf.att.com com.test.appr.@[user.name].myRole -** Expect 200,404 ** -Failed [SVC1404]: Cannot delete non-existent User Role - -# TC_Appr2.99.79.POS Delete Role -role delete com.test.appr.@[user.name].myRole -** Expect 200,404 ** -Deleted Role - -# TC_Appr2.99.80.POS Delete Namespaces for TestSuite -ns delete com.test.appr -** Expect 200,404 ** -Deleted Namespace - -ns delete com.test.appr.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Appr2.99.81.POS Delete Credential used to generate approvals -as XX@NS:<pass> user cred del testbatch@aaf.att.com -** Expect 200,404 ** -Deleted Credential [testbatch@aaf.att.com] - diff --git a/authz-test/TestSuite/expected/TC_Cred1.expected b/authz-test/TestSuite/expected/TC_Cred1.expected deleted file mode 100644 index 8d310d91..00000000 --- a/authz-test/TestSuite/expected/TC_Cred1.expected +++ /dev/null @@ -1,269 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus boguspass -set XX@NS <pass> -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Cred1.10.0.POS List NS to prove ok -ns list name com.test.TC_Cred1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Cred1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Cred1.10.1.POS Create Personalized Namespace to add Credentials -ns create com.test.TC_Cred1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Cred1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_Cred1.@[user.name].cred_admin testid@aaf.att.com -** Expect 201 ** -Created Role -Added User [testid@aaf.att.com] to Role [com.test.TC_Cred1.@[THE_USER].cred_admin] - -role create com.test.TC_Cred1.@[user.name].pw_reset -** Expect 201 ** -Created Role - -# TC_Cred1.10.11.POS Assign roles to perms -as XX@NS -perm create com.att.aaf.password com.test reset com.test.TC_Cred1.@[user.name].pw_reset -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.password|com.test|reset] to Role [com.test.TC_Cred1.@[THE_USER].pw_reset] - -perm create com.att.aaf.mechid com.test create com.test.TC_Cred1.@[user.name].cred_admin -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.mechid|com.test|create] to Role [com.test.TC_Cred1.@[THE_USER].cred_admin] - -perm grant com.att.aaf.mechid com.att create com.test.TC_Cred1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_Cred1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_Cred1.10.30.POS Assign user for creating creds -user cred add m99999@@[user.name].TC_Cred1.test.com password123 -** Expect 201 ** -Added Credential [m99999@@[THE_USER].TC_Cred1.test.com] - -set m99999@@[THE_USER].TC_Cred1.test.com password123 -# TC_Cred1.10.31.POS Credential used to similate non-admin Tier1 user with reset and create permissions -user role add m99999@@[user.name].TC_Cred1.test.com com.test.TC_Cred1.@[user.name].pw_reset,com.test.TC_Cred1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_Cred1.@[THE_USER].pw_reset] to User [m99999@@[THE_USER].TC_Cred1.test.com] -Added Role [com.test.TC_Cred1.@[THE_USER].cred_admin] to User [m99999@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.10.32.POS Remove create rights for testing -user role del testid@aaf.att.com com.test.TC_Cred1.@[user.name].cred_admin -** Expect 200 ** -Removed Role [com.test.TC_Cred1.@[THE_USER].cred_admin] from User [testid@aaf.att.com] - -# TC_Cred1.15.1.NEG Non-Admin, no permission user cannot create mechID -as testunused@aaf.att.com -user cred add m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 403 ** -Failed [SVC1403]: Forbidden - testunused@aaf.att.com does not have permission to create MechIDs at AT&T - -# TC_Cred1.15.3.POS Non-Admin, with create permission user can create mechID -as m99999@@[THE_USER].TC_Cred1.test.com -user cred add m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.15.10.NEG Non-Admin, no reset permission cannot reset mechID -as testunused@aaf.att.com -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 403 ** -Failed [SVC1403]: Forbidden - testunused@aaf.att.com is not allowed to change m99990@@[THE_USER].TC_Cred1.test.com in com.test.TC_Cred1.@[THE_USER] - -# TC_Cred1.15.11.POS Non-Admin, with reset permission can reset mechID -as m99999@@[THE_USER].TC_Cred1.test.com -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 200 ** -Reset Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.15.12.POS Admin, without reset permission can reset Password -as testid@aaf.att.com -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 200 ** -Reset Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.15.15.POS Admin, without reset permission can reset mechID -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 1 -** Expect 200 ** -Reset Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.15.20.POS Admin, delete -user cred del m99990@@[user.name].TC_Cred1.test.com password123 1 -** Expect 200 ** -Deleted Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.30.1.NEG Multiple options available to delete -as XX@NS -user cred add m99990@@[user.name].TC_Cred1.test.com pass23Word -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -as testid@aaf.att.com -user cred add m99990@@[user.name].TC_Cred1.test.com pass23worD -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.30.2.POS Succeeds when we choose last option -user cred del m99990@@[user.name].TC_Cred1.test.com 2 -** Expect 200 ** -Deleted Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.30.10.POS Add another credential -user cred add m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.30.11.NEG Multiple options available to reset -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 -** Expect 300 ** -Failed [SVC1300]: Choice - Select which cred to update: - Id Type Expires - 1) m99990@@[THE_USER].TC_Cred1.test.com 2 [Placeholder] - 2) m99990@@[THE_USER].TC_Cred1.test.com 2 [Placeholder] -Run same command again with chosen entry as last parameter - -# TC_Cred1.30.12.NEG Fails when we choose a bad option -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 0 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - User chose invalid credential selection - -# TC_Cred1.30.13.POS Succeeds when we choose last option -user cred reset m99990@@[user.name].TC_Cred1.test.com password123 2 -** Expect 200 ** -Reset Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -#TC_Cred1.30.30.NEG Fails when we don't have specific property -user cred extend m99990@@[user.name].TC_Cred1.test.com -** Expect 403 ** -Failed [SVC3403]: Forbidden - testid@aaf.att.com does not have permission to extend passwords at AT&T - -#### EXTENDS behavior #### -#TC_Cred1.30.32.POS Setup Temp Role for Extend Permission -as XX@NS -role create com.test.TC_Cred1.@[user.name].extendTemp -** Expect 201 ** -Created Role - -#TC_Cred1.30.33.POS Grant Extends Permission to Role -perm grant com.att.aaf.password com.att extend com.test.TC_Cred1.@[user.name].extendTemp -** Expect 201 ** -Granted Permission [com.att.aaf.password|com.att|extend] to Role [com.test.TC_Cred1.@[THE_USER].extendTemp] - -#TC_Cred1.30.35.POS Add current User to Temp Role for Extend Permission -role user add com.test.TC_Cred1.@[user.name].extendTemp XX@NS -** Expect 201 ** -Added User [XX@NS] to Role [com.test.TC_Cred1.@[THE_USER].extendTemp] - -#TC_Cred1.30.36.POS Extend Password, expecting Single Response -user cred extend m99990@@[user.name].TC_Cred1.test.com 1 -** Expect 200 ** -Extended Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -#TC_Cred1.30.39.POS Remove Role -set force true -role delete com.test.TC_Cred1.@[user.name].extendTemp -** Expect 200 ** -Deleted Role - -#### MULTI CLEANUP ##### -role list user m99990@@[user.name].TC_Cred1.test.com -** Expect 200 ** - -List Roles for User [m99990@@[THE_USER].TC_Cred1.test.com] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- - -# TC_Cred1.30.80.POS Delete all entries for this cred -set force true -user cred del m99990@@[user.name].TC_Cred1.test.com -** Expect 200 ** -Deleted Credential [m99990@@[THE_USER].TC_Cred1.test.com] - -# TC_Cred1.30.99.POS List ns shows no creds attached -ns list name com.test.TC_Cred1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Cred1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Cred1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Cred1.@[THE_USER].admin - com.test.TC_Cred1.@[THE_USER].cred_admin - com.test.TC_Cred1.@[THE_USER].owner - com.test.TC_Cred1.@[THE_USER].pw_reset - Permissions - com.test.TC_Cred1.@[THE_USER].access * * - com.test.TC_Cred1.@[THE_USER].access * read - Credentials - m99999@@[THE_USER].TC_Cred1.test.com - -as testid@aaf.att.com -# TC_Cred1.99.1.POS Delete credentials -force user cred del m99990@@[user.name].TC_Cred1.test.com -** Expect 200,404 ** -Failed [SVC5404]: Not Found - Credential does not exist - -#TC_Cred1.99.2.POS Ensure Remove Role -set force true -role delete com.test.TC_Cred1.@[user.name].extendTemp -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Cred1.@[THE_USER].extendTemp] does not exist - -# TC_Cred1.99.10.POS Remove ability to create creds -force user role del testid@aaf.att.com com.test.TC_Cred1.@[user.name].cred_admin -** Expect 200,404 ** -Failed [SVC6404]: Not Found - User [ testid@aaf.att.com ] is not Assigned to the Role [ com.test.TC_Cred1.@[THE_USER].cred_admin ] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Cred1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_Cred1.@[THE_USER].cred_admin] - -force perm delete com.att.aaf.password com.test reset -** Expect 200,404 ** -Deleted Permission - -force perm delete com.att.aaf.mechid com.test create -** Expect 200,404 ** -Deleted Permission - -as testid@aaf.att.com -force role delete com.test.TC_Cred1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Cred1.@[user.name].pw_reset -** Expect 200,404 ** -Deleted Role - -# TC_Cred1.99.99.POS Delete Namespace for TestSuite -set force true -set force=true ns delete com.test.TC_Cred1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -as XX@NS -force ns delete com.test.TC_Cred1.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test.TC_Cred1.@[THE_USER] does not exist - -force ns delete com.test.TC_Cred1 -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test.TC_Cred1 does not exist - diff --git a/authz-test/TestSuite/expected/TC_DELG1.expected b/authz-test/TestSuite/expected/TC_DELG1.expected deleted file mode 100644 index 962caf6a..00000000 --- a/authz-test/TestSuite/expected/TC_DELG1.expected +++ /dev/null @@ -1,223 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set m99999@@[THE_USER].delg.test.com password123 -set bogus@aaf.att.com boguspass -#delay 10 -set NFR 0 -# TC_DELG1.10.1.POS Check For Existing Data -as testid@aaf.att.com -ns list name com.test.delg.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.delg.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -as XX@NS -perm create com.att.aaf.delg com.att * com.att.admin -** Expect 201,409 ** -Failed [SVC1409]: Conflict Already Exists - Permission [com.att.aaf.delg|com.att|*] already exists. - -user list delegates delegate @[user.name]@csp.att.com -** Expect 404 ** -Failed [SVC7404]: Not Found - Delegate [@[THE_USER]@csp.att.com] is not delegating for anyone. - -as testid@aaf.att.com -# TC_DELG1.10.2.POS Create Namespace to add IDs -ns create com.test.delg.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -as XX@NS -# TC_DELG1.10.10.POS Grant ability to change delegates -force perm grant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg -** Expect 404 ** -Failed [SVC3404]: Not Found - Role [com.test.delg.@[THE_USER].change_delg] does not exist - -# TC_DELG1.10.11.POS Grant ability to change delegates -role create com.test.delg.@[user.name].change_delg -** Expect 201 ** -Created Role - -# TC_DELG1.10.12.POS Grant ability to change delegates -force perm grant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.delg.@[THE_USER].change_delg] - -# TC_DELG1.10.14.POS Create user role to change delegates -user role add testid@aaf.att.com com.test.delg.@[user.name].change_delg -** Expect 201 ** -Added Role [com.test.delg.@[THE_USER].change_delg] to User [testid@aaf.att.com] - -# TC_DELG1.10.15.POS Grant ability to create cred -perm grant com.att.aaf.delg com.att create com.test.delg.@[user.name].change_delg -** Expect 201 ** -Granted Permission [com.att.aaf.delg|com.att|create] to Role [com.test.delg.@[THE_USER].change_delg] - -as testid@aaf.att.com -# TC_DELG1.10.30.POS Create cred that will change his own delg -user cred add m99999@@[user.name].delg.test.com password123 -** Expect 201 ** -Added Credential [m99999@@[THE_USER].delg.test.com] - -as XX@NS -Unknown Instruction "TC_DELG1.10.31.POS" -perm ungrant com.att.aaf.mechid com.att create com.test.delg.@[user.name].change_delg -** Expect 200 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.delg.@[THE_USER].change_delg] - -as testid@aaf.att.com -# TC_DELG1.10.99.POS Check for Data as Correct -ns list name com.test.delg.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.delg.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.delg.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.delg.@[THE_USER].admin - com.test.delg.@[THE_USER].change_delg - com.test.delg.@[THE_USER].owner - Permissions - com.test.delg.@[THE_USER].access * * - com.test.delg.@[THE_USER].access * read - Credentials - m99999@@[THE_USER].delg.test.com - -# TC_DELG1.20.10.NEG Cannot create delegate with unknown user ID -user delegate add aa111q@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 404 ** -Failed [SVC5404]: Not Found - [aa111q@csp.att.com] is not a user in the company database. - -# TC_DELG1.20.11.NEG Cannot Create Delegate with unknown delegate -user delegate add @[user.name]@csp.att.com aa111q@csp.att.com '2099-12-31 06:00' -** Expect 404 ** -Failed [SVC5404]: Not Found - [aa111q@csp.att.com] is not a user in the company database. - -# TC_DELG1.20.20.NEG May not change user, no delegate permission -as m99999@@[THE_USER].delg.test.com -force user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].delg.test.com] may not create a delegate for [@[THE_USER]@csp.att.com] - -as testid@aaf.att.com -# TC_DELG1.20.21.NEG Fail to Update Delegate that doesnt exist -user delegate upd @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 404 ** -Failed [SVC1404]: Not Found - [@[THE_USER]@csp.att.com] does not have a Delegate Record to [write]. - -# TC_DELG1.20.22.NEG May not create delegate for self. -user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - [@[THE_USER]@csp.att.com] cannot be a delegate for self - -# TC_DELG1.20.23.POS May create delegate for self for tests by forcing. -force user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 201 ** -Delegate Added - -as XX@NS -# TC_DELG1.20.30.POS Expect Delegates for User -user list delegates user @[user.name]@csp.att.com -** Expect 200 ** - -List Delegates by user[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -as testid@aaf.att.com -# TC_DELG1.20.35.NEG Fail Create when exists -user delegate add @[user.name]@csp.att.com @[user.name]@csp.att.com '2099-12-31 06:00' -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - [@[THE_USER]@csp.att.com] already delegates to [@[THE_USER]@csp.att.com] - -as XX@NS -# TC_DELG1.20.40.POS Expect Delegates for User -user list delegates user @[user.name]@csp.att.com -** Expect 200 ** - -List Delegates by user[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -as testid@aaf.att.com -# TC_DELG1.20.46.POS Update Delegate with new Date -user delegate upd @[user.name]@csp.att.com @[user.name]@csp.att.com '2999-01-01 06:00' -** Expect 200 ** -Delegate Updated - -as XX@NS -# TC_DELG1.20.82.POS Expect Delegates for User -user list delegates user @[user.name]@csp.att.com -** Expect 200 ** - -List Delegates by user[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -# TC_DELG1.20.83.POS Expect Delegate to show up in list -user list delegates delegate @[user.name]@csp.att.com -** Expect 200 ** - -List Delegates by delegate[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -as XX@NS -# TC_DELG1.99.0.POS Check for Data as Correct -ns list name com.test.delg.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.delg.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.delg.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.delg.@[THE_USER].admin - com.test.delg.@[THE_USER].change_delg - com.test.delg.@[THE_USER].owner - Permissions - com.test.delg.@[THE_USER].access * * - com.test.delg.@[THE_USER].access * read - Credentials - m99999@@[THE_USER].delg.test.com - -# TC_DELG1.99.10.POS Delete Delegates -user delegate del @[user.name]@csp.att.com -** Expect 200,404 ** -Delegate Deleted - -# TC_DELG1.99.30.POS Delete Namespace com.att.test.id -force ns delete com.test.delg.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_DELG1.99.98.POS Check for Delegate Data as Correct -user list delegates user @[user.name]@csp.att.com -** Expect 200,404 ** -Failed [SVC7404]: Not Found - No Delegate found for [@[THE_USER]@csp.att.com] - -# TC_DELG1.99.99.POS Check for NS Data as Correct -ns list name com.test.delg.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.delg.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Link.expected b/authz-test/TestSuite/expected/TC_Link.expected deleted file mode 100644 index 3c58002e..00000000 --- a/authz-test/TestSuite/expected/TC_Link.expected +++ /dev/null @@ -1,253 +0,0 @@ -set testid <pass> -set testid@aaf.att.com <pass> -set XX@NS <pass> -set testunused <pass> -set bogus boguspass -#delay 10 -set NFR 0 -# TC_05 -ns list name com.test.TC_Link_1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Link_1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Link_2.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Link_2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -perm list role com.test.TC_Link_1.@[user.name].myRole -** Expect 200,404 ** - -List Perms by Role [com.test.TC_Link_1.@[THE_USER].myRole] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction -** Expect 200,404 ** - -List Roles by Perm com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- - -# TC_10 -as XX@NS -ns create com.test.TC_Link_1.@[user.name] @[user.name] XX@NS -** Expect 201 ** -Created Namespace - -ns create com.test.TC_Link_2.@[user.name] @[user.name] XX@NS -** Expect 201 ** -Created Namespace - -role create com.test.TC_Link_1.@[user.name].myRole -** Expect 201 ** -Created Role - -perm create com.test.TC_Link_2.@[user.name].myPerm myInstance myAction -** Expect 201 ** -Created Permission - -perm grant com.test.TC_Link_2.@[user.name].myPerm myInstance myAction com.test.TC_Link_1.@[user.name].myRole -** Expect 201 ** -Granted Permission [com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction] to Role [com.test.TC_Link_1.@[THE_USER].myRole] - -# 15_print -ns list name com.test.TC_Link_1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_1.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_1.@[THE_USER].admin - com.test.TC_Link_1.@[THE_USER].myRole - com.test.TC_Link_1.@[THE_USER].owner - Permissions - com.test.TC_Link_1.@[THE_USER].access * * - com.test.TC_Link_1.@[THE_USER].access * read - -ns list name com.test.TC_Link_2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_2.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_2.@[THE_USER].admin - com.test.TC_Link_2.@[THE_USER].owner - Permissions - com.test.TC_Link_2.@[THE_USER].access * * - com.test.TC_Link_2.@[THE_USER].access * read - com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - -perm list role com.test.TC_Link_1.@[user.name].myRole -** Expect 200 ** - -List Perms by Role [com.test.TC_Link_1.@[THE_USER].myRole] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - - -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction -** Expect 200 ** - -List Roles by Perm com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Link_1.@[THE_USER].myRole - com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - -role delete com.test.TC_Link_1.@[user.name].myRole -** Expect 200 ** -Deleted Role - -# 15_print -ns list name com.test.TC_Link_1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_1.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_1.@[THE_USER].admin - com.test.TC_Link_1.@[THE_USER].owner - Permissions - com.test.TC_Link_1.@[THE_USER].access * * - com.test.TC_Link_1.@[THE_USER].access * read - -ns list name com.test.TC_Link_2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_2.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_2.@[THE_USER].admin - com.test.TC_Link_2.@[THE_USER].owner - Permissions - com.test.TC_Link_2.@[THE_USER].access * * - com.test.TC_Link_2.@[THE_USER].access * read - com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - -perm list role com.test.TC_Link_1.@[user.name].myRole -** Expect 200 ** - -List Perms by Role [com.test.TC_Link_1.@[THE_USER].myRole] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction -** Expect 200 ** - -List Roles by Perm com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- - -role create com.test.TC_Link_1.@[user.name].myRole -** Expect 201 ** -Created Role - -perm grant com.test.TC_Link_2.@[user.name].myPerm myInstance myAction com.test.TC_Link_1.@[user.name].myRole -** Expect 201 ** -Granted Permission [com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction] to Role [com.test.TC_Link_1.@[THE_USER].myRole] - -# 15_print -ns list name com.test.TC_Link_1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_1.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_1.@[THE_USER].admin - com.test.TC_Link_1.@[THE_USER].myRole - com.test.TC_Link_1.@[THE_USER].owner - Permissions - com.test.TC_Link_1.@[THE_USER].access * * - com.test.TC_Link_1.@[THE_USER].access * read - -ns list name com.test.TC_Link_2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Link_2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Link_2.@[THE_USER] - Administrators - XX@NS - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Link_2.@[THE_USER].admin - com.test.TC_Link_2.@[THE_USER].owner - Permissions - com.test.TC_Link_2.@[THE_USER].access * * - com.test.TC_Link_2.@[THE_USER].access * read - com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - -perm list role com.test.TC_Link_1.@[user.name].myRole -** Expect 200 ** - -List Perms by Role [com.test.TC_Link_1.@[THE_USER].myRole] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - - -role list perm com.test.TC_Link_2.@[user.name].myPerm myInstance myAction -** Expect 200 ** - -List Roles by Perm com.test.TC_Link_2.@[THE_USER].myPerm|myInstance|myAction --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Link_1.@[THE_USER].myRole - com.test.TC_Link_2.@[THE_USER].myPerm myInstance myAction - -as XX@NS -force ns delete com.test.TC_Link_2.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test.TC_Link_1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - diff --git a/authz-test/TestSuite/expected/TC_NS1.expected b/authz-test/TestSuite/expected/TC_NS1.expected deleted file mode 100644 index 6c5a89ec..00000000 --- a/authz-test/TestSuite/expected/TC_NS1.expected +++ /dev/null @@ -1,327 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus@aaf.att.com boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_NS1.01.0.POS Expect Clean Namespace to start -ns list name com.test.TC_NS1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NS1.01.1.NEG Create Namespace with mechID as Responsible Party -ns create com.test.TC_NS1.@[user.name] testunused@aaf.att.com testid@aaf.att.com,XX@NS -** Expect 403 ** -Failed [SVC3403]: Forbidden - testunused@aaf.att.com does not have permission to assume test status at AT&T - -# TC_NS1.01.2.NEG Create Namespace with Bad ID for Admin -ns create com.test.TC_NS1.@[user.name] @[user.name] bogus@aaf.att.com,XX@NS -** Expect 403 ** -Failed [SVC2403]: Forbidden - bogus@aaf.att.com is not a valid AAF Credential - -as testid@aaf.att.com -# TC_NS1.10.0.POS Check for Existing Data -ns list name com.test.TC_NS1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NS1.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_NS1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_NS1.10.40.POS Expect Namespace to be created -ns list name com.test.TC_NS1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS1.@[THE_USER].admin - com.test.TC_NS1.@[THE_USER].owner - Permissions - com.test.TC_NS1.@[THE_USER].access * * - com.test.TC_NS1.@[THE_USER].access * read - -# TC_NS1.10.41.POS Expect Namespace to be created -perm list role com.test.TC_NS1.@[user.name].admin -** Expect 200 ** - -List Perms by Role [com.test.TC_NS1.@[THE_USER].admin] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER].access * * - - -# TC_NS1.10.42.POS Expect Namespace to be created -perm list role com.test.TC_NS1.@[user.name].owner -** Expect 200 ** - -List Perms by Role [com.test.TC_NS1.@[THE_USER].owner] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER].access * read - - -# TC_NS1.10.43.POS Expect Namespace to be created -role list perm com.test.TC_NS1.@[user.name].access * * -** Expect 200 ** - -List Roles by Perm com.test.TC_NS1.@[THE_USER].access|*|* --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER].admin - com.test.TC_NS1.@[THE_USER].access * * - -# TC_NS1.10.44.POS Expect Namespace to be created -role list perm com.test.TC_NS1.@[user.name].access * read -** Expect 200 ** - -List Roles by Perm com.test.TC_NS1.@[THE_USER].access|*|read --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER].owner - com.test.TC_NS1.@[THE_USER].access * read - -# TC_NS1.11.1.NEG Create Namespace when exists -ns create com.test.TC_NS1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Target Namespace already exists - -# TC_NS1.20.1.NEG Too Few Args for Create 1 -ns create -** Expect -1 ** -Too few args: create <name> <responsible (id[,id]*)> [admin (id[,id]*)] - -# TC_NS1.20.2.NEG Too Few Args for Create 2 -ns create bogus -** Expect -1 ** -Too few args: create <name> <responsible (id[,id]*)> [admin (id[,id]*)] - -# TC_NS1.30.10.NEG Non-admins can't change description -as testunused@aaf.att.com -ns describe com.test.TC_NS1.@[user.name] Description for my Namespace -** Expect 403 ** -Failed [SVC1403]: Forbidden - You do not have approval to change com.test.TC_NS1.@[THE_USER] - -# TC_NS1.30.11.NEG Namespace must exist to change description -as testid@aaf.att.com -ns describe com.test.TC_NS1.@[user.name].project1 Description for my project -** Expect 404 ** -Failed [SVC1404]: Not Found - Namespace [com.test.TC_NS1.@[THE_USER].project1] does not exist - -# TC_NS1.30.12.POS Admin can change description -ns describe com.test.TC_NS1.@[user.name] Description for my Namespace -** Expect 200 ** -Description added to Namespace - -# TC_NS1.50.1.NEG Adding a Bogus ID -ns admin add com.test.TC_NS1.@[user.name] bogus -** Expect 403 ** -Failed [SVC1403]: Forbidden - AT&T reports that bogus@csp.att.com is a faulty ID - -# TC_NS1.50.2.NEG Adding a Bogus ID, full Domain -ns admin add com.test.TC_NS1.@[user.name] bogus@csp.att.com -** Expect 403 ** -Failed [SVC1403]: Forbidden - AT&T reports that bogus@csp.att.com is a faulty ID - -# TC_NS1.50.3.NEG Adding an OK ID, bad domain -ns admin add com.test.TC_NS1.@[user.name] xz9914@bogus.test.com -** Expect 403 ** -Failed [SVC2403]: Forbidden - xz9914@bogus.test.com is not a valid AAF Credential - -# TC_NS1.50.4.NEG Deleting an OK ID, but not an admin -ns admin del com.test.TC_NS1.@[user.name] XX@NS -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [XX@NS] [com.test.TC_NS1.@[THE_USER].admin] - -sleep 0 -# TC_NS1.50.10.POS Adding an OK ID -ns admin add com.test.TC_NS1.@[user.name] XX@NS -** Expect 201 ** -Admin XX@NS added to com.test.TC_NS1.@[THE_USER] - -# TC_NS1.50.11.POS Deleting One of Two -ns admin del com.test.TC_NS1.@[user.name] testid@aaf.att.com -** Expect 200 ** -Admin testid@aaf.att.com deleted from com.test.TC_NS1.@[THE_USER] - -# TC_NS1.50.12.NEG testid@aaf.att.com no longer Admin -ns admin del com.test.TC_NS1.@[user.name] testid@aaf.att.com -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [testid@aaf.att.com] [com.test.TC_NS1.@[THE_USER].admin] - -# TC_NS1.50.13.POS Add ID back in -ns admin add com.test.TC_NS1.@[user.name] testid@aaf.att.com -** Expect 201 ** -Admin testid@aaf.att.com added to com.test.TC_NS1.@[THE_USER] - -# TC_NS1.50.14.POS Deleting original -ns admin del com.test.TC_NS1.@[user.name] XX@NS -** Expect 200 ** -Admin XX@NS deleted from com.test.TC_NS1.@[THE_USER] - -# TC_NS1.50.15.NEG Can't remove twice -ns admin del com.test.TC_NS1.@[user.name] XX@NS -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [XX@NS] [com.test.TC_NS1.@[THE_USER].admin] - -# TC_NS1.50.20.NEG User Role Add should obey same "addAdmin" restrictions -role user add com.test.TC_NS1.@[user.name].admin m88888@i.have.no.domain -** Expect 403 ** -Failed [SVC2403]: Forbidden - m88888@i.have.no.domain is not a valid AAF Credential - -# TC_NS1.50.21.NEG Role User Add should obey same "addAdmin" restrictions -user role add m88888@i.have.no.domain com.test.TC_NS1.@[user.name].admin -** Expect 403 ** -Failed [SVC2403]: Forbidden - m88888@i.have.no.domain is not a valid AAF Credential - -# TC_NS1.60.1.NEG Adding a Bogus ID -ns responsible add com.test.TC_NS1.@[user.name] bogus -** Expect 403 ** -Failed [SVC3403]: Forbidden - AT&T reports that this is not a valid credential - -# TC_NS1.60.2.NEG Adding a Bogus ID, full Domain -ns responsible add com.test.TC_NS1.@[user.name] bogus@csp.att.com -** Expect 403 ** -Failed [SVC3403]: Forbidden - AT&T reports that this is not a valid credential - -# TC_NS1.60.3.NEG Adding an OK ID, bad domain -ns responsible add com.test.TC_NS1.@[user.name] xz9914@bogus.test.com -** Expect 403 ** -Failed [SVC3403]: Forbidden - AT&T reports that this is not a valid credential - -# TC_NS1.60.4.NEG Deleting an OK ID, short, but not existent -ns responsible del com.test.TC_NS1.@[user.name] testid -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [testid@csp.att.com] [com.test.TC_NS1.@[THE_USER].owner] - -# TC_NS1.60.5.NEG Deleting an OK ID, long, but not existent -ns responsible del com.test.TC_NS1.@[user.name] testid@aaf.att.com -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [testid@aaf.att.com] [com.test.TC_NS1.@[THE_USER].owner] - -sleep 0 -# TC_NS1.60.10.POS Adding an OK ID -# Note: mw9749 used because we must have employee as responsible -ns responsible add com.test.TC_NS1.@[user.name] mw9749 -** Expect 201 ** -mw9749@csp.att.com is now responsible for com.test.TC_NS1.@[THE_USER] - -# TC_NS1.60.11.POS Deleting One of Two -ns responsible del com.test.TC_NS1.@[user.name] mw9749 -** Expect 200 ** -mw9749@csp.att.com is no longer responsible for com.test.TC_NS1.@[THE_USER] - -# TC_NS1.60.12.NEG mw9749 no longer Admin -ns responsible del com.test.TC_NS1.@[user.name] mw9749 -** Expect 404 ** -Failed [SVC6404]: Not Found - UserRole [mw9749@csp.att.com] [com.test.TC_NS1.@[THE_USER].owner] - -# TC_NS1.60.20.NEG User Role Add should obey same "addResponsible" restrictions -role user add com.test.TC_NS1.@[user.name].owner m88888@i.have.no.domain -** Expect 403 ** -Failed [SVC3403]: Forbidden - AT&T reports that this is not a valid credential - -# TC_NS1.60.21.NEG Role User Add should obey same "addResponsible" restrictions -user role add m88888@i.have.no.domain com.test.TC_NS1.@[user.name].owner -** Expect 403 ** -Failed [SVC3403]: Forbidden - AT&T reports that this is not a valid credential - -sleep 0 -# TC_NS1.80.1.POS List Data on Empty NS -as testid@aaf.att.com -ns list name com.test.TC_NS1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS1.@[THE_USER].admin - com.test.TC_NS1.@[THE_USER].owner - Permissions - com.test.TC_NS1.@[THE_USER].access * * - com.test.TC_NS1.@[THE_USER].access * read - -# TC_NS1.80.2.POS Add Roles to NS for Listing -role create com.test.TC_NS1.@[user.name].r.A -** Expect 201 ** -Created Role - -role create com.test.TC_NS1.@[user.name].r.B -** Expect 201 ** -Created Role - -# TC_NS1.80.3.POS List Data on non-Empty NS -ns list name com.test.TC_NS1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS1.@[THE_USER].admin - com.test.TC_NS1.@[THE_USER].owner - com.test.TC_NS1.@[THE_USER].r.A - com.test.TC_NS1.@[THE_USER].r.B - Permissions - com.test.TC_NS1.@[THE_USER].access * * - com.test.TC_NS1.@[THE_USER].access * read - -# TC_NS1.90.1.NEG Non Namespace Admin Delete Namespace -as testunused@aaf.att.com -ns delete com.test.TC_NS1.@[user.name] -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not write in NS [com.test.TC_NS1.@[THE_USER]] - -sleep 0 -as testid@aaf.att.com -# TC_NS1.99.1.POS Namespace Admin can delete Namepace defined Roles -role delete com.test.TC_NS1.@[user.name].r.A -** Expect 200,404 ** -Deleted Role - -role delete com.test.TC_NS1.@[user.name].r.B -** Expect 200,404 ** -Deleted Role - -# TC_NS1.99.2.POS Namespace Admin can delete Namespace -ns delete com.test.TC_NS1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -sleep 0 -# TC_NS1.99.99.POS Check Clean Namespace -ns list name com.test.TC_NS1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_NS1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_NS2.expected b/authz-test/TestSuite/expected/TC_NS2.expected deleted file mode 100644 index f8de4564..00000000 --- a/authz-test/TestSuite/expected/TC_NS2.expected +++ /dev/null @@ -1,389 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus@aaf.att.com boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_NS2.10.0.POS Check for Existing Data -ns list name com.test.TC_NS2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NS2.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_NS2.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -ns create com.test.TC_NS2.@[user.name].project @[user.name] testunused@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_NS2.10.10.POS Create role to assign mechid perm to -role create com.test.TC_NS2.@[user.name].cred_admin testid@aaf.att.com -** Expect 201 ** -Created Role -Added User [testid@aaf.att.com] to Role [com.test.TC_NS2.@[THE_USER].cred_admin] - -as XX@NS -# TC_NS2.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_NS2.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_NS2.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -ns list name com.test.TC_NS2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS2.@[THE_USER].admin - com.test.TC_NS2.@[THE_USER].cred_admin - com.test.TC_NS2.@[THE_USER].owner - Permissions - com.test.TC_NS2.@[THE_USER].access * * - com.test.TC_NS2.@[THE_USER].access * read - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -perm list role com.test.TC_NS2.@[user.name].admin -** Expect 200 ** - -List Perms by Role [com.test.TC_NS2.@[THE_USER].admin] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].access * * - - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -perm list role com.test.TC_NS2.@[user.name].owner -** Expect 200 ** - -List Perms by Role [com.test.TC_NS2.@[THE_USER].owner] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].access * read - - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -role list perm com.test.TC_NS2.@[user.name].access * * -** Expect 200 ** - -List Roles by Perm com.test.TC_NS2.@[THE_USER].access|*|* --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].admin - com.test.TC_NS2.@[THE_USER].access * * - -as testid@aaf.att.com -# TC_NS2.10.70.POS Expect Namespace to be created -role list perm com.test.TC_NS2.@[user.name].access * read -** Expect 200 ** - -List Roles by Perm com.test.TC_NS2.@[THE_USER].access|*|read --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].owner - com.test.TC_NS2.@[THE_USER].access * read - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -ns list name com.test.TC_NS2.@[user.name].project -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER].project] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project - Administrators - testunused@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS2.@[THE_USER].project.admin - com.test.TC_NS2.@[THE_USER].project.owner - Permissions - com.test.TC_NS2.@[THE_USER].project.access * * - com.test.TC_NS2.@[THE_USER].project.access * read - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -perm list role com.test.TC_NS2.@[user.name].project.admin -** Expect 200 ** - -List Perms by Role [com.test.TC_NS2.@[THE_USER].project.admin] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project.access * * - - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -perm list role com.test.TC_NS2.@[user.name].project.owner -** Expect 200 ** - -List Perms by Role [com.test.TC_NS2.@[THE_USER].project.owner] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project.access * read - - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -role list perm com.test.TC_NS2.@[user.name].project.access * * -** Expect 200 ** - -List Roles by Perm com.test.TC_NS2.@[THE_USER].project.access|*|* --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project.admin - com.test.TC_NS2.@[THE_USER].project.access * * - -as testid@aaf.att.com -# TC_NS2.10.80.POS Expect Namespace to be created -role list perm com.test.TC_NS2.@[user.name].project.access * read -** Expect 200 ** - -List Roles by Perm com.test.TC_NS2.@[THE_USER].project.access|*|read --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project.owner - com.test.TC_NS2.@[THE_USER].project.access * read - -as testid@aaf.att.com -# TC_NS2.20.1.POS Create roles -role create com.test.TC_NS2.@[user.name].watcher -** Expect 201 ** -Created Role - -role create com.test.TC_NS2.@[user.name].myRole -** Expect 201 ** -Created Role - -# TC_NS2.20.2.POS Create permissions -perm create com.test.TC_NS2.@[user.name].myType myInstance myAction -** Expect 201 ** -Created Permission - -perm create com.test.TC_NS2.@[user.name].myType * * -** Expect 201 ** -Created Permission - -# TC_NS2.20.3.POS Create mechid -user cred add m99990@@[user.name].TC_NS2.test.com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_NS2.test.com] - -as XX@NS -# TC_NS2.20.10.POS Grant view perms to watcher role -perm create com.att.aaf.ns :com.test.TC_NS2.@[user.name]:ns read com.test.TC_NS2.@[user.name].watcher -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.ns|:com.test.TC_NS2.@[THE_USER]:ns|read] to Role [com.test.TC_NS2.@[THE_USER].watcher] - -as testunused@aaf.att.com -# TC_NS2.40.1.NEG Non-admin, not granted user should not view -ns list name com.test.TC_NS2.@[user.name] -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read in NS [com.test.TC_NS2.@[THE_USER]] - -as testid@aaf.att.com -# Tens test user granted to permission -# TC_NS2.40.10.POS Add user to watcher role -user role add testunused@aaf.att.com com.test.TC_NS2.@[user.name].watcher -** Expect 201 ** -Added Role [com.test.TC_NS2.@[THE_USER].watcher] to User [testunused@aaf.att.com] - -as testunused@aaf.att.com -# TC_NS2.40.11.POS Non-admin, granted user should view -ns list name com.test.TC_NS2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS2.@[THE_USER].admin - com.test.TC_NS2.@[THE_USER].cred_admin - com.test.TC_NS2.@[THE_USER].myRole - com.test.TC_NS2.@[THE_USER].owner - com.test.TC_NS2.@[THE_USER].watcher - Permissions - com.test.TC_NS2.@[THE_USER].access * * - com.test.TC_NS2.@[THE_USER].access * read - com.test.TC_NS2.@[THE_USER].myType * * - com.test.TC_NS2.@[THE_USER].myType myInstance myAction - Credentials - m99990@@[THE_USER].TC_NS2.test.com - -as testid@aaf.att.com -# TC_NS2.40.19.POS Remove user from watcher role -user role del testunused@aaf.att.com com.test.TC_NS2.@[user.name].watcher -** Expect 200 ** -Removed Role [com.test.TC_NS2.@[THE_USER].watcher] from User [testunused@aaf.att.com] - -# Thirties test admin user -# TC_NS2.40.20.POS Admin should be able to view -ns list name com.test.TC_NS2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS2.@[THE_USER].admin - com.test.TC_NS2.@[THE_USER].cred_admin - com.test.TC_NS2.@[THE_USER].myRole - com.test.TC_NS2.@[THE_USER].owner - com.test.TC_NS2.@[THE_USER].watcher - Permissions - com.test.TC_NS2.@[THE_USER].access * * - com.test.TC_NS2.@[THE_USER].access * read - com.test.TC_NS2.@[THE_USER].myType * * - com.test.TC_NS2.@[THE_USER].myType myInstance myAction - Credentials - m99990@@[THE_USER].TC_NS2.test.com - -# TC_NS2.40.21.POS Admin of parent NS should be able to view -ns list name com.test.TC_NS2.@[user.name].project -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER].project] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project - Administrators - testunused@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NS2.@[THE_USER].project.admin - com.test.TC_NS2.@[THE_USER].project.owner - Permissions - com.test.TC_NS2.@[THE_USER].project.access * * - com.test.TC_NS2.@[THE_USER].project.access * read - -# TC_NS2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -ns list admin testunused@aaf.att.com -** Expect 200 ** - -List Namespaces with admin privileges for [testunused@aaf.att.com] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project - -# TC_NS2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -ns list admin testunused@aaf.att.com -** Expect 200 ** - -List Namespaces with admin privileges for [testunused@aaf.att.com] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project - -# TC_NS2.41.20.POS List by User when not same as Caller, but parent owner of Namespace -as XX@NS -ns list admin testunused@aaf.att.com -** Expect 200 ** - -List Namespaces with admin privileges for [testunused@aaf.att.com] --------------------------------------------------------------------------------- -com.test.TC_NS2.@[THE_USER].project - -# TC_NS2.41.80.NEG List by User when not Caller nor associated to Namespace -as testunused@aaf.att.com -ns list admin XX@NS -** Expect 200 ** - -List Namespaces with admin privileges for [XX@NS] --------------------------------------------------------------------------------- -com -com.att -com.att.aaf -com.test - -as testid@aaf.att.com -# TC_NS2.99.1.POS Namespace Admin can delete Namepace defined Roles & Perms -role delete com.test.TC_NS2.@[user.name].myRole -** Expect 200,404 ** -Deleted Role - -role delete com.test.TC_NS2.@[user.name].watcher -** Expect 200,404 ** -Deleted Role - -perm delete com.test.TC_NS2.@[user.name].myType myInstance myAction -** Expect 200,404 ** -Deleted Permission - -perm delete com.test.TC_NS2.@[user.name].myType * * -** Expect 200,404 ** -Deleted Permission - -user cred del m99990@@[user.name].TC_NS2.test.com -** Expect 200,404 ** -Deleted Credential [m99990@@[THE_USER].TC_NS2.test.com] - -as XX@NS -force perm delete com.att.aaf.ns :com.test.TC_NS2.@[user.name]:ns read -** Expect 200,404 ** -Deleted Permission - -# TC_NS2.99.15.POS Remove ability to create creds -perm ungrant com.att.aaf.mechid com.att create com.test.TC_NS2.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_NS2.@[THE_USER].cred_admin] - -as testid@aaf.att.com -force role delete com.test.TC_NS2.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_NS2.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_NS2.@[user.name].project -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test.TC_NS2.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -sleep 0 -# TC_NS2.99.99.POS Check Clean Namespace -ns list name com.test.TC_NS2.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_NS2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_NS3.expected b/authz-test/TestSuite/expected/TC_NS3.expected deleted file mode 100644 index 8ac3afcf..00000000 --- a/authz-test/TestSuite/expected/TC_NS3.expected +++ /dev/null @@ -1,192 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set testid_1@test.com <pass> -set testid_2@test.com <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as XX@NS -ns list name com.test.TC_NS3.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS3.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NS3.10.1.POS Create Namespace with User ID -ns create com.test.TC_NS3.@[user.name]_1 @[user.name] testid_1@test.com -** Expect 201 ** -Created Namespace - -as testid_1@test.com -# TC_NS3.20.0.NEG Too short -ns attrib -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.20.1.NEG Wrong command -ns attrib xyz -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.20.2.NEG Too Short after Command -ns attrib add -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.20.3.NEG Too Short after Namespace -ns attrib add com.test.TC_NS3.@[user.name] -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.20.4.NEG Too Short after Key -ns attrib add com.test.TC_NS3.@[user.name] TC_NS3_swm -** Expect -1 ** -Not added: Need more Data - -# TC_NS3.20.5.NEG No Permission -ns attrib add com.test.TC_NS3.@[user.name]_1 TC_NS3_swm v1 -** Expect 403 ** -Failed [SVC1403]: Forbidden - testid_1@test.com may not create NS Attrib [com.test.TC_NS3.@[THE_USER]_1:TC_NS3_swm] - -# TC_NS3.20.6.POS Create Permission to write Attrib -as XX@NS -perm create com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.attrib|:com.att.*:TC_NS3_swm|write] to Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -# TC_NS3.20.6.POS Create Permission -perm create com.att.aaf.attrib :com.att.*:* read com.test.TC_NS3.@[user.name]_1.admin -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.attrib|:com.att.*:*|read] to Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -# TC_NS3.20.10.POS Attribute added -as testid_1@test.com -ns attrib add com.test.TC_NS3.@[user.name]_1 TC_NS3_swm v1 -** Expect 201 ** -Add Attrib TC_NS3_swm=v1 to com.test.TC_NS3.@[THE_USER]_1 - -# TC_NS3.20.30.POS List NS by Attrib -ns list keys TC_NS3_swm -** Expect 200 ** - -List Namespace Names by Attribute --------------------------------------------------------------------------------- - com.test.TC_NS3.@[THE_USER]_1 - -# TC_NS3.20.40.POS List NS (shows Attrib) -ns list name com.test.TC_NS3.@[user.name]_1 -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS3.@[THE_USER]_1] --------------------------------------------------------------------------------- -com.test.TC_NS3.@[THE_USER]_1 - Administrators - testid_1@test.com - Responsible Parties - @[THE_USER]@csp.att.com - Namespace Attributes - TC_NS3_swm=v1 - Roles - com.test.TC_NS3.@[THE_USER]_1.admin - com.test.TC_NS3.@[THE_USER]_1.owner - Permissions - com.test.TC_NS3.@[THE_USER]_1.access * * - com.test.TC_NS3.@[THE_USER]_1.access * read - -# TC_NS3.20.42.POS Change Attrib -ns attrib upd com.test.TC_NS3.@[user.name]_1 TC_NS3_swm Version1 -** Expect 200 ** -Update Attrib TC_NS3_swm=Version1 for com.test.TC_NS3.@[THE_USER]_1 - -# TC_NS3.20.49.POS List NS (shows new Attrib) -ns list name com.test.TC_NS3.@[user.name]_1 -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NS3.@[THE_USER]_1] --------------------------------------------------------------------------------- -com.test.TC_NS3.@[THE_USER]_1 - Administrators - testid_1@test.com - Responsible Parties - @[THE_USER]@csp.att.com - Namespace Attributes - TC_NS3_swm=Version1 - Roles - com.test.TC_NS3.@[THE_USER]_1.admin - com.test.TC_NS3.@[THE_USER]_1.owner - Permissions - com.test.TC_NS3.@[THE_USER]_1.access * * - com.test.TC_NS3.@[THE_USER]_1.access * read - -# TC_NS3.20.80.POS Remove write Permission -perm ungrant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin -** Expect 200 ** -UnGranted Permission [com.att.aaf.attrib|:com.att.*:TC_NS3_swm|write] from Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -# TC_NS3.20.83.POS Remove read Permission -perm ungrant com.att.aaf.attrib :com.att.*:* read com.test.TC_NS3.@[user.name]_1.admin -** Expect 200 ** -UnGranted Permission [com.att.aaf.attrib|:com.att.*:*|read] from Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -as testid_1@test.com -# TC_NS3.50.2.NEG Too Short after Command -ns attrib del -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.50.3.NEG Too Short after Namespace -ns attrib del com.test.TC_NS3.@[user.name] -** Expect -1 ** -Too few args: attrib <add|upd|del> <ns> <key> [value] - -# TC_NS3.50.5.NEG No Permission -ns attrib del com.test.TC_NS3.@[user.name]_1 TC_NS3_swm -** Expect 403 ** -Failed [SVC1403]: Forbidden - testid_1@test.com may not delete NS Attrib [com.test.TC_NS3.@[THE_USER]_1:TC_NS3_swm] - -# TC_NS3.50.6.POS Create Permission -as XX@NS -perm grant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin -** Expect 201 ** -Granted Permission [com.att.aaf.attrib|:com.att.*:TC_NS3_swm|write] to Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -# TC_NS3.50.7.POS Attribute added -as testid_1@test.com -ns attrib del com.test.TC_NS3.@[user.name]_1 TC_NS3_swm -** Expect 200 ** -Attrib TC_NS3_swm deleted from com.test.TC_NS3.@[THE_USER]_1 - -# TC_NS3.50.8.POS Remove Permission -as XX@NS -perm ungrant com.att.aaf.attrib :com.att.*:TC_NS3_swm write com.test.TC_NS3.@[user.name]_1.admin -** Expect 200 ** -UnGranted Permission [com.att.aaf.attrib|:com.att.*:TC_NS3_swm|write] from Role [com.test.TC_NS3.@[THE_USER]_1.admin] - -as testid_1@test.com -# TC_NS3.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_NS3.@[user.name]_1 -** Expect 200,404 ** -Deleted Namespace - -# TC_NS3.99.3.POS Print Namespaces -ns list name com.test.TC_NS3.@[user.name]_1 -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_NS3.@[THE_USER]_1] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NS3.99.10.POS Remove Special Permissions -as XX@NS -force perm delete com.att.aaf.attrib :com.att.*:TC_NS3_swm write -** Expect 200,404 ** -Deleted Permission - -force perm delete com.att.aaf.attrib :com.att.*:* read -** Expect 200,404 ** -Deleted Permission - diff --git a/authz-test/TestSuite/expected/TC_NSdelete1.expected b/authz-test/TestSuite/expected/TC_NSdelete1.expected deleted file mode 100644 index 29732c5d..00000000 --- a/authz-test/TestSuite/expected/TC_NSdelete1.expected +++ /dev/null @@ -1,362 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus@aaf.att.com boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_NSdelete1.10.0.POS Check for Existing Data -ns list name com.test.TC_NSdelete1.@[user.name].app -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER].app] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.force.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.force.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -as XX@NS -# TC_NSdelete1.10.1.POS Create Namespaces with valid IDs and Responsible Parties -ns create com.test.TC_NSdelete1.@[user.name].app @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -ns create com.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -ns create com.test.force.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -ns create com.test.TC_NSdelete1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_NSdelete1.10.2.POS Expect Namespace to be created -ns list name com.test.TC_NSdelete1.@[user.name].app -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER].app] --------------------------------------------------------------------------------- -com.test.TC_NSdelete1.@[THE_USER].app - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NSdelete1.@[THE_USER].app.admin - com.test.TC_NSdelete1.@[THE_USER].app.owner - Permissions - com.test.TC_NSdelete1.@[THE_USER].app.access * * - com.test.TC_NSdelete1.@[THE_USER].app.access * read - -ns list name com.test.TC_NSdelete1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NSdelete1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NSdelete1.@[THE_USER].admin - com.test.TC_NSdelete1.@[THE_USER].owner - Permissions - com.test.TC_NSdelete1.@[THE_USER].access * * - com.test.TC_NSdelete1.@[THE_USER].access * read - -ns list name com.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.@[THE_USER]] --------------------------------------------------------------------------------- -com.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.@[THE_USER].admin - com.@[THE_USER].owner - Permissions - com.@[THE_USER].access * * - com.@[THE_USER].access * read - -ns list name com.test.force.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.force.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.force.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.force.@[THE_USER].admin - com.test.force.@[THE_USER].owner - Permissions - com.test.force.@[THE_USER].access * * - com.test.force.@[THE_USER].access * read - -# TC_NSdelete1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 201 ** -Created Role - -# TC_NSdelete1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_NSdelete1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_NSdelete1.10.12.POS Assign user for creating creds -user role add testid@aaf.att.com com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_NSdelete1.@[THE_USER].cred_admin] to User [testid@aaf.att.com] - -as testid@aaf.att.com -# TC_NSdelete1.20.1.POS Create valid Role in my Namespace -role create com.test.TC_NSdelete1.@[user.name].app.r.A -** Expect 201 ** -Created Role - -# TC_NSdelete1.20.2.POS Create valid permission -perm create com.test.TC_NSdelete1.@[user.name].app.p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_NSdelete1.20.3.POS Add credential to my namespace -user cred add m99990@app.@[user.name].TC_NSdelete1.test.com password123 -** Expect 201 ** -Added Credential [m99990@app.@[THE_USER].TC_NSdelete1.test.com] - -# TC_NSdelete1.20.10.NEG Delete Program Should fail because of attached credential -ns delete com.test.TC_NSdelete1.@[user.name].app -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - [com.test.TC_NSdelete1.@[THE_USER].app] contains users, permissions, roles. - Delete dependencies and try again. Note: using force=true will delete all. force=move will delete Creds, but move Roles and Perms to parent. - -# TC_NSdelete1.20.11.POS Delete Credential -set force true -user cred del m99990@app.@[user.name].TC_NSdelete1.test.com -** Expect 200 ** -Deleted Credential [m99990@app.@[THE_USER].TC_NSdelete1.test.com] - -# TC_NSdelete1.20.12.NEG Delete Program with role and permission attached -ns delete com.test.TC_NSdelete1.@[user.name].app -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - [com.test.TC_NSdelete1.@[THE_USER].app] contains permissions, roles. - Delete dependencies and try again. Note: using force=true will delete all. force=move will delete Creds, but move Roles and Perms to parent. - -# TC_NSdelete1.20.20.POS Expect role and permission to move to parent ns -set force move -set force=move ns list name com.test.TC_NSdelete1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_NSdelete1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_NSdelete1.@[THE_USER].admin - com.test.TC_NSdelete1.@[THE_USER].cred_admin - com.test.TC_NSdelete1.@[THE_USER].owner - Permissions - com.test.TC_NSdelete1.@[THE_USER].access * * - com.test.TC_NSdelete1.@[THE_USER].access * read - -as testid@aaf.att.com -# TC_NSdelete1.30.1.POS Create valid Role in my Namespace -role create com.@[user.name].r.A -** Expect 201 ** -Created Role - -# TC_NSdelete1.30.2.NEG Delete Company with role attached -ns delete com.@[user.name] -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - [com.@[THE_USER]] contains roles. - Delete dependencies and try again. Note: using force=true will delete all. force=move will delete Creds, but move Roles and Perms to parent. - -# TC_NSdelete1.30.3.POS Namespace Admin can delete Namepace defined Roles -role delete com.@[user.name].r.A -** Expect 200 ** -Deleted Role - -# TC_NSdelete1.30.10.POS Create valid permission -perm create com.@[user.name].p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_NSdelete1.30.11.NEG Delete Company with permission attached -ns delete com.@[user.name] -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - [com.@[THE_USER]] contains permissions. - Delete dependencies and try again. Note: using force=true will delete all. force=move will delete Creds, but move Roles and Perms to parent. - -# TC_NSdelete1.30.12.POS Namespace Admin can delete Namepace defined Perms -perm delete com.@[user.name].p.A myInstance myAction -** Expect 200 ** -Deleted Permission - -# TC_NSdelete1.30.20.POS Create valid Credential in my namespace -user cred add m99990@@[user.name].com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].com] - -# TC_NSdelete1.30.21.NEG Delete Company with credential attached -ns delete com.@[user.name] -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - [com.@[THE_USER]] contains users. - Delete dependencies and try again. Note: using force=true will delete all. force=move will delete Creds, but move Roles and Perms to parent. - -# TC_NSdelete1.30.22.POS Namespace admin can remove Cred -set force true -user cred del m99990@@[user.name].com -** Expect 200 ** -Deleted Credential [m99990@@[THE_USER].com] - -# TC_NSdelete1.30.30.POS Delete Company with no roles or perms attached -ns delete com.@[user.name] -** Expect 200 ** -Deleted Namespace - -# TC_NSdelete1.40.1.POS Create valid Role in my Namespace -role create com.test.force.@[user.name].r.A -** Expect 201 ** -Created Role - -# TC_NSdelete1.40.2.POS Create valid permission in my Namespace -perm create com.test.force.@[user.name].p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_NSdelete1.40.3.POS Add credential to my namespace -user cred add m99990@@[user.name].force.test.com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].force.test.com] - -# TC_NSdelete1.40.10.POS Delete Program in my Namespace -set force true -set force=true ns delete com.test.force.@[user.name] -** Expect 200 ** -Deleted Namespace - -sleep 0 -# TC_NSdelete1.40.20.NEG Role and permission should not exist -ns list name com.test.force.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.force.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NSdelete1.40.22.NEG Credential should not exist -set force true -user cred del m99990@@[user.name].force.test.com -** Expect 404 ** -Failed [SVC5404]: Not Found - Credential does not exist - -as testid@aaf.att.com -# TC_NSdelete1.99.1.POS Namespace Admin can delete Namepace defined Roles -role delete com.test.TC_NSdelete1.@[user.name].app.r.A -** Expect 200,404 ** -Deleted Role - -# TC_NSdelete1.99.2.POS Namespace Admin can delete Namepace defined Roles -perm delete com.test.TC_NSdelete1.@[user.name].app.p.A myInstance myAction -** Expect 200,404 ** -Deleted Permission - -# TC_NSdelete1.99.3.POS Namespace Admin can remove Namepace defined Credentials -set force true -set force=true user cred del m99990@@app.[user.name].TC_NSdelete1.test.com -** Expect 200,404 ** -Failed [SVC5404]: Not Found - Credential does not exist - -# TC_NSdelete1.99.10.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 200,404 ** -Removed Role [com.test.TC_NSdelete1.@[THE_USER].cred_admin] from User [testid@aaf.att.com] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_NSdelete1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -set force true -set force=true role delete com.test.TC_NSdelete1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_NSdelete1.99.97.POS Clean Namespace -set force true -set force=true ns delete com.test.TC_NSdelete1.@[user.name].app -** Expect 200,404 ** -Deleted Namespace - -set force true -set force=true ns delete com.test.TC_NSdelete1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -set force true -set force=true ns delete com.test.force.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test.force.@[THE_USER] does not exist - -# TC_NSdelete1.99.98.POS Check Clean Namespace -ns list name com.test.TC_NSdelete1.@[user.name].app -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER].app] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_NSdelete1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_NSdelete1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.force.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.force.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_NSdelete1.99.99.POS Clean and check Company Namespace -as XX@NS -set force true -set force=true ns delete com.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.@[THE_USER] does not exist - -ns list name com.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_PW1.expected b/authz-test/TestSuite/expected/TC_PW1.expected deleted file mode 100644 index b167edbb..00000000 --- a/authz-test/TestSuite/expected/TC_PW1.expected +++ /dev/null @@ -1,170 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_PW1.10.0.POS Validate no NS -ns list name com.test.TC_PW1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_PW1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_PW1.10.1.POS Create Namespace to add IDs -ns create com.test.TC_PW1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_PW1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_PW1.@[user.name].cred_admin -** Expect 201 ** -Created Role - -as XX@NS -# TC_PW1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_PW1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_PW1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_PW1.10.12.POS Assign user for creating creds -user role add testid@aaf.att.com com.test.TC_PW1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_PW1.@[THE_USER].cred_admin] to User [testid@aaf.att.com] - -# TC_PW1.20.1.NEG ASPR 1010 Passwords must be at least 8 characters in length -user cred add m12345@TC_PW1.test.com 12 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Password must be 8 chars or greater in length (ASPR-1010), -Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.20.2.NEG ASPR 1010 Passwords must be at least 8 characters in length -user cred add m12345@TC_PW1.test.com 1 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Password must be 8 chars or greater in length (ASPR-1010), -Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.20.3.NEG ASPR 1010 Passwords must be at least 8 characters in length -user cred add m12345@TC_PW1.test.com 1234567 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Password must be 8 chars or greater in length (ASPR-1010), -Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.21.1.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com 12345678 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.21.2.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com abcdefgh -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.21.3.NEG ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com "!@#%^()*" -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Passwords must include characters from at least two of these groupings: alpha, numeric and one of these special chars: !@#$%^*()-+?/,:;. (ASPR-1010) - -# TC_PW1.21.4.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com "!@#a%^()*" -** Expect 201 ** -Added Credential [m12345@@[THE_USER].TC_PW1.test.com] - -sleep 0 -user cred del m12345@@[user.name].TC_PW1.test.com -** Expect 200 ** -Deleted Credential [m12345@@[THE_USER].TC_PW1.test.com] - -# TC_PW1.21.5.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com "!@#2%^()*" -** Expect 201 ** -Added Credential [m12345@@[THE_USER].TC_PW1.test.com] - -sleep 0 -user cred del m12345@@[user.name].TC_PW1.test.com -** Expect 200 ** -Deleted Credential [m12345@@[THE_USER].TC_PW1.test.com] - -# TC_PW1.21.6.POS ASPR 1010 Passwords must include chars from 2 groupings, alpha, numeric and special -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sd" -** Expect 201 ** -Added Credential [m12345@@[THE_USER].TC_PW1.test.com] - -sleep 0 -user cred del m12345@@[user.name].TC_PW1.test.com -** Expect 200 ** -Deleted Credential [m12345@@[THE_USER].TC_PW1.test.com] - -# TC_PW1.21.10.NEG ASPR 1010 Passwords cannot be the same as the User ID -user cred add m12345@@[user.name].TC_PW1.test.com m12345 -** Expect 406 ** -Failed [SVC1406]: Not Acceptable - Password must be 8 chars or greater in length (ASPR-1010) - -# TC_PW1.23.1.NEG Too Few Args for User Cred 1 -user cred -** Expect -1 ** -Too few args: cred <add|del|reset|extend> <id> [password (! D|E)] [entry# (if multi)] - -# TC_PW1.23.2.NEG Too Few Args for User Cred add -user cred add -** Expect -1 ** -Too few args: cred <add|del|reset|extend> <id> [password (! D|E)] [entry# (if multi)] - -# TC_PW1.30.1.POS Create a Credential, with Temporary Time -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sd" -** Expect 201 ** -Added Credential [m12345@@[THE_USER].TC_PW1.test.com] - -# TC_PW1.30.3.NEG Credential Exists -user cred add m12345@@[user.name].TC_PW1.test.com "abc123sf" -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Credential with same Expiration Date exists, use 'reset' - -# TC_PW1.30.8.POS Reset this Password -user cred reset m12345@@[user.name].TC_PW1.test.com "ABC123SD" 1 -** Expect 200 ** -Reset Credential [m12345@@[THE_USER].TC_PW1.test.com] - -# TC_PW1.30.9.POS Delete a Credential -user cred del m12345@@[user.name].TC_PW1.test.com 1 -** Expect 200 ** -Deleted Credential [m12345@@[THE_USER].TC_PW1.test.com] - -as testid@aaf.att.com -# TC_PW1.99.1.NEG Delete ID m12345@@[user.name].TC_PW1.test.com -set force true -user cred del m12345@@[user.name].TC_PW1.test.com -** Expect 200,404 ** -Failed [SVC5404]: Not Found - Credential does not exist - -# TC_PW1.99.2.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_PW1.@[user.name].cred_admin -** Expect 200,404 ** -Removed Role [com.test.TC_PW1.@[THE_USER].cred_admin] from User [testid@aaf.att.com] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_PW1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_PW1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -role delete com.test.TC_PW1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_PW1.99.98.POS Delete Namespace com..test.TC_PW1 -ns delete com.test.TC_PW1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_PW1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_PW1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_PW1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Perm1.expected b/authz-test/TestSuite/expected/TC_Perm1.expected deleted file mode 100644 index d099990c..00000000 --- a/authz-test/TestSuite/expected/TC_Perm1.expected +++ /dev/null @@ -1,963 +0,0 @@ -set testid <pass> -set testid@aaf.att.com <pass> -set XX@NS <pass> -set testunused <pass> -set bogus boguspass -#delay 10 -set NFR 0 -# TC_Perm1.10.0.POS Validate Namespace is empty first -as testid@aaf.att.com -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Perm1.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_Perm1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Perm1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_Perm1.@[user.name].cred_admin -** Expect 201 ** -Created Role - -as XX@NS -# TC_Perm1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_Perm1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_Perm1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_Perm1.10.12.POS Assign user for creating creds -user role add XX@NS com.test.TC_Perm1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_Perm1.@[THE_USER].cred_admin] to User [XX@NS] - -# TC_Perm1.20.1.POS List Data on non-Empty NS -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - -# TC_Perm1.20.2.POS Add Perm -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm1.20.3.NEG Already Added Perm -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Permission [com.test.TC_Perm1.@[THE_USER].p.A|myInstance|myAction] already exists. - -# TC_Perm1.20.4.POS Add Perm with non-existent Roles as well -force perm create com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].r.A,com.test.TC_Perm1.@[user.name].r.B -** Expect 201 ** -Created Role [com.test.TC_Perm1.@[THE_USER].r.A] -Created Role [com.test.TC_Perm1.@[THE_USER].r.B] -Created Permission -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.B|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.A] -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.B|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.B] - -# TC_Perm1.20.8.POS Print Info for Validation -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - -# TC_Perm1.20.9.NEG Already Added Perm with some Roles as well -perm create com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].r.A,com.test.TC_Perm1.@[user.name].r.B -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Permission [com.test.TC_Perm1.@[THE_USER].p.B|myInstance|myAction] already exists. - -# TC_Perm1.20.10.NEG Non-admins can't change description -as testunused -perm describe com.test.TC_Perm1.@[user.name].p.A myInstance myAction Description for A -** Expect 403 ** -Failed [SVC1403]: Forbidden - You do not have approval to change Permission [com.test.TC_Perm1.@[THE_USER].p.A|myInstance|myAction] - -# TC_Perm1.20.11.NEG Permission must exist to change description -as testid -perm describe com.test.TC_Perm1.@[user.name].p.C myInstance myAction Description for C -** Expect 404 ** -Failed [SVC1404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] does not exist - -# TC_Perm1.20.12.POS Admin can change description -perm describe com.test.TC_Perm1.@[user.name].p.A myInstance myAction Description for A -** Expect 200 ** -Description added to Permission - -# TC_Perm1.22.1.NEG Try to rename permission without changing anything -perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].p.B myInstance myAction -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - New Permission must be different than original permission - -# TC_Perm1.22.2.NEG Try to rename parent ns -perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.att.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - You do not have approval to change Permission [com.att.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.22.10.POS View permission in original state -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - -# TC_Perm1.22.11.POS Rename permission instance -perm rename com.test.TC_Perm1.@[user.name].p.B myInstance myAction com.test.TC_Perm1.@[user.name].p.B yourInstance myAction -** Expect 200 ** -Updated Permission - -# TC_Perm1.22.12.POS Verify change in permission instance -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B yourInstance myAction - -# TC_Perm1.22.13.POS Rename permission action -perm rename com.test.TC_Perm1.@[user.name].p.B yourInstance myAction com.test.TC_Perm1.@[user.name].p.B yourInstance yourAction -** Expect 200 ** -Updated Permission - -# TC_Perm1.22.14.POS Verify change in permission action -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B yourInstance yourAction - -# TC_Perm1.22.15.POS Rename permission type -perm rename com.test.TC_Perm1.@[user.name].p.B yourInstance yourAction com.test.TC_Perm1.@[user.name].p.yourB yourInstance yourAction -** Expect 200 ** -Updated Permission - -# TC_Perm1.22.16.POS Verify change in permission type -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.yourB yourInstance yourAction - -# TC_Perm1.22.20.POS See permission is attached to this role -role list role com.test.TC_Perm1.@[user.name].r.A -** Expect 200 ** - -List Roles for Role[com.test.TC_Perm1.@[THE_USER].r.A] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].p.yourB yourInstance yourAction - -# TC_Perm1.22.21.POS Rename permission type, instance and action -perm rename com.test.TC_Perm1.@[user.name].p.yourB yourInstance yourAction com.test.TC_Perm1.@[user.name].p.B myInstance myAction -** Expect 200 ** -Updated Permission - -# TC_Perm1.22.22.POS See permission stays attached after rename -role list role com.test.TC_Perm1.@[user.name].r.A -** Expect 200 ** - -List Roles for Role[com.test.TC_Perm1.@[THE_USER].r.A] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - -# TC_Perm1.22.23.POS Verify permission is back to original state -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - -# TC_Perm1.25.1.POS Create another Role in This namespace -role create com.test.TC_Perm1.@[user.name].r.C -** Expect 201 ** -Created Role - -# TC_Perm1.25.2.POS Create another Perm in This namespace -perm create com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm1.25.3.NEG Permission must Exist to Add to Role -perm grant com.test.TC_Perm1.@[user.name].p.NO myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.NO|myInstance|myAction] does not exist - -# TC_Perm1.25.4.POS Grant individual new Perm to new Role -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 201 ** -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.25.5.NEG Already Granted Perm -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] already granted to Role [com.test.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.25.6.POS Print Info for Validation -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - com.test.TC_Perm1.@[THE_USER].r.C - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.C myInstance myAction - -# TC_Perm1.25.10.POS UnGrant individual new Perm to new Role -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 200 ** -UnGranted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] from Role [com.test.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.25.11.NEG Already UnGranted Perm -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] not associated with any Role - -# TC_Perm1.25.20.POS Reset roles attached to permision with setTo -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C,com.test.TC_Perm1.@[user.name].r.A -** Expect 200 ** -Set Permission's Roles to [com.test.TC_Perm1.@[THE_USER].r.C,com.test.TC_Perm1.@[THE_USER].r.A] - -# TC_Perm1.25.21.POS Owner of permission can reset roles -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 200 ** -Set Permission's Roles to [] - -# TC_Perm1.26.1.POS Create another Namespace, not owned by testid, one in company, one not -as XX@NS -ns create com.test2.TC_Perm1.@[user.name] @[user.name] XX@NS -** Expect 201 ** -Created Namespace - -ns create com.test.TC_Perm1.@[user.name]_2 @[user.name] XX@NS -** Expect 201 ** -Created Namespace - -# TC_Perm1.26.2.POS Create ID in other Namespace -user cred add m99990@@[user.name].TC_Perm1.test2.com aRealPass7 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_Perm1.test2.com] - -# TC_Perm1.26.3.POS Create a Role in other Namespaces, not owned by testid -role create com.test2.TC_Perm1.@[user.name].r.C -** Expect 201 ** -Created Role - -role create com.test2.TC_Perm1.@[user.name]_2.r.C -** Expect 201 ** -Created Role - -# TC_Perm1.26.11.NEG Grant Perm to Role in Other Namespace, when Role ID -as m99990@@[THE_USER].TC_Perm1.test2.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.11a.NEG Grant Perm to Role in Other Namespace, when Role ID -as m99990@@[THE_USER].TC_Perm1.test2.com -set request true -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Perm1.26.12.NEG Grant Perm to Role in Other Namespace, when Perm ID, but different Company -as testid@aaf.att.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid@aaf.att.com] may not write Role [com.test2.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.26.13.NEG Fail Grant Perm to Role in Other Namespace, when Perm ID, but same Company -as testid@aaf.att.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] does not exist - -# TC_Perm1.26.14.POS Create Role -as testid@aaf.att.com -role create com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 201 ** -Created Role - -# TC_Perm1.26.15.POS Fail Create/Grant Perm to Role in Other Namespace, when Perm ID, but same Company -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 201 ** -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] - -# TC_Perm1.26.16.POS Print Info for Validation -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - com.test.TC_Perm1.@[THE_USER].r.C - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.C myInstance myAction - -# TC_Perm1.26.17.POS Grant individual new Perm to new Role -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 201 ** -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.26.18.NEG Already Granted Perm -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] already granted to Role [com.test.TC_Perm1.@[THE_USER].r.C] - -# TC_Perm1.26.19.POS UnGrant Perm from Role in Other Namespace, when Perm ID -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 200 ** -UnGranted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] from Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] - -# TC_Perm1.26.21.NEG No Permission to Grant Perm to Role with Unrelated ID -as m99990@@[THE_USER].TC_Perm1.test2.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.22.NEG No Permission to Grant Perm to Role with Unrelated ID -set request true -as m99990@@[THE_USER].TC_Perm1.test2.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Perm1.26.25.NEG No Permission to UnGrant with Unrelated ID -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.B -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.26.NEG No Permission to UnGrant with Unrelated ID -set request true -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.B -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Perm1.26.30.POS Add ID to Role -as XX@NS -ns admin add com.test2.TC_Perm1.@[user.name] m99990@@[user.name].TC_Perm1.test2.com -** Expect 201 ** -Admin m99990@@[THE_USER].TC_Perm1.test2.com added to com.test2.TC_Perm1.@[THE_USER] - -as m99990@@[THE_USER].TC_Perm1.test2.com -sleep 0 -# TC_Perm1.26.31.NEG No Permission Grant Perm to Role if not Perm Owner -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.31.NEG No Permission Grant Perm to Role if not Perm Owner -set request true -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test2.TC_Perm1.@[user.name].r.C -** Expect 202 ** -Permission Role Granted Accepted, but requires Approvals before actualizing - -# TC_Perm1.26.32.POS Grant individual new Perm to Role in Other Namespace -as testid@aaf.att.com -perm grant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 201 ** -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] - -# TC_Perm1.26.34.POS Print Info for Validation -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - com.test.TC_Perm1.@[THE_USER].r.C - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.C myInstance myAction - -as XX@NS -# TC_Perm1.26.35.POS Print Info for Validation -ns list name com.test2.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test2.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test2.TC_Perm1.@[THE_USER] - Administrators - XX@NS - m99990@@[THE_USER].TC_Perm1.test2.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test2.TC_Perm1.@[THE_USER].admin - com.test2.TC_Perm1.@[THE_USER].owner - com.test2.TC_Perm1.@[THE_USER].r.C - Permissions - com.test2.TC_Perm1.@[THE_USER].access * * - com.test2.TC_Perm1.@[THE_USER].access * read - Credentials - m99990@@[THE_USER].TC_Perm1.test2.com - -as testid@aaf.att.com -# TC_Perm1.26.36.POS UnGrant individual new Perm to new Role -as testid@aaf.att.com -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 200 ** -UnGranted Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] from Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] - -# TC_Perm1.26.37.NEG Already UnGranted Perm -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] not associated with any Role - -# TC_Perm1.26.40.POS Reset roles attached to permision with setTo -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C,com.test.TC_Perm1.@[user.name].r.A -** Expect 200 ** -Set Permission's Roles to [com.test.TC_Perm1.@[THE_USER].r.C,com.test.TC_Perm1.@[THE_USER].r.A] - -# TC_Perm1.26.41.NEG Non-owner of permission cannot reset roles -as m99990@@[THE_USER].TC_Perm1.test2.com -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.42.NEG Non-owner of permission cannot ungrant -perm ungrant com.test.TC_Perm1.@[user.name].p.C myInstance myAction com.test.TC_Perm1.@[user.name].r.C -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.43.NEG Non-owner of permission cannot delete -perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_Perm1.test2.com] may not write Perm [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] - -# TC_Perm1.26.45.POS Owner of permission can reset roles -as testid@aaf.att.com -perm setTo com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 200 ** -Set Permission's Roles to [] - -as XX@NS -# TC_Perm1.26.97.POS List the Namespaces -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.B - com.test.TC_Perm1.@[THE_USER].r.C - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.B myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.C myInstance myAction - -ns list name com.test2.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test2.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test2.TC_Perm1.@[THE_USER] - Administrators - XX@NS - m99990@@[THE_USER].TC_Perm1.test2.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test2.TC_Perm1.@[THE_USER].admin - com.test2.TC_Perm1.@[THE_USER].owner - com.test2.TC_Perm1.@[THE_USER].r.C - Permissions - com.test2.TC_Perm1.@[THE_USER].access * * - com.test2.TC_Perm1.@[THE_USER].access * read - Credentials - m99990@@[THE_USER].TC_Perm1.test2.com - -as testid@aaf.att.com -# TC_Perm1.26.98.POS Cleanup -role delete com.test.TC_Perm1.@[user.name].r.A -** Expect 200 ** -Deleted Role - -role delete com.test.TC_Perm1.@[user.name].r.B -** Expect 200 ** -Deleted Role - -role delete com.test.TC_Perm1.@[user.name].r.C -** Expect 200 ** -Deleted Role - -role delete com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 200 ** -Deleted Role - -as XX@NS -role delete com.test2.TC_Perm1.@[user.name]_2.r.C -** Expect 200 ** -Deleted Role - -role delete com.test2.TC_Perm1.@[user.name].r.C -** Expect 200 ** -Deleted Role - -as testid@aaf.att.com -perm delete com.test.TC_Perm1.@[user.name].p.A myInstance myAction -** Expect 200 ** -Deleted Permission - -perm delete com.test.TC_Perm1.@[user.name].p.B myInstance myAction -** Expect 200 ** -Deleted Permission - -perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 200 ** -Deleted Permission - -force ns delete com.test.TC_Perm1.@[user.name]_2 -** Expect 200 ** -Deleted Namespace - -as XX@NS -set force true -set force=true user cred del m99990@@[user.name].TC_Perm1.test2.com -** Expect 200 ** -Deleted Credential [m99990@@[THE_USER].TC_Perm1.test2.com] - -ns delete com.test2.TC_Perm1.@[user.name] -** Expect 200 ** -Deleted Namespace - -# TC_Perm1.26.99.POS List the Now Empty Namespaces -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - -ns list name com.test2.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test2.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Perm1.27.1.POS Create Permission -perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm1.27.2.POS Create Role -role create com.test.TC_Perm1.@[user.name].r.A -** Expect 201 ** -Created Role - -# TC_Perm1.27.10.NEG Role must Exist to Add to Role without force -perm grant com.test.TC_Perm1.@[user.name].p.A myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown -** Expect 404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Perm1.@[THE_USER].r.unknown] does not exist - -# TC_Perm1.27.11.POS Role is created with force -force perm create com.test.TC_Perm1.@[user.name].p.A myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown -** Expect 201 ** -Created Role [com.test.TC_Perm1.@[THE_USER].r.unknown] -Created Permission -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.A|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.unknown] - -# TC_Perm1.27.12.NEG Perm must Exist to Grant without force -perm grant com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction com.test.TC_Perm1.@[user.name].r.A -** Expect 404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.unknown|myInstance|myAction] does not exist - -# TC_Perm1.27.13.POS Perm is created with force -force perm grant com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction com.test.TC_Perm1.@[user.name].r.A -** Expect 201 ** -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.unknown|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.A] - -# TC_Perm1.27.14.POS Role and perm are created with force -force perm create com.test.TC_Perm1.@[user.name].p.unknown2 myInstance myAction com.test.TC_Perm1.@[user.name].r.unknown2 -** Expect 201 ** -Created Role [com.test.TC_Perm1.@[THE_USER].r.unknown2] -Created Permission -Granted Permission [com.test.TC_Perm1.@[THE_USER].p.unknown2|myInstance|myAction] to Role [com.test.TC_Perm1.@[THE_USER].r.unknown2] - -# TC_Perm1.30.1.POS List Data on non-Empty NS -as testid -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.unknown - com.test.TC_Perm1.@[THE_USER].r.unknown2 - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.unknown myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.unknown2 myInstance myAction - -# TC_Perm1.30.2.POS Create Sub-ns when Roles that exist -ns create com.test.TC_Perm1.@[user.name].r @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Perm1.30.3.POS List Data on NS with sub-roles -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].admin - com.test.TC_Perm1.@[THE_USER].cred_admin - com.test.TC_Perm1.@[THE_USER].owner - Permissions - com.test.TC_Perm1.@[THE_USER].access * * - com.test.TC_Perm1.@[THE_USER].access * read - com.test.TC_Perm1.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.unknown myInstance myAction - com.test.TC_Perm1.@[THE_USER].p.unknown2 myInstance myAction - -ns list name com.test.TC_Perm1.@[user.name].r -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER].r] --------------------------------------------------------------------------------- -com.test.TC_Perm1.@[THE_USER].r - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm1.@[THE_USER].r.A - com.test.TC_Perm1.@[THE_USER].r.admin - com.test.TC_Perm1.@[THE_USER].r.owner - com.test.TC_Perm1.@[THE_USER].r.unknown - com.test.TC_Perm1.@[THE_USER].r.unknown2 - Permissions - com.test.TC_Perm1.@[THE_USER].r.access * * - com.test.TC_Perm1.@[THE_USER].r.access * read - -as XX@NS -# TC_Perm1.99.1.POS Namespace Admin can delete Namepace defined Roles -set force true -set force=true perm delete com.test.TC_Perm1.@[user.name].p.A myInstance myAction -** Expect 200,404 ** -Deleted Permission - -set force true -set force=true perm delete com.test.TC_Perm1.@[user.name].p.B myInstance myAction -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.B|myInstance|myAction] does not exist - -set force true -set force=true perm delete com.test.TC_Perm1.@[user.name].p.C myInstance myAction -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.test.TC_Perm1.@[THE_USER].p.C|myInstance|myAction] does not exist - -set force true -set force=true perm delete com.test.TC_Perm1.@[user.name].p.unknown myInstance myAction -** Expect 200,404 ** -Deleted Permission - -set force true -set force=true perm delete com.test.TC_Perm1.@[user.name].p.unknown2 myInstance myAction -** Expect 200,404 ** -Deleted Permission - -role delete com.test.TC_Perm1.@[user.name].r.A -** Expect 200,404 ** -Deleted Role - -role delete com.test.TC_Perm1.@[user.name].r.B -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Perm1.@[THE_USER].r.B] does not exist - -role delete com.test.TC_Perm1.@[user.name].r.C -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Perm1.@[THE_USER].r.C] does not exist - -role delete com.test.TC_Perm1.@[user.name].r.unknown -** Expect 200,404 ** -Deleted Role - -role delete com.test.TC_Perm1.@[user.name].r.unknown2 -** Expect 200,404 ** -Deleted Role - -role delete com.test2.TC_Perm1.@[user.name].r.C -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test2.TC_Perm1.@[THE_USER].r.C] does not exist - -role delete com.test.TC_Perm1.@[user.name]_2.r.C -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Perm1.@[THE_USER]_2.r.C] does not exist - -role delete com.test2.TC_Perm1.@[user.name]_2.r.C -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test2.TC_Perm1.@[THE_USER]_2.r.C] does not exist - -# TC_Perm1.99.2.POS Remove ability to create creds -user role del XX@NS com.test.TC_Perm1.@[user.name].cred_admin -** Expect 200,404 ** -Removed Role [com.test.TC_Perm1.@[THE_USER].cred_admin] from User [XX@NS] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Perm1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_Perm1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -role delete com.test.TC_Perm1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -sleep 0 -as XX@NS -# TC_Perm1.99.98.POS Namespace Admin can delete Namespace -set force true -set force=true ns delete com.test2.TC_Perm1.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test2.TC_Perm1.@[THE_USER] does not exist - -as testid -force ns delete com.test.TC_Perm1.@[user.name].r -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test.TC_Perm1.@[user.name]_2 -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test.TC_Perm1.@[THE_USER]_2 does not exist - -force ns delete com.test.TC_Perm1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test2.TC_Perm1.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test2.TC_Perm1.@[THE_USER] does not exist - -# TC_Perm1.99.99.POS List to prove removed -ns list name com.test.TC_Perm1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Perm1.@[user.name].r -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER].r] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Perm1.@[user.name]_2 -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm1.@[THE_USER]_2] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test2.TC_Perm1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test2.TC_Perm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Perm2.expected b/authz-test/TestSuite/expected/TC_Perm2.expected deleted file mode 100644 index dadff03b..00000000 --- a/authz-test/TestSuite/expected/TC_Perm2.expected +++ /dev/null @@ -1,554 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Perm2.10.0.POS Print NS to prove ok -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Perm2.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_Perm2.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -as testid@aaf.att.com -# TC_Perm2.20.1.POS List Data on non-Empty NS -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm2.@[THE_USER].admin - com.test.TC_Perm2.@[THE_USER].owner - Permissions - com.test.TC_Perm2.@[THE_USER].access * * - com.test.TC_Perm2.@[THE_USER].access * read - -# TC_Perm2.20.10.POS Add Perms with specific Instance and Action -perm create com.test.TC_Perm2.@[user.name].p.A myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm2.20.11.POS Add Perms with specific Instance and Star -perm create com.test.TC_Perm2.@[user.name].p.A myInstance * -** Expect 201 ** -Created Permission - -# TC_Perm2.20.12.POS Add Perms with Stars for Instance and Action -perm create com.test.TC_Perm2.@[user.name].p.A * * -** Expect 201 ** -Created Permission - -perm create com.test.TC_Perm2.@[user.name].p.phoneCalls * spy -** Expect 201 ** -Created Permission - -# TC_Perm2.20.20.POS Create role -role create com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Created Role - -role create com.test.TC_Perm2.@[user.name].p.secret -** Expect 201 ** -Created Role - -# TC_Perm2.20.21.POS Grant sub-NS perms to role -perm grant com.test.TC_Perm2.@[user.name].p.A myInstance myAction com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Granted Permission [com.test.TC_Perm2.@[THE_USER].p.A|myInstance|myAction] to Role [com.test.TC_Perm2.@[THE_USER].p.superUser] - -perm grant com.test.TC_Perm2.@[user.name].p.A myInstance * com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Granted Permission [com.test.TC_Perm2.@[THE_USER].p.A|myInstance|*] to Role [com.test.TC_Perm2.@[THE_USER].p.superUser] - -perm grant com.test.TC_Perm2.@[user.name].p.A * * com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Granted Permission [com.test.TC_Perm2.@[THE_USER].p.A|*|*] to Role [com.test.TC_Perm2.@[THE_USER].p.superUser] - -perm grant com.test.TC_Perm2.@[user.name].p.phoneCalls * spy com.test.TC_Perm2.@[user.name].p.secret -** Expect 201 ** -Granted Permission [com.test.TC_Perm2.@[THE_USER].p.phoneCalls|*|spy] to Role [com.test.TC_Perm2.@[THE_USER].p.secret] - -# TC_Perm2.20.30.POS List Data on non-Empty NS -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm2.@[THE_USER].admin - com.test.TC_Perm2.@[THE_USER].owner - com.test.TC_Perm2.@[THE_USER].p.secret - com.test.TC_Perm2.@[THE_USER].p.superUser - Permissions - com.test.TC_Perm2.@[THE_USER].access * * - com.test.TC_Perm2.@[THE_USER].access * read - com.test.TC_Perm2.@[THE_USER].p.A * * - com.test.TC_Perm2.@[THE_USER].p.A myInstance * - com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm2.@[THE_USER].p.phoneCalls * spy - -# TC_Perm2.20.40.POS Create role -role create com.test.TC_Perm2.@[user.name].p.watcher -** Expect 201 ** -Created Role - -as XX@NS -# TC_Perm2.20.50.POS Grant view perms to watcher role -perm create com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:myInstance:myAction view com.test.TC_Perm2.@[user.name].p.watcher -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.perm|:com.test.TC_Perm2.@[THE_USER].p.A:myInstance:myAction|view] to Role [com.test.TC_Perm2.@[THE_USER].p.watcher] - -perm create com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view com.test.TC_Perm2.@[user.name].p.watcher -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.perm|:com.test.TC_Perm2.@[THE_USER].p.A:*:*|view] to Role [com.test.TC_Perm2.@[THE_USER].p.watcher] - -as testid@aaf.att.com -# TC_Perm2.30.1.POS List Data on non-Empty NS -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm2.@[THE_USER].admin - com.test.TC_Perm2.@[THE_USER].owner - com.test.TC_Perm2.@[THE_USER].p.secret - com.test.TC_Perm2.@[THE_USER].p.superUser - com.test.TC_Perm2.@[THE_USER].p.watcher - Permissions - com.test.TC_Perm2.@[THE_USER].access * * - com.test.TC_Perm2.@[THE_USER].access * read - com.test.TC_Perm2.@[THE_USER].p.A * * - com.test.TC_Perm2.@[THE_USER].p.A myInstance * - com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm2.@[THE_USER].p.phoneCalls * spy - -# TC_Perm2.30.2.POS Create Sub-ns when Roles that exist -ns create com.test.TC_Perm2.@[user.name].p @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Perm2.30.3.POS List Data on NS with sub-roles -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm2.@[THE_USER].admin - com.test.TC_Perm2.@[THE_USER].owner - Permissions - com.test.TC_Perm2.@[THE_USER].access * * - com.test.TC_Perm2.@[THE_USER].access * read - -ns list name com.test.TC_Perm2.@[user.name].p -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER].p] --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Perm2.@[THE_USER].p.admin - com.test.TC_Perm2.@[THE_USER].p.owner - com.test.TC_Perm2.@[THE_USER].p.secret - com.test.TC_Perm2.@[THE_USER].p.superUser - com.test.TC_Perm2.@[THE_USER].p.watcher - Permissions - com.test.TC_Perm2.@[THE_USER].p.A * * - com.test.TC_Perm2.@[THE_USER].p.A myInstance * - com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - com.test.TC_Perm2.@[THE_USER].p.access * * - com.test.TC_Perm2.@[THE_USER].p.access * read - com.test.TC_Perm2.@[THE_USER].p.phoneCalls * spy - -as testunused@aaf.att.com -# TC_Perm2.40.1.NEG Non-admin, not granted user should not view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -as testid@aaf.att.com -# Tens test user granted to permission -# TC_Perm2.40.10.POS Add user to superUser role -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Added Role [com.test.TC_Perm2.@[THE_USER].p.superUser] to User [testunused@aaf.att.com] - -as testunused@aaf.att.com -# TC_Perm2.40.11.POS Non-admin, granted user should view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A * * -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -as testid@aaf.att.com -# TC_Perm2.40.12.POS Ungrant perm with wildcards -perm ungrant com.test.TC_Perm2.@[user.name].p.A * * com.test.TC_Perm2.@[user.name].p.superUser -** Expect 200 ** -UnGranted Permission [com.test.TC_Perm2.@[THE_USER].p.A|*|*] from Role [com.test.TC_Perm2.@[THE_USER].p.superUser] - -as testunused@aaf.att.com -# TC_Perm2.40.13.POS Non-admin, granted user should view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -as testid@aaf.att.com -# TC_Perm2.40.19.POS Remove user from superUser role -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -** Expect 200 ** -Removed Role [com.test.TC_Perm2.@[THE_USER].p.superUser] from User [testunused@aaf.att.com] - -# Twenties test user granted explicit view permission -# TC_Perm2.40.20.POS Add user to watcher role -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -** Expect 201 ** -Added Role [com.test.TC_Perm2.@[THE_USER].p.watcher] to User [testunused@aaf.att.com] - -as testunused@aaf.att.com -# TC_Perm2.40.21.NEG Non-admin, granted explicit view perm user should view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -as XX@NS -# TC_Perm2.40.22.POS Ungrant perm with wildcards -perm ungrant com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view com.test.TC_Perm2.@[user.name].p.watcher -** Expect 200 ** -UnGranted Permission [com.att.aaf.perm|:com.test.TC_Perm2.@[THE_USER].p.A:*:*|view] from Role [com.test.TC_Perm2.@[THE_USER].p.watcher] - -as testunused@aaf.att.com -# TC_Perm2.40.23.POS Non-admin, granted user should view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -as testid@aaf.att.com -# TC_Perm2.40.29.POS Remove user from watcher role -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -** Expect 200 ** -Removed Role [com.test.TC_Perm2.@[THE_USER].p.watcher] from User [testunused@aaf.att.com] - -# Thirties test admin user -# TC_Perm2.40.30.POS Admin should be able to view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A * * -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -# TC_Perm2.40.31.POS Add new admin for sub-NS -ns admin add com.test.TC_Perm2.@[user.name].p testunused@aaf.att.com -** Expect 201 ** -Admin testunused@aaf.att.com added to com.test.TC_Perm2.@[THE_USER].p - -# TC_Perm2.40.32.POS Remove admin from sub-NS -ns admin del com.test.TC_Perm2.@[user.name].p testid@aaf.att.com -** Expect 200 ** -Admin testid@aaf.att.com deleted from com.test.TC_Perm2.@[THE_USER].p - -# TC_Perm2.40.34.POS Admin of parent NS should be able to view -perm list name com.test.TC_Perm2.@[user.name].p.A -** Expect 200 ** - -List Child Permissions[com.test.TC_Perm2.@[THE_USER].p.A] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A * * -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -# TC_Perm2.40.80.POS Add new admin for sub-NS -ns admin add com.test.TC_Perm2.@[user.name].p testid@aaf.att.com -** Expect 201 ** -Admin testid@aaf.att.com added to com.test.TC_Perm2.@[THE_USER].p - -# TC_Perm2.40.81.POS Remove admin from sub-NS -ns admin del com.test.TC_Perm2.@[user.name].p testunused@aaf.att.com -** Expect 200 ** -Admin testunused@aaf.att.com deleted from com.test.TC_Perm2.@[THE_USER].p - -# TC_Perm2.41.1.POS Add user to some roles with perms attached -as testid@aaf.att.com -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -** Expect 201 ** -Added Role [com.test.TC_Perm2.@[THE_USER].p.superUser] to User [testunused@aaf.att.com] - -user role add testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -** Expect 201 ** -Added Role [com.test.TC_Perm2.@[THE_USER].p.watcher] to User [testunused@aaf.att.com] - -user role add XX@NS com.test.TC_Perm2.@[user.name].p.secret -** Expect 201 ** -Added Role [com.test.TC_Perm2.@[THE_USER].p.secret] to User [XX@NS] - -# TC_Perm2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -perm list user testunused@aaf.att.com -** Expect 200 ** - -List Permissions by User[testunused@aaf.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.aaf.perm :com.test.TC_Perm2.@[THE_USER].p.A:myInstance:myAction view -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -# TC_NS2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -perm list user testunused@aaf.att.com -** Expect 200 ** - -List Permissions by User[testunused@aaf.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -# TC_Perm2.41.20.POS List by User when not same as Caller, but parent owner/admin of Namespace -as XX@NS -perm list user testunused@aaf.att.com -** Expect 200 ** - -List Permissions by User[testunused@aaf.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.aaf.perm :com.test.TC_Perm2.@[THE_USER].p.A:myInstance:myAction view -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -# TC_Perm2.41.80.NEG List by User when not Caller nor associated to Namespace (nothing should be shown) -as testunused@aaf.att.com -perm list user XX@NS -** Expect 200 ** - -List Permissions by User[XX@NS] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -# TC_Perm2.41.99.POS Remove users from roles for later test -as testid@aaf.att.com -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.superUser -** Expect 200 ** -Removed Role [com.test.TC_Perm2.@[THE_USER].p.superUser] from User [testunused@aaf.att.com] - -user role del testunused@aaf.att.com com.test.TC_Perm2.@[user.name].p.watcher -** Expect 200 ** -Removed Role [com.test.TC_Perm2.@[THE_USER].p.watcher] from User [testunused@aaf.att.com] - -user role del XX@NS com.test.TC_Perm2.@[user.name].p.secret -** Expect 200 ** -Removed Role [com.test.TC_Perm2.@[THE_USER].p.secret] from User [XX@NS] - -# TC_Perm2.42.10.POS List Roles from NS when not allowed to see NS -as testid@aaf.att.com -perm list ns com.test.TC_Perm2.@[user.name].p -** Expect 200 ** - -List Perms by NS [com.test.TC_Perm2.@[THE_USER].p] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A * * -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction -com.test.TC_Perm2.@[THE_USER].p.access * * -com.test.TC_Perm2.@[THE_USER].p.access * read -com.test.TC_Perm2.@[THE_USER].p.phoneCalls * spy - - -# TC_Perm2.42.20.NEG Don't List Roles from NS when not allowed to see NS -as testunused@aaf.att.com -perm list ns com.test.TC_Perm2.@[user.name].p -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read in NS [com.test.TC_Perm2.@[THE_USER].p] - -# TC_Perm2.43.10.POS List perms when allowed to see Role -as testid@aaf.att.com -perm list role com.test.TC_Perm2.@[user.name].p.superUser -** Expect 200 ** - -List Perms by Role [com.test.TC_Perm2.@[THE_USER].p.superUser] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.A myInstance * -com.test.TC_Perm2.@[THE_USER].p.A myInstance myAction - - -perm list role com.test.TC_Perm2.@[user.name].p.watcher -** Expect 200 ** - -List Perms by Role [com.test.TC_Perm2.@[THE_USER].p.watcher] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- - - -perm list role com.test.TC_Perm2.@[user.name].p.secret -** Expect 200 ** - -List Perms by Role [com.test.TC_Perm2.@[THE_USER].p.secret] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Perm2.@[THE_USER].p.phoneCalls * spy - - -# TC_Perm2.43.20.NEG Don't List perms when not allowed to see Role -as testunused@aaf.att.com -perm list role com.test.TC_Perm2.@[user.name].p.superUser -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Perm2.@[THE_USER].p.superUser] - -perm list role com.test.TC_Perm2.@[user.name].p.watcher -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Perm2.@[THE_USER].p.watcher] - -perm list role com.test.TC_Perm2.@[user.name].p.secret -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Perm2.@[THE_USER].p.secret] - -as testid@aaf.att.com -# TC_Perm2.99.1.POS Namespace Admin can delete Namepace defined Roles -force perm delete com.test.TC_Perm2.@[user.name].p.A myInstance myAction -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Perm2.@[user.name].p.A myInstance * -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Perm2.@[user.name].p.A * * -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Perm2.@[user.name].p.phoneCalls * spy -** Expect 200,404 ** -Deleted Permission - -force role delete com.test.TC_Perm2.@[user.name].p.watcher -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Perm2.@[user.name].p.superUser -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Perm2.@[user.name].p.secret -** Expect 200,404 ** -Deleted Role - -as XX@NS -force perm delete com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:*:* view -** Expect 200,404 ** -Deleted Permission - -force perm delete com.att.aaf.perm :com.test.TC_Perm2.@[user.name].p.A:myInstance:myAction view -** Expect 200,404 ** -Deleted Permission - -# TC_Perm2.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Perm2.@[user.name].p -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test.TC_Perm2.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Perm2.99.3.POS Print Namespaces -ns list name com.test.TC_Perm2.@[user.name].p -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER].p] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Perm2.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Perm3.expected b/authz-test/TestSuite/expected/TC_Perm3.expected deleted file mode 100644 index 6cdf2297..00000000 --- a/authz-test/TestSuite/expected/TC_Perm3.expected +++ /dev/null @@ -1,136 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set testid_1@test.com <pass> -set testid_2@test.com <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as XX@NS -# TC_Perm3.10.0.POS Print NS to prove ok -ns list name com.test.TC_Perm3.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Perm3.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Perm3.10.1.POS Create Namespace with User ID -ns create com.test.TC_Perm3.@[user.name]_1 @[user.name] testid_1@test.com -** Expect 201 ** -Created Namespace - -# TC_Perm3.10.2.POS Create Namespace with Different ID -ns create com.test.TC_Perm3.@[user.name]_2 @[user.name] testid_2@test.com -** Expect 201 ** -Created Namespace - -# TC_Perm3.10.3.POS Create Namespace in Different Company -ns create com.att.TC_Perm3.@[user.name] @[user.name] testunused@aaf.att.com -** Expect 201 ** -Created Namespace - -as testid_1@test.com -# TC_Perm3.20.0.POS User1 Create a Perm -perm create com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm3.20.5.NEG User1 should not be able to create Role in other group -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_a -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid_1@test.com] may not write Role [com.test.TC_Perm3.@[THE_USER]_2.dev.myRole_a] - -# TC_Perm3.20.6.POS User2 should be able to create Role in own group -as testid_2@test.com -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_a -** Expect 201 ** -Created Role - -# TC_Perm3.20.7.NEG User2 should not be able to grant Perm to own Role -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid_2@test.com] may not write Perm [com.test.TC_Perm3.@[THE_USER]_1.dev.myPerm_a|myInstance|myAction] - -# TC_Perm3.20.8.NEG User2 cannot create Role in NS 2 -as testid_2@test.com -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid_2@test.com] may not write Perm [com.test.TC_Perm3.@[THE_USER]_1.dev.myPerm_a|myInstance|myAction] - -# TC_Perm3.20.9.POS Role created, but can't grant... has to be testid_1 -as testid_1@test.com -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_a myInstance myAction com.test.TC_Perm3.@[user.name]_2.dev.myRole_a -** Expect 201 ** -Granted Permission [com.test.TC_Perm3.@[THE_USER]_1.dev.myPerm_a|myInstance|myAction] to Role [com.test.TC_Perm3.@[THE_USER]_2.dev.myRole_a] - -# TC_Perm3.30.0.POS User1 Create a Perm -as testid_1@test.com -perm create com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Perm3.30.5.NEG User1 should not be able to create Role in other group -role create com.test.TC_Perm3.@[user.name]_2.dev.myRole_b -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid_1@test.com] may not write Role [com.test.TC_Perm3.@[THE_USER]_2.dev.myRole_b] - -# TC_Perm3.30.6.POS User2 should be able to create Role in own group -as testunused@aaf.att.com -role create com.att.TC_Perm3.@[user.name].dev.myRole_b -** Expect 201 ** -Created Role - -# TC_Perm3.30.7.NEG User2 should not be able to grant Perm to own Role -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction com.att.TC_Perm3.@[user.name].dev.myRole_b -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not write Perm [com.test.TC_Perm3.@[THE_USER]_1.dev.myPerm_b|myInstance|myAction] - -# TC_Perm3.30.8.POS User should be able to grant cross company only Double Perm -as testid_1@test.com -perm grant com.test.TC_Perm3.@[user.name]_1.dev.myPerm_b myInstance myAction com.att.TC_Perm3.@[user.name].dev.myRole_b -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testid_1@test.com] may not write Role [com.att.TC_Perm3.@[THE_USER].dev.myRole_b] - -as testid_1@test.com -# TC_Perm3.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Perm3.@[user.name]_1 -** Expect 200,404 ** -Deleted Namespace - -# TC_Perm3.99.3.POS Print Namespaces -ns list name com.test.TC_Perm3.@[user.name]_1 -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm3.@[THE_USER]_1] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -as testid_2@test.com -# TC_Perm3.99.4.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Perm3.@[user.name]_2 -** Expect 200,404 ** -Deleted Namespace - -# TC_Perm3.99.5.POS Print Namespaces -ns list name com.test.TC_Perm3.@[user.name]_2 -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Perm3.@[THE_USER]_2] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -as testunused@aaf.att.com -# TC_Perm3.99.6.POS Remove Namespace from other company -force ns delete com.att.TC_Perm3.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Perm3.99.7.POS Print Namespace from other company -ns list name com.att.TC_Perm3.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.att.TC_Perm3.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Realm1.expected b/authz-test/TestSuite/expected/TC_Realm1.expected deleted file mode 100644 index 67232e2a..00000000 --- a/authz-test/TestSuite/expected/TC_Realm1.expected +++ /dev/null @@ -1,210 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Realm1.10.0.POS Validate no NS -ns list name com.test.TC_Realm1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Realm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Realm1.10.1.POS Create Namespace to add IDs -ns create com.test.TC_Realm1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -as XX@NS -# TC_Realm1.10.10.POS Grant ability to change delegates -force perm create com.att.aaf.delg com.att create com.test.TC_Realm1.@[user.name].change_delg -** Expect 201 ** -Created Role [com.test.TC_Realm1.@[THE_USER].change_delg] -Created Permission -Granted Permission [com.att.aaf.delg|com.att|create] to Role [com.test.TC_Realm1.@[THE_USER].change_delg] - -# TC_Realm1.10.11.POS Create user role to change delegates -user role add testid@aaf.att.com com.test.TC_Realm1.@[user.name].change_delg -** Expect 201 ** -Added Role [com.test.TC_Realm1.@[THE_USER].change_delg] to User [testid@aaf.att.com] - -as testid@aaf.att.com -# TC_Realm1.20.1.NEG Fail to create - default domain wrong -ns create com.test.TC_Realm1.@[user.name].project1 testunused -** Expect 403 ** -Failed [SVC3403]: Forbidden - testunused@csp.att.com does not have permission to assume test status at AT&T - -# TC_Realm1.20.2.POS Create - default domain appended -ns create com.test.TC_Realm1.@[user.name].project1 @[user.name] @[user.name] -** Expect 201 ** -Created Namespace - -# TC_Realm1.20.3.NEG Fail to create - default domain wrong -ns admin add com.test.TC_Realm1.@[user.name].project1 testunused -** Expect 403 ** -Failed [SVC1403]: Forbidden - AT&T reports that testunused@csp.att.com is a faulty ID - -# TC_Realm1.20.4.POS Create - full domain given -ns admin add com.test.TC_Realm1.@[user.name].project1 testid@aaf.att.com -** Expect 201 ** -Admin testid@aaf.att.com added to com.test.TC_Realm1.@[THE_USER].project1 - -# TC_Realm1.20.5.POS Delete - default domain appended -ns admin del com.test.TC_Realm1.@[user.name].project1 @[user.name] -** Expect 200 ** -Admin @[THE_USER]@csp.att.com deleted from com.test.TC_Realm1.@[THE_USER].project1 - -# TC_Realm1.20.6.POS Add admin - default domain appended -ns admin add com.test.TC_Realm1.@[user.name].project1 @[user.name] -** Expect 201 ** -Admin @[THE_USER]@csp.att.com added to com.test.TC_Realm1.@[THE_USER].project1 - -# TC_Realm1.30.1.POS Create role to add to users -role create com.test.TC_Realm1.@[user.name].role1 -** Expect 201 ** -Created Role - -# TC_Realm1.30.2.NEG Add user, but default domain wrong -role user add com.test.TC_Realm1.@[user.name].role1 testunused -** Expect 403 ** -Failed [SVC1403]: Forbidden - AT&T reports that testunused@csp.att.com is a faulty ID - -# TC_Realm1.30.3.POS Add user, with default domain appended -role user add com.test.TC_Realm1.@[user.name].role1 @[user.name] -** Expect 201 ** -Added User [@[THE_USER]@csp.att.com] to Role [com.test.TC_Realm1.@[THE_USER].role1] - -# TC_Realm1.30.10.POS Role list, with default domain added -role list user testunused -** Expect 200 ** - -List Roles for User [testunused@csp.att.com] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- - -# TC_Realm1.30.80.POS Delete user, with default domain appended -role user del com.test.TC_Realm1.@[user.name].role1 @[user.name] -** Expect 200 ** -Removed User [@[THE_USER]@csp.att.com] from Role [com.test.TC_Realm1.@[THE_USER].role1] - -# TC_Realm1.40.1.POS Create role to add to users -role create com.test.TC_Realm1.@[user.name].role2 -** Expect 201 ** -Created Role - -# TC_Realm1.40.2.NEG Add user, but default domain wrong -user role add testunused com.test.TC_Realm1.@[user.name].role2 -** Expect 403 ** -Failed [SVC1403]: Forbidden - AT&T reports that testunused@csp.att.com is a faulty ID - -# TC_Realm1.40.3.POS Add user, with default domain appended -user role add @[user.name] com.test.TC_Realm1.@[user.name].role2 -** Expect 201 ** -Added Role [com.test.TC_Realm1.@[THE_USER].role2] to User [@[THE_USER]@csp.att.com] - -# TC_Realm1.40.10.NEG Add delegate, but default domain wrong -user delegate add testunused testid 2099-01-01 -** Expect 404 ** -Failed [SVC5404]: Not Found - [testunused@csp.att.com] is not a user in the company database. - -# TC_Realm1.40.11.POS Add delegate, with default domain appended -force user delegate add @[user.name] @[user.name] 2099-01-01 -** Expect 201 ** -Delegate Added - -# TC_Realm1.40.12.POS Update delegate, with default domain appended -user delegate upd @[user.name] @[user.name] 2099-01-01 -** Expect 200 ** -Delegate Updated - -as XX@NS -# TC_Realm1.40.20.POS List delegate, with default domain appended -user list delegates user @[user.name] -** Expect 200 ** - -List Delegates by user[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -# TC_Realm1.40.21.POS List delegate, with default domain appended -user list delegates delegate @[user.name] -** Expect 200 ** - -List Delegates by delegate[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -as testid@aaf.att.com -# TC_Realm1.40.80.POS Delete user, with default domain appended -user role del @[user.name] com.test.TC_Realm1.@[user.name].role2 -** Expect 200 ** -Removed Role [com.test.TC_Realm1.@[THE_USER].role2] from User [@[THE_USER]@csp.att.com] - -# TC_Realm1.40.81.POS Delete delegate, with default domain appended -user delegate del @[user.name] -** Expect 200 ** -Delegate Deleted - -as testid@aaf.att.com -# TC_Realm1.99.1.POS Delete delgates -user delegate del @[user.name] -** Expect 200,404 ** -Failed [SVC7404]: Not Found - Cannot delete non-existent Delegate - -# TC_Realm1.99.2.POS Delete user roles -role user del com.test.TC_Realm1.@[user.name].role1 @[user.name] -** Expect 200,404 ** -Failed [SVC6404]: Not Found - User [ @[THE_USER]@csp.att.com ] is not Assigned to the Role [ com.test.TC_Realm1.@[THE_USER].role1 ] - -user role del @[user.name] com.test.TC_Realm1.@[user.name].role2 -** Expect 200,404 ** -Failed [SVC6404]: Not Found - User [ @[THE_USER]@csp.att.com ] is not Assigned to the Role [ com.test.TC_Realm1.@[THE_USER].role2 ] - -# TC_Realm1.99.3.POS Delete roles -role delete com.test.TC_Realm1.@[user.name].role1 -** Expect 200,404 ** -Deleted Role - -role delete com.test.TC_Realm1.@[user.name].role2 -** Expect 200,404 ** -Deleted Role - -as XX@NS -# TC_Realm1.99.10.POS UnGrant ability to change delegates -perm ungrant com.att.aaf.delg com.att change com.test.TC_Realm1.@[user.name].change_delg -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.att.aaf.delg|com.att|change] not associated with any Role - -as testid@aaf.att.com -# TC_Realm1.99.11.POS Delete role to change delegates -set force true -set force=true role delete com.test.TC_Realm1.@[user.name].change_delg -** Expect 200,404 ** -Deleted Role - -# TC_Realm1.99.98.POS Delete Namespaces -ns delete com.test.TC_Realm1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -ns delete com.test.TC_Realm1.@[user.name].project1 -** Expect 200,404 ** -Deleted Namespace - -# TC_Realm1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_Realm1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Realm1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Role1.expected b/authz-test/TestSuite/expected/TC_Role1.expected deleted file mode 100644 index 5cb610fb..00000000 --- a/authz-test/TestSuite/expected/TC_Role1.expected +++ /dev/null @@ -1,369 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Role1.10.0.POS Validate NS ok -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Role1.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_Role1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Role1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_Role1.@[user.name].cred_admin -** Expect 201 ** -Created Role - -as XX@NS -# TC_Role1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_Role1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_Role1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_Role1.10.12.POS Assign user for creating creds -user role add testid@aaf.att.com com.test.TC_Role1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_Role1.@[THE_USER].cred_admin] to User [testid@aaf.att.com] - -# TC_Role1.20.1.POS List Data on non-Empty NS -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].admin - com.test.TC_Role1.@[THE_USER].cred_admin - com.test.TC_Role1.@[THE_USER].owner - Permissions - com.test.TC_Role1.@[THE_USER].access * * - com.test.TC_Role1.@[THE_USER].access * read - -# TC_Role1.20.2.POS Add Roles -role create com.test.TC_Role1.@[user.name].r.A -** Expect 201 ** -Created Role - -role create com.test.TC_Role1.@[user.name].r.B -** Expect 201 ** -Created Role - -# TC_Role1.20.3.POS List Data on non-Empty NS -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].admin - com.test.TC_Role1.@[THE_USER].cred_admin - com.test.TC_Role1.@[THE_USER].owner - com.test.TC_Role1.@[THE_USER].r.A - com.test.TC_Role1.@[THE_USER].r.B - Permissions - com.test.TC_Role1.@[THE_USER].access * * - com.test.TC_Role1.@[THE_USER].access * read - -# TC_Role1.20.4.NEG Don't write over Role -role create com.test.TC_Role1.@[user.name].r.A -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - Role [com.test.TC_Role1.@[THE_USER].r.A] already exists - -# TC_Role1.20.5.NEG Don't allow non-user to create -as bogus -role create com.test.TC_Role1.@[user.name].r.No -** Expect 401 ** -Failed with code 401, Unauthorized - -# TC_Role1.20.6.NEG Don't allow non-user to create without Approval -as testunused@aaf.att.com -role create com.test.TC_Role1.@[user.name].r.No -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not write Role [com.test.TC_Role1.@[THE_USER].r.No] - -# TC_Role1.20.10.NEG Non-admins can't change description -as testunused@aaf.att.com -role describe com.test.TC_Role1.@[user.name].r.A Description A -** Expect 403 ** -Failed [SVC1403]: Forbidden - You do not have approval to change com.test.TC_Role1.@[THE_USER].r.A - -# TC_Role1.20.11.NEG Role must exist to change description -as testid@aaf.att.com -role describe com.test.TC_Role1.@[user.name].r.C Description C -** Expect 404 ** -Failed [SVC1404]: Not Found - Role [com.test.TC_Role1.@[THE_USER].r.C] does not exist - -# TC_Role1.20.12.POS Admin can change description -role describe com.test.TC_Role1.@[user.name].r.A Description A -** Expect 200 ** -Description added to role - -# TC_Role1.30.1.POS List Data on non-Empty NS -as testid@aaf.att.com -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].admin - com.test.TC_Role1.@[THE_USER].cred_admin - com.test.TC_Role1.@[THE_USER].owner - com.test.TC_Role1.@[THE_USER].r.A - com.test.TC_Role1.@[THE_USER].r.B - Permissions - com.test.TC_Role1.@[THE_USER].access * * - com.test.TC_Role1.@[THE_USER].access * read - -# TC_Role1.30.2.POS Create Sub-ns when Roles that exist -ns create com.test.TC_Role1.@[user.name].r @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Role1.30.3.POS List Data on NS with sub-roles -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].admin - com.test.TC_Role1.@[THE_USER].cred_admin - com.test.TC_Role1.@[THE_USER].owner - Permissions - com.test.TC_Role1.@[THE_USER].access * * - com.test.TC_Role1.@[THE_USER].access * read - -ns list name com.test.TC_Role1.@[user.name].r -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER].r] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER].r - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].r.A - com.test.TC_Role1.@[THE_USER].r.B - com.test.TC_Role1.@[THE_USER].r.admin - com.test.TC_Role1.@[THE_USER].r.owner - Permissions - com.test.TC_Role1.@[THE_USER].r.access * * - com.test.TC_Role1.@[THE_USER].r.access * read - -# TC_Role1.40.01.POS List Data on non-Empty NS -role list role com.test.TC_Role1.@[user.name].r.A -** Expect 200 ** - -List Roles for Role[com.test.TC_Role1.@[THE_USER].r.A] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER].r.A - -# TC_Role1.40.20.POS Create a Perm, and add to Role -perm create com.test.TC_Role1.@[user.name].samplePerm1 some.long(involved).text SELECT com.test.TC_Role1.@[user.name].r.A -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role1.@[THE_USER].samplePerm1|some.long(involved).text|SELECT] to Role [com.test.TC_Role1.@[THE_USER].r.A] - -# TC_Role1.40.25.POS List -role list role com.test.TC_Role1.@[user.name].r.A -** Expect 200 ** - -List Roles for Role[com.test.TC_Role1.@[THE_USER].r.A] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER].r.A - com.test.TC_Role1.@[THE_USER].samplePerm1 some.long(involved).text SELECT - -# TC_Role1.40.30.POS Create a Perm -perm create com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case -** Expect 201 ** -Created Permission - -# TC_Role1.40.32.POS Separately Grant Perm -perm grant com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case com.test.TC_Role1.@[user.name].r.A -** Expect 201 ** -Granted Permission [com.test.TC_Role1.@[THE_USER].samplePerm1|some.other_long(less.involved).text|lower_case] to Role [com.test.TC_Role1.@[THE_USER].r.A] - -# TC_Role1.40.35.POS List -role list role com.test.TC_Role1.@[user.name].r.A -** Expect 200 ** - -List Roles for Role[com.test.TC_Role1.@[THE_USER].r.A] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER].r.A - com.test.TC_Role1.@[THE_USER].samplePerm1 some.long(involved).text SELECT - com.test.TC_Role1.@[THE_USER].samplePerm1 some.other_long(less.involved).text lower_case - -# TC_Role1.50.1.POS Create user to attach to role -user cred add m00001@@[user.name].TC_Role1.test.com password123 -** Expect 201 ** -Added Credential [m00001@@[THE_USER].TC_Role1.test.com] - -# TC_Role1.50.2.POS Create new role -role create com.test.TC_Role1.@[user.name].r.C -** Expect 201 ** -Created Role - -# TC_Role1.50.3.POS Attach user to role -user role add m00001@@[user.name].TC_Role1.test.com com.test.TC_Role1.@[user.name].r.C -** Expect 201 ** -Added Role [com.test.TC_Role1.@[THE_USER].r.C] to User [m00001@@[THE_USER].TC_Role1.test.com] - -# TC_Role1.50.4.POS Create permission and attach to role -perm create com.test.TC_Role1.@[user.name].p.C myInstance myAction com.test.TC_Role1.@[user.name].r.C -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role1.@[THE_USER].p.C|myInstance|myAction] to Role [com.test.TC_Role1.@[THE_USER].r.C] - -# TC_Role1.50.20.NEG Delete role with permission and user attached should fail -role delete com.test.TC_Role1.@[user.name].r.C -** Expect 424 ** -Failed [SVC1424]: Failed Dependency - Role [com.test.TC_Role1.@[THE_USER].r.C] cannot be deleted as it is used by 1 or more Users. - -# TC_Role1.50.21.POS Force delete role should work -set force true -set force=true role delete com.test.TC_Role1.@[user.name].r.C -** Expect 200 ** -Deleted Role - -# TC_Role1.50.30.POS List Data on non-Empty NS -ns list name com.test.TC_Role1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role1.@[THE_USER].admin - com.test.TC_Role1.@[THE_USER].cred_admin - com.test.TC_Role1.@[THE_USER].owner - Permissions - com.test.TC_Role1.@[THE_USER].access * * - com.test.TC_Role1.@[THE_USER].access * read - com.test.TC_Role1.@[THE_USER].p.C myInstance myAction - com.test.TC_Role1.@[THE_USER].samplePerm1 some.long(involved).text SELECT - com.test.TC_Role1.@[THE_USER].samplePerm1 some.other_long(less.involved).text lower_case - Credentials - m00001@@[THE_USER].TC_Role1.test.com - -# Need to let DB catch up on deletes -sleep 0 -as testid@aaf.att.com -# TC_Role1.99.05.POS Remove Permissions from "40_reports" -set force true -set force=true perm delete com.test.TC_Role1.@[user.name].samplePerm1 some.long(involved).text SELECT -** Expect 200,404 ** -Deleted Permission - -set force true -set force=true perm delete com.test.TC_Role1.@[user.name].samplePerm1 some.other_long(less.involved).text lower_case -** Expect 200,404 ** -Deleted Permission - -# TC_Role1.99.10.POS Namespace Admin can delete Namepace defined Roles -force role delete com.test.TC_Role1.@[user.name].r.A -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Role1.@[user.name].r.B -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Role1.@[user.name].r.C -** Expect 200,404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_Role1.@[THE_USER].r.C] does not exist - -# TC_Role1.99.15.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_Role1.@[user.name].cred_admin -** Expect 200,404 ** -Removed Role [com.test.TC_Role1.@[THE_USER].cred_admin] from User [testid@aaf.att.com] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_Role1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_Role1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -role delete com.test.TC_Role1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_Role1.99.20.POS Namespace Admin can delete permissions and credentials -perm delete com.test.TC_Role1.@[user.name].p.C myInstance myAction -** Expect 200,404 ** -Deleted Permission - -set force true -user cred del m00001@@[user.name].TC_Role1.test.com -** Expect 200,404 ** -Deleted Credential [m00001@@[THE_USER].TC_Role1.test.com] - -# TC_Role1.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Role1.@[user.name].r -** Expect 200,404 ** -Deleted Namespace - -force ns delete com.test.TC_Role1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Role1.99.99.POS List to prove clean Namespaces -ns list name com.test.TC_Role1.@[user.name].r -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER].r] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Role1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Role1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Role2.expected b/authz-test/TestSuite/expected/TC_Role2.expected deleted file mode 100644 index 45abf9fd..00000000 --- a/authz-test/TestSuite/expected/TC_Role2.expected +++ /dev/null @@ -1,447 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_Role2.10.0.POS Print NS to prove ok -ns list name com.test.TC_Role2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Role2.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_Role2.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -############## -# Testing Model -# We are making a Testing model based loosely on George Orwell's Animal Farm -# In Animal Farm, Animals did all the work but didn't get any priviledges. -# In our test, the animals can't see anything but their own role, etc -# Dogs were supervisors, and ostensibly did something, though mostly laid around -# In our test, they have Implicit Permissions by being Admins -# Pigs were the Elite. They did nothing, but watch everyone and eat the produce -# In our test, they have Explicit Permissions to see everything they want -############## -as testid@aaf.att.com -# TC_Role2.20.1.POS List Data on non-Empty NS -ns list name com.test.TC_Role2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role2.@[THE_USER].admin - com.test.TC_Role2.@[THE_USER].owner - Permissions - com.test.TC_Role2.@[THE_USER].access * * - com.test.TC_Role2.@[THE_USER].access * read - -# TC_Role2.20.10.POS Create Orwellian Roles -role create com.test.TC_Role2.@[user.name].r.animals -** Expect 201 ** -Created Role - -role create com.test.TC_Role2.@[user.name].r.dogs -** Expect 201 ** -Created Role - -role create com.test.TC_Role2.@[user.name].r.pigs -** Expect 201 ** -Created Role - -# TC_Role2.20.20.POS Create and Grant Perms to Dog Roles -perm create com.test.TC_Role2.@[user.name].r.A garbage eat com.test.TC_Role2.@[user.name].r.animals -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role2.@[THE_USER].r.A|garbage|eat] to Role [com.test.TC_Role2.@[THE_USER].r.animals] - -perm create com.test.TC_Role2.@[user.name].r.A grain eat com.test.TC_Role2.@[user.name].r.dogs -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role2.@[THE_USER].r.A|grain|eat] to Role [com.test.TC_Role2.@[THE_USER].r.dogs] - -perm create com.test.TC_Role2.@[user.name].r.A grain * com.test.TC_Role2.@[user.name].r.dogs -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role2.@[THE_USER].r.A|grain|*] to Role [com.test.TC_Role2.@[THE_USER].r.dogs] - -perm create com.test.TC_Role2.@[user.name].r.A * * com.test.TC_Role2.@[user.name].r.dogs -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_Role2.@[THE_USER].r.A|*|*] to Role [com.test.TC_Role2.@[THE_USER].r.dogs] - -# TC_Role2.20.25.POS Create and Grant Animal Farm Priviledges to Pigs -as XX@NS -perm create com.att.aaf.role com.test.TC_Role2.@[user.name].r.animals view com.test.TC_Role2.@[user.name].r.pigs -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.role|com.test.TC_Role2.@[THE_USER].r.animals|view] to Role [com.test.TC_Role2.@[THE_USER].r.pigs] - -perm create com.att.aaf.role com.test.TC_Role2.@[user.name].r.dogs view com.test.TC_Role2.@[user.name].r.pigs -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.role|com.test.TC_Role2.@[THE_USER].r.dogs|view] to Role [com.test.TC_Role2.@[THE_USER].r.pigs] - -# TC_Role2.20.60.POS List Data on non-Empty NS -as testid@aaf.att.com -ns list name com.test.TC_Role2.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Role2.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Role2.@[THE_USER].admin - com.test.TC_Role2.@[THE_USER].owner - com.test.TC_Role2.@[THE_USER].r.animals - com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.pigs - Permissions - com.test.TC_Role2.@[THE_USER].access * * - com.test.TC_Role2.@[THE_USER].access * read - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A garbage eat - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -as XX@NS -# TC_Role2.40.1.POS List Data on Role -role list role com.test.TC_Role2.@[user.name].r.animals -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.animals] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.animals - com.test.TC_Role2.@[THE_USER].r.A garbage eat - -role list role com.test.TC_Role2.@[user.name].r.dogs -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.dogs] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -role list role com.test.TC_Role2.@[user.name].r.pigs -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.pigs] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.40.10.POS Add testunused to animals -as testid@aaf.att.com -user role add testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.animals -** Expect 201 ** -Added Role [com.test.TC_Role2.@[THE_USER].r.animals] to User [testunused@aaf.att.com] - -# TC_Role2.40.11.POS List by Name when part of role -as testunused@aaf.att.com -role list role com.test.TC_Role2.@[user.name].r.animals -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.animals] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.animals - com.test.TC_Role2.@[THE_USER].r.A garbage eat - -# TC_Role2.40.12.NEG List by Name when not part of Role -role list role com.test.TC_Role2.@[user.name].r.dogs -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Role2.@[THE_USER].r.dogs] - -role list role com.test.TC_Role2.@[user.name].r.pigs -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Role2.@[THE_USER].r.pigs] - -# TC_Role2.40.30.POS Read various Roles based on being Admin in Namespace -as testid@aaf.att.com -role list role com.test.TC_Role2.@[user.name].r.animals -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.animals] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.animals - com.test.TC_Role2.@[THE_USER].r.A garbage eat - -role list role com.test.TC_Role2.@[user.name].r.dogs -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.dogs] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -role list role com.test.TC_Role2.@[user.name].r.pigs -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.pigs] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.40.50.POS Change testunused to Pigs -as testid@aaf.att.com -user role del testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.animals -** Expect 200 ** -Removed Role [com.test.TC_Role2.@[THE_USER].r.animals] from User [testunused@aaf.att.com] - -user role add testunused@aaf.att.com com.test.TC_Role2.@[user.name].r.pigs -** Expect 201 ** -Added Role [com.test.TC_Role2.@[THE_USER].r.pigs] to User [testunused@aaf.att.com] - -# TC_Role2.40.51.POS Read various Roles based on having Explicit Permissions -as testunused@aaf.att.com -role list role com.test.TC_Role2.@[user.name].r.animals -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Role2.@[THE_USER].r.animals] - -role list role com.test.TC_Role2.@[user.name].r.dogs -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_Role2.@[THE_USER].r.dogs] - -role list role com.test.TC_Role2.@[user.name].r.pigs -** Expect 200 ** - -List Roles for Role[com.test.TC_Role2.@[THE_USER].r.pigs] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.41.10.POS List by User when Same as Caller -as testunused@aaf.att.com -role list user testunused@aaf.att.com -** Expect 200 ** - -List Roles for User [testunused@aaf.att.com] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.41.15.POS List by User when not same as Caller, but own/admin namespace of Roles -as testid@aaf.att.com -role list user testunused@aaf.att.com -** Expect 200 ** - -List Roles for User [testunused@aaf.att.com] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.41.20.POS List by User when not same as Caller, but parent owner of Namespace -as XX@NS -role list user testunused@aaf.att.com -** Expect 200 ** - -List Roles for User [testunused@aaf.att.com] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.41.80.NEG List by User when not Caller nor associated to Namespace (nothing should be shown) -as testunused@aaf.att.com -role list user XX@NS -** Expect 200 ** - -List Roles for User [XX@NS] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- - -# TC_Role2.42.10.POS List Roles from NS when not allowed to see NS -as testid@aaf.att.com -role list ns com.test.TC_Role2.@[user.name] -** Expect 200 ** - -List Roles by NS [com.test.TC_Role2.@[THE_USER]] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].admin - com.test.TC_Role2.@[THE_USER].access * * -com.test.TC_Role2.@[THE_USER].owner - com.test.TC_Role2.@[THE_USER].access * read -com.test.TC_Role2.@[THE_USER].r.animals - com.test.TC_Role2.@[THE_USER].r.A garbage eat -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat -com.test.TC_Role2.@[THE_USER].r.pigs - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.animals view - com.att.aaf.role com.test.TC_Role2.@[THE_USER].r.dogs view - -# TC_Role2.42.20.NEG Don't List Roles from NS when not allowed to see NS -as testunused@aaf.att.com -role list ns com.test.TC_Role2.@[user.name] -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read in NS [com.test.TC_Role2.@[THE_USER]] - -# TC_Role2.43.10.POS List Roles when allowed to see Perm -as testid@aaf.att.com -role list perm com.test.TC_Role2.@[user.name].r.A grain eat -** Expect 200 ** - -List Roles by Perm com.test.TC_Role2.@[THE_USER].r.A|grain|eat --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -role list perm com.test.TC_Role2.@[user.name].r.A grain * -** Expect 200 ** - -List Roles by Perm com.test.TC_Role2.@[THE_USER].r.A|grain|* --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -role list perm com.test.TC_Role2.@[user.name].r.A * * -** Expect 200 ** - -List Roles by Perm com.test.TC_Role2.@[THE_USER].r.A|*|* --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.test.TC_Role2.@[THE_USER].r.dogs - com.test.TC_Role2.@[THE_USER].r.A * * - com.test.TC_Role2.@[THE_USER].r.A grain * - com.test.TC_Role2.@[THE_USER].r.A grain eat - -# TC_Role2.43.15.NEG Don't List Roles when not allowed to see Perm -as testunused@aaf.att.com -role list perm com.test.TC_Role2.@[user.name].r.A grain eat -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Perm [com.test.TC_Role2.@[THE_USER].r.A|grain|eat] - -role list perm com.test.TC_Role2.@[user.name].r.A grain * -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Perm [com.test.TC_Role2.@[THE_USER].r.A|grain|*] - -role list perm com.test.TC_Role2.@[user.name].r.A * * -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Perm [com.test.TC_Role2.@[THE_USER].r.A|*|*] - -as XX@NS -# TC_Role2.99.1.POS Delete Roles -force role delete com.test.TC_Role2.@[user.name].r.animals -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Role2.@[user.name].r.dogs -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_Role2.@[user.name].r.pigs -** Expect 200,404 ** -Deleted Role - -# TC_Role2.99.2.POS Delete Perms -force perm delete com.test.TC_Role2.@[user.name].r.A garbage eat -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Role2.@[user.name].r.A grain eat -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Role2.@[user.name].r.A grain * -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_Role2.@[user.name].r.A * * -** Expect 200,404 ** -Deleted Permission - -force perm delete com.att.aaf.role com.test.TC_Role2.@[user.name].r.animals view -** Expect 200,404 ** -Deleted Permission - -force perm delete com.att.aaf.role com.test.TC_Role2.@[user.name].r.dogs view -** Expect 200,404 ** -Deleted Permission - -# TC_Role2.99.2.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_Role2.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Role2.99.3.POS Print Namespaces -ns list name com.test.TC_Role2.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Role2.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_UR1.expected b/authz-test/TestSuite/expected/TC_UR1.expected deleted file mode 100644 index 7630488f..00000000 --- a/authz-test/TestSuite/expected/TC_UR1.expected +++ /dev/null @@ -1,266 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_UR1.10.0.POS Validate no NS -ns list name com.test.TC_UR1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_UR1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_UR1.10.1.POS Create Namespace to add IDs -ns create com.test.TC_UR1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Role1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_UR1.@[user.name].cred_admin -** Expect 201 ** -Created Role - -as XX@NS -# TC_Role1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_UR1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_UR1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_Role1.10.12.POS Assign user for creating creds -user role add testid@aaf.att.com com.test.TC_UR1.@[user.name].cred_admin -** Expect 201 ** -Added Role [com.test.TC_UR1.@[THE_USER].cred_admin] to User [testid@aaf.att.com] - -# TC_UR1.10.20.POS Create two Credentials -user cred add m00001@@[user.name].TC_UR1.test.com "abc123sd" -** Expect 201 ** -Added Credential [m00001@@[THE_USER].TC_UR1.test.com] - -user cred add m00002@@[user.name].TC_UR1.test.com "abc123sd" -** Expect 201 ** -Added Credential [m00002@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.10.21.POS Create two Roles -role create com.test.TC_UR1.@[user.name].r1 -** Expect 201 ** -Created Role - -role create com.test.TC_UR1.@[user.name].r2 -** Expect 201 ** -Created Role - -# TC_UR1.23.1.NEG Too Few Args for User Role 1 -user -** Expect 0 ** -user role <add|del|setTo|extend> <user> [role[,role]* (!REQ S)] - cred <add|del|reset|extend> <id> [password (! D|E)] [entry# (if multi)] - delegate <add|upd|del> <from> [to REQ A&U] [until (YYYY-MM-DD) REQ A] - list role <role> - perm <type> <instance> <action> - cred <ns|id> <value> - delegates <user|delegate> <id> - approvals <user|approver|ticket> <value> - activity <user> - -# TC_UR1.23.2.NEG Too Few Args for user role -user role -** Expect -1 ** -Too few args: role <add|del|setTo|extend> <user> [role[,role]* (!REQ S)] - -# TC_UR1.23.3.NEG Too Few Args for user role add -user role add -** Expect -1 ** -Too few args: role <add|del|setTo|extend> <user> [role[,role]* (!REQ S)] - -# TC_UR1.30.10.POS Create a UserRole -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 -** Expect 201 ** -Added Role [com.test.TC_UR1.@[THE_USER].r1] to User [m00001@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.30.11.NEG Created UserRole Exists -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - User Role exists - -# TC_UR1.30.13.POS Delete UserRole -sleep 0 -user role del m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 -** Expect 200 ** -Removed Role [com.test.TC_UR1.@[THE_USER].r1] from User [m00001@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.30.20.POS Create multiple UserRoles -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 -** Expect 201 ** -Added Role [com.test.TC_UR1.@[THE_USER].r1] to User [m00001@@[THE_USER].TC_UR1.test.com] -Added Role [com.test.TC_UR1.@[THE_USER].r2] to User [m00001@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.30.21.NEG Created UserRole Exists -user role add m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - User Role exists -Failed [SVC1409]: Conflict Already Exists - User Role exists - -# TC_UR1.30.23.POS Delete UserRole -sleep 0 -user role del m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 -** Expect 200 ** -Removed Role [com.test.TC_UR1.@[THE_USER].r1] from User [m00001@@[THE_USER].TC_UR1.test.com] -Removed Role [com.test.TC_UR1.@[THE_USER].r2] from User [m00001@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.30.30.POS Create a Role User -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com -** Expect 201 ** -Added User [m00001@@[THE_USER].TC_UR1.test.com] to Role [com.test.TC_UR1.@[THE_USER].r1] - -# TC_UR1.30.31.NEG Created Role User Exists -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - User Role exists - -# TC_UR1.30.33.POS Delete Role User -sleep 0 -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com -** Expect 200 ** -Removed User [m00001@@[THE_USER].TC_UR1.test.com] from Role [com.test.TC_UR1.@[THE_USER].r1] - -# TC_UR1.30.40.POS Create multiple Role Users -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -** Expect 201 ** -Added User [m00001@@[THE_USER].TC_UR1.test.com] to Role [com.test.TC_UR1.@[THE_USER].r1] -Added User [m00002@@[THE_USER].TC_UR1.test.com] to Role [com.test.TC_UR1.@[THE_USER].r1] - -# TC_UR1.30.41.NEG Created Role User Exists -role user add com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -** Expect 409 ** -Failed [SVC1409]: Conflict Already Exists - User Role exists -Failed [SVC1409]: Conflict Already Exists - User Role exists - -# TC_UR1.30.43.POS Delete Role Users -sleep 0 -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -** Expect 200 ** -Removed User [m00001@@[THE_USER].TC_UR1.test.com] from Role [com.test.TC_UR1.@[THE_USER].r1] -Removed User [m00002@@[THE_USER].TC_UR1.test.com] from Role [com.test.TC_UR1.@[THE_USER].r1] - -# TC_UR1.40.10.POS Create multiple UserRoles -user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1,com.test.TC_UR1.@[user.name].r2 -** Expect 200 ** -Set User's Roles to [com.test.TC_UR1.@[THE_USER].r1,com.test.TC_UR1.@[THE_USER].r2] - -# TC_UR1.40.11.POS Reset userrole for a user -user role setTo m00001@@[user.name].TC_UR1.test.com -** Expect 200 ** -Set User's Roles to [] - -# TC_UR1.40.12.NEG Create userrole where Role doesn't exist -user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r5 -** Expect 404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_UR1.@[THE_USER].r5] does not exist - -# TC_UR1.40.13.NEG Create userrole where User doesn't exist -user role setTo m99999@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 -** Expect 403 ** -Failed [SVC2403]: Forbidden - m99999@@[THE_USER].TC_UR1.test.com is not a valid AAF Credential - -as testunused@aaf.att.com -# TC_UR1.40.19.NEG User without permission tries to add userrole -user role setTo m00001@@[user.name].TC_UR1.test.com com.test.TC_UR1.@[user.name].r1 -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not write Role [com.test.TC_UR1.@[THE_USER].r1] - -# TC_UR1.40.20.NEG User without permission tries to add userrole -role user setTo com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not write Role [com.test.TC_UR1.@[THE_USER].r1] - -as testid@aaf.att.com -# TC_UR1.40.22.POS Reset userrole for a user -role user setTo com.test.TC_UR1.@[user.name].r1 -** Expect 200 ** -Set the Role to Users [] - -sleep 0 -# TC_UR1.40.23.NEG Create UserRole where Role doesn't exist -role user setTo com.test.TC_UR1.@[user.name].r5 m00001@@[user.name].TC_UR1.test.com -** Expect 404 ** -Failed [SVC3404]: Not Found - Role [com.test.TC_UR1.@[THE_USER].r5] does not exist - -sleep 0 -# TC_UR1.40.24.NEG Create UserRole where User doesn't exist -role user setTo com.test.TC_UR1.@[user.name].r1 m99999@@[user.name].TC_UR1.test.com -** Expect 403 ** -Failed [SVC2403]: Forbidden - m99999@@[THE_USER].TC_UR1.test.com is not a valid AAF Credential - -# Need to let DB catch up on deletes -sleep 0 -as testid@aaf.att.com -# TC_UR1.99.1.POS Remove User from Role -role user del com.test.TC_UR1.@[user.name].r1 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -** Expect 200,404 ** -Failed [SVC6404]: Not Found - User [ m00001@@[THE_USER].TC_UR1.test.com ] is not Assigned to the Role [ com.test.TC_UR1.@[THE_USER].r1 ] -Failed [SVC6404]: Not Found - User [ m00002@@[THE_USER].TC_UR1.test.com ] is not Assigned to the Role [ com.test.TC_UR1.@[THE_USER].r1 ] - -role user del com.test.TC_UR1.@[user.name].r2 m00001@@[user.name].TC_UR1.test.com,m00002@@[user.name].TC_UR1.test.com -** Expect 200,404 ** -Failed [SVC6404]: Not Found - User [ m00001@@[THE_USER].TC_UR1.test.com ] is not Assigned to the Role [ com.test.TC_UR1.@[THE_USER].r2 ] -Failed [SVC6404]: Not Found - User [ m00002@@[THE_USER].TC_UR1.test.com ] is not Assigned to the Role [ com.test.TC_UR1.@[THE_USER].r2 ] - -role user setTo com.test.TC_UR1.@[user.name].r1 -** Expect 200,404 ** -Set the Role to Users [] - -# TC_UR1.99.2.POS Remove ability to create creds -user role del testid@aaf.att.com com.test.TC_UR1.@[user.name].cred_admin -** Expect 200,404 ** -Removed Role [com.test.TC_UR1.@[THE_USER].cred_admin] from User [testid@aaf.att.com] - -as XX@NS -perm ungrant com.att.aaf.mechid com.att create com.test.TC_UR1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_UR1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -role delete com.test.TC_UR1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_UR1.99.3.POS Delete Creds -set force true -user cred del m00001@@[user.name].TC_UR1.test.com -** Expect 200,404 ** -Deleted Credential [m00001@@[THE_USER].TC_UR1.test.com] - -set force true -user cred del m00002@@[user.name].TC_UR1.test.com -** Expect 200,404 ** -Deleted Credential [m00002@@[THE_USER].TC_UR1.test.com] - -# TC_UR1.99.4.POS Delete Roles -set force true -set force=true role delete com.test.TC_UR1.@[user.name].r1 -** Expect 200,404 ** -Deleted Role - -set force true -set force=true role delete com.test.TC_UR1.@[user.name].r2 -** Expect 200,404 ** -Deleted Role - -# TC_UR1.99.5.POS Delete Namespace -set force true -set force=true ns delete com.test.TC_UR1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_UR1.99.99.POS Verify Cleaned NS -ns list name com.test.TC_UR1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_UR1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_User1.expected b/authz-test/TestSuite/expected/TC_User1.expected deleted file mode 100644 index e1d304f5..00000000 --- a/authz-test/TestSuite/expected/TC_User1.expected +++ /dev/null @@ -1,485 +0,0 @@ -set XX@NS <pass> -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set bogus@aaf.att.com boguspass -set m99990@@[THE_USER].TC_User1.test.com password123 -set m99995@@[THE_USER].TC_User1.test.com password123 -#delay 10 -set NFR 0 -as testid@aaf.att.com -# TC_User1.10.0.POS Check for Existing Data -ns list name com.test.TC_User1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_User1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_User1.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.test.TC_User1.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_User1.10.10.POS Create role to assign mechid perm to -role create com.test.TC_User1.@[user.name].cred_admin testid@aaf.att.com -** Expect 201 ** -Created Role -Added User [testid@aaf.att.com] to Role [com.test.TC_User1.@[THE_USER].cred_admin] - -as XX@NS -# TC_User1.10.11.POS Assign role to mechid perm -perm grant com.att.aaf.mechid com.att create com.test.TC_User1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.mechid|com.att|create] to Role [com.test.TC_User1.@[THE_USER].cred_admin] - -perm grant com.att.aaf.delg com.att change com.test.TC_User1.@[user.name].cred_admin -** Expect 201 ** -Granted Permission [com.att.aaf.delg|com.att|change] to Role [com.test.TC_User1.@[THE_USER].cred_admin] - -as testid@aaf.att.com -# TC_User1.01.99.POS Expect Namespace to be created -ns list name com.test.TC_User1.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_User1.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_User1.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_User1.@[THE_USER].admin - com.test.TC_User1.@[THE_USER].cred_admin - com.test.TC_User1.@[THE_USER].owner - Permissions - com.test.TC_User1.@[THE_USER].access * * - com.test.TC_User1.@[THE_USER].access * read - -as testid@aaf.att.com -# TC_User1.20.1.POS Create roles -role create com.test.TC_User1.@[user.name].manager -** Expect 201 ** -Created Role - -role create com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Created Role - -# TC_User1.20.2.POS Create permissions -perm create com.test.TC_User1.@[user.name].supplies * move com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_User1.@[THE_USER].supplies|*|move] to Role [com.test.TC_User1.@[THE_USER].worker] - -perm create com.test.TC_User1.@[user.name].supplies * stock com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_User1.@[THE_USER].supplies|*|stock] to Role [com.test.TC_User1.@[THE_USER].worker] - -perm create com.test.TC_User1.@[user.name].schedule worker create com.test.TC_User1.@[user.name].manager -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_User1.@[THE_USER].schedule|worker|create] to Role [com.test.TC_User1.@[THE_USER].manager] - -perm create com.test.TC_User1.@[user.name].worker * annoy com.test.TC_User1.@[user.name].manager -** Expect 201 ** -Created Permission -Granted Permission [com.test.TC_User1.@[THE_USER].worker|*|annoy] to Role [com.test.TC_User1.@[THE_USER].manager] - -# TC_User1.20.3.POS Create mechid -user cred add m99990@@[user.name].TC_User1.test.com password123 -** Expect 201 ** -Added Credential [m99990@@[THE_USER].TC_User1.test.com] - -user cred add m99995@@[user.name].TC_User1.test.com password123 -** Expect 201 ** -Added Credential [m99995@@[THE_USER].TC_User1.test.com] - -as XX@NS -# TC_User1.20.10.POS Add users to roles -user role add @[user.name] com.test.TC_User1.@[user.name].manager -** Expect 201 ** -Added Role [com.test.TC_User1.@[THE_USER].manager] to User [@[THE_USER]@csp.att.com] - -user role add m99990@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Added Role [com.test.TC_User1.@[THE_USER].worker] to User [m99990@@[THE_USER].TC_User1.test.com] - -# TC_User1.20.20.POS Add Delegate -as XX@NS -# TC_User1.20.20.POS Create delegates -force user delegate add @[user.name] @[user.name] -** Expect 201 ** -Delegate Added - -# TC_User1.40.1.NEG Non-admin, user not in role should not view -as testunused@aaf.att.com -user list role com.test.TC_User1.@[user.name].manager -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_User1.@[THE_USER].manager] - -user list role com.test.TC_User1.@[user.name].worker -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read Role [com.test.TC_User1.@[THE_USER].worker] - -as m99990@@[THE_USER].TC_User1.test.com -# TC_User1.40.2.NEG Non-admin, user in role should not view -user list role com.test.TC_User1.@[user.name].manager -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99990@@[THE_USER].TC_User1.test.com] may not read Role [com.test.TC_User1.@[THE_USER].manager] - -sleep 0 -# TC_User1.40.3.POS Non-admin, user in role can view himself -user list role com.test.TC_User1.@[user.name].worker -** Expect 200 ** - -List Users for Role[com.test.TC_User1.@[THE_USER].worker] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -as testid@aaf.att.com -# TC_User1.40.10.POS admin should view -user list role com.test.TC_User1.@[user.name].manager -** Expect 200 ** - -List Users for Role[com.test.TC_User1.@[THE_USER].manager] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -@[THE_USER]@csp.att.com XXXX-XX-XX - - -user list role com.test.TC_User1.@[user.name].worker -** Expect 200 ** - -List Users for Role[com.test.TC_User1.@[THE_USER].worker] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -as testunused@aaf.att.com -# TC_User1.41.1.NEG Non-admin, user not in perm should not view -user list perm com.test.TC_User1.@[user.name].supplies * move -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|move] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -user list perm com.test.TC_User1.@[user.name].supplies * stock -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|stock] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -user list perm com.test.TC_User1.@[user.name].schedule worker create -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].schedule|worker|create] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -user list perm com.test.TC_User1.@[user.name].worker * annoy -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].worker|*|annoy] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -as m99990@@[THE_USER].TC_User1.test.com -# TC_User1.41.2.POS Non-admin, user in perm can view himself -user list perm com.test.TC_User1.@[user.name].supplies * move -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|move] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * stock -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|stock] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -as m99990@@[THE_USER].TC_User1.test.com -# TC_User1.41.3.NEG Non-admin, user in perm should not view -user list perm com.test.TC_User1.@[user.name].schedule worker create -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].schedule|worker|create] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -user list perm com.test.TC_User1.@[user.name].worker * annoy -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].worker|*|annoy] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- - - -as testid@aaf.att.com -# TC_User1.41.10.POS admin should view -user list perm com.test.TC_User1.@[user.name].supplies * move -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|move] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * stock -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|stock] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].schedule worker create -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].schedule|worker|create] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -@[THE_USER]@csp.att.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].worker * annoy -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].worker|*|annoy] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -@[THE_USER]@csp.att.com XXXX-XX-XX - - -as testunused@aaf.att.com -# TC_User1.42.1.NEG Unrelated user can't view delegates -user list delegates user m99990@@[user.name].TC_User1.test.com -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read delegates for [m99990@@[THE_USER].TC_User1.test.com] - -user list delegates delegate m99995@@[user.name].TC_User1.test.com -** Expect 403 ** -Failed [SVC1403]: Forbidden - [testunused@aaf.att.com] may not read delegates for [m99995@@[THE_USER].TC_User1.test.com] - -as XX@NS -# TC_User1.42.10.POS Admin of domain NS can view -user list delegates user @[user.name] -** Expect 200 ** - -List Delegates by user[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -user list delegates delegate @[user.name] -** Expect 200 ** - -List Delegates by delegate[@[THE_USER]@csp.att.com] --------------------------------------------------------------------------------- - User Delegate Expires --------------------------------------------------------------------------------- - @[THE_USER]@csp.att.com @[THE_USER]@csp.att.com XXXX-XX-XX - -as testid@aaf.att.com -# TC_User1.43.1.POS Add another user to worker role -user role add m99995@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Added Role [com.test.TC_User1.@[THE_USER].worker] to User [m99995@@[THE_USER].TC_User1.test.com] - -as m99990@@[THE_USER].TC_User1.test.com -# TC_User1.43.2.POS User should only see himself here -user list role com.test.TC_User1.@[user.name].worker -** Expect 200 ** - -List Users for Role[com.test.TC_User1.@[THE_USER].worker] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * move -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|move] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * stock -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|stock] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -as XX@NS -# TC_User1.43.10.POS Grant explicit user perm to user -perm create com.att.aaf.user :com.test.TC_User1.@[user.name] view com.test.TC_User1.@[user.name].worker -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.user|:com.test.TC_User1.@[THE_USER]|view] to Role [com.test.TC_User1.@[THE_USER].worker] - -as m99990@@[THE_USER].TC_User1.test.com -# TC_User1.43.11.POS User should see all users of test domain now -user list role com.test.TC_User1.@[user.name].worker -** Expect 200 ** - -List Users for Role[com.test.TC_User1.@[THE_USER].worker] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * move -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|move] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -user list perm com.test.TC_User1.@[user.name].supplies * stock -** Expect 200 ** - -List Users for Permission[com.test.TC_User1.@[THE_USER].supplies|*|stock] --------------------------------------------------------------------------------- -User Expires --------------------------------------------------------------------------------- -m99990@@[THE_USER].TC_User1.test.com XXXX-XX-XX -m99995@@[THE_USER].TC_User1.test.com XXXX-XX-XX - - -as testid@aaf.att.com -# TC_User1.99.0.POS Remove user roles -user role del @[user.name] com.test.TC_User1.@[user.name].manager -** Expect 200,404 ** -Removed Role [com.test.TC_User1.@[THE_USER].manager] from User [@[THE_USER]@csp.att.com] - -user role del m99990@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker -** Expect 200,404 ** -Removed Role [com.test.TC_User1.@[THE_USER].worker] from User [m99990@@[THE_USER].TC_User1.test.com] - -user role del m99995@@[user.name].TC_User1.test.com com.test.TC_User1.@[user.name].worker -** Expect 200,404 ** -Removed Role [com.test.TC_User1.@[THE_USER].worker] from User [m99995@@[THE_USER].TC_User1.test.com] - -# TC_User1.99.1.POS Namespace Admin can delete Namepace defined Roles & Perms -force perm delete com.test.TC_User1.@[user.name].supplies * move -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_User1.@[user.name].supplies * stock -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_User1.@[user.name].schedule worker create -** Expect 200,404 ** -Deleted Permission - -force perm delete com.test.TC_User1.@[user.name].worker * annoy -** Expect 200,404 ** -Deleted Permission - -force role delete com.test.TC_User1.@[user.name].manager -** Expect 200,404 ** -Deleted Role - -force role delete com.test.TC_User1.@[user.name].worker -** Expect 200,404 ** -Deleted Role - -# TC_User1.99.10.POS Creds and delegate -user delegate del @[user.name] -** Expect 200,404 ** -Delegate Deleted - -user cred del m99990@@[user.name].TC_User1.test.com -** Expect 200,404 ** -Deleted Credential [m99990@@[THE_USER].TC_User1.test.com] - -user cred del m99995@@[user.name].TC_User1.test.com -** Expect 200,404 ** -Deleted Credential [m99995@@[THE_USER].TC_User1.test.com] - -as XX@NS -# TC_User1.99.15.POS Remove ability to create creds -perm ungrant com.att.aaf.mechid com.att create com.test.TC_User1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.mechid|com.att|create] from Role [com.test.TC_User1.@[THE_USER].cred_admin] - -perm ungrant com.att.aaf.delg com.att change com.test.TC_User1.@[user.name].cred_admin -** Expect 200,404 ** -UnGranted Permission [com.att.aaf.delg|com.att|change] from Role [com.test.TC_User1.@[THE_USER].cred_admin] - -perm delete com.att.aaf.user :com.test.TC_User1.@[user.name] view -** Expect 200,404 ** -Deleted Permission - -as testid@aaf.att.com -force role delete com.test.TC_User1.@[user.name].cred_admin -** Expect 200,404 ** -Deleted Role - -# TC_User1.99.90.POS Namespace Admin can delete Namespace -force ns delete com.test.TC_User1.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -sleep 0 -# TC_User1.99.99.POS Check Clean Namespace -ns list name com.test.TC_User1.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_User1.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/expected/TC_Wild.expected b/authz-test/TestSuite/expected/TC_Wild.expected deleted file mode 100644 index 448efa1d..00000000 --- a/authz-test/TestSuite/expected/TC_Wild.expected +++ /dev/null @@ -1,520 +0,0 @@ -set testid@aaf.att.com <pass> -set testunused@aaf.att.com <pass> -set XX@NS <pass> -set bogus boguspass -#delay 10 -set NFR 0 -as XX@NS -# TC_Wild.10.0.POS Validate NS ok -ns list name com.att.test.TC_Wild.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.att.test.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -# TC_Wild.10.1.POS Create Namespace with valid IDs and Responsible Parties -ns create com.att.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Wild.10.10.POS Create a clean MechID -user cred add m99999@@[user.name].TC_Wild.att.com aNewPass8 -** Expect 201 ** -Added Credential [m99999@@[THE_USER].TC_Wild.att.com] - -set m99999@@[THE_USER].TC_Wild.att.com aNewPass8 -as XX@NS -# TC_Wild.10.11.POS Create role and assign MechID to -role create com.att.TC_Wild.@[user.name].service m99999@@[user.name].TC_Wild.att.com -** Expect 201 ** -Created Role -Added User [m99999@@[THE_USER].TC_Wild.att.com] to Role [com.att.TC_Wild.@[THE_USER].service] - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.20.1.NEG Fail to create a perm in NS -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Perm [com.att.TC_Wild.@[THE_USER].myType|myInstance|myAction] - -# TC_Wild.20.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -perm create com.att.TC_Wild.@[user.name].access :perm:myType:*:myAction write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.TC_Wild.@[THE_USER].access|:perm:myType:*:myAction|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.20.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access :perm:myType:*:myAction write - - -# TC_Wild.20.7.POS Now able to create a perm in NS -as m99999@@[THE_USER].TC_Wild.att.com -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Wild.20.8.POS Print Perms -as XX@NS -perm list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Perms by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].access :perm:myType:*:myAction write -com.att.TC_Wild.@[THE_USER].myType myInstance myAction - - -# TC_Wild.20.10.POS Delete Perms Created -force perm delete com.att.TC_Wild.@[user.name].access :perm:myType:*:myAction write -** Expect 200 ** -Deleted Permission - -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 200 ** -Deleted Permission - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.21.1.NEG Fail to create a perm in NS -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Perm [com.att.TC_Wild.@[THE_USER].myType|myInstance|myAction] - -# TC_Wild.21.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -perm create com.att.TC_Wild.@[user.name].access :perm:myType:*:* write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.TC_Wild.@[THE_USER].access|:perm:myType:*:*|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.21.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access :perm:myType:*:* write - - -# TC_Wild.21.7.POS Now able to create a perm in NS -as m99999@@[THE_USER].TC_Wild.att.com -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Wild.21.8.POS Print Perms -as XX@NS -perm list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Perms by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].access :perm:myType:*:* write -com.att.TC_Wild.@[THE_USER].myType myInstance myAction - - -# TC_Wild.21.10.POS Delete Perms Created -force perm delete com.att.TC_Wild.@[user.name].access :perm:myType:*:* write -** Expect 200 ** -Deleted Permission - -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 200 ** -Deleted Permission - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.30.1.NEG Fail to create a role in NS -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Role [com.att.TC_Wild.@[THE_USER].tool.myRole] - -# TC_Wild.30.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -perm create com.att.TC_Wild.@[user.name].access :role:tool.* write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.TC_Wild.@[THE_USER].access|:role:tool.*|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.30.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access :role:tool.* write - - -# TC_Wild.30.7.POS Now able to create a role in NS -as m99999@@[THE_USER].TC_Wild.att.com -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 201 ** -Created Role - -# TC_Wild.30.8.POS Print Perms -as XX@NS -role list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Roles by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].admin - com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].owner - com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].service - com.att.TC_Wild.@[THE_USER].access :role:tool.* write -com.att.TC_Wild.@[THE_USER].tool.myRole - -# TC_Wild.30.10.POS Delete Perms Created -force perm delete com.att.TC_Wild.@[user.name].access :role:tool.* write -** Expect 200 ** -Deleted Permission - -force role delete com.att.TC_Wild.@[user.name].tool.myRole -** Expect 200 ** -Deleted Role - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.31.1.NEG Fail to create a role in NS -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Role [com.att.TC_Wild.@[THE_USER].tool.myRole] - -# TC_Wild.31.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -perm create com.att.TC_Wild.@[user.name].access :role:* write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.TC_Wild.@[THE_USER].access|:role:*|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.31.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access :role:* write - - -# TC_Wild.31.7.POS Now able to create a role in NS -as m99999@@[THE_USER].TC_Wild.att.com -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 201 ** -Created Role - -# TC_Wild.31.8.POS Print Perms -as XX@NS -role list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Roles by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].admin - com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].owner - com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].service - com.att.TC_Wild.@[THE_USER].access :role:* write -com.att.TC_Wild.@[THE_USER].tool.myRole - -# TC_Wild.31.10.POS Delete Perms Created -force perm delete com.att.TC_Wild.@[user.name].access :role:* write -** Expect 200 ** -Deleted Permission - -force role delete com.att.TC_Wild.@[user.name].tool.myRole -** Expect 200 ** -Deleted Role - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.32.1.NEG Fail to create a role in NS -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Role [com.att.TC_Wild.@[THE_USER].tool.myRole] - -# TC_Wild.32.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -perm create com.att.TC_Wild.@[user.name].access :role:* * com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.TC_Wild.@[THE_USER].access|:role:*|*] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.32.5.POS Print Perms -as m99999@@[THE_USER].TC_Wild.att.com -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access :role:* * - - -# TC_Wild.32.7.POS Now able to create a role in NS -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 201 ** -Created Role - -# TC_Wild.32.8.POS May Print Role -role list role com.att.TC_Wild.@[user.name].tool.myRole -** Expect 200 ** - -List Roles for Role[com.att.TC_Wild.@[THE_USER].tool.myRole] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].tool.myRole - -as XX@NS -# TC_Wild.32.10.POS Delete Perms Created -force perm delete com.att.TC_Wild.@[user.name].access :role:* * -** Expect 200 ** -Deleted Permission - -force role delete com.att.TC_Wild.@[user.name].tool.myRole -** Expect 200 ** -Deleted Role - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.50.1.NEG Fail to create a perm in NS -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Perm [com.att.TC_Wild.@[THE_USER].myType|myInstance|myAction] - -# TC_Wild.50.3.POS Add "access perm" based Wild Card with specific Action -as XX@NS -perm create com.att.aaf.ns :com.att.*:perm:myType:*:* write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.ns|:com.att.*:perm:myType:*:*|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.50.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.aaf.ns :com.att.*:perm:myType:*:* write - - -# TC_Wild.50.7.POS Now able to create a perm in NS -as m99999@@[THE_USER].TC_Wild.att.com -perm create com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 201 ** -Created Permission - -# TC_Wild.50.8.POS Print Perms -as XX@NS -perm list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Perms by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].myType myInstance myAction - - -# TC_Wild.50.10.POS Delete Perms Created -force perm delete com.att.aaf.ns :com.att.*:perm:myType:*:* write -** Expect 200 ** -Deleted Permission - -force perm delete com.att.TC_Wild.@[user.name].myType myInstance myAction -** Expect 200 ** -Deleted Permission - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.51.1.NEG Fail to create a role in NS -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write Role [com.att.TC_Wild.@[THE_USER].tool.myRole] - -# TC_Wild.51.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -perm create com.att.aaf.ns :com.att.*:role:tool.* write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.ns|:com.att.*:role:tool.*|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.51.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.aaf.ns :com.att.*:role:tool.* write - - -# TC_Wild.51.7.POS Now able to create a role in NS -as m99999@@[THE_USER].TC_Wild.att.com -role create com.att.TC_Wild.@[user.name].tool.myRole -** Expect 201 ** -Created Role - -# TC_Wild.51.8.POS Print Perms -as XX@NS -role list ns com.att.TC_Wild.@[user.name] -** Expect 200 ** - -List Roles by NS [com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -ROLE Name - PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.TC_Wild.@[THE_USER].admin - com.att.TC_Wild.@[THE_USER].access * * -com.att.TC_Wild.@[THE_USER].owner - com.att.TC_Wild.@[THE_USER].access * read -com.att.TC_Wild.@[THE_USER].service - com.att.aaf.ns :com.att.*:role:tool.* write -com.att.TC_Wild.@[THE_USER].tool.myRole - -# TC_Wild.51.10.POS Delete Perms Created -force perm delete com.att.aaf.ns :com.att.*:role:tool.* write -** Expect 200 ** -Deleted Permission - -force role delete com.att.TC_Wild.@[user.name].tool.myRole -** Expect 200 ** -Deleted Role - -as m99999@@[THE_USER].TC_Wild.att.com -# TC_Wild.52.1.NEG Fail to create a NS -ns create com.test.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com -** Expect 403 ** -Failed [SVC1403]: Forbidden - [m99999@@[THE_USER].TC_Wild.att.com] may not write in NS [com.test] - -# TC_Wild.52.3.POS Add "access role" based Wild Card with specific Action -as XX@NS -perm create com.att.aaf.ns :com.test:ns write com.att.TC_Wild.@[user.name].service -** Expect 201 ** -Created Permission -Granted Permission [com.att.aaf.ns|:com.test:ns|write] to Role [com.att.TC_Wild.@[THE_USER].service] - -# TC_Wild.52.5.POS Print Perms -perm list user m99999@@[user.name].TC_Wild.att.com -** Expect 200 ** - -List Permissions by User[m99999@@[THE_USER].TC_Wild.att.com] --------------------------------------------------------------------------------- -PERM Type Instance Action --------------------------------------------------------------------------------- -com.att.aaf.ns :com.test:ns write - - -# TC_Wild.52.7.POS Now able to create an NS -as m99999@@[THE_USER].TC_Wild.att.com -ns create com.test.TC_Wild.@[user.name] @[user.name] testid@aaf.att.com -** Expect 201 ** -Created Namespace - -# TC_Wild.52.8.POS Print Perms -as XX@NS -ns list name com.test.TC_Wild.@[user.name] -** Expect 200 ** - -List Namespaces by Name[com.test.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- -com.test.TC_Wild.@[THE_USER] - Administrators - testid@aaf.att.com - Responsible Parties - @[THE_USER]@csp.att.com - Roles - com.test.TC_Wild.@[THE_USER].admin - com.test.TC_Wild.@[THE_USER].owner - Permissions - com.test.TC_Wild.@[THE_USER].access * * - com.test.TC_Wild.@[THE_USER].access * read - -# TC_Wild.52.10.POS Delete Perms Created -force perm delete com.att.aaf.ns :com.test:ns write -** Expect 200 ** -Deleted Permission - -force ns delete com.test.TC_Wild.@[user.name] -** Expect 200 ** -Deleted Namespace - -as XX@NS -# TC_Wild.99.80.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:perm:*:* write -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.att.aaf.ns|:com.att.*:perm:*:*|write] does not exist - -# TC_Wild.99.81.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:perm:*:* * -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.att.aaf.ns|:com.att.*:perm:*:*|*] does not exist - -# TC_Wild.99.82.POS Cleanup -force perm delete com.att.aaf.ns :com.att.*:role:* write -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.att.aaf.ns|:com.att.*:role:*|write] does not exist - -# TC_Wild.99.83.POS Cleanup -force perm delete com.att.aaf.ns :com.test:ns write -** Expect 200,404 ** -Failed [SVC4404]: Not Found - Permission [com.att.aaf.ns|:com.test:ns|write] does not exist - -# TC_Wild.99.90.POS Cleanup -force ns delete com.test.TC_Wild.@[user.name] -** Expect 200,404 ** -Failed [SVC2404]: Not Found - com.test.TC_Wild.@[THE_USER] does not exist - -# TC_Wild.99.91.POS Cleanup -force ns delete com.att.TC_Wild.@[user.name] -** Expect 200,404 ** -Deleted Namespace - -# TC_Wild.99.99.POS List to prove clean Namespaces -ns list name com.att.TC_Wild.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.att.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - -ns list name com.test.TC_Wild.@[user.name] -** Expect 200,404 ** - -List Namespaces by Name[com.test.TC_Wild.@[THE_USER]] --------------------------------------------------------------------------------- - *** Namespace Not Found *** - diff --git a/authz-test/TestSuite/list b/authz-test/TestSuite/list deleted file mode 100644 index 8742d971..00000000 --- a/authz-test/TestSuite/list +++ /dev/null @@ -1,2 +0,0 @@ -# /bin/sh -find . -maxdepth 1 -name "TC*" -exec sh cmds {} \; | grep \# diff --git a/authz-test/TestSuite/qc b/authz-test/TestSuite/qc deleted file mode 100644 index 83149a3a..00000000 --- a/authz-test/TestSuite/qc +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# For Jenkins, we need to keep track of the exit code returned from each tc run; -# if it's ever non-zero (ie, a failure), must return that value when this script exits -# -STATUS=0 - -for DIR in `ls | grep ^TC_ | sort`; do - echo "**" | tee reports/$DIR.txt - echo "** TC Group: $DIR" | tee -a reports/$DIR.txt - echo "** Date : "`date` | tee -a reports/$DIR.txt - echo "** By : "`who | cut -d " " -f 1` | tee -a reports/$DIR.txt - echo "**" | tee -a reports/$DIR.txt - echo "" >> reports/$DIR.txt - echo "-- Description --" >> reports/$DIR.txt - cat $DIR/Description >> reports/$DIR.txt - echo -- Positive Cases -- >> reports/$DIR.txt - grep -h "^# $DIR.*POS " $DIR/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' >> reports/$DIR.txt - echo >> reports/$DIR.txt - echo -- Negative Cases -- >> reports/$DIR.txt - grep -h "^# $DIR.*NEG " $DIR/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' >> reports/$DIR.txt - - - echo "" >> reports/$DIR.txt - echo "-- Results" | tee -a reports/$DIR.txt - echo "" | tee -a reports/$DIR.txt - - bash ./tc $DIR | tee -a reports/$DIR.txt - - if [[ ${PIPESTATUS[0]} -ne 0 ]]; then - STATUS=1 - fi -done - - -exit $STATUS - - diff --git a/authz-test/TestSuite/reset b/authz-test/TestSuite/reset deleted file mode 100644 index af9b1005..00000000 --- a/authz-test/TestSuite/reset +++ /dev/null @@ -1,4 +0,0 @@ -set m12345=<pass> -as m12345 -ns create com.test testid@test.com - diff --git a/authz-test/TestSuite/rpt1 b/authz-test/TestSuite/rpt1 deleted file mode 100644 index 4997ed83..00000000 --- a/authz-test/TestSuite/rpt1 +++ /dev/null @@ -1,22 +0,0 @@ -# /bin/bash -if [ "$1" == "" ]; then - echo "Usage: rpt1 <TestCase>" - exit 1 -fi - -echo "**" -echo "** TC Group: $1" -echo "** Date : "`date` -echo "** By : "`who | cut -d " " -f 1` -echo "**" -echo "" -echo "-- Description --" -cat $1/Description -echo -- Positive Cases -- -grep -h "^# $1.*POS " $1/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' -echo -echo -- Negative Cases -- -grep -h "^# $1.*NEG " $1/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' - -cd .. -exit 0 diff --git a/authz-test/TestSuite/rpt2 b/authz-test/TestSuite/rpt2 deleted file mode 100644 index 45eb1e21..00000000 --- a/authz-test/TestSuite/rpt2 +++ /dev/null @@ -1,12 +0,0 @@ -# /bin/bash -if [ "$1" == "" ]; then - echo "Usage: rpt2 <TestCase>" - exit 1 -fi - -./rpt1 $1 -echo "" -echo "-- Results" -echo "" -./tc $1 - diff --git a/authz-test/TestSuite/tc b/authz-test/TestSuite/tc deleted file mode 100644 index ed21c64e..00000000 --- a/authz-test/TestSuite/tc +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -TS=`echo $0 | sed "s/\/tc//"` - -mkdir -p runs - -function failed { - echo "FAILED TEST! $*" - exit 1 -} - -if [ "$1" == "-a" ]; then - OPTS=$OPTS" -a"; - shift -elif [ "$1" == "clean" ]; then - CLEAN="TRUE" - shift -fi - -if [[ -z $USER ]]; then - THE_USER=`whoami` -elif [[ -n "$SUDO_USER" ]]; then - THE_USER=$SUDO_USER -elif [[ -n "$USER" ]]; then - THE_USER=$USER -fi - -if [ "$1" == "" ]; then - DIRS=`find $TS -maxdepth 2 -type d -name "TC_*" | sed "s/^$TS\///" | sort` - if [ "$DIRS" == "" ] ; then - echo "Usage: tc <TestCase> [expected]" - echo " expected - create the expected response for future comparison" - exit 1 - fi -else - DIRS=$1 - shift -fi - -if [ "$1" == "-a" ]; then - OPTS=$OPTS" -a"; - shift -elif [ "$1" == "clean" ]; then - CLEAN="TRUE" - shift -fi - -if [ -e tc.delay ]; then - OPTS=$OPTS" -delayAll "`cat tc.delay` -fi - - -SUFFIX=`date "+%Y-%m-%d_%H:%M:%S"` -for TC in $DIRS; do - echo $TC - if [ "$CLEAN" = "TRUE" ]; then - cat $TS/$TC/00* $TS/$TC/99* | aafcli -i -a -t -n - rm -f last - ln -s runs/$TC.CLEAN.$SUFFIX last - elif [ "$1" = "expected" ]; then - SUFFIX=$1 - cat $TS/$TC/[0-9]* | aafcli -i -t 2>&1 | sed -e "/$THE_USER/s//@[THE_USER]/g" | tee $TS/expected/$TC.$SUFFIX - elif [ -d "$TS/$TC" ]; then - if [ "$1" = "dryrun" ]; then - cat $TS/$TC/[0-9]* > temp - cat $TS/$TC/[0-9]* | aafcli -i -t - else - rm -f last - > runs/$TC.$SUFFIX - ln -s runs/$TC.$SUFFIX last - cat $TS/$TC/[0-9]* | aafcli -i -t $OPTS | sed -e "/$THE_USER/s//@[THE_USER]/g" -e "s/
//" 2>&1 > runs/$TC.$SUFFIX - - diff --ignore-blank-lines -w runs/$TC.$SUFFIX $TS/expected/$TC.expected || failed "[$TC.$SUFFIX]" - echo "SUCCESS! [$TC.$SUFFIX]" - fi - elif [ -f "$TS/$TC" ]; then - cat $TS/$TC | aafcli -i -t $OPTS - else - echo missed dir - fi -done - -exit 0 diff --git a/authz-test/etc/tc.connection b/authz-test/etc/tc.connection deleted file mode 100644 index 1fd9f6fd..00000000 --- a/authz-test/etc/tc.connection +++ /dev/null @@ -1,32 +0,0 @@ -# Load Passwords needed - -DME2REG=/Volumes/Data/src/authz/dme2reg - -# This is a fix for DME2 jar which doesn't register entries correctly -function fix { - for FILE in `find $DME2REG -name "*.txt"` - do - sed -e"s/null/https/" $FILE > temp3555 - cat temp3555 > $FILE - rm temp3555 - done -} - -function aafcli { - fix - java \ - -Daaf_id=testid \ - -Daaf_pass=<pass> \ - -Daaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0.1/envContext=DEV/routeOffer=BAU_SE \ - -DAFT_LATITUDE=32.780140 \ - -DAFT_LONGITUDE=-96.800451 \ - -DAFT_ENVIRONMENT=AFTUAT \ - -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG \ - -DDME2_EP_REGISTRY_CLASS=DME2FS \ - -Dtestid=<pass> \ - -Dbogus=xxx \ - -Dm12345=<pass> \ - -jar \ - /Volumes/Data/src/authz/authz-cmd/target/authz-cmd-2.0.2-SNAPSHOT-jar-with-dependencies.jar \ - $* -} diff --git a/authz-test/etc/tc.devl b/authz-test/etc/tc.devl deleted file mode 100644 index a85250c0..00000000 --- a/authz-test/etc/tc.devl +++ /dev/null @@ -1,22 +0,0 @@ -# Load Passwords needed -if [ -e ../../authz-service ]; then - CMD_DEPLOYED=authz-service -else - CMD_DEPLOYED=authz-cmd -fi -function aafcli { - java \ - -Daaf_id=testid \ - -Daaf_pass=<pass> \ - -Daaf_url=DMEServiceName=service=com.att.authz.AuthorizationService/version=2.0/envContext=AFTUAT/routeOffer=BAU_SE \ - -Dkeyfile=/Volumes/Data/src/authz/common/keyfile \ - -DAFT_LATITUDE=38.432930 \ - -DAFT_LONGITUDE=-90.432480 \ - -DAFT_ENVIRONMENT=AFTUAT \ - -Dtestid=<pass> \ - -Dbogus=xxx \ - -Dm12345=<pass> \ - -jar \ - ../../${CMD_DEPLOYED}/2.0.2/lib/authz-cmd-2.0.2-jar-with-dependencies.jar \ - $* -} diff --git a/authz-test/etc/tc.local b/authz-test/etc/tc.local deleted file mode 100644 index 8aec5c7a..00000000 --- a/authz-test/etc/tc.local +++ /dev/null @@ -1,22 +0,0 @@ -# Load Passwords needed - -DME2REG=../../dme2reg - -function aafcli { - java \ - -Daaf_id=testid \ - -Daaf_pass=<pass> \ - -Daaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0.3/envContext=DEV/routeOffer=BAU_SE \ - -Dkeyfile=../../common/keyfile \ - -DAFT_LATITUDE=32.780140 \ - -DAFT_LONGITUDE=-96.800451 \ - -DAFT_ENVIRONMENT=AFTUAT \ - -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG \ - -DDME2_EP_REGISTRY_CLASS=DME2FS \ - -Dtestid=<pass> \ - -Dbogus=xxx \ - -Dm12345=<pass> \ - -jar \ - ../../authz-cmd/target/authz-cmd-2.0.3-jar-with-dependencies.jar \ - $* -} diff --git a/authz-test/pom.xml b/authz-test/pom.xml deleted file mode 100644 index 8c145ebf..00000000 --- a/authz-test/pom.xml +++ /dev/null @@ -1,254 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * 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====================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
--->
-<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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>authz-test</artifactId>
- <name>Authz TestCases</name>
- <description>TestCase Suite for Authz/Authn</description>
- <packaging>jar</packaging>
- <url>https://github.com/att/AAF</url>
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
-
-
- <properties>
- <maven.test.failure.ignore>false</maven.test.failure.ignore>
- <project.swmVersion>0</project.swmVersion>
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>
- <sonar.language>java</sonar.language>
- <sonar.skip>true</sonar.skip>
- <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
- <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
- <sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
- <sonar.jacoco.itReportPath>${project.build.directory}/coverage-reports/jacoco-it.exec</sonar.jacoco.itReportPath>
- <sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
- <sonar.projectVersion>${project.version}</sonar.projectVersion>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>
-
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-client</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-cmd</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.att.aft</groupId>
- <artifactId>dme2</artifactId>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.jmeter</groupId>
- <artifactId>ApacheJMeter_java</artifactId>
- <version>2.11</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.7</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/AAFJUnitTest.java</include>
- </includes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/AAFJUnitTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-<plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.7.201606060606</version>
- <configuration>
- <dumpOnExit>true</dumpOnExit>
- <includes>
- <include>org.onap.aaf.*</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <id>pre-unit-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
- <!-- <append>true</append> -->
- </configuration>
- </execution>
- <execution>
- <id>pre-integration-test</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- <configuration>
- <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
- <!-- <append>true</append> -->
- </configuration>
- </execution>
- <execution>
- <goals>
- <goal>merge</goal>
- </goals>
- <phase>post-integration-test</phase>
- <configuration>
- <fileSets>
- <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
- <directory>${project.build.directory}/coverage-reports</directory>
- <includes>
- <include>*.exec</include>
- </includes>
- </fileSet>
- </fileSets>
- <destFile>${project.build.directory}/jacoco-dev.exec</destFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
-
- </plugins>
- </pluginManagement>
- </build>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
-</project>
diff --git a/authz-test/src/main/assemble/swm.xml b/authz-test/src/main/assemble/swm.xml deleted file mode 100644 index f2e86838..00000000 --- a/authz-test/src/main/assemble/swm.xml +++ /dev/null @@ -1,34 +0,0 @@ -<!--
- ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * 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====================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
--->
-<assembly>
- <id>swm</id>
- <formats>
- <format>zip</format>
- </formats>
- <baseDirectory>${artifactId}</baseDirectory>
- <fileSets>
- <fileSet>
- <directory>target/swm</directory>
- </fileSet>
- </fileSets>
-</assembly>
diff --git a/authz-test/src/main/config/lrm-authz-service.xml b/authz-test/src/main/config/lrm-authz-service.xml deleted file mode 100644 index 8cb7c9dc..00000000 --- a/authz-test/src/main/config/lrm-authz-service.xml +++ /dev/null @@ -1,81 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * 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====================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
--->
-<ns2:ManagedResourceList xmlns:ns2="http://scld.att.com/lrm/util" xmlns="http://scld.att.com/lrm/commontypes" xmlns:ns3="http://scld.att.com/lrm/types">
- <ns2:ManagedResource>
- <ResourceDescriptor>
- <ResourceName>com.att.authz._ARTIFACT_ID_</ResourceName>
- <ResourceVersion>
- <Major>_MAJOR_VER_</Major>
- <Minor>_MINOR_VER_</Minor>
- <Patch>_PATCH_VER_</Patch>
- </ResourceVersion>
- <RouteOffer>_ROUTE_OFFER_</RouteOffer>
- </ResourceDescriptor>
- <ResourceType>Java</ResourceType>
- <ResourcePath>com.att.authz.service.AuthzAPI</ResourcePath>
- <ResourceProps>
- <Tag>process.workdir</Tag>
- <Value>_ROOT_DIR_</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.version</Tag>
- <Value>1.6</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.args</Tag>
- <Value>-DAFT_LATITUDE=_AFT_LATITUDE_ -DAFT_LONGITUDE=_AFT_LONGITUDE_ -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ -Dplatform=_SCLD_PLATFORM_ -Dcom.sun.jndi.ldap.connect.pool.maxsize=20 -Dcom.sun.jndi.ldap.connect.pool.prefsize=10 -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 </Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.classpath</Tag>
- <Value>_ROOT_DIR_/etc:_ROOT_DIR_/lib/*:</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.heap.min</Tag>
- <Value>512m</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>jvm.heap.max</Tag>
- <Value>1024m</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>start.class</Tag>
- <Value>com.att.authz.service.AuthAPI</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>stdout.redirect</Tag>
- <Value>_ROOT_DIR_/logs/SystemOut.log</Value>
- </ResourceProps>
- <ResourceProps>
- <Tag>stderr.redirect</Tag>
- <Value>_ROOT_DIR_/logs/SystemErr.log</Value>
- </ResourceProps>
- <ResourceOSID>aft</ResourceOSID>
- <ResourceStartType>AUTO</ResourceStartType>
- <ResourceStartPriority>2</ResourceStartPriority>
- <ResourceMinCount>_RESOURCE_MIN_COUNT_</ResourceMinCount>
- <ResourceMaxCount>_RESOURCE_MAX_COUNT_</ResourceMaxCount>
- <ResourceSWMComponent>com.att.authz:_ARTIFACT_ID_</ResourceSWMComponent>
- <ResourceSWMComponentVersion>_ARTIFACT_VERSION_</ResourceSWMComponentVersion>
- </ns2:ManagedResource>
-</ns2:ManagedResourceList>
diff --git a/authz-test/src/main/config/tc.devl b/authz-test/src/main/config/tc.devl deleted file mode 100644 index 5d3dcb04..00000000 --- a/authz-test/src/main/config/tc.devl +++ /dev/null @@ -1,16 +0,0 @@ -# Load Passwords needed -function aafcli { - java \ - -Daaf_id=testid \ - -Daaf_pass=<pass> \ - -Daaf_url=DMEServiceName=service=com.att.authz.AuthorizationService/version=_MAJOR_VER_._MINOR_VER_/envContext=_AFT_ENVIRONMENT_/routeOffer=_ROUTE_OFFER_ \ - -DAFT_LATITUDE=_AFT_LATITUDE_ \ - -DAFT_LONGITUDE=_AFT_LONGITUDE_ \ - -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ \ - -Dtestid=<pass> \ - -Dbogus=xxx \ - -Dm12345=<pass> \ - -jar \ - /Volumes/Data/src/authz/authz-cmd/target/authz-cmd-2.0.2-SNAPSHOT-jar-with-dependencies.jar \ - $* -} diff --git a/authz-test/src/main/scripts/cmds b/authz-test/src/main/scripts/cmds deleted file mode 100644 index ae44312b..00000000 --- a/authz-test/src/main/scripts/cmds +++ /dev/null @@ -1,20 +0,0 @@ -# /bin/bash -. ~/.bashrc -function failed { - echo "FAILED TEST! " $* - exit 1 -} - -if [ "$1" != "" ] ; then - for FILE in TestCases/$1/[0-9]*; do - echo "*** "$FILE" ***" - cat $FILE - echo - done -else - echo "Usage: cmds <TestCase>" -fi - - - -exit 0 diff --git a/authz-test/src/main/scripts/copy b/authz-test/src/main/scripts/copy deleted file mode 100644 index 59e86bf9..00000000 --- a/authz-test/src/main/scripts/copy +++ /dev/null @@ -1,17 +0,0 @@ -# /bin/bash -if [ "$2" != "" ] ; then - if [ -e $2 ]; then - echo "$2 exists, copy aborted" - exit 1 - fi - mkdir -p TestCases/$2 - for FILE in TestCases/$1/*; do - FILE2=`echo $FILE | sed -e "s/$1/$2/"` - echo $FILE2 - sed -e "s/$1/$2/g" $FILE > $FILE2 - done -else - echo 'Usage: copy <Source TestCase> <Target TestCase>' -fi - -exit 0 diff --git a/authz-test/src/main/scripts/csv b/authz-test/src/main/scripts/csv deleted file mode 100644 index e8712ce3..00000000 --- a/authz-test/src/main/scripts/csv +++ /dev/null @@ -1,14 +0,0 @@ -# /bin/bash -cd TestCases -if [ "$1" == "" ]; then - DIRS=`ls -d TC*` -else - DIRS=$1 -fi - -echo '"Test Case","Description"' -for DIR in $DIRS; do - grep -h "^# $DIR" $DIR/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ /,"/' -e 's/$/"/' -done -cd .. -exit 0 diff --git a/authz-test/src/main/scripts/rpt1 b/authz-test/src/main/scripts/rpt1 deleted file mode 100644 index 61d149da..00000000 --- a/authz-test/src/main/scripts/rpt1 +++ /dev/null @@ -1,23 +0,0 @@ -# /bin/bash -if [ "$1" == "" ]; then - echo "Usage: rpt1 <TestCase>" - exit 1 -fi - -cd TestCases -echo "**" -echo "** TC Group: $1" -echo "** Date : "`date` -echo "** By : "`who | cut -d " " -f 1` -echo "**" -echo "" -echo "-- Description --" -cat $1/Description -echo -- Positive Cases -- -grep -h "^# $1.*OK " $1/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' -echo -echo -- Negative Cases -- -grep -h "^# $1.*FAIL " $1/[0-9]* | cut -d ' ' -f 2- | sed -e 's/ / /' - -cd .. -exit 0 diff --git a/authz-test/src/main/scripts/rpt2 b/authz-test/src/main/scripts/rpt2 deleted file mode 100644 index 2c6b6f72..00000000 --- a/authz-test/src/main/scripts/rpt2 +++ /dev/null @@ -1,12 +0,0 @@ -# /bin/bash -if [ "$1" == "" ]; then - echo "Usage: rpt2 <TestCase>" - exit 1 -fi - -bin/rpt1 TC_NS1 -echo "" -echo "-- Results" -echo "" -bin/tc TC_NS1 - diff --git a/authz-test/src/main/scripts/tc b/authz-test/src/main/scripts/tc deleted file mode 100644 index 11258490..00000000 --- a/authz-test/src/main/scripts/tc +++ /dev/null @@ -1,37 +0,0 @@ -# /bin/bash -mkdir -p runs -function failed { - echo "FAILED TEST! $*" - exit 1 -} - -if [ "$1" == "" ]; then - DIRS=`find TestCases -type d -name "TC_*" -maxdepth 1 | sed "s/^TestCases\///"` - if [ "$DIRS" == "" ] ; then - echo "Usage: tc <TestCase> [expected]" - echo " expected - create the expected response for future comparison" - exit 1 - fi -else - DIRS=$1 - shift -fi - -for TC in $DIRS; do - if [ "$1" = "expected" ]; then - SUFFIX=$1 - cat TestCases/$TC/[0-9]* | aafcli -i 2>&1 | tee TestCases/expected/$TC.$SUFFIX - elif [ -d "TestCases/$TC" ]; then - SUFFIX=`date "+%Y-%m-%d_%H:%M:%S"` - cat TestCases/$TC/[0-9]* | aafcli -i 2>&1 | tee runs/$TC.$SUFFIX > /dev/null - - diff runs/$TC.$SUFFIX TestCases/expected/$TC.expected || failed "[$TC.$SUFFIX]" - echo "SUCCESS! [$TC.$SUFFIX]" - else - echo missed dir -exit - cat $TC | aafcli -i - fi -done - -exit 0 diff --git a/authz-test/src/main/swm/common/deinstall.sh b/authz-test/src/main/swm/common/deinstall.sh deleted file mode 100644 index 740564ce..00000000 --- a/authz-test/src/main/swm/common/deinstall.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh
-##############################################################################
-# - Copyright 2012, 2016 AT&T Intellectual Properties
-############################################################################## -umask 022
-ROOT_DIR=${INSTALL_ROOT}/${distFilesRootDirPath}
-
-# Grab the IID of all resources running under the name and same version(s) we're working on and stop those instances
-${LRM_HOME}/bin/lrmcli -running | \
- grep ${artifactId} | \
- grep ${version} | \
- cut -f1 | \
-while read _iid
-do
- if [ -n "${_iid}" ]; then
- ${LRM_HOME}/bin/lrmcli -shutdown -iid ${_iid} | grep SUCCESS
- if [ $? -ne 0 ]; then
- echo "$LRMID-{_iid} Shutdown failed"
- fi
- fi
-done
-
-# Grab the resources configured under the name and same version we're working on and delete those instances
-${LRM_HOME}/bin/lrmcli -configured | \
- grep ${artifactId} | \
- grep ${version} | \
- cut -f1,2,3 | \
-while read _name _version _routeoffer
-do
- if [ -n "${_name}" ]; then
- ${LRM_HOME}/bin/lrmcli -delete -name ${_name} -version ${_version} -routeoffer ${_routeoffer} | grep SUCCESS
- if [ $? -ne 0 ]; then
- echo "${_version} Delete failed"
- fi
- fi
-done
-
-rm -rf ${ROOT_DIR}
-
-exit 0
diff --git a/authz-test/src/main/swm/common/install.sh b/authz-test/src/main/swm/common/install.sh deleted file mode 100644 index 0c38612d..00000000 --- a/authz-test/src/main/swm/common/install.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh -############################################################################## -# - Copyright 2012, 2016 AT&T Intellectual Properties -############################################################################## -umask 022 -ROOT_DIR=${INSTALL_ROOT}/${distFilesRootDirPath} -LOGGING_PROP_FILE=${ROOT_DIR}/etc/log4j.properties -RUN_FILE=${ROOT_DIR}/etc/tconn.sh - -cd ${ROOT_DIR} - -mkdir -p logs || fail 1 "Error on creating the logs directory." -mkdir -p back || fail 1 "Error on creating the back directory." -chmod 777 back || fail 1 "Error on creating the back directory." - -# -# Some Functions that Vastly cleanup this install file... -# You wouldn't believe how ugly it was before. Unreadable... JG -# -fail() { - rc=$1 - shift; - echo "ERROR: $@" - exit $rc -} - -# -# Set the "SED" replacement for this Variable. Error if missing -# Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_ -# Replacement Name -# Value -# -required() { - if [ -z "$2" ]; then - ERRS+="\n\t$1 must be set for this installation" - fi - SED_E+=" -e s|$1|$2|g" -} - -# -# Set the "SED" replacement for this Variable. Use Default (3rd parm) if missing -# Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_ -# Replacement Name -# Value -# Default Value -# -default() { - if [ -z "$2" ]; then - SED_E+=" -e s|$1|$3|g" - else - SED_E+=" -e s|$1|$2|g" - fi -} - -# Linux requires this. Mac blows with it. Who knows if Windoze even does SED -if [ -z "$SED_OPTS" ]; then - SED_E+=" -c " -else - SED_E+=$SED_OPTS; -fi - - -# -# Use "default" function if there is a property that isn't required, but can be defaulted -# use "required" function if the property must be set by the environment -# - required _ROOT_DIR_ ${ROOT_DIR} - default _COMMON_DIR_ ${COMMON_DIR} ${ROOT_DIR}/../../common - required _AFT_ENVIRONMENT_ ${AFT_ENVIRONMENT} - required _ENV_CONTEXT_ ${ENV_CONTEXT} - required _HOSTNAME_ ${HOSTNAME} - required _ARTIFACT_ID_ ${artifactId} - required _ARTIFACT_VERSION_ ${version} - - # Specifics for Service - if [ "${artifactId}" = "authz-service" ]; then - default _AUTHZ_SERVICE_PORT_ ${PORT} 0 - required _AUTHZ_CASS_CLUSTERS_ ${AUTHZ_CASS_CLUSTERS} - required _AUTHZ_CASS_PORT_ ${AUTHZ_CASS_PORT} - required _AUTHZ_CASS_PWD_ ${AUTHZ_CASS_PWD} - default _AUTHZ_CASS_USER_ ${AUTHZ_CASS_USER} authz - required _AUTHZ_KEYSTORE_PASSWORD_ ${AUTHZ_KEYSTORE_PASSWORD} - required _AUTHZ_KEY_PASSWORD_ ${AUTHZ_KEY_PASSWORD} - required _SCLD_PLATFORM_ ${SCLD_PLATFORM} - fi - - default _EMAIL_FROM_ ${EMAIL_FROM} authz@ems.att.com - default _EMAIL_HOST_ ${EMAIL_HOST} mailhost.att.com - default _ROUTE_OFFER_ ${ROUTE_OFFER} BAU_SE - default _DME_TIMEOUT_ ${DME_TIMEOUT} 3000 - - # Choose defaults for log level and logfile size - if [ "${SCLD_PLATFORM}" = "PROD" ]; then - LOG4J_LEVEL=WARN - fi - default _LOG4J_LEVEL_ ${LOG4J_LEVEL} INFO - default _LOG4J_SIZE_ ${LOG4J_SIZE} 10000KB - default _LOG_DIR_ ${LOG_DIR} ${ROOT_DIR}/logs - default _MAX_LOG_FILE_SIZE_ ${MAX_LOG_FILE_SIZE} 10000KB - default _MAX_LOG_FILE_BACKUP_COUNT_ ${MAX_LOG_FILE_BACKUP_COUNT} 7 - default _RESOURCE_MIN_COUNT_ ${RESOURCE_MIN_COUNT} 1 - default _RESOURCE_MAX_COUNT_ ${RESOURCE_MAX_COUNT} 1 - - required _LOGGING_PROP_FILE_ ${LOGGING_PROP_FILE} - required _AFT_LATITUDE_ ${LATITUDE} - required _AFT_LONGITUDE_ ${LONGITUDE} - required _HOSTNAME_ ${HOSTNAME} - - # Divide up Version - default _MAJOR_VER_ "`expr ${version} : '\([0-9]*\)\..*'`" - default _MINOR_VER_ "`expr ${version} : '[0-9]*\.\([0-9]*\)\..*'`" - default _PATCH_VER_ "`expr ${version} : '[0-9]\.[0-9]*\.\(.*\)'`" - - - -# Now Fail if Required items are not set... -# Report all of them at once! -if [ "${ERRS}" != "" ] ; then - fail 1 "${ERRS}" -fi - -#echo ${SED_E} - -for i in ${PROPERTIES_FILE} ${LRM_XML} ${LOGGING_PROP_FILE} ${RUN_FILE} ; do - if [ -r ${i} ]; then - if [ -w ${i} ]; then -# echo ${i} - sed ${SED_E} -i'.sed' ${i} || fail 8 "could not sed ${i} " - mv -f ${i}.sed ${ROOT_DIR}/back - fi - fi -done - -# -# Add the resource to LRM using the newly created/substituted XML file. -# -# Note: No LRM for authz-test -#if [ -r ${LRM_XML} ]; then -# ${LRM_HOME}/bin/lrmcli -addOrUpgrade -file ${LRM_XML} || fail 1 "Add to LRM Failed" -# ${LRM_HOME}/bin/lrmcli -start -name com.att.authz.${artifactId} -version ${version} -routeoffer ${ROUTE_OFFER} | grep SUCCESS -#fi -# -# Note: Must exit 0 or, it will be exit default 1 and fail -exit 0 diff --git a/authz-test/src/main/swm/deinstall/postproc/post_proc b/authz-test/src/main/swm/deinstall/postproc/post_proc deleted file mode 100644 index beec0a2a..00000000 --- a/authz-test/src/main/swm/deinstall/postproc/post_proc +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### -#!/bin/sh -exit 0
\ No newline at end of file diff --git a/authz-test/src/main/swm/deinstall/preproc/pre_proc b/authz-test/src/main/swm/deinstall/preproc/pre_proc deleted file mode 100644 index 2a6a5292..00000000 --- a/authz-test/src/main/swm/deinstall/preproc/pre_proc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec sh -x ../../common/deinstall.sh diff --git a/authz-test/src/main/swm/descriptor.xml b/authz-test/src/main/swm/descriptor.xml deleted file mode 100644 index 625ed2d7..00000000 --- a/authz-test/src/main/swm/descriptor.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<!--
- ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * 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====================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
--->
-<descriptor version="1" xmlns="http://aft.att.com/swm/descriptor">
- <platforms>
- <platform architecture="*" os="*" osVersions="*"/>
- </platforms>
- <paths>
- <path name="/opt/app/aft/auth/${artifactId}/${version}" type="d" user="aft" group="aft" permissions="0755" recursive="true"/>
- </paths>
- <actions>
- <action type="INIT">
- <proc stage="PRE" user="aft" group="aft"/>
- <proc stage="POST" user="aft" group="aft"/>
- </action>
- <action type="INST">
- <proc stage="PRE" user="aft" group="aft"/>
- <proc stage="POST" user="aft" group="aft"/>
- </action>
- <action type="DINST">
- <proc stage="PRE" user="aft" group="aft"/>
- <proc stage="POST" user="aft" group="aft"/>
- </action>
- <action type="FALL">
- <proc stage="PRE" user="aft" group="aft"/>
- <proc stage="POST" user="aft" group="aft"/>
- </action>
- </actions>
-</descriptor>
diff --git a/authz-test/src/main/swm/fallback/postproc/post_proc b/authz-test/src/main/swm/fallback/postproc/post_proc deleted file mode 100644 index 3eb8e6d0..00000000 --- a/authz-test/src/main/swm/fallback/postproc/post_proc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh
-######################################################################
-# $RCSfile$ - $Revision$
-# Copyright 2012 AT&T Intellectual Property. All rights reserved.
-######################################################################
-exec sh -x ../../common/install.sh
\ No newline at end of file diff --git a/authz-test/src/main/swm/fallback/preproc/pre_proc b/authz-test/src/main/swm/fallback/preproc/pre_proc deleted file mode 100644 index 08958477..00000000 --- a/authz-test/src/main/swm/fallback/preproc/pre_proc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### -exit 0
\ No newline at end of file diff --git a/authz-test/src/main/swm/initinst/postproc/post_proc b/authz-test/src/main/swm/initinst/postproc/post_proc deleted file mode 100644 index 1f27b41f..00000000 --- a/authz-test/src/main/swm/initinst/postproc/post_proc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### -exec sh -x ../../common/install.sh diff --git a/authz-test/src/main/swm/initinst/preproc/pre_proc b/authz-test/src/main/swm/initinst/preproc/pre_proc deleted file mode 100644 index beec0a2a..00000000 --- a/authz-test/src/main/swm/initinst/preproc/pre_proc +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### -#!/bin/sh -exit 0
\ No newline at end of file diff --git a/authz-test/src/main/swm/install/postproc/post_proc b/authz-test/src/main/swm/install/postproc/post_proc deleted file mode 100644 index 4cdbce1b..00000000 --- a/authz-test/src/main/swm/install/postproc/post_proc +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### - -exec sh -x ../../common/install.sh diff --git a/authz-test/src/main/swm/install/preproc/pre_proc b/authz-test/src/main/swm/install/preproc/pre_proc deleted file mode 100644 index 807ebdc2..00000000 --- a/authz-test/src/main/swm/install/preproc/pre_proc +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -###################################################################### -# $RCSfile$ - $Revision$ -# Copyright 2012 AT&T Intellectual Property. All rights reserved. -###################################################################### - -exit 0 diff --git a/authz-test/src/main/swm/packageNotes.txt b/authz-test/src/main/swm/packageNotes.txt deleted file mode 100644 index cc8c7ee8..00000000 --- a/authz-test/src/main/swm/packageNotes.txt +++ /dev/null @@ -1,32 +0,0 @@ -#-------------------------------------------------------------------------------
-# ============LICENSE_START====================================================
-# * org.onap.aaf
-# * ===========================================================================
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# * ===========================================================================
-# * 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====================================================
-# *
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# *
-#-------------------------------------------------------------------------------
-The following two commands can be used to create and approve a SWM installation package.
-
-These steps assume:
- 1. The component has been added in SWM
- 2. The java6 directory resides, by itself, under the directory '${artifactId}-${version}'
- 3. The SWM client is executed from the same directory containing '${artifactId}-${version}'
-
-
- attuid@swmcli- --> component pkgcreate -c ${groupId}:${artifactId}:${version} -d ${artifactId}-${version}
- attuid@swmcli- --> component pkgapprove -c ${groupId}:${artifactId}:${version}
diff --git a/dme2reg/service=org.onap.aaf.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE.txt b/dme2reg/service=org.onap.aaf.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE.txt deleted file mode 100644 index b88df64e..00000000 --- a/dme2reg/service=org.onap.aaf.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE.txt +++ /dev/null @@ -1,8 +0,0 @@ -# -#Wed Nov 30 23:48:45 EST 2016 -alcdtl15rj6015,60498=latitude\=32.78014;longitude\=-96.800451;lease\=1480372013837;protocol\=http;contextPath\=/;routeOffer\=BAU_SE -ALCDTL46RJ6015,55998=latitude\=32.78014;longitude\=-96.800451;lease\=1479687428093;protocol\=http;contextPath\=/;routeOffer\=BAU_SE -localhost,42246=latitude\=32.78014;longitude\=-96.800451;lease\=1478985613892;protocol\=http;contextPath\=/;routeOffer\=BAU_SE -localhost,39157=latitude\=32.78014;longitude\=-96.800451;lease\=1478811101528;protocol\=http;contextPath\=/;routeOffer\=BAU_SE -alcdtl15rj6015,55889=latitude\=32.78014;longitude\=-96.800451;lease\=1480371829514;protocol\=http;contextPath\=/;routeOffer\=BAU_SE -localhost,36473=latitude\=32.78014;longitude\=-96.800451;lease\=1478801682319;protocol\=http;contextPath\=/;routeOffer\=BAU_SE diff --git a/misc/.gitignore b/misc/.gitignore new file mode 100644 index 00000000..0c2b833e --- /dev/null +++ b/misc/.gitignore @@ -0,0 +1,2 @@ +/.settings/ +/.project diff --git a/misc/env/.gitignore b/misc/env/.gitignore new file mode 100644 index 00000000..51037e60 --- /dev/null +++ b/misc/env/.gitignore @@ -0,0 +1,5 @@ +/target/ +/.classpath +/.settings/ +/target/ +/.project diff --git a/misc/env/pom.xml b/misc/env/pom.xml new file mode 100644 index 00000000..e724f8ef --- /dev/null +++ b/misc/env/pom.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<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.onap.aaf.misc</groupId> + <artifactId>parent</artifactId> + <version>1.3.0-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>aaf-misc-env</artifactId> + <name>AAF Misc Env</name> + <packaging>jar</packaging> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>compile</scope> <!-- Provides scope only, in case other users prefer another Logging Implementation --> + </dependency> + </dependencies> +</project> + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java b/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java new file mode 100644 index 00000000..2b663450 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/APIException.java @@ -0,0 +1,89 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +/** + * An Exception with the ability to hold a payload.<p> + * + * This is important, because sometimes, the output of a Framework + * may be a descriptive object which doesn't inherit from Throwable + * and thus cannot be attached in "initCause".<p> + * + * Examples may be a SOAP Fault. + * + * @author Jonathan + * + */ +public class APIException extends Exception { + + private Object payload = null; + + /** + * @param t + */ + public APIException(Throwable t) { + super(t); + } + + /** + * @param string + */ + public APIException(String string) { + super(string); + } + + /** + * @param errorMessage + * @param t + */ + public APIException(String errorMessage, Throwable t) { + super(errorMessage,t); + } + + /** + * Return payload, or null if none was set. Type is up to the calling + * System. + * + * @return Object + */ + public Object getPayload() { + return payload; + } + + /** + * Set a specific payload into this Exception, which doesn't necessarily + * inherit from Throwable. + * + * @param payload + * @return APIException + */ + public APIException setPayload(Object payload) { + this.payload = payload; + return this; + } + + /** + * Java expected serial ID + */ + private static final long serialVersionUID = 3505343458251445169L; +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java new file mode 100644 index 00000000..4750b3ef --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/BaseDataFactory.java @@ -0,0 +1,478 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.xml.XMLConstants; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchema; +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.onap.aaf.misc.env.impl.EnvFactory; +import org.xml.sax.SAXException; + + + +/** + * DataFactory Constructor will create the Stringifiers and Objectifiers necessary + * by Type and store the Class of the Type for quick creation of Data Objects + * with reused (and thread safe) components + * s + * Native Types are included. + * Those types covered by Env Implementation are covered dynamically. + * Types outside of Env mechanism can be added with "add" function + * + * @author Jonathan + * + * @param <T> + */ +public class BaseDataFactory { + + /** + * Generate a Schema Object for use in validation based on FileNames. + * + * WARNING: The java.xml.binding code requires YOU to figure out what order the + * files go in. If there is an import from A in B, then you must list A first. + * + * @param err + * @param filenames + * @return + * @throws APIException + */ + public static Schema genSchema(Store env, String ... filenames) throws APIException { + String schemaDir = env.get( + env.staticSlot(EnvFactory.SCHEMA_DIR), + EnvFactory.DEFAULT_SCHEMA_DIR); + File dir = new File(schemaDir); + if(!dir.exists())throw new APIException("Schema Directory " + schemaDir + " does not exist. You can set this with " + EnvFactory.SCHEMA_DIR + " property"); + FileInputStream[] fis = new FileInputStream[filenames.length]; + Source[] sources = new Source[filenames.length]; + File f; + for(int i=0; i<filenames.length; ++i) { + if(!(f=new File(schemaDir + File.separatorChar + filenames[i])).exists()) { + if(!f.exists()) throw new APIException("Cannot find " + f.getName() + " for schema validation"); + } + try { + fis[i]=new FileInputStream(f); + } catch (FileNotFoundException e) { + throw new APIException(e); + } + sources[i]= new StreamSource(fis[i]); + } + try { + //Note: SchemaFactory is not reentrant or very thread safe either... see docs + synchronized(XMLConstants.W3C_XML_SCHEMA_NS_URI) { // SchemaFactory is not reentrant + return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) + .newSchema(sources); + } + } catch (SAXException e) { + throw new APIException(e); + } finally { + for(FileInputStream d : fis) { + try { + d.close(); + } catch (IOException e) { + // Never mind... we did our best + } + } + } + + } + + public static QName getQName(Class<?> clss) throws APIException { + // Obtain the Necessary info for QName from Requirement + XmlRootElement xre = clss.getAnnotation(XmlRootElement.class); + if(xre==null)throw new APIException(clss.getName() + " does not have an XmlRootElement annotation"); + Package pkg = clss.getPackage(); + XmlSchema xs = pkg.getAnnotation(XmlSchema.class); + if(xs==null) throw new APIException(clss.getName() + " package-info does not have an XmlSchema annotation"); + return new QName(xs.namespace(),xre.name()); + } + + ///////////////////////////////////////////// + // Native Type Converters + ///////////////////////////////////////////// +// /** +// * StringStringifier +// * +// * Support the Native Type String.. just return it back +// * +// * @author Jonathan +// * +// */ +// public static class StringStringifier extends NullLifeCycle implements Stringifier<String> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, String input) throws APIException { +// return input; +// } +// }; +// +// /** +// * StringObjectifier +// * +// * Support the Native Type String.. just return it back +// * +// * @author Jonathan +// * +// */ +// public static class StringObjectifier extends NullLifeCycle implements Objectifier<String> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public String objectify(Env env, String input) throws APIException { +// return input; +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public String newInstance() throws APIException { +// return ""; +// } +// }; +// +// /** +// * LongStringifier +// * +// * Support the Native Type Long.. use Long parse functions +// * +// * @author Jonathan +// * +// */ +// public static class LongStringifier extends NullLifeCycle implements Stringifier<Long> { +// public String stringify(Env env, Long input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * LongObjectifier +// * +// * Support the Native Type Long.. use Long parse functions +// * +// * @author Jonathan +// * +// */ +// public static class LongObjectifier extends NullLifeCycle implements Objectifier<Long> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Long objectify(Env env, String input) throws APIException { +// try { +// return new Long(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Long\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Long newInstance() throws APIException { +// return 0L; +// } +// } +// +// /** +// * IntegerStringifier +// * +// * Support the Native Integer.. use Integer parse functions +// * +// * @author Jonathan +// * +// */ +// public static class IntegerStringifier extends NullLifeCycle implements Stringifier<Integer> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, Integer input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * IntegerObjectifier +// * +// * Support the Native Integer.. use Integer parse functions +// * +// * @author Jonathan +// * +// */ +// public static class IntegerObjectifier extends NullLifeCycle implements Objectifier<Integer> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Integer objectify(Env env, String input) throws APIException { +// try { +// return new Integer(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Integer\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Integer newInstance() throws APIException { +// return 0; +// } +// } +// +// /** +// * ShortStringifier +// * +// * Support the Native Short.. use Short parse functions +// * +// * @author Jonathan +// * +// */ +// public static class ShortStringifier extends NullLifeCycle implements Stringifier<Short> { +// public String stringify(Env env, Short input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * ShortObjectifier +// * +// * Support the Native Short.. use Short parse functions +// * +// * @author Jonathan +// * +// */ +// public static class ShortObjectifier extends NullLifeCycle implements Objectifier<Short> { +// public Short objectify(Env env, String input) throws APIException { +// try { +// return new Short(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Short\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// public Short newInstance() throws APIException { +// return 0; +// } +// } +// +// /** +// * ByteStringifier +// * +// * Support the Native Byte.. use Byte parse functions +// * +// * @author Jonathan +// * +// */ +// public static class ByteStringifier extends NullLifeCycle implements Stringifier<Byte> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, Byte input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * ByteObjectifier +// * +// * Support the Native Byte.. use Byte parse functions +// * +// * @author Jonathan +// * +// */ +// public static class ByteObjectifier extends NullLifeCycle implements Objectifier<Byte> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Byte objectify(Env env, String input) throws APIException { +// try { +// return new Byte(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Byte\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Byte newInstance() throws APIException { +// return 0; +// } +// } +// +// /** +// * CharacterStringifier +// * +// * Support the Native Character.. use Character parse functions +// * +// * @author Jonathan +// * +// */ +// public static class CharacterStringifier extends NullLifeCycle implements Stringifier<Character> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, Character input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * CharacterObjectifier +// * +// * Support the Native Character.. use Character parse functions +// * +// * @author Jonathan +// * +// */ +// public static class CharacterObjectifier extends NullLifeCycle implements Objectifier<Character> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Character objectify(Env env, String input) throws APIException { +// int length = input.length(); +// if(length<1 || length>1) { +// throw new APIException("String [" + input + "] does not represent a single Character"); +// } +// return input.charAt(0); +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Character newInstance() throws APIException { +// return 0; +// } +// } +// +// /** +// * FloatStringifier +// * +// * Support the Native Float.. use Float parse functions +// * +// * @author Jonathan +// * +// */ +// public static class FloatStringifier extends NullLifeCycle implements Stringifier<Float> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, Float input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * FloatObjectifier +// * +// * Support the Native Float.. use Float parse functions +// * +// * @author Jonathan +// * +// */ +// public static class FloatObjectifier extends NullLifeCycle implements Objectifier<Float> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Float objectify(Env env, String input) throws APIException { +// try { +// return new Float(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Float\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Float newInstance() throws APIException { +// return 0.0f; +// } +// } +// +// /** +// * DoubleStringifier +// * +// * Support the Native Double.. use Double parse functions +// * +// * @author Jonathan +// * +// */ +// public static class DoubleStringifier extends NullLifeCycle implements Stringifier<Double> { +// /* (non-Javadoc) +// * @see com.att.env.Stringifier#stringify(com.att.env.Env, java.lang.Object) +// */ +// public String stringify(Env env, Double input) throws APIException { +// return input.toString(); +// } +// } +// +// /** +// * DoubleObjectifier +// * +// * Support the Native Double.. use Double parse functions +// * +// * @author Jonathan +// * +// */ +// public static class DoubleObjectifier extends NullLifeCycle implements Objectifier<Double> { +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#objectify(com.att.env.Env, java.lang.String) +// */ +// public Double objectify(Env env, String input) throws APIException { +// try { +// return new Double(input); +// } catch (Exception e) { +// APIException ae = new APIException("Cannot create a \"Double\" from [" + input + ']'); +// ae.initCause(e); +// throw ae; +// } +// } +// +// /* (non-Javadoc) +// * @see com.att.env.Objectifier#newObject() +// */ +// public Double newInstance() throws APIException { +// return 0.0; +// } +// } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java new file mode 100644 index 00000000..995819e9 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Creatable.java @@ -0,0 +1,52 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +/** + * <h1>Creatable</h1> + * <b>**Must implement constructor T(ENV env, long currentTimeMillis);**</b><p> + * + * This interface exists to cover basic LifeCycle semantics so that Objects + * can be created dynamically and managed at a basic level (destroy(env)). + * + * @author Jonathan + * + * @param <T> + */ +public interface Creatable<T> { + /** + * Return the timestamp (Unix long) when this object was created.<p> + * This can be used to see if the object is out of date in certain + * circumstances, or perhaps has already been notified in others. + * + * @return long + */ + public abstract long created(); + + /** + * Allow LifeCycle aware process to signal this element as destroyed. + * + * @param env + */ + public abstract void destroy(Env env); +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java new file mode 100644 index 00000000..2c24cb12 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Data.java @@ -0,0 +1,113 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +/** + * <H1>Data</H1> + * <i>Data</i> facilitates lazy marshaling of data with a pre-determined + * marshaling mechanism.<p> + * + * It stores either Object (defined by Generic {@literal <T>}) or String.<p> + * + * On asking for Object of type {@literal <T>}, it will respond with the object + * if it exists, or unmarshal the string and pass the result back.<p> + * + * On asking for String, it will respond with the String + * if it exists, or marshal the String and pass the result back.<p> + * + * the "options" available on several functions control the output of this particular call. When + * blank, they will default to the DataFactory defaults. When present, they override this + * particular call. + * The available options are "pretty" (for XML and JSON) and "fragment" (XML only concept), which drops + * the "<?xml ...?>" header so you can create larger XML documents from the output. + * + * @author Jonathan + * + * @param <T> + */ +public interface Data<T> { + static enum TYPE {XML,JSON,JAXB,RAW,DEFAULT}; + // can & with 0xFFFF; +// public static final int XML = 0x1; +// public static final int JSON = 0x2; +// public static final int JAXB = 0x4; +// public static final int RAW = 0x1000; + + // can & with 0xF00000; + public static final int PRETTY = 0x100000; + public static final int FRAGMENT = 0x200000; + + /** + * Respond with the String if it exists, or marshal the String and pass the result back. + * + * However, use the Env the Data Object was created with. + * + * @return String + * @throws APIException + */ + public String asString() throws APIException; + + /** + * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String + * and pass the result back.<p> + * + * However, use the Env the Data Object was created with. + * + * @return T + * @throws APIException + */ + public T asObject() throws APIException; + + /** + * Set a particular option on an existing Out + * + * if int is negative, it should remove the option + * @param option + */ + public Data<T> option(int option); + + public Data<T> to(OutputStream os) throws APIException, IOException; + public Data<T> to(Writer writer) throws APIException, IOException; + + public Data<T> load(T t) throws APIException; + public Data<T> load(String str) throws APIException; + public Data<T> load(InputStream is) throws APIException; + public Data<T> load(Reader rdr) throws APIException; + + public Data<T> in(TYPE type); + public Data<T> out(TYPE type); + /** + * Return the Class Type supported by this DataObject + * + * @return {@literal Class<T>} + */ + public Class<T> getTypeClass(); + + public void direct(InputStream input, OutputStream output) throws APIException, IOException; + + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java new file mode 100644 index 00000000..4ce7eaf9 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/DataFactory.java @@ -0,0 +1,30 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +public interface DataFactory<T> { + public abstract Data<T> newData(); + public abstract Data<T> newData(Env trans); // and Env or Trans object + public abstract Class<T> getTypeClass(); +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java new file mode 100644 index 00000000..039cb2f4 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Decryptor.java @@ -0,0 +1,34 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +public interface Decryptor { + public String decrypt(String tag); + + public static final Decryptor NULL = new Decryptor() { + @Override + public String decrypt(String tag) { + return tag; + } + }; +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java new file mode 100644 index 00000000..9e621136 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Encryptor.java @@ -0,0 +1,34 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +public interface Encryptor { + public String encrypt(String data); + + public static final Encryptor NULL = new Encryptor() { + @Override + public String encrypt(String data) { + return data; + } + }; +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java new file mode 100644 index 00000000..71f79222 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Env.java @@ -0,0 +1,136 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +/** + * <H1>Env</H1> + * <i>Env</i> is the basic representation of what can be obtained from the + * Environment. Environments also need the ability to Log and Track Time, so + * to keep the interfaces clean, Env Interface inherits from Trans. This does NOT + * mean that all Environments are Transactions... It only means Environments need + * to Log and Track Times. + * .<p> + * + * Using this abstraction, Components can be built on a modular basis, + * and still have the essentials of functioning within the service mechanism.<p> + * + * Thus, for instance, an Module could be made to work in two separate + * service types, with substantial differences in choices of logging, or auditing, + * and still have reasonably deep insight, such as the exact time a + * remote service was invoked.<p> + * + * There is a bit of an assumption corresponding to the reality of the 2000s that + * XML plays a part in most service work. + * + * @author Jonathan + * + */ +public interface Env { + /** + * Very Severe Error may cause program to abort + */ + public LogTarget fatal(); + + /** + * Severe Error, but program might continue running + */ + public LogTarget error(); + + /** + * Required Audit statements + * @return + */ + public LogTarget audit(); + + /** + * Initialization steps... Allows a Logger to separate startup info + * @return + */ + public LogTarget init(); + + /** + * Potentially harmful situations + * @return + */ + public LogTarget warn(); + + /** + * Course Grained highlights of program progress + * @return + */ + public LogTarget info(); + + /** + * Fine-grained informational events useful for debugging + * @return + */ + public LogTarget debug(); + + /** + * Finest grained Informational events... more detailed than Debug + * @return + */ + public LogTarget trace(); + + + /** + * Basic and Common Audit info... + * + * Note Apps can define, but should use Integers after 0x1F. They can combine with "&" + */ + public static final int REMOTE = 0x01; + public static final int XML = 0x02; + public static final int JSON = 0x04; + public static final int SUB = 0x08; + public static final int CHECKPOINT = 0x10; + public static final int ALWAYS = 0x20; // Mark as a line to print, even in WARN+ mode + + + + /** + * Start a Time Trail with differentiation by flag. This can be Defined By above flags or combined with + * app flag definitions + * + * @param string + * @param flag + * @return + */ + public TimeTaken start(String name, int flag); + + public String setProperty(String tag, String value); + public String getProperty(String tag); + public String getProperty(String tag, String deflt); + + /** + * Passwords should be encrypted on the disk. Use this method to apply decryption before + * using. The Implementation should give ways to decrypt + * + * @param tag + * @return + */ + public Decryptor decryptor(); + + public Encryptor encryptor(); + +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java new file mode 100644 index 00000000..27f423b0 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXB.java @@ -0,0 +1,52 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +public interface EnvJAXB extends EnvStore<TransJAXB> { + /** + * Obtain a DataInterface from this Environment + * + * @param <T> + * @param classes + * @return + * @throws APIException + */ + public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException; + + /** + * Obtain a DataInterface from this Environment, with Validating Schema + * + * @param <T> + * @param classes + * @return + * @throws APIException + */ + public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException; + + public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException; + + public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException; + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXBProps.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXBProps.java new file mode 100644 index 00000000..1aba7465 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvJAXBProps.java @@ -0,0 +1,31 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +/** + * An interface to express both JAXB and Property elements of Env + * @author Jonathan + * + */ +public interface EnvJAXBProps extends EnvJAXB, EnvProps { + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java new file mode 100644 index 00000000..2bfc027b --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvProps.java @@ -0,0 +1,80 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.util.Map; + +public interface EnvProps extends Env { + public interface EnvProperty { + public String getProperty(String input); + }; + + /** + * Obtain a Property (String) based on a Key. Implementor decides how + * that works, i.e. from a complex set of Configurations, or just + * "System" (Java standard) + * + * @param key + * @return APIException + */ + public String getProperty(String key); + + /** + * Obtain a Property (String) based on a Key. Implementor decides how + * that works, i.e. from a complex set of Configurations, or just + * "System" (Java standard) + * + * If Property Value is null, then default will be used. + * @param key + * @return APIException + */ + public String getProperty(String tag, String defaultValue); + + /** + * Set a Property (String) based on a Key accessible to all in Env. Implementor decides how + * that works, i.e. from a complex set of Configurations, or just + * "System" (Java standard) + * + * @param key + * @return APIException + */ + public String setProperty(String key, String value); + + /** + * Get the SubProperties based on key. + * + * use "false" to remove prefix, "true" to leave prefix in. + * + * @param key + * @return APIException + * Given a known property set (or in this case, properties starting with key), + * return map of all properties with appropriate key names + */ + public Map<String, String> getSubProperties(String key, boolean includePrefix); + + /** + * Get all of the properties in the Environment + * @return + */ + public Map<String, String> getProperties(); + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/EnvStore.java b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvStore.java new file mode 100644 index 00000000..32dda01d --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/EnvStore.java @@ -0,0 +1,27 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + +public interface EnvStore<TRANS extends Trans> extends Env, Store, TransCreate<TRANS>{ + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java new file mode 100644 index 00000000..d4e28688 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/IOObjectifier.java @@ -0,0 +1,54 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.InputStream; +import java.io.Reader; + +public interface IOObjectifier<T> extends Objectifier<T> { + /** + * Marshal to Object T from a Reader, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, Reader rdr) throws APIException; + + /** + * Marshal to Object T from an InputStream, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, InputStream is) throws APIException; + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java new file mode 100644 index 00000000..1eab8db8 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/IOStringifier.java @@ -0,0 +1,74 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.OutputStream; +import java.io.Writer; + +/** + * Allow Extended IO interface usage without muddying up the Stringifier Interface + */ +public interface IOStringifier<T> extends Stringifier<T> { + /** + * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException; + + /** + * Marshal from a String to an Object T, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException; + + /** + * Set Pretty XML, where possible + * + * @param pretty + * @throws APIException + */ + public abstract IOStringifier<T> pretty(boolean pretty); + + /** + * Set Generate Fragment + * + * @param fragment + * @throws APIException + */ + public abstract IOStringifier<T> asFragment(boolean fragment); + + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java b/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java new file mode 100644 index 00000000..3e14511a --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/LifeCycle.java @@ -0,0 +1,123 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/** + * + * Created on: Aug 19, 2009 + * Created by: Jonathan + * + * (c) 2009 SBC Knowledge Ventures, L.P. All rights reserved. + ******************************************************************* + * RESTRICTED - PROPRIETARY INFORMATION The Information contained + * herein is for use only by authorized employees of AT&T Services, + * Inc., and authorized Affiliates of AT&T Services, Inc., and is + * not for general distribution within or outside the respective + * companies. + ******************************************************************* + */ +package org.onap.aaf.misc.env; + +import org.onap.aaf.misc.env.util.RefreshableThreadObject; + + +/** + * @author Jonathan + * + */ +public interface LifeCycle { + /** + * The Service using LifeCycle Elements is required to call this method at + * the appropriate startup time. This is better for services than a simple + * static call, because the exact moment of starting can be determined + * programatically. + * <p> + * + * An excellent use is to establish security credentials with a backend + * after appropriate configurations have been read and available as part of + * the {@link Env} Object. + * + * @param env + * @throws APIException + */ + public abstract void servicePrestart(Env env) throws APIException; + + /** + * Many cases of implementations are not thread safe, and mechanisms must be + * derived to accomodate them by holding per Thread. + * <p> + * + * {@link ThreadLocal} is a valuable resource, but start up times within the + * thread, depending on what it is, can be substantial. + * <p> + * + * Use ThreadPrestart to do all that is possible before actually performing + * work, i.e. inside of a client transaction. + * + * @param env + * @throws APIException + */ + public abstract void threadPrestart(Env env) throws APIException; + + /** + * The Service will call this when (service-defined) configurations change. + * <p> + * + * This mechanism allows the Service to recognize events, such as file + * changes, and pass on the event to all LifeCycle implementors. + * <p> + * + * The code should take the opportunity to evaluate configuration and change + * as necessary. + * <p> + * + * <h2>IMPORTANT:</h2> + * The LifeCycle implementor cannot guarantee it will not be in the middle + * of a transaction, so it would behoove the implementor to construct + * content that does not affect anything until finished, then apply to an + * appropriate atomic action (i.e. setting an Object to a field), or even + * synchronizing. + * + * If you are using Java's "ThreadLocal", consider + * {@link RefreshableThreadObject}, because it implements LifeCycle, and + * responds to the refresh command. + * + * @param env + * @throws APIException + */ + public abstract void refresh(Env env) throws APIException; + + /** + * Parallel to threadPrestart, threadDestroy tells the implementor that the + * service is ending this particular thread, and to take this opportunity to + * close out any content specific to this thread that can be closed. + * + * @param env + * @throws APIException + */ + public abstract void threadDestroy(Env env) throws APIException; + + /** + * Parallel to servicePrestart, serviceDestroy tells the implementor that + * the service is ending, and to take this opportunity to close out any + * content under it's control that can or should be closed explicitly. + */ + public abstract void serviceDestroy(Env env) throws APIException; +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java new file mode 100644 index 00000000..7ceaf953 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java @@ -0,0 +1,142 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.PrintStream; +import java.util.Date; + +import org.onap.aaf.misc.env.util.Chrono; + +/** + * LogTarget is the interface with which to assign any kind of Logging Implementations. + * + * Implement for any Logging Library of your choice, and for any logging string Format desired. + * + * Included are several Static Implementations for various uses: + * NULL: Does nothing with Logging Messages + * SYSOUT: Writes messages in general form to System Out + * SYSERR: Writes messages in general form to System Err + * + * @author Jonathan + * + */ +public interface LogTarget { + public abstract void log(Object... msgs); + public abstract void log(Throwable e, Object ... msgs); + public abstract boolean isLoggable(); + public abstract void printf(String fmt, Object ... vars); + + // A Convenient LogTarget to insert when a NO-OP is desired. + public static final LogTarget NULL = new LogTarget() { + public void log(Object ... msgs) { + } + + public void log(Throwable t, Object ... msgs) { + } + + public boolean isLoggable() { + return false; + } + + @Override + public void printf(String fmt, Object ... vars) { + } + }; + + // A Convenient LogTarget to write to the Console + public static final LogTarget SYSOUT = new LogTarget() { + public void log(Object ... msgs) { + PrintStream out = System.out; + out.print(org.onap.aaf.misc.env.util.Chrono.dateFmt.format(new Date())); + out.print(": "); + for(Object str : msgs) { + if(str!=null) { + out.print(str.toString()); + out.print(' '); + } else { + out.print("null "); + } + } + out.println(); + } + + public void log(Throwable t, Object ... msgs) { + PrintStream out = System.out; + out.print(Chrono.dateFmt.format(new Date())); + out.print(": "); + for(Object str : msgs) { + out.print(str.toString()); + out.print(' '); + } + out.println(); + t.printStackTrace(out); + out.println(); + } + + public boolean isLoggable() { + return true; + } + + @Override + public void printf(String fmt, Object ... vars) { + log(String.format(fmt,vars)); + } + }; + + // A Convenient LogTarget to write to the Console + public static final LogTarget SYSERR = new LogTarget() { + public void log(Object ... msgs) { + PrintStream out = System.err; + out.print(Chrono.dateFmt.format(new Date())); + out.print(": "); + for(Object str : msgs) { + out.print(str.toString()); + out.print(' '); + } + out.println(); + out.flush(); + } + + public void log(Throwable t, Object ... msgs) { + PrintStream out = System.err; + out.print(Chrono.dateFmt.format(new Date())); + out.print(": "); + for(Object str : msgs) { + out.print(str.toString()); + out.print(' '); + } + out.println(); + t.printStackTrace(out); + } + + public boolean isLoggable() { + return true; + } + @Override + public void printf(String fmt, Object ... vars) { + log(String.format(fmt,vars)); + } + + }; + + +};
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java new file mode 100644 index 00000000..09397dec --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Objectifier.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + + +/** + * <h1>Objectifier</h1> + * <i>Objectifier</i> abstracts the unmarshaling of an Object from a String, and + * the creation of an uninitialized object. + */ +public interface Objectifier<T> extends LifeCycle { + /** + * Marshal to Object T from a String, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, String input) throws APIException; + + /** + * Create a new object of type T. This is often more efficiently done with + * the underlying XML (or other) Library. + * @return T + * @throws APIException + */ + public abstract T newInstance() throws APIException; + + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java new file mode 100644 index 00000000..e2024726 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Slot.java @@ -0,0 +1,102 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/** + * Slot.java + * + * Created on: Dec 5, 2008 + * Created by: Jonathan + * + * (c) 2008 SBC Knowledge Ventures, L.P. All rights reserved. + ******************************************************************* + * RESTRICTED - PROPRIETARY INFORMATION The Information contained + * herein is for use only by authorized employees of AT&T Services, + * Inc., and authorized Affiliates of AT&T Services, Inc., and is + * not for general distribution within or outside the respective + * companies. + ******************************************************************* + */ +package org.onap.aaf.misc.env; + +/** + * Slot's are used to store and retrieve data in the transaction's State object. + */ +public final class Slot { + + /* + * The name of the Slot. + */ + private final String key; + + /* + * The index of the State's local map associated with this Slot. + */ + final int slot; + + /** + * Constructs a new Slot. + * + * @param index + * The index of State's local map this Slot is associated with. + * @param name + * The name of the Slot's key. + */ + Slot(int index, String name) { + slot = index; + key = name; + } + + /** + * Debug method only to print key=slot pairs. + */ + public String toString() { + return key + '=' + slot; + } + + /** + * Returns the name of this Slot's key. + * + * @return + * The name of this Slot's key. + */ + public String getKey() { + return key; + } + + /** + * Put an Object into the slot on the State + * @param state + * @param obj + */ + public void put(Object[] state, Object obj) { + state[slot]=obj; + } + + /** + * Get an Object from the slot on the State + * @param state + * @param obj + */ + public Object get(Object[] state) { + return state[slot]; + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java b/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java new file mode 100644 index 00000000..4a1033fe --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java @@ -0,0 +1,85 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/** + * Slot.java + * + * Created on: Dec 5, 2008 + * Created by: Jonathan + * + * (c)2008 SBC Knowledge Ventures, L.P. All rights reserved. + ******************************************************************* + * RESTRICTED - PROPRIETARY INFORMATION The Information contained + * herein is for use only by authorized employees of AT&T Services, + * Inc., and authorized Affiliates of AT&T Services, Inc., and is + * not for general distribution within or outside the respective + * companies. + ******************************************************************* + */ +package org.onap.aaf.misc.env; + +/** + * StaticSlot's are used to store and retrieve data from the Organizer that does not change. + */ +public final class StaticSlot { + + /* + * The name of the StaticSlot. + */ + private final String key; + + /* + * The index of the Organizer's static map associated with this StaticSlot. + */ + final int slot; + + /** + * Constructs a new StaticSlot. + * + * @param index + * The index of Organizer's static map this StaticSlot is associated with. + * @param name + * The name of the StaticSlot's key. + */ + StaticSlot(int index, String name) { + slot = index; + key = name; + } + + /** + * Debug method only to print key=slot pairs. + */ + public String toString() { + return key + '=' + slot; + } + + /** + * Returns the name of this StaticSlot's key. + * + * @return + * The name of this StaticSlot's key. + */ + public String getKey() { + return key; + } + +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java new file mode 100644 index 00000000..4e34dcdc --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Store.java @@ -0,0 +1,108 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.util.List; + +public interface Store { + /** + * Returns the Slot assigned to the supplied name. + * + * @param name + * The name of the Slot to acquire. + * @return + * The Slot associated with the supplied name. + */ + public abstract Slot slot(String name); + + /** + * Returns the existing Slot associated with the supplied name, or null if it doesn't exist. + * + * @param name + * The name of the Slot to get. + * @return + * The Slot assigned to the supplied name, or null if it doesn't exist. + * + */ + public abstract Slot existingSlot(String name); + + /** + * Returns the names used while creating Slots in a List + * + * @return + */ + public abstract List<String> existingSlotNames(); + + /** + * Returns the StaticSlot assigned to the supplied name. + * + * @param name + * The name of the StaticSlot to acquire. + * @return + * The StaticSlot associated with the supplied name. + */ + public abstract StaticSlot staticSlot(String name); + + /** + * Returns the names used while creating Static Slots in a List + * + * @return + */ + public abstract List<String> existingStaticSlotNames(); + + /** + * Store the supplied value in the StaticSlot of the Organizer's static state. + * + * @param slot + * The StaticSlot used to store the object. + * @param value + * The object to store. + */ + public abstract void put(StaticSlot slot, Object value); + + /** + * Returns an Object from the Organizer's static state, or the Default if null + * + * @param slot + * The StaticSlot to retrieve the data from. + * @return + * The Object located in the supplied StaticSlot of the Organizer's static state. + */ + public abstract<T> T get(StaticSlot slot, T dflt); + + /** + * Returns an Object from the Organizer's static state + * + * @param slot + * The StaticSlot to retrieve the data from. + * @return + * The Object located in the supplied StaticSlot of the Organizer's static state. + */ + public abstract<T> T get(StaticSlot slot); + +// /** +// * Transfer (targeted) Args to Slots +// * +// * Transfer Strings with format "tag=value" into Static Slots +// */ +// public abstract void transfer(String args[], String ... tagss); +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java b/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java new file mode 100644 index 00000000..90fb1f2b --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/StoreImpl.java @@ -0,0 +1,240 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.GenericArrayType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import org.onap.aaf.misc.env.util.Split; + +import java.util.Properties; + + +public class StoreImpl implements Store { + /* + * The re-adjustment factor for growing the Static State array. + */ + private static final int growSize = 10; + + /* + * The index reference for Slot assignment. + */ + private int local; + + /* + * The index reference for StaticSlot assignment. + */ + private int stat; + + /* + * The name/slot map for local (transaction specific) State. + */ + private HashMap<String, Slot> localMap; + + /* + * The name/slot map for Static State. + */ + private HashMap<String, StaticSlot> staticMap; + + private Object[] staticState; + + public StoreImpl() { + staticState = new Object[growSize]; + staticMap = new HashMap<String,StaticSlot>(); + localMap = new HashMap<String,Slot>(); + } + + public StoreImpl(String tag) { + staticState = new Object[growSize]; + staticMap = new HashMap<String,StaticSlot>(); + localMap = new HashMap<String,Slot>(); + } + + + public StoreImpl(String tag, String[] args) { + staticState = new Object[growSize]; + staticMap = new HashMap<String,StaticSlot>(); + localMap = new HashMap<String,Slot>(); + + if(tag!=null) { + String tequals = tag + '='; + for(String arg : args) { + if(arg.startsWith(tequals) && !arg.equals(tequals)) { // needs to have something after = + Properties props = new Properties(); + for(String f : Split.split(File.pathSeparatorChar,arg.substring(tequals.length()))) { + moreProps(new File(f),props); + } + for(Entry<Object, Object> es : props.entrySet()) { + put(staticSlot(es.getKey().toString()),es.getValue()); + } + } + } + } + + // Make sure properties on command line override those in Props + propsFromArgs(tag,args); + } + + public StoreImpl(String tag, Properties props) { + staticState = new Object[growSize]; + staticMap = new HashMap<String,StaticSlot>(); + localMap = new HashMap<String,Slot>(); + + if(tag!=null) { + String fname = props.getProperty(tag); + if(fname!=null) { + for(String f : Split.split(File.pathSeparatorChar,fname)) { + if(!moreProps(new File(f),props)) { + System.err.println("Unable to load Properties from " + f); + } + } + } + } + + for(Entry<Object, Object> es : props.entrySet()) { + put(staticSlot(es.getKey().toString()),es.getValue()); + } + } + + public void propsFromArgs(String tag, String[] args) { + if(tag!=null) { + for(String arg : args) { + String sarg[] = Split.split('=',arg); + if(sarg.length==2) { + if(tag.equals(sarg[0])) { + for(String fname : Split.split(File.pathSeparatorChar,sarg[1])) { + moreProps(new File(fname),null /* no target */); + } + } + put(staticSlot(sarg[0]),sarg[1]); + } + } + } + } + + private boolean moreProps(File f, Properties target) { + if(f.exists()) { + Properties props = new Properties(); + try { + FileInputStream fis = new FileInputStream(f); + try { + props.load(fis); + if(target!=null) { + target.load(fis); + } + } finally { + fis.close(); + } + } catch(IOException e) { + System.err.println(e); + } + for(Entry<Object, Object> es : props.entrySet()) { + put(staticSlot(es.getKey().toString()),es.getValue()); + } + return true; + } else { + return false; + } + } + + public Object[] newTransState() { + return new Object[local]; + } + + /* (non-Javadoc) + * @see com.att.env.Store#slot(java.lang.String) + */ + public synchronized Slot slot(String name) { + name = name == null ? "" : name.trim(); + Slot slot = localMap.get(name); + if (slot == null) { + slot = new Slot(local++, name); + localMap.put(name, slot); + } + return slot; + } + + + /* (non-Javadoc) + * @see com.att.env.Store#existingSlot(java.lang.String) + */ + public Slot existingSlot(String name) { + return localMap.get(name); + } + + /* (non-Javadoc) + * @see com.att.env.Store#existingSlotNames() + */ + public List<String> existingSlotNames() { + return new ArrayList<String>(localMap.keySet()); + } + + /* (non-Javadoc) + * @see com.att.env.Store#staticSlot(java.lang.String) + */ + public synchronized StaticSlot staticSlot(String name) { + name = name == null ? "" : name.trim(); + StaticSlot slot = staticMap.get(name); + if (slot == null) { + if (stat%growSize == 0) { + Object[] temp = staticState; + staticState = new Object[temp.length+growSize]; + System.arraycopy(temp, 0, staticState, 0, temp.length); + } + slot = new StaticSlot(stat++, name); + staticMap.put(name, slot); + } + return slot; + } + + /* (non-Javadoc) + * @see com.att.env.Store#put(com.att.env.StaticSlot, java.lang.Object) + */ + public void put(StaticSlot slot, Object value) { + staticState[slot.slot] = value; + } + + /* (non-Javadoc) + * @see com.att.env.Store#get(com.att.env.StaticSlot T defaultObject) + */ + @SuppressWarnings("unchecked") + public<T> T get(StaticSlot sslot,T dflt) { + T t = (T)staticState[sslot.slot]; + return t==null?dflt:t; + } + + @SuppressWarnings("unchecked") + public <T> T get(StaticSlot sslot) { + return (T)staticState[sslot.slot]; + } + + public List<String> existingStaticSlotNames() { + return new ArrayList<String>(staticMap.keySet()); + } +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java new file mode 100644 index 00000000..3d29366a --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Stringifier.java @@ -0,0 +1,45 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + + +/** + * <h1>Stringifier</h1> + * <i>Stringifier</i> abstracts the marshaling of a String to an Object + */ +public interface Stringifier<T> extends LifeCycle { + + /** + * Marshal from a String to an Object T, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract String stringify(Env env, T input, boolean ... options) throws APIException; + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java new file mode 100644 index 00000000..053d4d6f --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java @@ -0,0 +1,116 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +/** + * <h1>TimeTaken</h1> + * This simple interface allows for many different kinds of + * Audit Logs to be accomplished, by assuming that the creation + * of this object indicates "start", and the calling of "done" + * ends. + * + * The implementor of this class can easily be stored in efficient + * mechanisms to minimize impact of Auditing on performance. + * + * @author Jonathan + * + */ +public abstract class TimeTaken { + public final long start; + protected long end, size; + public final int flag; + public final String name; + + /** + * The name is as it will appear when written to output (abstract method) + * + * The flag is an integer which can be System type (XML, REMOTE, etc), or End User defined for reporting purposes + * + * @param name + * @param flag + */ + public TimeTaken(String name, int flag) { + start = System.nanoTime(); + this.flag = flag; + this.name = name; + size = -1; + } + + + /** + * Call this when process is done to state ending time.<p> + * + * It is <i>exceedingly prudent</i> to wrap the process called with a try-finally:<p> + * + * <pre> + * TimeTaken tt = env.startSubTime(); + * try { + * process.me(); // code to be timed. + * } finally { + * tt.done(); + * } + * </pre> + */ + public void done() { + end = System.nanoTime(); + } + + + /** + * For sizable contents, set the size. Implementations can simply write a no-op if they don't wish to + * store the size. + * + * @param size + */ + public void size(long theSize) { + size = theSize; + } + + /** + * Give readonly access to End, which isn't final + * @return + */ + public long end() { + return end; + } + + /** + * Time is taken in NanoSeconds. This method converts to decimals of Milliseconds + * @return + */ + public float millis() { + return (end-start)/1000000f; + } + /** + * Write self to a String Builder (for making Audits) + * @param sb + */ + public abstract void output(StringBuilder sb); + + /** + * For Debugging + */ + public String toString() { + return name + ' ' + millis() + "ms " + (size>0?Long.toString(size):""); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java new file mode 100644 index 00000000..ced64e8a --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/Trans.java @@ -0,0 +1,74 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + + + + +/** + * A Trans is like an Env, however, it's purpose it to track the Transient + * Data associated with Transactions, or other short term elements. + * + * Any Object implementing Trans should expect to go in an out of scope quickly + * + * Implementations should also overload the concepts of "Start", etc and build up + * and Audit Log, so it can implement "metric" below + * + * All Transactions (i.e. a call to a service) will need these items. + * + * @author Jonathan + * + */ +public interface Trans extends Env { + /** + * Add a completed entry in the Audit Trail for tracking purposes. + * + * @param text + */ + public void checkpoint(String text); + + /** + * Add a completed entry in the Audit Trail for tracking purposes, and combine flag with "CHECKPOINT" + * + * @param text + */ + public void checkpoint(String text, int additionalFlag); + + /** + * Output an Audit Trail onto the StringBuilder + * + * Load metrics into an array of floats from passed in Flags + * + * @param flag + * @param sb + * @return + */ + public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flag); + + public Metric auditTrail(int indent, StringBuilder sb, int ... flag); + + public class Metric { + public float[] buckets; + public float total; + public int entries; + } +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java new file mode 100644 index 00000000..7c166139 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TransCreate.java @@ -0,0 +1,26 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +public interface TransCreate<TRANS> { + public TRANS newTrans(); +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TransJAXB.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TransJAXB.java new file mode 100644 index 00000000..dfc12b6e --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TransJAXB.java @@ -0,0 +1,26 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +public interface TransJAXB extends Trans, TransStore { + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java new file mode 100644 index 00000000..6b503130 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TransStore.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env; + +public interface TransStore extends Trans { + /** + * Returns the Slot assigned to the supplied name. + * + * @param name + * The name of the Slot to acquire. + * @return + * The Slot associated with the supplied name. + */ + public abstract Slot slot(String name); + + /** + * Put data into the right slot + */ + public void put(Slot slot, Object value); + + /** + * Get data from the right slot + * + * This will do a cast to the expected type derived from Default + */ + public<T> T get(Slot slot, T deflt); + + /** + * Returns an Object from the Organizer's static state, or the Default if null + * + * @param slot + * The StaticSlot to retrieve the data from. + * @return + * The Object located in the supplied StaticSlot of the Organizer's static state. + */ + public abstract<T> T get(StaticSlot slot, T dflt); + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java new file mode 100644 index 00000000..a04b63e6 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java @@ -0,0 +1,214 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.Slot; +import org.onap.aaf.misc.env.StoreImpl; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.TransStore; + +public abstract class AbsTrans<ENV extends Env> implements TransStore { + private static final float[] EMPTYF = new float[0]; + private static final Object[] EMPTYO = new Object[0]; + + protected ENV delegate; + protected List<TimeTaken> trail = new ArrayList<TimeTaken>(30); + private Object[] state; + + + public AbsTrans(ENV delegate) { + this.delegate = delegate; + state = delegate instanceof StoreImpl?((StoreImpl) delegate).newTransState():EMPTYO; + } + + // @Override + public LogTarget fatal() { + return delegate.fatal(); + } + +// @Override + public LogTarget error() { + return delegate.error(); + } + +// @Override + public LogTarget audit() { + return delegate.audit(); + } + +// @Override + public LogTarget init() { + return delegate.init(); + } + +// @Override + public LogTarget warn() { + return delegate.warn(); + } + +// @Override + public LogTarget info() { + return delegate.info(); + } + +// @Override + public LogTarget debug() { + return delegate.debug(); + } + +// @Override + public LogTarget trace() { + return delegate.trace(); + } + + /** + * Let the final Trans Implementation choose the exact kind of TimeTaken to use + * @param name + * @param flag + * @return + */ + protected abstract TimeTaken newTimeTaken(String name, int flag); + +// @Override + public final TimeTaken start(String name, int flag) { + TimeTaken tt = newTimeTaken(name,flag); + trail.add(tt); + return tt; + } + +// @Override + public final void checkpoint(String name) { + TimeTaken tt = newTimeTaken(name,CHECKPOINT); + tt.done(); + trail.add(tt); + } + + public final void checkpoint(String name, int additionalFlag) { + TimeTaken tt = newTimeTaken(name,CHECKPOINT|additionalFlag); + trail.add(tt); + tt.done(); + } + + @Override + public Metric auditTrail(int indent, StringBuilder sb, int ... flags) { + return auditTrail(info(),indent,sb,flags); + } + + @Override + public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int ... flags) { + Metric metric = new Metric(); + int last = (metric.entries = trail.size()) -1; + metric.buckets = flags.length==0?EMPTYF:new float[flags.length]; + if(last>=0) { + TimeTaken first = trail.get(0); + // If first entry is sub, then it's actually the last "end" as well + // otherwise, check end + //long end = (first.flag&SUB)==SUB?first.end():trail.get(last).end(); + long end = trail.get(last).end(); + metric.total = (end - first.start) / 1000000f; + } + + if(sb==null) { + for(TimeTaken tt : trail) { + float ms = tt.millis(); + for(int i=0;i<flags.length;++i) { + if(tt.flag == flags[i]) metric.buckets[i]+=ms; + } + } + } else if(!lt.isLoggable()) { + boolean first = true; + for(TimeTaken tt : trail) { + float ms = tt.millis(); + for(int i=0;i<flags.length;++i) { + if(tt.flag == flags[i]) metric.buckets[i]+=ms; + } + if((tt.flag&ALWAYS)==ALWAYS) { + if(first) first = false; + else sb.append('/'); + sb.append(tt.name); + } + } + } else { + Stack<Long> stack = new Stack<Long>(); + for(TimeTaken tt : trail) { + // Create Indentation based on SUB + while(!stack.isEmpty() && tt.end()>stack.peek()) { + --indent; + stack.pop(); + } + for(int i=0;i<indent;++i) { + sb.append(" "); + } + tt.output(sb); + sb.append('\n'); + if((tt.flag&SUB)==SUB) { + stack.push(tt.end()); + ++indent; + } + + // Add time values to Metric + float ms = tt.millis(); + for(int i=0;i<flags.length;++i) { + if(tt.flag == flags[i]) metric.buckets[i]+=ms; + } + } + } + return metric; + } + + /** + * Put data into the Trans State at the right slot + */ +// @Override + public void put(Slot slot, Object value) { + slot.put(state, value); + } + + /** + * Get data from the Trans State from the right slot + * + * This will do a cast to the expected type derived from Default + */ +// @Override + @SuppressWarnings("unchecked") + public<T> T get(Slot slot, T deflt) { + Object o; + try { + o = slot.get(state); + } catch(ArrayIndexOutOfBoundsException e) { + // Env State Size has changed because of dynamic Object creation... Rare event, but needs to be covered + Object[] temp = ((StoreImpl) delegate).newTransState(); + System.arraycopy(state, 0, temp, 0, state.length); + state = temp; + o=null; + } + return o==null?deflt:(T)o; + } + + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java new file mode 100644 index 00000000..5c4a80b3 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTransJAXB.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.DataFactory; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.TransJAXB; + +public abstract class AbsTransJAXB extends AbsTrans<EnvJAXB> implements TransJAXB { + public AbsTransJAXB(EnvJAXB env) { + super(env); + } + +// @Override + public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException { + return delegate.newDataFactory(classes); + } + +// @Override + public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException { + return delegate.newDataFactory(schema, classes); + } + +// @Override + public <T> DataFactory<T> newDataFactory(QName qName, Class<?>... classes) throws APIException { + return delegate.newDataFactory(qName, classes); + } + +// @Override + public <T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?>... classes) throws APIException { + return delegate.newDataFactory(schema, qName, classes); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java new file mode 100644 index 00000000..65fe9d80 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicEnv.java @@ -0,0 +1,352 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import java.applet.Applet; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Properties; + +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.DataFactory; +import org.onap.aaf.misc.env.Decryptor; +import org.onap.aaf.misc.env.Encryptor; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.StaticSlot; +import org.onap.aaf.misc.env.StoreImpl; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.TransCreate; +import org.onap.aaf.misc.env.TransJAXB; +import org.onap.aaf.misc.env.jaxb.JAXBDF; +import org.onap.aaf.misc.env.util.Split; + +/** + * An essential Implementation of Env, which will fully function, without any sort + * of configuration. + * + * Use as a basis for Group level Env, just overriding where needed. + * @author Jonathan + * + */ +public class BasicEnv extends StoreImpl implements EnvJAXB, TransCreate<TransJAXB>{ + protected LogTarget fatal=LogTarget.SYSERR; + protected LogTarget error=LogTarget.SYSERR; + protected LogTarget audit=LogTarget.SYSOUT; + protected LogTarget init=LogTarget.SYSOUT; + protected LogTarget warn=LogTarget.SYSERR; + protected LogTarget info=LogTarget.SYSOUT; + protected LogTarget debug=LogTarget.NULL; + protected LogTarget trace=LogTarget.NULL; +// protected Map<String, String> props; + +// private boolean sysprops; + + public BasicEnv(String ... args) { + super(null,args); + } + + public BasicEnv(String tag, String[] args) { + super(tag, args); + } + + + /** + * Suitable for use in Applets... obtain all the values + * listed for the variable String arg "tags" + */ + public BasicEnv(Applet applet, String ... tags) { + super(null, tags); +// props = new HashMap<String, String>(); +// String value; +// for(int i=0;i<tags.length;++i) { +// value = applet.getParameter(tags[i]); +// if(value!=null) { +// props.put(tags[i], value); +// } +// } + } + + public BasicEnv(Properties props) { + super(null, props); + } + + public BasicEnv(String tag, Properties props) { + super(tag, props); + } + + + + // @Override + public LogTarget fatal() { + return fatal; + } + + // @Override + public LogTarget error() { + return error; + } + + + // @Override + public LogTarget audit() { + return audit; + } + + // @Override + public LogTarget init() { + return init; + } + + // @Override + public LogTarget warn() { + return warn; + } + + // @Override + public LogTarget info() { + return info; + } + + // @Override + public LogTarget debug() { + return debug; + } + + public void debug(LogTarget lt) { + debug = lt; + } + + // @Override + public LogTarget trace() { + return trace; + } + + // @Override + public TimeTaken start(String name, int flag) { + return new TimeTaken(name, flag) { + /** + * Format to be printed when called upon + */ + // @Override + public void output(StringBuilder sb) { + + switch(flag) { + case Env.XML: sb.append("XML "); break; + case Env.JSON: sb.append("JSON "); break; + case Env.REMOTE: sb.append("REMOTE "); break; + } + sb.append(name); + if(flag != Env.CHECKPOINT) { + sb.append(' '); + sb.append((end-start)/1000000f); + sb.append("ms"); + if(size>=0) { + sb.append(" size: "); + sb.append(Long.toString(size)); + } + } + } + }; + } + + // @Override + public String getProperty(String key) { + return get(staticSlot(key),null); + } + + public Properties getProperties(String ... filter) { + Properties props = new Properties(); + boolean yes; + for(String key : existingStaticSlotNames()) { + if(filter.length>0) { + yes = false; + for(String f : filter) { + if(key.startsWith(f)) { + yes = true; + break; + } + } + } else { + yes = true; + } + if(yes) { + String value = getProperty(key); + if(value!=null) { + props.put(key, value); + } + } + } + return props; + } + + // @Override + public String getProperty(String key, String defaultValue) { + return get(staticSlot(key),defaultValue); + } + + // @Override + public String setProperty(String key, String value) { + put(staticSlot(key),value==null?null:value.trim()); + return value; + } + + protected Decryptor decryptor = Decryptor.NULL; + protected Encryptor encryptor = Encryptor.NULL; + + + public Decryptor decryptor() { + return decryptor; + } + + public void set(Decryptor newDecryptor) { + decryptor = newDecryptor; + } + + public Encryptor encryptor() { + return encryptor; + } + + public void set(Encryptor newEncryptor) { + encryptor = newEncryptor; + } + + +// @SuppressWarnings("unchecked") + // @Override + public <T> DataFactory<T> newDataFactory(Class<?>... classes) throws APIException { +// if(String.class.isAssignableFrom(classes[0])) +// return (DataFactory<T>) new StringDF(this); + return new JAXBDF<T>(this,classes); + } + +// @SuppressWarnings("unchecked") + // @Override + public <T> DataFactory<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException { +// if(String.class.isAssignableFrom(classes[0])) +// return (DataFactory<T>) new StringDF(this); + return new JAXBDF<T>(this, schema, classes); + } + +// @SuppressWarnings("unchecked") + // @Override + public<T> DataFactory<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException { +// if(String.class.isAssignableFrom(classes[0])) +// return (DataFactory<T>) new StringDF(this); + return new JAXBDF<T>(this, qName, classes); + } + + // @Override + public<T> DataFactory<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException { + return new JAXBDF<T>(this, schema, qName, classes); + } + + // @Override + public BasicTrans newTrans() { + return new BasicTrans(this); + } + + public void loadFromSystemPropsStartsWith(String ... str) { + for(String name : System.getProperties().stringPropertyNames()) { + for(String s : str) { + if(name.startsWith(s)) { + setProperty(name, System.getProperty(name)); + } + } + } + } + + /** + * + * + */ + public void loadToSystemPropsStartsWith(String ... str) { + String value; + for(String name : existingStaticSlotNames()) { + for(String s : str) { + if(name.startsWith(s)) { + if((value = getProperty(name))!=null) + System.setProperty(name,value); + } + } + } + } + + public void loadPropFiles(String tag, ClassLoader classloader) throws IOException { + String propfiles = getProperty(tag); + if(propfiles!=null) { + for(String pf : Split.splitTrim(File.pathSeparatorChar, propfiles)) { + InputStream is = classloader==null?null:classloader.getResourceAsStream(pf); + if(is==null) { + File f = new File(pf); + if(f.exists()) { + is = new FileInputStream(f); + } + } + if(is!=null) { + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + try { + String line; + while((line=br.readLine())!=null) { + line = line.trim(); + if(!line.startsWith("#")) { + String[] tv = Split.splitTrim('=', line); + if(tv.length==2) { + setProperty(tv[0],tv[1]); + } + } + } + } finally { + try { + br.close(); + } catch (IOException e) { + error().log(e); + } + } + } + } + } + } + + /** + * Create a StaticSlot, and load it from existing Properties + * + * @param name + * @param propName + * @return + */ + public synchronized StaticSlot staticSlot(String name, final String propName) { + StaticSlot ss = staticSlot(name); + put(ss,getProperty(propName)); + return ss; + } + + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java new file mode 100644 index 00000000..eb33ff59 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/BasicTrans.java @@ -0,0 +1,81 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import org.onap.aaf.misc.env.Decryptor; +import org.onap.aaf.misc.env.Encryptor; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.Slot; +import org.onap.aaf.misc.env.StaticSlot; +import org.onap.aaf.misc.env.TimeTaken; + + +public class BasicTrans extends AbsTransJAXB { + + public BasicTrans(EnvJAXB env) { + super(env); + } + + @Override + protected TimeTaken newTimeTaken(String name, int flag) { + /** + * Note: could have created a different format for Time Taken, but using BasicEnv's instead + */ + return delegate.start(name, flag); + } + + public Slot slot(String name) { + return delegate.slot(name); + } + + public <T> T get(StaticSlot slot) { + return delegate.get(slot); + } + + public <T> T get(StaticSlot slot, T dflt) { + return delegate.get(slot,dflt); + } + + public String setProperty(String tag, String value) { + delegate.setProperty(tag, value); + return value; + } + + public String getProperty(String tag) { + return delegate.getProperty(tag); + } + + public String getProperty(String tag, String deflt) { + return delegate.getProperty(tag, deflt); + } + + @Override + public Decryptor decryptor() { + return delegate.decryptor(); + } + + @Override + public Encryptor encryptor() { + return delegate.encryptor(); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java new file mode 100644 index 00000000..a882c748 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/EnvFactory.java @@ -0,0 +1,68 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.TransCreate; +import org.onap.aaf.misc.env.TransJAXB; + +/** + * EnvFactory + * + * @author Jonathan + * + */ +public class EnvFactory { + + public static final String SCHEMA_DIR = "env-schema_dir"; + public static final String DEFAULT_SCHEMA_DIR = "src/main/xsd"; + static BasicEnv singleton; + + static { + singleton = new BasicEnv(); + } + public static BasicEnv singleton() { + return singleton; + } + + public static void setSingleton(BasicEnv be) { + singleton = be; + } + + public static TransJAXB newTrans() { + return new BasicTrans(singleton); + } + + public static TransJAXB newTrans(EnvJAXB env) { + return new BasicTrans(env); + } + + public static TransCreate<TransJAXB> transCreator() { + return new TransCreate<TransJAXB>() { + // @Override + public BasicTrans newTrans() { + return singleton.newTrans(); + } + }; + } +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java new file mode 100644 index 00000000..84a78bfd --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/JavaUtilLogTarget.java @@ -0,0 +1,90 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.onap.aaf.misc.env.LogTarget; + +/** + * This LogTarget Implementation is included mostly because the JavaUtil based logging is included in the + * JDK. This makes the default implementation independent of any external Jars. + * + * Log4j is often considered more Enterprise capable. See Log4JLogTarget for that implementation + * + * @author Jonathan + * + */ +public class JavaUtilLogTarget implements LogTarget { + private Level level; + private Logger log; + + public JavaUtilLogTarget(Logger logger, Level theLevel) { + log = logger; + level = theLevel; + } + + public boolean isLoggable() { + return log.isLoggable(level); + } + + public void log(Object ... msgs) { + if(log.isLoggable(level)) { + StringBuilder sb = new StringBuilder(); + String msg; + for(int i=0;i<msgs.length;++i) { + msg = msgs[i].toString(); + if(msg!=null && msg.length()>0) { + int sbl = sb.length(); + if(sbl>0) { + char last = sb.charAt(sbl-1); + if(" (.".indexOf(last)<0 && "().".indexOf(msg.charAt(0))<0)sb.append(' '); + } + sb.append(msg); + } + } + log.log(level, sb.toString()); + } + } + + public void log(Throwable e, Object ... msgs) { + String str = e.getLocalizedMessage(); + if(str==null) { + str = e.getMessage(); + } + if(str==null) { + str = e.getClass().getName(); + } + log.log(level,str,msgs); + } + + /* (non-Javadoc) + * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[]) + */ + @Override + public void printf(String fmt, Object ... vars) { + if(log.isLoggable(level)) { + log.log(level,String.format(fmt,vars)); + } + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java new file mode 100644 index 00000000..44da65e6 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/Log4JLogTarget.java @@ -0,0 +1,109 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import java.io.PrintWriter; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.util.StringBuilderWriter; + +/** + * Many services have chosen to use Log4J for their lower level Logging Implementation. This LogTarget will allow + * any of the messages sent to be set to the appropriate Log4J level. + * + * @author Jonathan + * + */ +public class Log4JLogTarget implements LogTarget { + private Level level; + private Logger log; + + public Log4JLogTarget(String loggerName, Level level) throws APIException { + this.level = level; + if (loggerName != null && loggerName.length() > 0) { + log = Logger.getLogger(loggerName); + } else { + log = Logger.getRootLogger(); + } + } + + // @Override + public boolean isLoggable() { + return log.isEnabledFor(level); + } + + // @Override + public void log(Object... msgs) { + log(null, msgs); + } + + // @Override + public void log(Throwable e, Object... msgs) { + if (log.isEnabledFor(level)) { + StringBuilder sb = new StringBuilder(); + + String msg; + if (e != null) { + e.printStackTrace(new PrintWriter(new StringBuilderWriter(sb))); + } + for (int i = 0; i < msgs.length; ++i) { + if(msgs[i]!=null) { + msg = msgs[i].toString(); + if (msg != null && msg.length() > 0) { + int sbl = sb.length(); + if (sbl > 0) { + char last = sb.charAt(sbl - 1); + if (" (.".indexOf(last) < 0 + && "().".indexOf(msg.charAt(0)) < 0) + sb.append(' '); + } + sb.append(msg); + } + } + } + log.log(level, sb.toString()); + } + } + + /* (non-Javadoc) + * @see com.att.inno.env.LogTarget#printf(java.lang.String, java.lang.String[]) + */ + @Override + public void printf(String fmt, Object ... vars) { + if(log.isEnabledFor(level)) { + log.log(level,String.format(fmt,vars)); + } + } + + public static void setLog4JEnv(String loggerName, BasicEnv env) throws APIException { + env.fatal = new Log4JLogTarget(loggerName,Level.FATAL); + env.error = new Log4JLogTarget(loggerName,Level.ERROR); + env.warn = env.audit = env.init = new Log4JLogTarget(loggerName,Level.WARN); + env.info = new Log4JLogTarget(loggerName,Level.INFO); + env.debug = new Log4JLogTarget(loggerName,Level.DEBUG); + env.trace = new Log4JLogTarget(loggerName,Level.TRACE); + } + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java new file mode 100644 index 00000000..5cda17f0 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/NullLifeCycle.java @@ -0,0 +1,59 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.impl; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LifeCycle; + + + +/** + * <h1>NullLifeCycle</h1> + * + * This is a convenience class for those Objects which should + * implement LifeCycle, but don't have anything to do in any of the + * LifeCycle methods defined. Extending + * NullLifeCycle reduces the required methods for the class by 5. + * Any one or two of them can be overloaded.<p> + * + * If more are overloaded, it is + * recommended just to implement LifeCycle. + * <p> + * + * This only works, though, if the Object doesn't need to extend something + * else, due to Java's Single Extension policy. In other cases, just + * implement LifeCycle, and leave them empty. + * + * @author Jonathan + * + */ +public class NullLifeCycle implements LifeCycle { + public void servicePrestart(Env env) throws APIException {} + public void threadPrestart(Env env) throws APIException {} + public void refresh(Env env) throws APIException {} + public void threadDestroy(Env env) throws APIException {} + public void serviceDestroy(Env env) throws APIException {} +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java new file mode 100644 index 00000000..74fcc830 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBDF.java @@ -0,0 +1,309 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.jaxb; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; + +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.BaseDataFactory; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.old.IOObjectifier; +import org.onap.aaf.misc.env.old.IOStringifier; +import org.onap.aaf.misc.env.old.OldDataFactory; + +public class JAXBDF<T> extends BaseDataFactory implements OldDataFactory<T>,IOObjectifier<T>, IOStringifier<T> { + // Package on purpose + EnvJAXB primaryEnv; + JAXBumar jumar; + JAXBmar jmar; + + public JAXBDF(EnvJAXB env, Class<?> ... classes) throws APIException { + try { + primaryEnv = env; + jumar = new JAXBumar(classes); + jmar = new JAXBmar(classes) ; + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public JAXBDF(EnvJAXB env, Schema schema, Class<?> ... classes) throws APIException { + try { + primaryEnv = env; + jumar = new JAXBumar(schema, classes); + jmar = new JAXBmar(classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public JAXBDF(EnvJAXB env, QName qname, Class<?> ... classes) throws APIException { + try { + primaryEnv = env; + jumar = new JAXBumar(classes); + jmar = new JAXBmar(qname, classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public JAXBDF(EnvJAXB env, Schema schema, QName qname, Class<?> ... classes) throws APIException { + try { + primaryEnv = env; + jumar = new JAXBumar(schema, classes); + jmar = new JAXBmar(qname, classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public T newInstance() throws APIException { + try { + return jumar.newInstance(); + } catch (Exception e) { + throw new APIException(e); + } + } + + // @Override + public IOStringifier<T> pretty(boolean pretty) { + jmar.pretty(pretty); + return this; + } + + // @Override + public IOStringifier<T> asFragment(boolean fragment) { + jmar.asFragment(fragment); + return this; + } + + // @Override + public void servicePrestart(Env env) throws APIException { + } + + // @Override + public void threadPrestart(Env env) throws APIException { + } + + // @Override + public void refresh(Env env) throws APIException { + } + + // @Override + public void threadDestroy(Env env) throws APIException { + } + + // @Override + public void serviceDestroy(Env env) throws APIException { + } + + @SuppressWarnings("unchecked") + // @Override + public Data<T> newData() { + return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass()); + } + + @SuppressWarnings("unchecked") + // @Override + public Data<T> newData(Env env) { + return new JAXBData<T>(env, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),"",(Class<T>)jmar.getMarshalClass()); + } + + // @Override + public Data<T> newData(T type) { + return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), type); + } + + // @Override + public Data<T> newDataFromStream(Env env, InputStream input) throws APIException { + //TODO Write an unvalidated String using STAX checking for end of Doc? + // perhaps key evaluation as well. + try { + T t = jumar.unmarshal(env.debug(), input); + return new JAXBData<T>(primaryEnv, this, new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar),t); + } catch(JAXBException e) { + throw new APIException(e); + } + } + + @SuppressWarnings("unchecked") + // @Override + public Data<T> newDataFromString(String string) { + return new JAXBData<T>(primaryEnv, this,new JAXBStringifier<T>(jmar), new JAXBObjectifier<T>(jumar), string,(Class<T>)jmar.getMarshalClass()); + } + + /////////// Old DataFactory Interface + // @Override + public String stringify(T type) throws APIException { + try { + StringWriter sw = new StringWriter(); + jmar.marshal(primaryEnv.debug(), type, sw); + return sw.toString(); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public void stringify(T type, Writer writer) throws APIException { + try { + jmar.marshal(primaryEnv.debug(), type, writer); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public void stringify(T type, OutputStream os) throws APIException { + try { + jmar.marshal(primaryEnv.debug(), type, os); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + /////////// New DataFactory Interface + // @Override + public String stringify(Env env, T input, boolean ... options) throws APIException { + try { + StringWriter sw = new StringWriter(); + TimeTaken tt = env.start("JAXB Stringify", Env.XML); + try { + jmar.marshal(env.debug(), input, sw, options); + } finally { + tt.done(); + } + String str = sw.toString(); + tt.size(str.getBytes().length); + return str; + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException { + TimeTaken tt = env.start("JAXB Stringify", Env.XML); + try { + jmar.marshal(env.debug(), input, writer, options); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException { + TimeTaken tt = env.start("JAXB Stringify", Env.XML); + try { + jmar.marshal(env.debug(), input, os, options); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public T objectify(Env env, Reader rdr) throws APIException { + TimeTaken tt = env.start("JAXB Objectify", Env.XML); + try { + return jumar.unmarshal(env.debug(), rdr); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public T objectify(Reader rdr) throws APIException { + try { + return jumar.unmarshal(primaryEnv.debug(), rdr); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public T objectify(Env env, InputStream is) throws APIException { + TimeTaken tt = env.start("JAXB Objectify", Env.XML); + try { + return jumar.unmarshal(env.debug(), is); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public T objectify(InputStream is) throws APIException { + try { + return jumar.unmarshal(primaryEnv.debug(), is); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // @Override + public T objectify(Env env, String input) throws APIException { + TimeTaken tt = env.start("JAXB Objectify", Env.XML); + tt.size(input.getBytes().length); + try { + return jumar.unmarshal(env.debug(), input); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public T objectify(String text) throws APIException { + try { + return jumar.unmarshal(primaryEnv.debug(), text); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + @SuppressWarnings("unchecked") + // @Override + public Class<T> getTypeClass() { + return (Class<T>)jmar.getMarshalClass(); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java new file mode 100644 index 00000000..e1c54c63 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBData.java @@ -0,0 +1,321 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.jaxb; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; + +import javax.xml.bind.JAXBException; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.old.IOStringifier; +import org.onap.aaf.misc.env.old.Objectifier; +import org.onap.aaf.misc.env.old.Stringifier; +/** + * <H1>Data</H1> + * <i>Data</i> facilitates lazy marshaling of data with a pre-determined + * marshaling mechanism.<p> + * + * It stores either Object (defined by Generic {@literal <T>}) or String.<p> + * + * On asking for Object of type {@literal <T>}, it will respond with the object + * if it exists, or unmarshal the string and pass the result back.<p> + * + * On asking for String, it will respond with the String + * if it exists, or marshal the String and pass the result back.<p> + * + * @author Jonathan + * + * @param <T> + */ +public final class JAXBData<T> implements Data<T>{ + private Stringifier<T> stringifier; + private Objectifier<T> objectifier; + private String dataAsString; + private T dataAsObject; + private Class<T> tclass; + private JAXBDF<T> df; + private Env creatingEnv; + private boolean options[] = new boolean[] {false, false}; + + /** + * Construct a Data Object with an appropriate Stringifier, Objectifier and Class to support + * + * @param env + * @param strfr + * @param objfr + * @param text + * @param typeClass + */ + JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, String text, Class<T> typeClass) { + dataAsString = text; + dataAsObject = null; + stringifier = strfr; + objectifier = objfr; + tclass = typeClass; + creatingEnv = env; + this.df = df; + } + + + /** + * Construct a Data Object with an appropriate Stringifier, Objectifier and Object (which will + * yield it's class) + * + * @param env + * @param strfr + * @param objfr + * @param object + */ + @SuppressWarnings("unchecked") + JAXBData(Env env, JAXBDF<T> df, Stringifier<T> strfr, Objectifier<T> objfr, T object) { + dataAsString = null; + dataAsObject = object; + stringifier = strfr; + objectifier = objfr; + tclass = (Class<T>) object.getClass(); + creatingEnv = env; + this.df = df; + } + + /** + * Respond with the String if it exists, or marshal the String and pass the result back.<p> + * + * Explicitly use a specific Env for logging purposes + * + * @param env + * @return String + * @throws APIException + */ + public String asString(EnvJAXB env) throws APIException { + if(dataAsString!=null) { + return dataAsString; + } else { + return dataAsString = stringifier.stringify(env, dataAsObject); + } + } + + /** + * Respond with the String if it exists, or marshal the String and pass the result back. + * + * However, use the Env the Data Object was created with. + * + * @return String + * @throws APIException + */ + // @Override + public String asString() throws APIException { + if(dataAsString!=null) { + return dataAsString; + } else { + return dataAsString = stringifier.stringify(creatingEnv, dataAsObject,options); + } + } + + public Data<T> to(OutputStream os) throws APIException, IOException { + if(dataAsString!=null) { + os.write(dataAsString.getBytes()); + } else if (stringifier instanceof IOStringifier){ + ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, os, options); + } else { + dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options); + os.write(dataAsString.getBytes()); + } + return this; + } + + + // @Override + public JAXBData<T> to(Writer writer) throws APIException, IOException { + if(dataAsString!=null) { + writer.write(dataAsString); + } else if (stringifier instanceof IOStringifier){ + ((IOStringifier<T>)stringifier).stringify(creatingEnv, dataAsObject, writer, options); + } else { + dataAsString = stringifier.stringify(creatingEnv, dataAsObject, options); + writer.write(dataAsString); + } + return this; + } + + + public InputStream getInputStream() throws APIException { + if(dataAsString==null) { + dataAsString = stringifier.stringify(creatingEnv,dataAsObject,options); + } + return new ByteArrayInputStream(dataAsString.getBytes()); + } + + /** + * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String + * and pass the result back.<p> + * + * Explicitly use a specific Env for logging purposes + * + * @param env + * @return T + * @throws APIException + */ + + public T asObject(EnvJAXB env) throws APIException { + if(dataAsObject !=null) { + return dataAsObject; + } else { + // Some Java compilers need two statements here + dataAsObject = objectifier.objectify(env, dataAsString); + return dataAsObject; + } + } + + /** + * Respond with the Object of type {@literal <T>} if it exists, or unmarshal from String + * and pass the result back.<p> + * + * However, use the Env the Data Object was created with. + * + * @return T + * @throws APIException + */ + // @Override + public T asObject() throws APIException { + if(dataAsObject !=null) { + return dataAsObject; + } else { + // Some Java compilers need two statements here + dataAsObject = objectifier.objectify(creatingEnv, dataAsString); + return dataAsObject; + } + } + + + /** + * Return the Class Type supported by this DataObject + * + * @return {@literal Class<T>} + */ + // @Override + public Class<T> getTypeClass() { + return tclass; + } + + + /** + * For Debugging Convenience, we marshal to String if possible. + * + * Behavior is essentially the same as asString(), except asString() throws + * an APIException. <p> + * Since toString() must not throw exceptions, the function just catches and prints an + * error, which is probably not the behavior desired.<p> + * + * Therefore, use "asString()" where possible in actual Transactional code. + * + * @see java.lang.Object#toString() + */ + // @Override + public String toString() { + if(dataAsString!=null) { + return dataAsString; + } else { + try { + return dataAsString = stringifier.stringify(creatingEnv, dataAsObject); + } catch (APIException e) { + return "ERROR - Can't Stringify from Object " + e.getLocalizedMessage(); + } + } + } + + public Data<T> load(T t) throws APIException { + dataAsObject = t; + dataAsString = null; + return this; + } + + + public Data<T> load(String str) throws APIException { + dataAsObject = null; + dataAsString = str; + return this; + } + + + public Data<T> load(InputStream is) throws APIException { + try { + dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),is); + dataAsString = null; + } catch (JAXBException e) { + throw new APIException(e); + } + return this; + } + + + public Data<T> load(Reader rdr) throws APIException { + try { + dataAsObject = df.jumar.unmarshal(creatingEnv.debug(),rdr); + dataAsString = null; + } catch (JAXBException e) { + throw new APIException(e); + } + return this; + } + + + // @Override + public void direct(InputStream input, OutputStream output) throws APIException, IOException { + byte b[] = new byte[128]; + int count; + do { + count = input.read(b); + if(count>0)output.write(b, 0, count); + } while(count>=0); + } + + + // @Override + public Data<T> out(TYPE type) { + // it's going to be XML regardless... + return this; + } + + + // @Override + public Data<T> in(TYPE type) { + // Not Supported... will still be XML + return this; + } + + + // @Override + public Data<T> option(int option) { + options[0] = (option&Data.PRETTY)==Data.PRETTY; + options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT; + return this; + } + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java new file mode 100644 index 00000000..9679d841 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java @@ -0,0 +1,135 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.jaxb; + +import java.io.InputStream; +import java.io.Reader; + +import javax.xml.bind.JAXBException; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.old.IOObjectifier; + +/** + * Allow Extended IO interface usage without muddying up the Stringifier Interface + */ +public class JAXBObjectifier<T> implements IOObjectifier<T> { + private JAXBumar jumar; + + public JAXBObjectifier(Schema schema, Class<?>... classes) throws APIException { + try { + jumar = new JAXBumar(schema, classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public JAXBObjectifier(Class<?>... classes) throws APIException { + try { + jumar = new JAXBumar(classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // package on purpose + JAXBObjectifier(JAXBumar jumar) { + this.jumar = jumar; + } + + @SuppressWarnings("unchecked") + // @Override + public T objectify(Env env, String input) throws APIException { + TimeTaken tt = env.start("JAXB Unmarshal", Env.XML); + try { + tt.size(input.length()); + return (T)jumar.unmarshal(env.debug(), input); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + @SuppressWarnings("unchecked") + // @Override + public T objectify(Env env, Reader rdr) throws APIException { + //TODO create a Reader that Counts? + TimeTaken tt = env.start("JAXB Unmarshal", Env.XML); + try { + return (T)jumar.unmarshal(env.debug(), rdr); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + + @SuppressWarnings("unchecked") + // @Override + public T objectify(Env env, InputStream is) throws APIException { + //TODO create a Reader that Counts? + TimeTaken tt = env.start("JAXB Unmarshal", Env.XML); + try { + return (T)jumar.unmarshal(env.debug(), is); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + + public void servicePrestart(Env env) throws APIException { + } + + public void threadPrestart(Env env) throws APIException { + } + + // // @Override + public void refresh(Env env) throws APIException { + } + + // // @Override + public void threadDestroy(Env env) throws APIException { + } + + // // @Override + public void serviceDestroy(Env env) throws APIException { + } + + + @SuppressWarnings("unchecked") + public T newInstance() throws APIException { + try { + return (T)jumar.newInstance(); + } catch (Exception e) { + throw new APIException(e); + } + } + +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java new file mode 100644 index 00000000..5bed4fd8 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java @@ -0,0 +1,137 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.jaxb; + +import java.io.OutputStream; +import java.io.StringWriter; +import java.io.Writer; + +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.old.IOStringifier; + +public class JAXBStringifier<T> implements IOStringifier<T> { + private JAXBmar jmar; + + public JAXBStringifier(Class<?>... classes) throws APIException { + try { + jmar = new JAXBmar(classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public JAXBStringifier(QName qname, Class<?>... classes) + throws APIException { + try { + jmar = new JAXBmar(qname, classes); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + // package on purpose + JAXBStringifier(JAXBmar jmar) { + this.jmar = jmar; + } + + // // @Override + public void stringify(Env env, T input, Writer writer, boolean ... options) + throws APIException { + TimeTaken tt = env.start("JAXB Marshal", Env.XML); + try { + jmar.marshal(env.debug(), input, writer, options); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public void stringify(Env env, T input, OutputStream os, boolean ... options) + throws APIException { + // TODO create an OutputStream that Counts? + TimeTaken tt = env.start("JAXB Marshal", Env.XML); + try { + jmar.marshal(env.debug(), input, os, options); + } catch (JAXBException e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public String stringify(Env env, T input, boolean ... options) throws APIException { + TimeTaken tt = env.start("JAXB Marshal", Env.XML); + StringWriter sw = new StringWriter(); + try { + jmar.marshal(env.debug(), input, sw, options); + String rv = sw.toString(); + tt.size(rv.length()); + return rv; + } catch (JAXBException e) { + tt.size(0); + throw new APIException(e); + } finally { + tt.done(); + } + } + + // // @Override + public void servicePrestart(Env env) throws APIException { + } + + // // @Override + public void threadPrestart(Env env) throws APIException { + } + + // // @Override + public void refresh(Env env) throws APIException { + } + + // // @Override + public void threadDestroy(Env env) throws APIException { + } + + // // @Override + public void serviceDestroy(Env env) throws APIException { + } + + // @Override + public JAXBStringifier<T> pretty(boolean pretty) { + jmar.pretty(pretty); + return this; + } + + // @Override + public JAXBStringifier<T> asFragment(boolean fragment) { + jmar.asFragment(fragment); + return this; + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java new file mode 100644 index 00000000..f35ffb7a --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBmar.java @@ -0,0 +1,253 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/** + * JAXBumar.java + * + * Created on: Apr 10, 2009 + * Created by: Jonathan + * + * Revamped to do away with ThreadLocal 5/27/2011, JG1555 + * + * (c) 2009 SBC Knowledge Ventures, L.P. All rights reserved. + ******************************************************************* + * RESTRICTED - PROPRIETARY INFORMATION The Information contained + * herein is for use only by authorized employees of AT&T Services, + * Inc., and authorized Affiliates of AT&T Services, Inc., and is + * not for general distribution within or outside the respective + * companies. + ******************************************************************* + */ +package org.onap.aaf.misc.env.jaxb; + +import java.io.OutputStream; +import java.io.StringWriter; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.util.Pool; +import org.onap.aaf.misc.env.util.Pool.Pooled; + +/** + * JAXBmar classes are inexpensive for going in and out of scope + * and have been made thread safe via Pooling + + * @author Jonathan + * + */ +public class JAXBmar { + // Need to store off possible JAXBContexts based on Class, which will be stored in Creator + private static Map<Class<?>[],Pool<PMarshaller>> pools = new HashMap<Class<?>[], Pool<PMarshaller>>(); + + // Handle Marshaller class setting of properties only when needed + private class PMarshaller { + private Marshaller m; + private boolean p; + private boolean f; + + public PMarshaller(Marshaller marshaller) throws JAXBException { + m = marshaller; + m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = false); + m.setProperty(Marshaller.JAXB_FRAGMENT, f = false); + } + + public Marshaller get(boolean pretty, boolean fragment) throws JAXBException { + if(pretty != p) { + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, p = pretty); + } + if(fragment != f) { + m.setProperty(Marshaller.JAXB_FRAGMENT, f = fragment); + } + return m; + } + } + + private class Creator implements Pool.Creator<PMarshaller> { + private JAXBContext jc; + private String name; + public Creator(Class<?>[] classes) throws JAXBException { + jc = JAXBContext.newInstance(classes); + name = "JAXBmar: " + classes[0].getName(); + } + + // @Override + public PMarshaller create() throws APIException { + try { + return new PMarshaller(jc.createMarshaller()); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public String toString() { + return name; + } + + // @Override + public void reuse(PMarshaller pm) { + // Nothing to do + } + + // @Override + public void destroy(PMarshaller pm) { + // Nothing to do + } + + // @Override + public boolean isValid(PMarshaller t) { + return true; + } + } + + //TODO isn't UTF-8 a standard string somewhere for encoding? + private boolean fragment= false; + private boolean pretty=false; + private QName qname; + + private Pool<PMarshaller> mpool; // specific Pool associated with constructed Classes + private Class<?> cls; + + private Pool<PMarshaller> getPool(Class<?> ... classes) throws JAXBException { + Pool<PMarshaller> mp; + synchronized(pools) { + mp = pools.get(classes); + if(mp==null) { + pools.put(classes,mp = new Pool<PMarshaller>(new Creator(classes))); + } + } + return mp; + } + + public JAXBmar(Class<?>... classes) throws JAXBException { + cls = classes[0]; + mpool = getPool(classes); + qname = null; + } + + public JAXBmar(QName theQname, Class<?>... classes) throws JAXBException { + cls = classes[0]; + mpool = getPool(classes); + qname = theQname; + } + + @SuppressWarnings("unchecked") + public<O> O marshal(LogTarget lt,O o, Writer writer, boolean ... options) throws JAXBException, APIException { + boolean pretty, fragment; + pretty = options.length>0?options[0]:this.pretty; + fragment = options.length>1?options[1]:this.fragment; + Pooled<PMarshaller> m = mpool.get(lt); + try { + if(qname==null) { + m.content.get(pretty,fragment).marshal(o, writer); + } else { + m.content.get(pretty,fragment).marshal( + new JAXBElement<O>(qname, (Class<O>)cls, o ), + writer); + } + return o; + } finally { + m.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O marshal(LogTarget lt, O o, OutputStream os, boolean ... options) throws JAXBException, APIException { + boolean pretty, fragment; + pretty = options.length>0?options[0]:this.pretty; + fragment = options.length>1?options[1]:this.fragment; + Pooled<PMarshaller> m = mpool.get(lt); + try { + if(qname==null) { + m.content.get(pretty,fragment).marshal(o, os); + } else { + m.content.get(pretty,fragment).marshal( + new JAXBElement<O>(qname, (Class<O>)cls, o ),os); + } + return o; + } finally { + m.done(); + } + } + + public<O> O marshal(LogTarget lt, O o, Writer writer, Class<O> clss) throws JAXBException, APIException { + Pooled<PMarshaller> m = mpool.get(lt); + try { + if(qname==null) { + m.content.get(pretty,fragment).marshal(o, writer); + } else { + m.content.get(pretty,fragment).marshal( + new JAXBElement<O>(qname, clss, o),writer); + } + return o; + } finally { + m.done(); + } + + } + + public<O> O marshal(LogTarget lt, O o, OutputStream os, Class<O> clss) throws JAXBException, APIException { + Pooled<PMarshaller> m = mpool.get(lt); + try { + if(qname==null) { + m.content.get(pretty,fragment).marshal(o, os); + } else { + m.content.get(pretty,fragment).marshal( + new JAXBElement<O>(qname, clss, o ),os); + } + return o; + } finally { + m.done(); + } + } + + /** + * @return + */ + public Class<?> getMarshalClass() { + return cls; + } + + public<O> String stringify(LogTarget lt, O o) throws JAXBException, APIException { + StringWriter sw = new StringWriter(); + marshal(lt,o,sw); + return sw.toString(); + } + + public JAXBmar pretty(boolean pretty) { + this.pretty = pretty; + return this; + } + + public JAXBmar asFragment(boolean fragment) { + this.fragment = fragment; + return this; + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java new file mode 100644 index 00000000..7e60bce8 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/jaxb/JAXBumar.java @@ -0,0 +1,243 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/** + * JAXBumar.java + * + * Created on: Apr 10, 2009 + * Created by: Jonathan + * + * Revamped to do away with ThreadLocal 5/27/2011, JG1555 + * + * (c) 2009 SBC Knowledge Ventures, L.P. All rights reserved. + ******************************************************************* + * RESTRICTED - PROPRIETARY INFORMATION The Information contained + * herein is for use only by authorized employees of AT&T Services, + * Inc., and authorized Affiliates of AT&T Services, Inc., and is + * not for general distribution within or outside the respective + * companies. + ******************************************************************* + */ +package org.onap.aaf.misc.env.jaxb; + +import java.io.File; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.util.Pool; +import org.onap.aaf.misc.env.util.Pool.Pooled; +import org.w3c.dom.Node; + +/** + * JAXBumar classes are inexpensive for going in and out of scope + * and have been made thread safe via Pooling + * + * @author Jonathan + * + */ +public class JAXBumar { + // Need to store off possible JAXBContexts based on Class, which will be stored in Creator + private static Map<Class<?>[],Pool<SUnmarshaller>> pools = new HashMap<Class<?>[], Pool<SUnmarshaller>>(); + + private Class<?> cls; + private Schema schema; + private Pool<SUnmarshaller> mpool;; + + // Handle Marshaller class setting of properties only when needed + private class SUnmarshaller { + private Unmarshaller u; + private Schema s; + + public SUnmarshaller(Unmarshaller unmarshaller) throws JAXBException { + u = unmarshaller; + s = null; + } + + public Unmarshaller get(Schema schema) throws JAXBException { + if(s != schema) { + u.setSchema(s = schema); + } + return u; + } + } + + private class Creator implements Pool.Creator<SUnmarshaller> { + private JAXBContext jc; + private String name; + + public Creator(Class<?>[] classes) throws JAXBException { + jc = JAXBContext.newInstance(classes); + name = "JAXBumar: " + classes[0].getName(); + } + + // @Override + public SUnmarshaller create() throws APIException { + try { + return new SUnmarshaller(jc.createUnmarshaller()); + } catch (JAXBException e) { + throw new APIException(e); + } + } + + public String toString() { + return name; + } + + // @Override + public void destroy(SUnmarshaller sui) { + // Nothing to do + } + + // @Override + public boolean isValid(SUnmarshaller t) { + return true; + } + + // @Override + public void reuse(SUnmarshaller t) { + // Nothing to do here + } + + } + + private Pool<SUnmarshaller> getPool(Class<?> ... classes) throws JAXBException { + Pool<SUnmarshaller> mp; + synchronized(pools) { + mp = pools.get(classes); + if(mp==null) { + pools.put(classes,mp = new Pool<SUnmarshaller>(new Creator(classes))); + } + } + return mp; + } + + public JAXBumar(Class<?> ... classes) throws JAXBException { + cls = classes[0]; + mpool = getPool(classes); + schema = null; + } + + /** + * Constructs a new JAXBumar with schema validation enabled. + * + * @param schema + * @param theClass + * @throws JAXBException + */ + public JAXBumar(Schema schema, Class<?> ... classes) throws JAXBException { + cls = classes[0]; + mpool = getPool(classes); + this.schema = schema; + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, Node node) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return s.content.get(schema).unmarshal(node,(Class<O>)cls).getValue(); + } finally { + s.done(); + } + + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, String xml) throws JAXBException, APIException { + if(xml==null) throw new JAXBException("Null Input for String unmarshal"); + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal( + new StreamSource(new StringReader(xml)) + ,(Class<O>)cls).getValue(); + } finally { + s.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, File xmlFile) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal(xmlFile); + } finally { + s.done(); + } + + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env,InputStream is) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal(is); + } finally { + s.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, Reader rdr) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal(rdr); + } finally { + s.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, XMLStreamReader xsr) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal(xsr,(Class<O>)cls).getValue(); + } finally { + s.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O unmarshal(LogTarget env, XMLEventReader xer) throws JAXBException, APIException { + Pooled<SUnmarshaller> s = mpool.get(env); + try { + return (O)s.content.get(schema).unmarshal(xer,(Class<O>)cls).getValue(); + } finally { + s.done(); + } + } + + @SuppressWarnings("unchecked") + public<O> O newInstance() throws InstantiationException, IllegalAccessException{ + return ((Class<O>)cls).newInstance(); + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java new file mode 100644 index 00000000..65c5a36e --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOObjectifier.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.old; + +import java.io.InputStream; +import java.io.Reader; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; + +public interface IOObjectifier<T> extends Objectifier<T> { + /** + * Marshal to Object T from a Reader, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, Reader rdr) throws APIException; + + /** + * Marshal to Object T from an InputStream, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, InputStream is) throws APIException; + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java new file mode 100644 index 00000000..c5f57b98 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/IOStringifier.java @@ -0,0 +1,77 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.old; + +import java.io.OutputStream; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; + +/** + * Allow Extended IO interface usage without muddying up the Stringifier Interface + */ +public interface IOStringifier<T> extends Stringifier<T> { + /** + * Marshal from an Object T onto a Writer, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startTime(<string>, Env.XML)" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract void stringify(Env env, T input, Writer writer, boolean ... options) throws APIException; + + /** + * Marshal from a String to an Object T, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract void stringify(Env env, T input, OutputStream os, boolean ... options) throws APIException; + + /** + * Set Pretty XML, where possible + * + * @param pretty + * @throws APIException + */ + public abstract IOStringifier<T> pretty(boolean pretty); + + /** + * Set Generate Fragment + * + * @param fragment + * @throws APIException + */ + public abstract IOStringifier<T> asFragment(boolean fragment); + + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java new file mode 100644 index 00000000..6ec72ba4 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Objectifier.java @@ -0,0 +1,60 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.old; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LifeCycle; + + +/** + * <h1>Objectifier</h1> + * <i>Objectifier</i> abstracts the unmarshaling of an Object from a String, and + * the creation of an uninitialized object. + */ +public interface Objectifier<T> extends LifeCycle { + /** + * Marshal to Object T from a String, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return T + * @throws APIException + */ + public abstract T objectify(Env env, String input) throws APIException; + + /** + * Create a new object of type T. This is often more efficiently done with + * the underlying XML (or other) Library. + * @return T + * @throws APIException + */ + public abstract T newInstance() throws APIException; + + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java new file mode 100644 index 00000000..a4342614 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/OldDataFactory.java @@ -0,0 +1,47 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.old; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.DataFactory; +import org.onap.aaf.misc.env.Env; + +public interface OldDataFactory<T> extends DataFactory<T> { + public abstract String stringify(T type) throws APIException; + public abstract void stringify(T type, OutputStream os) throws APIException; + public abstract void stringify(T type, Writer writer) throws APIException; + public abstract T objectify(InputStream is) throws APIException; + public abstract T objectify(Reader rdr) throws APIException; + public abstract T objectify(String text) throws APIException; + public abstract T newInstance() throws APIException; + public abstract Data<T> newData(T type); + public abstract Data<T> newDataFromStream(Env env, InputStream input) throws APIException; + public abstract Data<T> newDataFromString(String string); + +} + diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java new file mode 100644 index 00000000..7dcdf34f --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/old/Stringifier.java @@ -0,0 +1,48 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.old; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LifeCycle; + + +/** + * <h1>Stringifier</h1> + * <i>Stringifier</i> abstracts the marshaling of a String to an Object + */ +public interface Stringifier<T> extends LifeCycle { + + /** + * Marshal from a String to an Object T, using contents from Env as necessary.<p> + * + * Implementations should use the {@link Env} to call "env.startXMLTime()" to mark + * XML time, since this is often a costly process. + * + * @param env + * @param input + * @return String + * @throws APIException + */ + public abstract String stringify(Env env, T input, boolean ... options) throws APIException; + +}
\ No newline at end of file diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java new file mode 100644 index 00000000..74fbef65 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Chrono.java @@ -0,0 +1,310 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.security.SecureRandom; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import java.util.UUID; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +public class Chrono { + private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; + + public final static DateFormat dateFmt, dateOnlyFmt, niceDateFmt, utcFmt,iso8601Fmt; + // Give general access to XML DataType Factory, since it's pretty common + public static final DatatypeFactory xmlDatatypeFactory; + + static { + try { + xmlDatatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException(e); + } + dateOnlyFmt = new SimpleDateFormat("yyyy-MM-dd"); + niceDateFmt = new SimpleDateFormat("yyyy/MM/dd HH:mm zzz"); + dateFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + utcFmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + iso8601Fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); + utcFmt.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + + public static class Formatter8601 extends Formatter { + + @Override + public String format(LogRecord r) { + StringBuilder sb = new StringBuilder(); + sb.append(dateFmt.format(new Date(r.getMillis()))); + sb.append(' '); + sb.append(r.getThreadID()); + sb.append(' '); + sb.append(r.getLevel()); + sb.append(": "); + sb.append(r.getMessage()); + sb.append('\n'); + return sb.toString(); + } + + } + + /** + * timeStamp + * + * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with "now" + * @return + */ + public static XMLGregorianCalendar timeStamp() { + return xmlDatatypeFactory.newXMLGregorianCalendar(new GregorianCalendar()); + } + + /** + * timestamp + * + * Convenience method to setup an XML dateTime (XMLGregorianCalendar) with passed in Date + * @param date + * @return + */ + public static XMLGregorianCalendar timeStamp(Date date) { + GregorianCalendar gc = new GregorianCalendar(); + gc.setTime(date); + return xmlDatatypeFactory.newXMLGregorianCalendar(gc); + } + + public static XMLGregorianCalendar timeStamp(GregorianCalendar gc) { + return xmlDatatypeFactory.newXMLGregorianCalendar(gc); + } + + public static String utcStamp() { + return utcFmt.format(new Date()); + } + + public static String utcStamp(Date date) { + if(date==null)return ""; + return utcFmt.format(date); + } + + public static String utcStamp(GregorianCalendar gc) { + if(gc==null)return ""; + return utcFmt.format(gc.getTime()); + } + + public static String utcStamp(XMLGregorianCalendar xgc) { + if(xgc==null)return ""; + return utcFmt.format(xgc.toGregorianCalendar().getTime()); + } + + public static String dateStamp() { + return dateFmt.format(new Date()); + } + + public static String dateStamp(GregorianCalendar gc) { + if(gc == null)return ""; + return dateFmt.format(gc.getTime()); + } + + public static String dateStamp(Date date) { + if(date == null)return ""; + return dateFmt.format(date); + } + + public static String dateStamp(XMLGregorianCalendar xgc) { + if(xgc==null)return ""; + return dateFmt.format(xgc.toGregorianCalendar().getTime()); + } + + /** + * JAXB compatible dataTime Stamp + * + * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it. + * + * @return + */ + public static String dateTime() { + return dateTime(new GregorianCalendar()); + } + + /** + * JAXB compatible dataTime Stamp + * + * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it. + * + * @return + */ + public static String dateTime(Date date) { + GregorianCalendar gc = new GregorianCalendar(); + gc.setTime(date); + return dateTime(gc); + } + + /** + * JAXB compatible dataTime Stamp + * + * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it. + * + * @return + */ + public static String dateTime(GregorianCalendar gc) { + if(gc == null)return ""; + TimeZone tz = gc.getTimeZone(); + int tz1 = (tz.getRawOffset()+tz.getDSTSavings())/0x8CA0; + int tz1abs = Math.abs(tz1); + return String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d", + gc.get(GregorianCalendar.YEAR), + gc.get(GregorianCalendar.MONTH)+1, + gc.get(GregorianCalendar.DAY_OF_MONTH), + gc.get(GregorianCalendar.HOUR), + gc.get(GregorianCalendar.MINUTE), + gc.get(GregorianCalendar.SECOND), + gc.get(GregorianCalendar.MILLISECOND), + tz1==tz1abs?'+':'-', + tz1abs/100, + ((tz1abs-(tz1abs/100)*100)*6)/10 // Get the "10s", then convert to mins (without losing int place) + ); + } + + /** + * JAXB compatible dataTime Stamp + * + * Java 6 does not format Timezone with -05:00 format, and JAXB XML breaks without it. + * + * @return + */ + public static String dateTime(XMLGregorianCalendar xgc) { + return xgc==null?"":dateTime(xgc.toGregorianCalendar()); + } + + public static String dateOnlyStamp() { + return dateOnlyFmt.format(new Date()); + } + + public static String dateOnlyStamp(GregorianCalendar gc) { + return gc == null?"":dateOnlyFmt.format(gc.getTime()); + } + + public static String dateOnlyStamp(Date date) { + return date == null?"":dateOnlyFmt.format(date); + } + + public static String dateOnlyStamp(XMLGregorianCalendar xgc) { + return xgc==null?"":dateOnlyFmt.format(xgc.toGregorianCalendar().getTime()); + } + + public static String niceDateStamp() { + return niceDateFmt.format(new Date()); + } + + public static String niceDateStamp(Date date) { + return date==null?"":niceDateFmt.format(date); + } + + public static String niceDateStamp(GregorianCalendar gc) { + return gc==null?"":niceDateFmt.format(gc.getTime()); + } + + public static String niceDateStamp(XMLGregorianCalendar xgc) { + return xgc==null?"":niceDateFmt.format(xgc.toGregorianCalendar().getTime()); + } + + + ////////////////////// HELPFUL Strings + public static final String BAD_DIR_CHARS_REGEX = "[/:\\;.]"; + public static final String SPLIT_DIR_REGEX = "/"; + + public static long firstMomentOfDay(long utc) { + GregorianCalendar begin = new GregorianCalendar(); + begin.setTimeInMillis(utc); + return firstMomentOfDay(begin).getTimeInMillis(); + } + + public static long lastMomentOfDay(long utc) { + GregorianCalendar end = new GregorianCalendar(); + end.setTimeInMillis(utc); + return lastMomentOfDay(end).getTimeInMillis(); + } + + public static GregorianCalendar firstMomentOfDay(GregorianCalendar begin) { + if(begin==null)begin = new GregorianCalendar(); + begin.set(GregorianCalendar.HOUR, 0); + begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM); + begin.set(GregorianCalendar.MINUTE, 0); + begin.set(GregorianCalendar.SECOND, 0); + begin.set(GregorianCalendar.MILLISECOND, 0); + return begin; + } + + public static GregorianCalendar lastMomentOfDay(GregorianCalendar end) { + if(end==null)end = new GregorianCalendar(); + end.set(GregorianCalendar.HOUR, 11); + end.set(GregorianCalendar.MINUTE, 59); + end.set(GregorianCalendar.SECOND, 59); + end.set(GregorianCalendar.MILLISECOND, 999); + end.set(GregorianCalendar.AM_PM, GregorianCalendar.PM); + return end; + } + + // UUID needs to be converted from UUID Epoch + public static final Date uuidToDate(UUID id) { + return new Date((id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000); + } + + public static final long uuidToUnix(UUID id) { + return (id.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH)/10000; + } + + public static float millisFromNanos(long start, long end) { + return (end - start) / 1000000f; + } + + + private static long sequence = new SecureRandom().nextInt(); + private static synchronized long sequence() { + return ++sequence; + } + + public static final UUID dateToUUID(Date origTime) { + return dateToUUID(origTime.getTime()); + } + + public static final UUID dateToUUID(long origTime) { + /* + * From Cassandra : http://wiki.apache.org/cassandra/FAQ + Magic number obtained from #cassandra's thobbs, who + claims to have stolen it from a Python library. + */ + long time = origTime * 10000 + NUM_100NS_INTERVALS_SINCE_UUID_EPOCH; + long timeLow = time & 0xffffffffL; + long timeMid = time & 0xffff00000000L; + long timeHi = time & 0xfff000000000000L; + long upperLong = (timeLow << 32) | (timeMid >> 16) | (1 << 12) | (timeHi >> 48) ; + return new java.util.UUID(upperLong, (0xC000000000000000L | sequence())); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java new file mode 100644 index 00000000..0bce4733 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/DoubleOutputStream.java @@ -0,0 +1,97 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.io.IOException; +import java.io.OutputStream; + +public class DoubleOutputStream extends OutputStream { + private OutputStream[] oss; + private boolean[] close; + + /** + * Create a Double Stream Writer + * Some Streams should not be closed by this object (i.e. System.out), therefore, mark them with booleans + */ + public DoubleOutputStream(OutputStream a, boolean closeA, OutputStream b, boolean closeB) { + oss = new OutputStream[] {a,b}; + close = new boolean[] {closeA,closeB}; + } + + /** + * Write a single character. + * @throws IOException + */ + @Override + public void write(int c) throws IOException { + for(OutputStream os : oss) { + os.write(c); + } + } + + /** + * Write a portion of an array of characters. + * + * @param bbuf Array of characters + * @param off Offset from which to start writing characters + * @param len Number of characters to write + * @throws IOException + */ + @Override + public void write(byte bbuf[], int off, int len) throws IOException { + for(OutputStream os : oss) { + os.write(bbuf,off,len); + } + } + + @Override + public void write(byte[] b) throws IOException { + for(OutputStream os : oss) { + os.write(b); + } + } + + /* (non-Javadoc) + * @see java.io.OutputStream#close() + */ + @Override + public void close() throws IOException { + for(int i=0;i<oss.length;++i) { + if(close[i]) { + oss[i].close(); + } + } + } + + /* (non-Javadoc) + * @see java.io.OutputStream#flush() + */ + @Override + public void flush() throws IOException { + for(OutputStream os : oss) { + os.flush(); + } + } + + + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java new file mode 100644 index 00000000..d6ac850d --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IPValidator.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.util.regex.Pattern; + +public class IPValidator { + private static final Pattern ipv4_p = Pattern.compile( + "^((\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}\\2$" + ); + + private static final Pattern ipv6_p = Pattern.compile( + "^(([0-9a-fA-F]{0,4})([:|.])){2,7}([0-9a-fA-F]{0,4})$" + ); + + private static final Pattern doubleColon = Pattern.compile( + ".*::.*::.*" + ); + + private static final Pattern tooManyColon = Pattern.compile( + "(.*:){1,7}" + ); + + + public static boolean ipv4(String str) { + return ipv4_p.matcher(str).matches(); + } + + public static boolean ipv6(String str) { + return ipv6_p.matcher(str).matches() && + !doubleColon.matcher(str).matches() && + !tooManyColon.matcher(str).matches(); + } + + public static boolean ip (String str) { + return ipv4_p.matcher(str).matches() || ipv6(str); + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/IndentPrintWriter.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IndentPrintWriter.java new file mode 100644 index 00000000..17cbff37 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/IndentPrintWriter.java @@ -0,0 +1,114 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Writer; + +/** + * @author Jonathan + * + * Catch \n and indent according to current indent levels of JavaGen + */ +public class IndentPrintWriter extends PrintWriter { + public static int INDENT = 2; + private boolean addIndent; + private int indent; + private int col; + + public IndentPrintWriter(Writer out) { + super(out); + addIndent = false; + indent = col = 0; + } + + public IndentPrintWriter(OutputStream out) { + super(out); + addIndent = false; + indent = col = 0; + } + + + public void write(String str) { + int len = str.length(); + for(int i=0;i<len;++i) { + write((int)str.charAt(i)); + } + } + + public void println() { + write((int)'\n'); + } + public void write(String str, int off, int len) { + len = Math.min(str.length(),off+len); + for(int i=off;i<len;++i) { + write((int)str.charAt(i)); + } + } + public void write(int b) { + if (b == '\n') { + addIndent = true; + col = 0; + } else if (addIndent) { + addIndent = false; + toIndent(); + } else { + ++col; + } + super.write(b); + } + + @Override + public void write(char[] buf, int off, int len) { + for (int i = 0; i < len; ++i) + write(buf[i] + off); + } + + public void setIndent(int size) { + indent = size; + } + + public void inc() { + ++indent; + } + + public void dec() { + --indent; + } + + public void toCol(int idx) { + while(idx>col++)super.write((int)' '); + } + + public int getIndent() { + return indent; + } + + public void toIndent() { + int end = indent * INDENT; + for (int i = 0; i < end; ++i) { + super.write((int) ' '); + } + col = end; + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java new file mode 100644 index 00000000..cd11dcb3 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Pool.java @@ -0,0 +1,398 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * + */ + +/* + * Pool + * + * Author: Jonathan + * 5/27/2011 + */ +package org.onap.aaf.misc.env.util; + +import java.util.LinkedList; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.LogTarget; + +/** + * This Class pools on an As-Needed-Basis any particular kind of class, which is + * quite suitable for expensive operations. + * + * The user calls "get" on a Pool, and if a waiting resource (T) is available, + * it will be returned. Otherwise, one will be created with the "Creator" class + * (must be defined for (T)). + * + * You can Prime the instances to avoid huge startup costs + * + * The returned "Pooled" object simply has to call "done()" and the object is + * returned to the pool. If the developer does not return the object, a memory + * leak does not occur. There are no references to the object once "get" is + * called. However, the developer who does not return the object when done + * obviates the point of the pool, as new Objects are created in place of the + * Object not returned when another call to "get" is made. + * + * There is a cushion of extra objects, currently defaulted to MAX_RANGE. If the + * items returned become higher than the MAX_RANGE, the object is allowed to go + * out of scope, and be cleaned up. the default can be changed on a per-pool + * basis. + * + * + * @author Jonathan + * + * @param <T> + */ +public class Pool<T> { + /** + * This is a constant which specified the default maximum number of unused + * objects to be held at any given time. + */ + private static final int MAX_RANGE = 6; // safety + + /** + * only Simple List needed. + * + * NOTE TO MAINTAINERS: THIS OBJECT DOES IT'S OWN SYNCHRONIZATION. All + * changes that touch list must account for correctly synchronizing list. + */ + private LinkedList<Pooled<T>> list; + + /** + * keep track of how many elements exist, to avoid asking list. + */ + private int count; + + /** + * Spares are those Object that are primed and ready to go. + */ + private int spares; + + /** + * Actual MAX number of spares allowed to hang around. Can be set to + * something besides the default MAX_RANGE. + */ + private int max_range = MAX_RANGE; + + /** + * The Creator for this particular pool. It must work for type T. + */ + private Creator<T> creator; + + /** + * Create a new Pool, given the implementation of Creator<T>, which must be + * able to create/destroy T objects at will. + * + * @param creator + */ + public Pool(Creator<T> creator) { + count = spares = 0; + this.creator = creator; + list = new LinkedList<Pooled<T>>(); + } + + /** + * Preallocate a certain number of T Objects. Useful for services so that + * the first transactions don't get hit with all the Object creation costs + * + * @param lt + * @param prime + * @throws APIException + */ + public void prime(LogTarget lt, int prime) throws APIException { + for (int i = 0; i < prime; ++i) { + Pooled<T> pt = new Pooled<T>(creator.create(), this, lt); + synchronized (list) { + list.addFirst(pt); + ++count; + } + } + + } + + /** + * Destroy and remove all remaining objects. This is valuable for closing + * down all Allocated objects cleanly for exiting. It is also a good method + * for removing objects when, for instance, all Objects are invalid because + * of broken connections, etc. + */ + public void drain() { + synchronized (list) { + for (int i = 0; i < list.size(); ++i) { + Pooled<T> pt = list.remove(); + creator.destroy(pt.content); + pt.logTarget.log("Pool drained ", creator.toString()); + } + count = spares = 0; + } + + } + + /** + * This is the essential function for Pool. Get an Object "T" inside a + * "Pooled<T>" object. If there is a spare Object, then use it. If not, then + * create and pass back. + * + * This one uses a Null LogTarget + * + * IMPORTANT: When the use of this object is done (and the object is still + * in a valid state), then "done()" should be called immediately to allow + * the object to be reused. That is the point of the Pool... + * + * If the Object is in an invalid state, then "toss()" should be used so the + * Pool doesn't pass on invalid objects to others. + * + * @param lt + * @return + * @throws APIException + */ + public Pooled<T> get() throws APIException { + Pooled<T> pt; + synchronized (list) { + if (list.isEmpty()) { + pt = null; + } else { + pt = list.removeLast(); + --count; + creator.reuse(pt.content); + } + } + if (pt == null) { + if (spares < max_range) + ++spares; + pt = new Pooled<T>(creator.create(), this, LogTarget.NULL); + } else { + if (spares > 1) + --spares; + } + return pt; + } + + /** + * This is the essential function for Pool. Get an Object "T" inside a + * "Pooled<T>" object. If there is a spare Object, then use it. If not, then + * create and pass back. + * + * If you don't have access to a LogTarget from Env, use LogTarget.NULL + * + * IMPORTANT: When the use of this object is done (and the object is still + * in a valid state), then "done()" should be called immediately to allow + * the object to be reused. That is the point of the Pool... + * + * If the Object is in an invalid state, then "toss()" should be used so the + * Pool doesn't pass on invalid objects to others. + * + * @param lt + * @return + * @throws APIException + */ + public Pooled<T> get(LogTarget lt) throws APIException { + Pooled<T> pt; + synchronized (list) { + if (list.isEmpty()) { + pt = null; + } else { + pt = list.remove(); + --count; + creator.reuse(pt.content); + } + } + if (pt == null) { + if (spares < max_range) + ++spares; + pt = new Pooled<T>(creator.create(), this, lt); + lt.log("Pool created ", creator.toString()); + } else { + if (spares > 1) + --spares; + } + return pt; + } + + /** + * This function will validate whether the Objects are still in a usable + * state. If not, they are tossed from the Pool. This is valuable to have + * when Remote Connections go down, and there is a question on whether the + * Pooled Objects are still functional. + * + * @return + */ + public boolean validate() { + boolean rv = true; + synchronized (list) { + for (Pooled<T> t : list) { + if (!creator.isValid(t.content)) { + rv = false; + t.toss(); + list.remove(t); + } + } + } + return rv; + } + + /** + * This is an internal method, used only by the Internal Pooled<T> class. + * + * The Pooled<T> class "offers" it's Object back after use. It is an + * "offer", because Pool will simply destroy and remove the object if it has + * more than enough spares. + * + * @param lt + * @param used + * @return + */ + // Used only by Pooled<T> + private boolean offer(LogTarget lt, Pooled<T> used) { + if (count < spares) { + synchronized (list) { + list.addFirst(used); + ++count; + } + lt.log("Pool recovered ", creator.toString()); + } else { + lt.log("Pool destroyed ", creator.toString()); + creator.destroy(used.content); + } + return false; + } + + /** + * The Creator Interface give the Pool the ability to Create, Destroy and + * Validate the Objects it is maintaining. Thus, it is a specially written + * Implementation for each type. + * + * @author Jonathan + * + * @param <T> + */ + public interface Creator<T> { + public T create() throws APIException; + + public void destroy(T t); + + public boolean isValid(T t); + + public void reuse(T t); + } + + /** + * The "Pooled<T>" class is the transient class that wraps the actual Object + * T for API use/ It gives the ability to return ("done()", or "toss()") the + * Object to the Pool when processing is finished. + * + * For Safety, i.e. to avoid memory leaks and invalid Object States, there + * is a "finalize" method. It is strictly for when coder forgets to return + * the object, or perhaps hasn't covered the case during Exceptions or + * Runtime Exceptions with finally (preferred). This should not be + * considered normal procedure, as finalize() is called at an undetermined + * time during garbage collection, and is thus rather useless for a Pool. + * However, we don't want Coding Mistakes to put the whole program in an + * invalid state, so if something happened such that "done()" or "toss()" + * were not called, the resource is still cleaned up as well as possible. + * + * @author Jonathan + * + * @param <T> + */ + public static class Pooled<T> { + public final T content; + private Pool<T> pool; + protected LogTarget logTarget; + + /** + * Create the Wrapping Object Pooled<T>. + * + * @param t + * @param pool + * @param logTarget + */ + public Pooled(T t, Pool<T> pool, LogTarget logTarget) { + content = t; + this.pool = pool; + this.logTarget = logTarget; + } + + /** + * This is the key API for the Pool, as calling "done()" offers this + * object back to the Pool for reuse. + * + * Do not use the Pooled<T> object again after calling "done()". + */ + public void done() { + if (pool != null) { + pool.offer(logTarget, this); + } + } + + /** + * The user of the Object may discover that the Object t is no longer in + * a valid state. Don't put Garbage back in the Refrigerator... Toss it, + * if it's no longer valid. + * + * toss() is also used for draining the Pool, etc. + * + * toss() will attempt to destroy the Object by using the Creator + * Interface. + * + */ + public void toss() { + if (pool != null) { + pool.creator.destroy(content); + } + // Don't allow finalize to put it back in. + pool = null; + } + + /** + * Just in case someone neglected to offer back object... Do not rely on + * this, as there is no specific time when finalize is called, which + * rather defeats the purpose of a Pool. + */ + @Override + protected void finalize() throws Throwable { + if (pool != null) { + done(); + pool = null; + } + } + } + + /** + * Get the maximum number of spare objects allowed at any moment + * + * @return + */ + public int getMaxRange() { + return max_range; + } + + /** + * Set a Max Range for numbers of spare objects waiting to be used. + * + * No negative numbers are allowed + * + * @return + */ + public void setMaxRange(int max_range) { + // Do not allow negative numbers + this.max_range = Math.max(0, max_range); + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java new file mode 100644 index 00000000..56153393 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/RefreshableThreadObject.java @@ -0,0 +1,124 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Creatable; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LifeCycle; + + +/** + * <h1>RefreshableThreadObject</h1> + * This is a ThreadLocal like implementation, but it responds to + * the {@link LifeCycle} mechanism for configuration refreshes, and + * implements {@link Creatable} (for use in destroy, etc).<p> + * + * In addition to the Thread instance semantics, it compares when the object + * was created versus the last "refresh(env)" call when getting, for the + * thread, and if necessary to replace the created object, destroying the + * previous.<p> + * + * In most cases, it's better to use the new "Pool" mechanism, as it deals with + * gaining and returning resources on an as needed basis. This, however, remains + * in the cases where specific Objects need to be retained to specific Threads.<p> + * + * There is no way to do this kind of specialized behavior in ThreadLocal. + * + * @author Jonathan + * + * @param <T> + */ +public class RefreshableThreadObject<T extends Creatable<T>> { + private Map<Thread,T> objs; + private long refreshed; + private Constructor<T> cnst; + + /** + * The passed in class <b>must</b> implement the constructor + * <pre> + * public MyClass(Env env) { + * ... + * } + * </pre> + * @param clss + * @throws APIException + */ + public RefreshableThreadObject(Class<T> clss) throws APIException { + objs = new ConcurrentHashMap<Thread,T>(); + try { + cnst = clss.getConstructor(new Class[]{Env.class} ); + } catch (Exception e) { + throw new APIException(e); + } + } + + /** + * Get the "T" class from the current thread + * + * @param env + * @return T + * @throws APIException + */ + public T get(Env env) throws APIException { + Thread t = Thread.currentThread(); + T obj = objs.get(t); + if(obj==null || refreshed>obj.created()) { + try { + obj = cnst.newInstance(new Object[]{env}); + } catch (InvocationTargetException e) { + throw new APIException(e.getTargetException()); + } catch (Exception e) { + throw new APIException(e); + } + T destroyMe = objs.put(t,obj); + if(destroyMe!=null) { + destroyMe.destroy(env); + } + } + return obj; + } + + /** + * Mark the timestamp of refreshed. + * + * @param env + */ + public void refresh(Env env) { + refreshed = System.currentTimeMillis(); + } + + /** + * Remove the object from the Thread instances + * @param env + */ + public void remove(Env env) { + T obj = objs.remove(Thread.currentThread()); + if(obj!=null) + obj.destroy(env); + } +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java new file mode 100644 index 00000000..79a74031 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/Split.java @@ -0,0 +1,89 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +/** + * Split by Char, optional Trim + * + * Note: I read the String split and Pattern split code, and we can do this more efficiently for a single Character + * + * Jonathan 8/20/2015 + */ + +public class Split { + public static String[] split(char c, String value) { + // Count items to preallocate Array (memory alloc is more expensive than counting twice) + int count,idx; + for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count); + String[] rv = new String[count]; + if(count==1) { + rv[0]=value; + } else { + int last=0; + count=-1; + for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) { + rv[++count]=value.substring(last,idx); + last = ++idx; + } + rv[++count]=value.substring(last); + } + return rv; + } + + public static String[] splitTrim(char c, String value) { + // Count items to preallocate Array (memory alloc is more expensive than counting twice) + int count,idx; + for(count=1,idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,++idx),++count); + String[] rv = new String[count]; + if(count==1) { + rv[0]=value.trim(); + } else { + int last=0; + count=-1; + for(idx=value.indexOf(c);idx>=0;idx=value.indexOf(c,idx)) { + rv[++count]=value.substring(last,idx).trim(); + last = ++idx; + } + rv[++count]=value.substring(last).trim(); + } + return rv; + } + + public static String[] splitTrim(char c, String value, int size) { + int idx; + String[] rv = new String[size]; + if(size==1) { + rv[0]=value.trim(); + } else { + int last=0; + int count=-1; + size-=2; + for(idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) { + rv[++count]=value.substring(last,idx).trim(); + last = ++idx; + } + rv[++count]=value.substring(last).trim(); + } + return rv; + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java new file mode 100644 index 00000000..c2a1f91a --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderOutputStream.java @@ -0,0 +1,178 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.io.IOException; +import java.io.OutputStream; + +public class StringBuilderOutputStream extends OutputStream { + private StringBuilder buf; + + + /** + * Create a new string writer using the default initial string-buffer + * size. + */ + public StringBuilderOutputStream() { + buf = new StringBuilder(); + } + + /** + * Create a new string writer using a passed in StringBuilder + * size. + */ + public StringBuilderOutputStream(StringBuilder sb) { + buf = sb; + } + + /** + * Create a new string writer using the specified initial string-buffer + * size. + * + * @param initialSize + * The number of <tt>byte</tt> values that will fit into this buffer + * before it is automatically expanded + * + * @throws IllegalArgumentException + * If <tt>initialSize</tt> is negative + */ + public StringBuilderOutputStream(int initialSize) { + if (initialSize < 0) { + throw new IllegalArgumentException("Negative buffer size"); + } + buf = new StringBuilder(initialSize); + } + + /** + * Write a single character. + */ + public void write(int c) { + buf.append((byte) c); + } + + /** + * Write a portion of an array of characters. + * + * @param bbuf Array of characters + * @param off Offset from which to start writing characters + * @param len Number of characters to write + */ + + public void write(byte bbuf[], int off, int len) { + if ((off < 0) || (off > bbuf.length) || (len < 0) || + ((off + len) > bbuf.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + buf.append(new String(bbuf, off, len)); + } + + @Override + public void write(byte[] b) throws IOException { + buf.append(new String(b)); + } + + /** + * Write a string. + */ + public void write(String str) { + buf.append(str); + } + + /** + * Write a portion of a string. + * + * @param str String to be written + * @param off Offset from which to start writing characters + * @param len Number of characters to write + */ + public void write(String str, int off, int len) { + buf.append(str,off,len); + } + + public StringBuilderOutputStream append(CharSequence csq) { + if (csq == null) { + write("null"); + } else { + for(int i = 0;i<csq.length();++i) { + buf.append(csq.charAt(i)); + } + } + return this; + } + + public StringBuilderOutputStream append(CharSequence csq, int start, int end) { + CharSequence cs = (csq == null ? "null" : csq); + return append(cs.subSequence(start, end)); + } + + /** + * Appends the specified character to this writer. + * + * <p> An invocation of this method of the form <tt>out.append(c)</tt> + * behaves in exactly the same way as the invocation + * + * <pre> + * out.write(c) </pre> + * + * @param c + * The 16-bit character to append + * + * @return This writer + * + * @since 1.5 + */ + public StringBuilderOutputStream append(byte c) { + buf.append(c); + return this; + } + + /** + * Return the buffer's current value as a string. + */ + public String toString() { + return buf.toString(); + } + + /** + * Return the string buffer itself. + * + * @return StringBuffer holding the current buffer value. + */ + public StringBuilder getBuffer() { + return buf; + } + + public void reset() { + buf.setLength(0); + } + + @Override + public void flush() throws IOException { + } + + @Override + public void close() throws IOException { + } + +} diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java new file mode 100644 index 00000000..cea4d859 --- /dev/null +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/util/StringBuilderWriter.java @@ -0,0 +1,172 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util; + +import java.io.IOException; +import java.io.Writer; + +public class StringBuilderWriter extends Writer { + private StringBuilder buf; + + + /** + * Create a new string writer using the default initial string-buffer + * size. + */ + public StringBuilderWriter() { + buf = new StringBuilder(); + } + + /** + * Create a new string writer using a passed in StringBuilder + * size. + */ + public StringBuilderWriter(StringBuilder sb) { + buf = sb; + } + + /** + * Create a new string writer using the specified initial string-buffer + * size. + * + * @param initialSize + * The number of <tt>char</tt> values that will fit into this buffer + * before it is automatically expanded + * + * @throws IllegalArgumentException + * If <tt>initialSize</tt> is negative + */ + public StringBuilderWriter(int initialSize) { + if (initialSize < 0) { + throw new IllegalArgumentException("Negative buffer size"); + } + buf = new StringBuilder(initialSize); + } + + /** + * Write a single character. + */ + public void write(int c) { + buf.append((char) c); + } + + /** + * Write a portion of an array of characters. + * + * @param cbuf Array of characters + * @param off Offset from which to start writing characters + * @param len Number of characters to write + */ + public void write(char cbuf[], int off, int len) { + if ((off < 0) || (off > cbuf.length) || (len < 0) || + ((off + len) > cbuf.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + buf.append(cbuf, off, len); + } + + /** + * Write a string. + */ + public void write(String str) { + buf.append(str); + } + + /** + * Write a portion of a string. + * + * @param str String to be written + * @param off Offset from which to start writing characters + * @param len Number of characters to write + */ + public void write(String str, int off, int len) { + char[] chars = new char[len]; + str.getChars(off, off+len, chars, 0); + buf.append(chars); + } + + public StringBuilderWriter append(CharSequence csq) { + if (csq == null) { + write("null"); + } else { + buf.append(csq); + } + return this; + } + + public StringBuilderWriter append(CharSequence csq, int start, int end) { + CharSequence cs = (csq == null ? "null" : csq); + return append(cs.subSequence(start, end)); + } + + /** + * Appends the specified character to this writer. + * + * <p> An invocation of this method of the form <tt>out.append(c)</tt> + * behaves in exactly the same way as the invocation + * + * <pre> + * out.write(c) </pre> + * + * @param c + * The 16-bit character to append + * + * @return This writer + * + * @since 1.5 + */ + public StringBuilderWriter append(char c) { + buf.append(c); + return this; + } + + /** + * Return the buffer's current value as a string. + */ + public String toString() { + return buf.toString(); + } + + /** + * Return the string buffer itself. + * + * @return StringBuffer holding the current buffer value. + */ + public StringBuilder getBuffer() { + return buf; + } + + public void reset() { + buf.setLength(0); + } + + @Override + public void flush() throws IOException { + } + + @Override + public void close() throws IOException { + } + +} diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java new file mode 100644 index 00000000..01acf218 --- /dev/null +++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java @@ -0,0 +1,70 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.util.test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.junit.Test; +import org.onap.aaf.misc.env.util.IPValidator; + +public class JU_IPValidator { + + @Test + public void test() { + assertTrue(IPValidator.ipv4("10.10.10.10")); + assertTrue(IPValidator.ipv4("127.0.0.0")); + assertFalse(IPValidator.ipv4("10")); + assertFalse(IPValidator.ipv4("10.10.10")); + assertFalse(IPValidator.ipv4("10.10.10.")); + assertFalse(IPValidator.ipv4("10.10.10.10.")); + assertFalse(IPValidator.ipv4("10.10.10.10.10")); + assertFalse(IPValidator.ipv4("something10.10.10.10")); + assertTrue(IPValidator.ipv4("0.10.10.10")); + assertTrue(IPValidator.ipv4("0.0.0.0")); + assertTrue(IPValidator.ipv4("0.10.10.10")); + assertFalse(IPValidator.ipv4("011.255.255.255")); + assertFalse(IPValidator.ipv4("255.01.255.255")); + assertFalse(IPValidator.ipv4("255.255.255.256")); + assertFalse(IPValidator.ipv4("255.299.255.255")); + + + assertTrue(IPValidator.ipv6("0000:0000:0000:0000:0000:0000:0000:0000")); + assertTrue(IPValidator.ipv6("0:0:0:0:0:0:0:0")); + assertTrue(IPValidator.ipv6("2001:08DB:0000:0000:0023:F422:FE3B:AC10")); + assertTrue(IPValidator.ipv6("2001:8DB:0:0:23:F422:FE3B:AC10")); + assertTrue(IPValidator.ipv6("2001:8DB::23:F422:FE3B:AC10")); + assertTrue(IPValidator.ipv6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")); + assertTrue(IPValidator.ipv6("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF")); + assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10")); + assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10")); + // more than one Double Colons + assertFalse(IPValidator.ipv6("0000:0000:0000::0000::0000")); + assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10:FFFF")); + + + + assertTrue(IPValidator.ip("2001:08DB:0000:0000:0023:F422:FE3B:AC10")); + assertTrue(IPValidator.ip("192.168.7.2")); + } + +} diff --git a/misc/log4j/.gitignore b/misc/log4j/.gitignore new file mode 100644 index 00000000..45aeec64 --- /dev/null +++ b/misc/log4j/.gitignore @@ -0,0 +1,5 @@ +/target/ +/.settings/ +/.classpath +/logs/ +/.project diff --git a/misc/log4j/pom.xml b/misc/log4j/pom.xml new file mode 100644 index 00000000..facb2f7a --- /dev/null +++ b/misc/log4j/pom.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<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.onap.aaf.misc</groupId> + <artifactId>parent</artifactId> + <version>1.3.0-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>aaf-misc-log4j</artifactId> + <name>AAF Misc Log4J</name> + <packaging>jar</packaging> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>org.onap.aaf.misc</groupId> + <artifactId>aaf-misc-env</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna-platform</artifactId> + <version>4.0.0</version> + </dependency> + + </dependencies> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.6</version> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + +</project> diff --git a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java new file mode 100644 index 00000000..a8830b47 --- /dev/null +++ b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java @@ -0,0 +1,81 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.log4j; + +import java.io.File; +import java.net.URL; + +public class LogFileNamer { + public static final int pid = PIDAccess.INSTANCE.getpid(); + public final String root; + private boolean printPID; + + public LogFileNamer(String root) { + if(root==null || "".equals(root) || root.endsWith("/")) { + this.root = root; + } else { + this.root = root + "-"; + } + printPID=true; + } + + public LogFileNamer noPID() { + printPID = false; + return this; + } + /** + * Accepts a String. + * If Separated by "|" then first part is the Appender name, and the second is used in the FileNaming + * (This is to allow for shortened Logger names, and more verbose file names) + * + * @param appender + * + * returns the String Appender + */ + public String setAppender(String appender) { + int pipe = appender.indexOf('|'); + if(pipe>=0) { + String rv; + System.setProperty( + "LOG4J_FILENAME_"+(rv=appender.substring(0,pipe)), + root + appender.substring(pipe+1) + (printPID?('-' + pid):"") + ".log"); + return rv; + } else { + System.setProperty( + "LOG4J_FILENAME_"+appender, + root + appender + (printPID?('-' + pid):"") + ".log"); + return appender; + } + + } + + public void configure(String props) { + String fname; + if(new File(fname="etc/"+props).exists()) { + org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000); + } else { + URL rsrc = ClassLoader.getSystemResource(props); + if(rsrc==null) System.err.println("Neither File: " + fname + " or resource on Classpath " + props + " exist" ); + org.apache.log4j.PropertyConfigurator.configure(rsrc); + } + } +} diff --git a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/PIDAccess.java b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/PIDAccess.java new file mode 100644 index 00000000..6e23ce63 --- /dev/null +++ b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/PIDAccess.java @@ -0,0 +1,30 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.log4j; + +import com.sun.jna.Library; +import com.sun.jna.Native; + +public interface PIDAccess extends Library { + PIDAccess INSTANCE = (PIDAccess) Native.loadLibrary("c", PIDAccess.class); + int getpid (); +} diff --git a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/LogTest.java b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/LogTest.java new file mode 100644 index 00000000..d5c9062f --- /dev/null +++ b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/LogTest.java @@ -0,0 +1,45 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.env.log4j; + +import java.util.logging.Logger; + +import org.onap.aaf.misc.env.log4j.LogFileNamer; + + +public class LogTest +{ + public static void main(String[] args) throws Exception + { + LogFileNamer lfn = new LogFileNamer("authz"); + lfn.setAppender("service"); + lfn.setAppender("init"); + lfn.setAppender("audit"); + lfn.setAppender("test"); + lfn.configure("src/test/resources/log4j-test.properties"); + Logger log = Logger.getLogger( "init" ); + + + + log.info("Hello"); + } +} diff --git a/misc/log4j/src/test/resources/.gitignore b/misc/log4j/src/test/resources/.gitignore new file mode 100644 index 00000000..2079777e --- /dev/null +++ b/misc/log4j/src/test/resources/.gitignore @@ -0,0 +1 @@ +/log4j-test.properties diff --git a/misc/pom.xml b/misc/pom.xml new file mode 100644 index 00000000..4eba2fd5 --- /dev/null +++ b/misc/pom.xml @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<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"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.aaf.misc</groupId> + <artifactId>parent</artifactId> + <name>AAF Misc Parent</name> + <version>1.3.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <powermock.version>1.5.1</powermock.version> + </properties> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.9.5</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + <version>${powermock.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <version>${powermock.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.10</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <testSourceDirectory>src/test/java</testSourceDirectory> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <version>2.4</version> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <outputDirectory>target</outputDirectory> + </configuration> + </plugin> + + <plugin> + <inherited>true</inherited> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <distributionManagement> + <repository> + <id>nexus</id> + <name>attarch-releases</name> + <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases</url> + </repository> + <snapshotRepository> + <id>nexus</id> + <name>attarch-snapshots</name> + <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots</url> + </snapshotRepository> + </distributionManagement> + + <modules> + <module>env</module> + <module>xgen</module> + <module>rosetta</module> + <module>log4j</module> <!-- note: generates log4j, to avoid Jar conflict --> + </modules> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.7.5</version> + </dependency> + </dependencies> + </dependencyManagement> +</project> diff --git a/misc/rosetta/.gitignore b/misc/rosetta/.gitignore new file mode 100644 index 00000000..3b314b88 --- /dev/null +++ b/misc/rosetta/.gitignore @@ -0,0 +1,6 @@ +/target/ +/.classpath +/.settings/ +/logs/ +/target/ +/.project diff --git a/misc/rosetta/pom.xml b/misc/rosetta/pom.xml new file mode 100644 index 00000000..1f3c1490 --- /dev/null +++ b/misc/rosetta/pom.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<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.onap.aaf.misc</groupId> + <artifactId>parent</artifactId> + <version>1.3.0-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>aaf-misc-rosetta</artifactId> + <name>AAF Misc Rosetta</name> + <packaging>jar</packaging> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>org.onap.aaf.misc</groupId> + <artifactId>aaf-misc-env</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.jvnet.jaxb2.maven2</groupId> + <artifactId>maven-jaxb2-plugin</artifactId> + <version>0.8.2</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <configuration> + <schemaDirectory>src/main/xsd</schemaDirectory> + </configuration> + </plugin> + </plugins> + + </build> + +</project> diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java new file mode 100644 index 00000000..725389c9 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InJson.java @@ -0,0 +1,154 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Reader; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.rosetta.InJson.State; + +public class InJson implements Parse<Reader, State> { + public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException { + // First things first, if there's a "leftover" event, process that immediately + State state = (State)parsed.state; + if(state.unsent > 0) { + parsed.event = state.unsent; + state.unsent = 0; + return parsed; + } + + int ch; + char c; + StringBuilder sb = parsed.sb; + boolean inQuotes = false, escaped = false; + boolean go = true; + try { + // Gather data from Reader, looking for special characters when not in Quotes + while(go && (ch=r.read())>=0) { + if(state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content + c=(char)ch; + // Character is a quote. + if(c=='"') { + if(inQuotes) { + if(escaped) { // if escaped Quote, add to data. + sb.append(c); + escaped = false; + } else { + inQuotes = false; + } + } else { + parsed.isString=true; + inQuotes = true; + } + } else { // Not a Quote + if(inQuotes) { + if(c=='\\') { + if(escaped) { + sb.append("\\\\"); + escaped = false; + } else { + escaped = true; + } + } else { + sb.append(c); + } + } else { + switch(c) { + case ':': + parsed.dataIsName(); + parsed.isString = false; + break; + case Parse.START_OBJ: + if(state.braces++ == 0) { + parsed.event = START_DOC; + state.unsent = c; + } else { + parsed.event = c; + } + go = false; + break; + case Parse.END_OBJ: + if(--state.braces == 0) { + parsed.event = c; + state.unsent = END_DOC; + } else { + parsed.event = c; + } + go = false; + break; + // These three end the data gathering, and send it along with the event that is ending the data gathering + case Parse.NEXT: + if(parsed.name.startsWith("__")) { + parsed.event = Parse.ATTRIB; + parsed.name = parsed.name.substring(2); + } else { + parsed.event = c; + } + go = false; + break; + case Parse.START_ARRAY: + case Parse.END_ARRAY: + parsed.event = c; + go = false; + break; + + // The Escape Sequence, for Quote marks within Quotes + case '\\': + // Ignore these, unless within quotes, at which point data-gather + case ' ': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + break; + // Normal data... gather it + default: + sb.append(c); + } + } + } + } + } + return parsed; + } catch (IOException e) { + throw new ParseException(e); + } + } + + public static class State { + public int braces = 0; + public char unsent = 0; + } + +// @Override + public Parsed<State> newParsed() { + return new Parsed<State>(new State()); // no State needed + } + +// @Override + public TimeTaken start(Env env) { + return env.start("Rosetta JSON In", Env.JSON); + } +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java new file mode 100644 index 00000000..51926573 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/InXML.java @@ -0,0 +1,486 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.rosetta.InXML.State; + +public class InXML implements Parse<Reader, State> { + // package on purpose + JaxInfo jaxInfo; + + public InXML(JaxInfo jaxInfo) { + this.jaxInfo = jaxInfo; + } + + public InXML(Class<?> cls, String ... rootNs) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException { + jaxInfo = JaxInfo.build(cls,rootNs); + } + + + // @Override + public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException { + State state = parsed.state; + + // OK, before anything else, see if there is leftover processing, if so, do it! + if(state.unevaluated!=null) { + DerTag dt = state.unevaluated; + state.unevaluated = null; + if(!state.greatExp.eval(parsed, dt))return parsed; + } + + if(state.hasAttributes()) { + Prop prop = state.pop(); + parsed.event = Parse.ATTRIB; + parsed.name = prop.tag; + parsed.sb.append(prop.value); + parsed.isString=true; + return parsed; + } + int ch; + char c; + boolean inQuotes = false, escaped = false; + + StringBuilder sb = parsed.sb, tempSB = new StringBuilder(); + boolean go = true; + + try { + while(go && (ch=r.read())>=0) { + c = (char)ch; + if(c == '"') { + if(state.greatExp instanceof LeafExpectations) { // within a set of Tags, make a Quote + sb.append(c); + } else { + if(inQuotes) { + if(escaped) { + sb.append('\\'); + sb.append(c); + escaped = false; + } else { + inQuotes = false; + } + } else { + parsed.isString=true; + inQuotes = true; + } + } + } else if(inQuotes) { + sb.append(c); + } else if(c=='&') { + XmlEscape.xmlEscape(sb,r); + } else { + switch(c) { + case '<': + DerTag tag=new DerTag().parse(r, tempSB); + go = state.greatExp.eval(parsed, tag); + break; + default: + // don't add Whitespace to start of SB... saves removing later + if(sb.length()>0) { + sb.append(c); + } else if(!Character.isWhitespace(c)) { + sb.append(c); + } + } + } + } + return parsed; + } catch (IOException e) { + throw new ParseException(e); + } + } + + public static final class DerTag { + public String name; + public boolean isEndTag; + public List<Prop> props; + private boolean isXmlInfo; + //private String ns; + + public DerTag() { + name=null; + isEndTag = false; + props = null; + isXmlInfo = false; + } + + public DerTag parse(Reader r, StringBuilder sb) throws ParseException { + int ch; + char c; + boolean inQuotes = false, escaped = false; + boolean go = true; + String tag = null; + + try { + if((ch = r.read())<0) throw new ParseException("Reader content ended before complete"); + if(ch=='?') { + isXmlInfo = true; + } + // TODO Check for !-- comments + do { + c=(char)ch; + if(c=='"') { + if(inQuotes) { + if(escaped) { + sb.append(c); + escaped = false; + } else { + inQuotes = false; + } + } else { + inQuotes = true; + } + } else if(inQuotes) { + sb.append(c); + } else { + switch(c) { + case '/': + isEndTag = true; + break; + case ' ': + endField(tag,sb); + tag = null; + break; + case '>': + endField(tag,sb); + go = false; + break; + case '=': + tag = sb.toString(); + sb.setLength(0); + break; +// case ':': +// ns = sb.toString(); +// sb.setLength(0); +// break; + case '?': + if(!isXmlInfo)sb.append(c); + break; + default: + sb.append(c); + } + } + } while(go && (ch=r.read())>=0); + } catch (IOException e) { + throw new ParseException(e); + } + return this; + } + + private void endField(String tag, StringBuilder sb) { + if(name==null) { + name = sb.toString(); + sb.setLength(0); + } else { + String value = sb.toString(); + sb.setLength(0); + if(tag !=null && value != null) { + if(props==null)props = new ArrayList<Prop>(); + props.add(new Prop(tag,value)); + } + } + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(isEndTag?"End":"Start"); + sb.append(" Tag\n"); + sb.append(" Name: "); + sb.append(name); + if(props!=null) for(Prop p : props) { + sb.append("\n "); + sb.append(p.tag); + sb.append("=\""); + sb.append(p.value); + sb.append('"'); + } + return sb.toString(); + } + } + + private static class ArrayState { + public boolean firstObj = true; + public boolean didNext = false; + } + + public static class State { + public GreatExpectations greatExp; + public DerTag unevaluated; + public Stack<ArrayState> arrayInfo; + private List<Prop> attribs; + private int idx; + public State(JaxInfo ji, DerTag dt) throws ParseException { + greatExp = new RootExpectations(this, ji, null); + unevaluated = null; + attribs = null;; + } + + public boolean hasAttributes() { + return attribs!=null && idx<attribs.size(); + } + + public void push(Prop prop) { + if(attribs==null) { + attribs = new ArrayList<Prop>(); + idx = 0; + } + attribs.add(prop); + } + + public Prop pop() { + Prop rv = null; + if(attribs!=null) { + rv = attribs.get(idx++); + if(idx>=attribs.size())attribs = null; + } + return rv; + } + } + + private static abstract class GreatExpectations { + protected JaxInfo ji; + protected GreatExpectations prev; + private Map<String,String> ns; + + public GreatExpectations(State state, JaxInfo curr, GreatExpectations prev, DerTag derTag) throws ParseException { + this.prev = prev; + ns = null; + ji = getDerived(state, curr,derTag); + } + + public abstract boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException; + + // Recursively look back for any namespaces + protected Map<String,String> getNS() { + if(ns!=null)return ns; + if(prev!=null) { + return prev.getNS(); + } + return null; + } + + private void addNS(Prop prop) { + Map<String,String> existingNS = getNS(); + if(ns==null)ns = new HashMap<String,String>(); + // First make a copy of previous NSs so that we have everything we need, but can overwrite, if necessary + if(existingNS!=null && ns!=existingNS) { + ns.putAll(ns); + } + ns.put(prop.tag, prop.value); + } + + private JaxInfo getDerived(State state, JaxInfo ji, DerTag derTag) throws ParseException { + if(derTag==null)return ji; + + List<Prop> props = derTag.props; + + Prop derived = null; + if(props!=null) { + // Load Namespaces (if any) + for(Prop prop : props) { + if(prop.tag.startsWith("xmlns:")) { + addNS(prop); + } + } + for(Prop prop : props) { + if(prop.tag.endsWith(":type")) { + int idx = prop.tag.indexOf(':'); + String potentialNS = "xmlns:"+prop.tag.substring(0,idx); + Map<String,String> ns = getNS(); + boolean noNamespace = false; + if(ns==null) { + noNamespace = true; + } else { + String nsVal = ns.get(potentialNS); + if(nsVal==null) noNamespace = true; + else { + derived = new Prop(Parsed.EXTENSION_TAG,prop.value); + state.push(derived); + } + } + if(noNamespace) { + throw new ParseException(prop.tag + " utilizes an invalid Namespace prefix"); + } + } else if(!prop.tag.startsWith("xmlns")) { + state.push(prop); + } + } + } + return derived==null?ji:ji.getDerived(derived.value); + } + } + + private static class RootExpectations extends GreatExpectations { + + public RootExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException { + super(state,curr,prev, null); + } + + // @Override + public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException { + if(derTag.isXmlInfo) { + parsed.event = START_DOC; + } else if(ji.name.equals(derTag.name)) { + if(derTag.isEndTag) { + parsed.event = END_DOC; + parsed.state.greatExp = prev; + } else { + //parsed.name = derTag.name; + parsed.event = START_OBJ; + parsed.state.greatExp = new ObjectExpectations(parsed.state,ji, this, false, derTag); + } + } + return false; + } + } + + private static class ObjectExpectations extends GreatExpectations { + private boolean printName; + + public ObjectExpectations(State state, JaxInfo curr, GreatExpectations prev, boolean printName, DerTag derTag) throws ParseException { + super(state, curr, prev, derTag); + this.printName=printName; + } + + // @Override + public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException { + if(derTag.isEndTag && ji.name.equals(derTag.name)) { + parsed.state.greatExp = prev; + parsed.event = END_OBJ; + if(printName)parsed.name = ji.name; + } else { + //Standard Members + for(JaxInfo memb : ji.members) { + if(memb.name.equals(derTag.name)) { + parsed.name = memb.name; + if(memb.isArray) { + parsed.state.unevaluated = derTag; // evaluate within Array Context + parsed.event = START_ARRAY; + parsed.state.greatExp = new ArrayExpectations(parsed.state,memb,this); + return false; + } else if(memb.isObject()) { + if(derTag.isEndTag) { + throw new ParseException("Unexpected End Tag </" + derTag.name + '>'); + } else { + parsed.event = START_OBJ; + + parsed.state.greatExp = new ObjectExpectations(parsed.state, memb,this,true,derTag); + return false; + } + } else { // a leaf + if(derTag.isEndTag) { + throw new ParseException("Misplaced End Tag </" + parsed.name + '>'); + } else { + parsed.state.greatExp = new LeafExpectations(parsed.state,memb, this); + return true; // finish out Leaf without returning + } + } + } + } + + throw new ParseException("Unexpected Tag <" + derTag.name + '>'); + } + return false; + } + } + + private static class LeafExpectations extends GreatExpectations { + public LeafExpectations(State state, JaxInfo curr, GreatExpectations prev) throws ParseException { + super(state, curr, prev, null); + } + + // @Override + public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException { + if(ji.name.equals(derTag.name) && derTag.isEndTag) { + parsed.event = NEXT; + parsed.isString = ji.isString; + parsed.state.greatExp = prev; + } else { + throw new ParseException("Expected </" + ji.name + '>'); + } + return false; + } + } + + private static class ArrayExpectations extends GreatExpectations { + public ArrayExpectations(State state, JaxInfo ji, GreatExpectations prev) throws ParseException { + super(state, ji, prev,null); + if(state.arrayInfo==null)state.arrayInfo=new Stack<ArrayState>(); + state.arrayInfo.push(new ArrayState()); + } + // @Override + public boolean eval(Parsed<State> parsed, DerTag derTag) throws ParseException { + if(ji.name.equals(derTag.name) && !derTag.isEndTag) { + if(ji.isObject()) { + if(derTag.isEndTag) { + throw new ParseException("Unexpected End Tag </" + derTag.name + '>'); + } else { + ArrayState ai = parsed.state.arrayInfo.peek(); + if(ai.firstObj || ai.didNext) { + ai.firstObj = false; + ai.didNext = false; + parsed.event = START_OBJ; + parsed.name=derTag.name; + parsed.state.greatExp = new ObjectExpectations(parsed.state,ji,this,true, derTag); + } else { + ai.didNext = true; + parsed.event = NEXT; + parsed.state.unevaluated = derTag; + } + } + } else { // a leave + if(derTag.isEndTag) { + throw new ParseException("Misplaced End Tag </" + parsed.name + '>'); + } else { + parsed.state.greatExp = new LeafExpectations(parsed.state, ji, this); + return true; // finish out Leaf without returning + } + } + } else { // Tag now different... Array is done + parsed.state.unevaluated = derTag; + parsed.event=END_ARRAY; + parsed.state.greatExp = prev; + parsed.state.arrayInfo.pop(); + } + return false; + } + } + // @Override + public Parsed<State> newParsed() throws ParseException { + return new Parsed<State>(new State(jaxInfo, null)); + } + + // @Override + public TimeTaken start(Env env) { + return env.start("Rosetta XML In", Env.XML); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java new file mode 100644 index 00000000..2708aa2f --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxEval.java @@ -0,0 +1,26 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +public interface JaxEval{ + public abstract JaxEval eval(Parsed<?> p) throws ParseException; +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java new file mode 100644 index 00000000..5f38c8c7 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxInfo.java @@ -0,0 +1,248 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchema; +import javax.xml.bind.annotation.XmlType; +import javax.xml.datatype.XMLGregorianCalendar; + +public class JaxInfo { + private static final String DEFAULT = "##default"; + public static final int DATA = 0; + public static final int ARRAY = 1; + public static final int OBJECT = 2; + + public final String name; + public final Class<?> clss; + public Map<String, JaxInfo> extensions; // Classes, which might be found at runtime, that extend this class. Lazy Instantiation + public final JaxInfo[] members; + public final boolean isArray; + public final boolean isString; + public final boolean required; + public final boolean nillable; + public String ns; + public boolean isObject() {return members!=null;} + + private JaxInfo(String n, String ns, Class<?> c, JaxInfo[] members, boolean string, boolean array, boolean required, boolean nillable) { + name = n; + this.ns = ns; + clss = c; + this.members = members; + this.isString = string; + isArray = array; + this.required = required; + this.nillable = nillable; + extensions = null; + } + + + public int getType() { + if(isArray)return ARRAY; + else if(members!=null)return OBJECT; + return DATA; + } + + public JaxInfo getDerived(String derivedName) { + JaxInfo derived; + // Lazy Instantiation + if(extensions == null) { + extensions = new HashMap<String,JaxInfo>(); + derived = null; + } else { + derived = extensions.get(derivedName); + } + + if(derived == null) { + //TODO for the moment, Classes are in same package + Package pkg = clss.getPackage(); + try { + Class<?> dc = getClass().getClassLoader().loadClass(pkg.getName()+'.'+Character.toUpperCase(derivedName.charAt(0))+derivedName.substring(1)); + derived = JaxInfo.build(dc, this); // Use this JAXInfo's name so the tags are correct + extensions.put(derivedName, derived); + } catch (Exception e) { + e.printStackTrace(); + } + } + return derived; + } + + public static JaxInfo get(JaxInfo[] fields, String name) { + for(JaxInfo f : fields) { + if(name.equals(f.name)) return f; + } + return null; + } + + /** + * Build up JAXB Information (recursively) + * + * @param cls + * @param rootNns + * @return + * @throws SecurityException + * @throws NoSuchFieldException + * @throws ClassNotFoundException + * @throws ParseException + */ + public static JaxInfo build(Class<?> cls, JaxInfo parent) throws NoSuchFieldException, ClassNotFoundException, ParseException { + return new JaxInfo(parent.name,parent.ns, cls,buildFields(cls,parent.ns),parent.isString, parent.isArray,parent.required,parent.nillable); + } + /** + * Build up JAXB Information (recursively) + * + * @param cls + * @param rootNns + * @return + * @throws SecurityException + * @throws NoSuchFieldException + * @throws ClassNotFoundException + * @throws ParseException + */ + public static JaxInfo build(Class<?> cls, String ... rootNns) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException { + String defaultNS; + if(rootNns.length>0 && rootNns[0]!=null) { + defaultNS = rootNns[0]; + } else { + Package pkg = cls.getPackage(); + XmlSchema xs = pkg.getAnnotation(XmlSchema.class); + defaultNS = xs==null?"":xs.namespace(); + } + String name; + if(rootNns.length>1) { + name = rootNns[1]; + } else { + XmlRootElement xre = cls.getAnnotation(XmlRootElement.class); + if(xre!=null) { + name = xre.name(); + } else { + XmlType xt = cls.getAnnotation(XmlType.class); + if(xt!=null) { + name=xt.name(); + } else { + throw new ParseException("Need a JAXB Object with XmlRootElement, or stipulate in parms"); + } + } + } + + return new JaxInfo(name,defaultNS, cls,buildFields(cls,defaultNS),false,false,false,false); + } + + // Build up the name and members of this particular class + // This is recursive, if a member is a JAXB Object as well. + private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException { + ArrayList<JaxInfo> fields = null; // allow for lazy instantiation, because many structures won't have XmlType + Class<?> cls = clazz; + // Build up Method names from JAXB Annotations + XmlType xt; + while((xt = cls.getAnnotation(XmlType.class))!=null) { + if(fields==null)fields = new ArrayList<JaxInfo>(); + for(String field : xt.propOrder()) { + if("".equals(field)) break; // odd bug. "" returned when no fields exist, rather than empty array + Field rf = cls.getDeclaredField(field); + Class<?> ft = rf.getType(); + + boolean required = false; + boolean nillable = false; + String xmlName = field; + String namespace = defaultNS; + + XmlElement xe = rf.getAnnotation(XmlElement.class); + if(xe!=null) { + xmlName=xe.name(); + required = xe.required(); + nillable = false; + if(DEFAULT.equals(xmlName)) { + xmlName = field; + } + namespace = xe.namespace(); + if(DEFAULT.equals(namespace)) { + namespace = defaultNS; + } + } + // If object is a List, then it is possible multiple, per XML/JAXB evaluation + if(ft.isAssignableFrom(List.class)) { + Type t = rf.getGenericType(); + String classname = t.toString(); + int start = classname.indexOf('<'); + int end = classname.indexOf('>'); + Class<?> genClass = Class.forName(classname.substring(start+1, end)); + xe = genClass.getAnnotation(XmlElement.class); + if(xe!=null && !DEFAULT.equals(xe.namespace())) { + namespace = xe.namespace(); + } + // add recursed recursed member, marked as array + fields.add(new JaxInfo(xmlName,namespace,genClass,buildFields(genClass,namespace), genClass.equals(String.class),true,required,nillable)); + } else { + boolean isString = ft.equals(String.class) || ft.equals(XMLGregorianCalendar.class); + // add recursed member + fields.add(new JaxInfo(xmlName,namespace,ft,buildFields(ft,namespace),isString,false,required,nillable)); + } + } + cls = cls.getSuperclass(); + }; + if(fields!=null) { + JaxInfo[] rv = new JaxInfo[fields.size()]; + fields.toArray(rv); + return rv; + } else { + return null; + } + } + + + public StringBuilder dump(StringBuilder sb, int idx) { + for(int i=0;i<idx;++i)sb.append(' '); + sb.append("Field "); + sb.append(name); + sb.append(" ["); + sb.append(clss.getName()); + sb.append("] "); + if(isArray)sb.append(" (array)"); + if(required)sb.append(" (required)"); + if(nillable)sb.append(" (nillable)"); + if(members!=null) { + for(JaxInfo f : members) { + sb.append('\n'); + f.dump(sb,idx+2); + } + } + return sb; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Structure of "); + sb.append(clss.getName()); + sb.append('\n'); + dump(sb,2); + return sb.toString(); + } +}
\ No newline at end of file diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java new file mode 100644 index 00000000..bb6784c8 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/JaxSet.java @@ -0,0 +1,91 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +import javax.xml.bind.annotation.XmlType; + +/** + * For specific XML class, quickly find a Setter Method which will load the object + * + * Object type of Setter must match String at this time. + * + * @author Jonathan + * + * @param <T> + */ +public class JaxSet<T> { + private static Map<Class<?>,JaxSet<?>> jsets = new HashMap<Class<?>,JaxSet<?>>(); + private Map<String,Setter<T>> members; + + private JaxSet(Class<?> cls) { + members = new TreeMap<String, Setter<T>>(); + XmlType xmltype = cls.getAnnotation(XmlType.class); + Class<?> paramType[] = new Class[] {String.class}; + for(String str : xmltype.propOrder()) { + try { + String setName = "set" + Character.toUpperCase(str.charAt(0)) + str.subSequence(1, str.length()); + Method meth = cls.getMethod(setName,paramType ); + if(meth!=null) { + members.put(str, new Setter<T>(meth) { + public void set(T o, Object t) throws ParseException { + try { + this.meth.invoke(o, t); + } catch (Exception e) { + throw new ParseException(e); + } + } + }); + } + } catch (Exception e) { + // oops + } + } + } + + public static abstract class Setter<O> { + protected final Method meth; + public Setter(Method meth) { + this.meth = meth; + } + public abstract void set(O o, Object obj) throws ParseException; + } + + public static <X> JaxSet<X> get(Class<?> cls) { + synchronized(jsets) { + @SuppressWarnings("unchecked") + JaxSet<X> js = (JaxSet<X>)jsets.get(cls); + if(js == null) { + jsets.put(cls, js = new JaxSet<X>(cls)); + } + return js; + } + } + + public Setter<T> get(String key) { + return members.get(key); + } +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java new file mode 100644 index 00000000..51cec078 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Ladder.java @@ -0,0 +1,113 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + + +/** + * A Ladder is a Stack like Storage Class, but where you can ascend and descend while + * the elements exists. + * + * Like an extension ladder, you can make taller as you go + * + * @author Jonathan + * + */ +public class Ladder<T> { + public static final int DEFAULT_INIT_SIZE=8; + private final int init_size; + private int rung; // as in ladder + private Object[] struts; + + public Ladder() { + rung=0; + init_size = DEFAULT_INIT_SIZE; + struts=new Object[init_size]; + } + + public Ladder(int initSize) { + rung=0; + init_size = initSize; + struts=new Object[init_size]; + } + + public void bottom() { + rung = 0; + } + + public void top() { + rung = struts.length-1; + while(rung>0 && struts[rung]==null)--rung; + } + + public int howHigh() { + return rung; + } + + public void jumpTo(int rung) { + if(rung>=struts.length) { + Object[] temp = new Object[init_size*((rung/init_size)+1)]; + System.arraycopy(struts, 0, temp, 0, struts.length); + struts = temp; + } + this.rung = rung; + } + + public int height() { + return struts.length; + } + + public void cutTo(int rungs) { + Object[] temp = new Object[rungs]; + System.arraycopy(struts, 0, temp, 0, Math.min(rungs, struts.length)); + struts = temp; + } + + public void ascend() { + ++rung; + if(rung>=struts.length) { + Object[] temp = new Object[struts.length+init_size]; + System.arraycopy(struts, 0, temp, 0, struts.length); + struts = temp; + } + } + + public void descend() { + --rung; + } + + @SuppressWarnings("unchecked") + public T peek() { + return (T)struts[rung]; + } + + public void push(T t) { + struts[rung]=t; + } + + @SuppressWarnings("unchecked") + public T pop() { + T t = (T)struts[rung]; + struts[rung]=null; + return t; + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java new file mode 100644 index 00000000..d482b247 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Marshal.java @@ -0,0 +1,81 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.util.Iterator; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; + +public abstract class Marshal<T> implements Parse<T, Marshal.State> { + + /* (non-Javadoc) + * @see org.onap.aaf.misc.rosetta.Parse#newParsed() + */ + @Override + public Parsed<State> newParsed() throws ParseException { + return new Parsed<State>(new State()); + } + + @Override + public TimeTaken start(Env env) { + //TODO is a way to mark not-JSON? + return env.start("Rosetta Marshal", Env.JSON); + }; + + public static class State { + // Note: Need a STATEFUL stack... one that will remain stateful until marked as finished + // "finished" is know by Iterators with no more to do/null + // Thus the concept of "Ladder", which one ascends and decends + public Ladder<Iterator<?>> ladder = new Ladder<Iterator<?>>(); + public boolean smallest = true; + } + + public static final Iterator<Void> DONE_ITERATOR = new Iterator<Void>() { + @Override + public boolean hasNext() { + return false; + } + + @Override + public Void next() { + return null; + } + + @Override + public void remove() { + } + }; + + /** + * Typical definition of Done is when Iterator in Ladder is "DONE_ITERATOR" + * + * It is important, however, that the "Ladder Rung" is set to the right level. + * + * @param state + * @return + */ + public boolean amFinished(State state) { + return DONE_ITERATOR.equals(state.ladder.peek()); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java new file mode 100644 index 00000000..38b021ea --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Nulls.java @@ -0,0 +1,66 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; + +public class Nulls { + public static final Parse<Reader, ?> IN = new Parse<Reader, Void>() { + + // @Override + public Parsed<Void> parse(Reader r, Parsed<Void> parsed)throws ParseException { + parsed.event = Parse.END_DOC; + return parsed; + } + + // @Override + public Parsed<Void> newParsed() { + Parsed<Void> parsed = new Parsed<Void>(); + parsed.event = Parse.END_DOC; + return parsed; + } + + // @Override + public TimeTaken start(Env env) { + return env.start("IN", Env.SUB); + } + + }; + + public static final Out OUT = new Out() { + + // @Override + public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options)throws IOException, ParseException { + } + @Override + public String logName() { + return "Rosetta NULL"; + } + + + }; +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java new file mode 100644 index 00000000..567a6261 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Out.java @@ -0,0 +1,43 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +public abstract class Out { + public abstract<IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException; + + public<IN,S> void extract(IN in, OutputStream os, Parse<IN, S> parse, boolean ... options) throws IOException, ParseException { + Writer w = new OutputStreamWriter(os); + try { + extract(in, w, parse, options); + } finally { + w.flush(); + } + } + + public abstract String logName(); + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java new file mode 100644 index 00000000..db7b956c --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJax.java @@ -0,0 +1,52 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Writer; + +public class OutJax extends Out { + private JaxEval jaxEval; + + public OutJax(JaxEval je) { + this.jaxEval = je; + } + + @Override + public <IN,S> void extract(IN in, Writer writer, Parse<IN, S> parse, boolean... options) throws IOException, ParseException { + Parsed<S> p = parse.newParsed(); + JaxEval je = this.jaxEval; + while((p = parse.parse(in,p.reuse())).valid()) { + if(je==null)throw new ParseException("Incomplete content"); + je = je.eval(p); + } + + } + + @Override + public String logName() { + return "Rosetta JAX"; + } + + + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java new file mode 100644 index 00000000..2340bdb6 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutJson.java @@ -0,0 +1,232 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Writer; +import java.util.Stack; + +import org.onap.aaf.misc.env.util.IndentPrintWriter; + +public class OutJson extends Out { + + @Override + public<IN,S> void extract(IN in, Writer writer, Parse<IN, S> prs, boolean ... options) throws IOException, ParseException { + Parsed<S> p = prs.newParsed(); + IndentPrintWriter ipw; + if(options.length>0 && options[0]) { // is Pretty + ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); + writer = ipw; + } else { + ipw = null; + } + + // If it's a fragment, print first Object Name. If root Object, skip first name + Stack<LevelStack> jsonLevel = new Stack<LevelStack>(); + jsonLevel.push(new LevelStack(options.length>1 && options[1])); + boolean print = true, hadData=false; + char afterName=0, beforeName=0, maybe = 0, prev=0; + + int count = 0; + while((p = prs.parse(in,p.reuse())).valid()) { + ++count; + switch(p.event) { + case 1: + continue; + case 2: + if(count==2) { // it's empty, write open/close on it's own + writer.append('{'); + writer.append('}'); + } + writer.flush(); + return; + case '{': + afterName = '{'; + if(jsonLevel.peek().printObjectName) { + print = true; + } else { // don't print names on first + print=false; + } + maybe=jsonLevel.peek().listItem(); + jsonLevel.push(new LevelStack(true)); + break; + case '}': + if(p.hasData()) { // if we have data, we print that, so may need to prepend a comma. + maybe = jsonLevel.peek().listItem(); + } else { // No data means just print, + p.name = ""; // XML tags come through with names, but no data + } + print = true; + jsonLevel.pop(); + afterName = p.event; + break; + case '[': + afterName = p.event; + if((prev==',' && !hadData) || prev==']')maybe=','; + else maybe = jsonLevel.peek().listItem(); + + jsonLevel.push(new LevelStack(false)); + print=true; + break; + case ']': + afterName = p.event; + if(p.hasData()) { + if(prev==',' && !hadData)maybe=','; + else maybe = jsonLevel.peek().listItem(); + } else { + p.name = ""; // XML tags come through with names, but no data + } + jsonLevel.pop(); + + print = true; + break; + case 3: + case ',': + if(!p.hasData()) { + p.isString=false; + print=false; + } else { + maybe=jsonLevel.peek().listItem(); + print = true; + } + break; + default: + print = true; + } + + if(maybe!=0) { + if(ipw==null)writer.append(maybe); + else ipw.println(maybe); + maybe = 0; + } + + if(beforeName!=0) { + if(ipw==null)writer.append(beforeName); + else ipw.println(beforeName); + beforeName = 0; + } + if(print) { + if(p.hasName()) { + writer.append('"'); + if(p.event==3)writer.append("__"); + writer.append(p.name); + writer.append("\":"); + } + if(p.hasData()) { + if(p.isString) { + writer.append('"'); + escapedWrite(writer, p.sb); + writer.append('"'); + } else if(p.sb.length()>0) { + writer.append(p.sb); + } + } + } + if(afterName!=0) { + if(ipw==null)writer.append(afterName); + else { + switch(afterName) { + case '{': + ipw.println(afterName); + ipw.inc(); + break; + case '}': + ipw.dec(); + ipw.println(); + ipw.print(afterName); + break; + case ']': + if(prev=='}' || prev==',')ipw.println(); + ipw.dec(); + ipw.print(afterName); + break; + + case ',': + ipw.println(afterName); + break; + default: + ipw.print(afterName); + } + } + afterName = 0; + } + + if(ipw!=null) { + switch(p.event) { + case '[': + ipw.inc(); + ipw.println(); + break; + } + } + prev = p.event; + hadData = p.hasData(); + + } + writer.flush(); + } + + private void escapedWrite(Writer writer, StringBuilder sb) throws IOException { + char c; + for(int i=0;i<sb.length();++i) { + switch(c=sb.charAt(i)) { + case '\\': + writer.append(c); + if(i<sb.length()) { + c=sb.charAt(++i); + writer.append(c); + } + break; + case '"': + writer.append('\\'); + // Passthrough on purpose + default: + writer.append(c); + } + } + + + } + + @Override + public String logName() { + return "Rosetta JSON"; + } + + private static class LevelStack { + public boolean printObjectName=false; + private boolean first_n_List=true; + + public LevelStack(boolean printObjectName) { + this.printObjectName = printObjectName; + } + + public char listItem() { + if(first_n_List) { + first_n_List=false; + return 0; + } else { + return ','; + } + } + } +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java new file mode 100644 index 00000000..bf833f7b --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutRaw.java @@ -0,0 +1,46 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Writer; + +public class OutRaw extends Out{ + + @Override + public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { + Parsed<S> p = prs.newParsed(); + + while((p = prs.parse(in,p.reuse())).valid()) { + writer.append(p.toString()); + writer.append('\n'); + } + } + + @Override + public String logName() { + return "Rosetta RAW"; + } + + + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java new file mode 100644 index 00000000..f3ce1c22 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/OutXML.java @@ -0,0 +1,225 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +import org.onap.aaf.misc.env.util.IndentPrintWriter; +import org.onap.aaf.misc.env.util.StringBuilderWriter; + +public class OutXML extends Out{ + private static final String XMLNS_XSI = "xmlns:xsi"; + public static final String XML_INFO = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; + public static final String XML_SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance"; + + private String root; + private List<Prop> props; + + public OutXML(String root, String ... params) { + this.root = root; + props = new ArrayList<Prop>(); + for(String p : params) { + String[] tv=p.split("="); + if(tv.length==2) + props.add(new Prop(tv[0],tv[1])); + } + } + + public OutXML(JaxInfo jaxInfo) { + this(jaxInfo.name,genNS(jaxInfo)); + } + + public OutXML(InXML inXML) { + this(inXML.jaxInfo.name,genNS(inXML.jaxInfo)); + } + + private static String[] genNS(JaxInfo jaxInfo) { + return new String[] {"xmlns=" + jaxInfo.ns}; + } + + + @Override + public<IN,S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { + Parsed<S> p = prs.newParsed(); + Stack<Level> stack = new Stack<Level>(); + // If it's an IndentPrintWriter, it is pretty printing. + boolean pretty = (options.length>0&&options[0]); + + IndentPrintWriter ipw; + if(pretty) { + if(writer instanceof IndentPrintWriter) { + ipw = (IndentPrintWriter)writer; + } else { + writer = ipw = new IndentPrintWriter(writer); + } + } else { + ipw=null; + } + boolean closeTag = false; + Level level = new Level(null); + while((p = prs.parse(in,p.reuse())).valid()) { + if(!p.hasName() && level.multi!=null) { + p.name=level.multi; + } + if(closeTag && p.event!=Parse.ATTRIB) { + writer.append('>'); + if(pretty)writer.append('\n'); + closeTag = false; + } + switch(p.event) { + case Parse.START_DOC: + if(!(options.length>1&&options[1])) // if not a fragment, print XML Info data + if(pretty)ipw.println(XML_INFO); + else writer.append(XML_INFO); + break; + case Parse.END_DOC: + break; + case Parse.START_OBJ: + stack.push(level); + level = new Level(level); + if(p.hasName()) { + closeTag = tag(writer,level.sbw,pretty,pretty,p.name,null); + } else if(root!=null && stack.size()==1) { // first Object + closeTag = tag(writer,level.sbw,pretty,pretty,root,null); + // Write Root Props + for(Prop prop : props) { + attrib(writer,pretty,prop.tag, prop.value,level); + } + } + if(pretty)ipw.inc(); + break; + case Parse.END_OBJ: + if(p.hasData()) + closeTag = tag(writer,writer,pretty,false,p.name, XmlEscape.convert(p.sb)); + if(pretty)ipw.dec(); + writer.append(level.sbw.getBuffer()); + level = stack.pop(); + break; + case Parse.START_ARRAY: + level.multi = p.name; + break; + case Parse.END_ARRAY: + if(p.hasData()) + closeTag = tag(writer,writer,pretty,false, p.name, XmlEscape.convert(p.sb)); + level.multi=null; + break; + case Parse.ATTRIB: + if(p.hasData()) + attrib(writer,pretty,p.name, XmlEscape.convert(p.sb), level); + break; + case Parse.NEXT: + if(p.hasData()) + closeTag = tag(writer,writer,pretty, false,p.name, XmlEscape.convert(p.sb)); + break; + } + } + writer.append(level.sbw.getBuffer()); + writer.flush(); + } + + private class Level { + public final StringBuilderWriter sbw; + public String multi; + private Level prev; + private Map<String,String> nses; + + public Level(Level level) { + sbw = new StringBuilderWriter(); + multi = null; + prev = level; + } + + public boolean hasPrinted(String ns, String value, boolean create) { + boolean rv = false; + if(nses==null) { + if(prev!=null)rv = prev.hasPrinted(ns, value, false); + } else { + String v = nses.get(ns); + return value.equals(v); // note: accomodates not finding NS as well + } + + if(create && !rv) { + if(nses == null) nses = new HashMap<String,String>(); + nses.put(ns, value); + } + return rv; + } + + + + } + + private boolean tag(Writer fore, Writer aft, boolean pretty, boolean returns, String tag, String data) throws IOException { + fore.append('<'); + fore.append(tag); + if(data!=null) { + fore.append('>'); // if no data, it may need some attributes... + fore.append(data); + if(returns)fore.append('\n'); + } + aft.append("</"); + aft.append(tag); + aft.append(">"); + if(pretty)aft.append('\n'); + return data==null; + } + + private void attrib(Writer fore, boolean pretty, String tag, String value, Level level) throws IOException { + String realTag = tag.startsWith("__")?tag.substring(2):tag; // remove __ + if(realTag.equals(Parsed.EXTENSION_TAG)) { // Convert Derived name into XML defined Inheritance + fore.append(" xsi:type=\""); + fore.append(value); + fore.append('"'); + if(!level.hasPrinted(XMLNS_XSI, XML_SCHEMA_INSTANCE,true)) { + fore.append(' '); + fore.append(XMLNS_XSI); + fore.append("=\""); + fore.append(XML_SCHEMA_INSTANCE); + fore.append("\""); + } + } else { + if(realTag.startsWith("xmlns:") ) { + if(level.hasPrinted(realTag, value, true)) { + return; + } + } + fore.append(' '); + fore.append(realTag); + fore.append("=\""); + fore.append(value); + fore.append('"'); + } + } + + @Override + public String logName() { + return "Rosetta XML"; + } + + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java new file mode 100644 index 00000000..657baf5c --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parse.java @@ -0,0 +1,45 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; + +public interface Parse<IN, S> { + public Parsed<S> parse(IN in, Parsed<S> parsed) throws ParseException; + + // EVENTS + public static final char NONE = 0; + public static final char START_DOC = 1; + public static final char END_DOC = 2; + public static final char ATTRIB = 3; + + public static final char NEXT = ','; + public static final char START_OBJ = '{'; + public static final char END_OBJ = '}'; + public static final char START_ARRAY = '['; + public static final char END_ARRAY = ']'; + + public Parsed<S> newParsed() throws ParseException; + public TimeTaken start(Env env); + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java new file mode 100644 index 00000000..d986776d --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/ParseException.java @@ -0,0 +1,42 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +public class ParseException extends Exception { + private static final long serialVersionUID = 7808836939102997012L; + + public ParseException() { + } + + public ParseException(String message) { + super(message); + } + + public ParseException(Throwable cause) { + super(cause); + } + + public ParseException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java new file mode 100644 index 00000000..326c5bba --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Parsed.java @@ -0,0 +1,89 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + + +public class Parsed<S> { + public static final String EXTENSION_TAG="extension"; + + public boolean isString; + + public StringBuilder sb; + public char event; + public String name; + public S state; + + public Parsed() { + this(null); + } + + // Package on purpose + Parsed(S theState) { + sb = new StringBuilder(); + isString = false; + event = Parse.NONE; + name = ""; + state = theState; + } + + public boolean valid() { + return event!=Parse.NONE; + } + + public Parsed<S> reuse() { + isString=false; + sb.setLength(0); + event = Parse.NONE; + name = ""; + // don't touch T... + return this; + } + + public void dataIsName() { + name = sb.toString(); + sb.setLength(0); + } + + public boolean hasName() { + return name.length()>0; + } + + public boolean hasData() { + return sb.length()>0; + } + + public String toString() { + StringBuilder sb2 = new StringBuilder(); + if(event<40)sb2.append((int)event); + else sb2.append(event); + sb2.append(" - "); + sb2.append(name); + if(sb.length()>0) { + sb2.append(" : "); + if(isString)sb2.append('"'); + sb2.append(sb); + if(isString)sb2.append('"'); + } + return sb2.toString(); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java new file mode 100644 index 00000000..07bd40f0 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Prop.java @@ -0,0 +1,43 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +class Prop { + public String tag; + public String value; + public Prop(String t, String v) { + tag = t; + value =v; + } + + public Prop(String t_equals_v) { + String[] tv = t_equals_v.split("="); + if(tv.length>1) { + tag = tv[0]; + value = tv[1]; + } + } + + public String toString() { + return tag + '=' + value; + } +}
\ No newline at end of file diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java new file mode 100644 index 00000000..45c27052 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/Saved.java @@ -0,0 +1,194 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.util.List; + +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.rosetta.Saved.State; + +/** + * An Out Object that will save off produced Parsed Stream and + * a Parse (In) Object that will reproduce Parsed Stream on demand + * + * @author Jonathan + * + */ +public class Saved extends Out implements Parse<Reader, State>{ + private static final String ROSETTA_SAVED = "Rosetta Saved"; + private final static int INIT_SIZE=128; + private Content content[]; + private int idx; + private boolean append = false; + + /** + * Read from Parsed Stream and save + */ + // @Override + public<IN,S> void extract(IN in, Writer ignore, Parse<IN,S> parser, boolean ... options) throws IOException, ParseException { + Parsed<S> p = parser.newParsed(); + if(!append) { + // reuse array if not too big + if(content==null||content.length>INIT_SIZE*3) { + content = new Content[INIT_SIZE]; + idx = -1; + } else do { + content[idx]=null; + } while(--idx>=0); + } + + // Note: idx needs to be -1 on initialization and no appendages + while((p = parser.parse(in,p.reuse())).valid()) { + if(!(append && (p.event==START_DOC || p.event==END_DOC))) { // skip any start/end of document in appendages + if(++idx>=content.length) { + Content temp[] = new Content[content.length*2]; + System.arraycopy(content, 0, temp, 0, idx); + content = temp; + } + content[idx]= new Content(p); + } + } + } + + // @Override + public Parsed<State> parse(Reader ignore, Parsed<State> parsed) throws ParseException { + int i; + if((i=parsed.state.count++)<=idx) + content[i].load(parsed); + else + parsed.event = Parse.NONE; + return parsed; + } + + public Content[] cut(char event, int count) { + append = true; + for(int i=idx;i>=0;--i) { + if(content[i].event==event) count--; + if(count==0) { + Content[] appended = new Content[idx-i+1]; + System.arraycopy(content, i, appended, 0, appended.length); + idx = i-1; + return appended; + } + } + return new Content[0]; + } + + public void paste(Content[] appended) { + if(appended!=null) { + if(idx+appended.length>content.length) { + Content temp[] = new Content[content.length*2]; + System.arraycopy(content, 0, temp, 0, idx); + content = temp; + } + System.arraycopy(appended,0,content,idx+1,appended.length); + idx+=appended.length; + } + this.append = false; + } + + public static class State { + public int count = 0; + } + + public static class Content { + private boolean isString; + private char event; + private String name; + private List<Prop> props; + private String str; + + public Content(Parsed<?> p) { + isString = p.isString; + event = p.event; + name = p.name; + // avoid copying, because most elements don't have content + // Cannot set to "equals", because sb ends up being cleared (and reused) + str = p.sb.length()==0?null:p.sb.toString(); + } + + public void load(Parsed<State> p) { + p.isString = isString; + p.event = event; + p.name = name; + if(str!=null) + p.sb.append(str); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(event); + sb.append(" - "); + sb.append(name); + sb.append(": "); + if(isString)sb.append('"'); + sb.append(str); + if(isString)sb.append('"'); + sb.append(' '); + if(props!=null) { + boolean comma = false; + for(Prop prop : props) { + if(comma)sb.append(','); + else comma = true; + sb.append(prop.tag); + sb.append('='); + sb.append(prop.value); + } + } + return sb.toString(); + } + } + + //// @Override + public Parsed<State> newParsed() { + Parsed<State> ps = new Parsed<State>(new State()); + return ps; + } + + /** + * Convenience function + * @param rdr + * @param in + * @throws IOException + * @throws ParseException + */ + public<IN,S> void load(IN in, Parse<IN, S> parser) throws IOException, ParseException { + extract(in,(Writer)null, parser); + } + + + // @Override + public TimeTaken start(Env env) { + return env.start(ROSETTA_SAVED, 0); + } + + @Override + public String logName() { + return ROSETTA_SAVED; + } + + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java new file mode 100644 index 00000000..f1cde6e5 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/XmlEscape.java @@ -0,0 +1,371 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta; + +import java.io.IOException; +import java.io.Reader; +import java.util.Map.Entry; +import java.util.TreeMap; + +public class XmlEscape { + private XmlEscape() {} + + private static final TreeMap<String,Integer> charMap; // see initialization at end + private static final TreeMap<Integer,String> intMap; // see initialization at end + + public static void xmlEscape(StringBuilder sb, Reader r) throws ParseException { + try { + int c; + StringBuilder esc = new StringBuilder(); + for(int cnt = 0;cnt<9 /*max*/; ++cnt) { + if((c=r.read())<0)throw new ParseException("Invalid Data: Unfinished Escape Sequence"); + if(c!=';') { + esc.append((char)c); + } else { // evaluate + Integer i = charMap.get(esc.toString()); + if(i==null) { + // leave in nasty XML format for now. + sb.append('&'); + sb.append(esc); + sb.append(';'); + } else { + sb.append((char)i.intValue()); + } + break; + } + } + + + } catch (IOException e) { + throw new ParseException(e); + } + } + + public static void xmlEscape(StringBuilder sb, int chr) { + sb.append('&'); + sb.append(intMap.get(chr)); + sb.append(';'); + } + + public static String convert(StringBuilder insb) { + int idx, ch; + StringBuilder sb=null; + for(idx=0;idx<insb.length();++idx) { + ch = insb.charAt(idx); + if(ch>=160 || ch==34 || ch==38 || ch==39 || ch==60 || ch==62) { + sb = new StringBuilder(); + sb.append(insb,0,idx); + break; + } + } + + if(sb==null)return insb.toString(); + + for(int i=idx;i<insb.length();++i) { + ch = insb.charAt(i); + if(ch<160) { + switch(ch) { + case 34: sb.append("""); break; + case 38: sb.append("&"); break; + case 39: sb.append("'"); break; + case 60: sb.append("<"); break; + case 62: sb.append(">"); break; + default: + sb.append((char)ch); + } + } else { // use map + String s = intMap.get(ch); + if(s==null)sb.append((char)ch); + else { + sb.append('&'); + sb.append(s); + sb.append(';'); + } + } + } + return sb.toString(); + } + + static { + charMap = new TreeMap<String, Integer>(); + intMap = new TreeMap<Integer,String>(); + charMap.put("quot", 34); + charMap.put("amp",38); + charMap.put("apos",39); + charMap.put("lt",60); + charMap.put("gt",62); + charMap.put("nbsp",160); + charMap.put("iexcl",161); + charMap.put("cent",162); + charMap.put("pound",163); + charMap.put("curren",164); + charMap.put("yen",165); + charMap.put("brvbar",166); + charMap.put("sect",167); + charMap.put("uml",168); + charMap.put("copy",169); + charMap.put("ordf",170); + charMap.put("laquo",171); + charMap.put("not",172); + charMap.put("shy",173); + charMap.put("reg",174); + charMap.put("macr",175); + charMap.put("deg",176); + charMap.put("plusmn",177); + charMap.put("sup2",178); + charMap.put("sup3",179); + charMap.put("acute",180); + charMap.put("micro",181); + charMap.put("para",182); + charMap.put("middot",183); + charMap.put("cedil",184); + charMap.put("sup1",185); + charMap.put("ordm",186); + charMap.put("raquo",187); + charMap.put("frac14",188); + charMap.put("frac12",189); + charMap.put("frac34",190); + charMap.put("iquest",191); + charMap.put("Agrave",192); + charMap.put("Aacute",193); + charMap.put("Acirc",194); + charMap.put("Atilde",195); + charMap.put("Auml",196); + charMap.put("Aring",197); + charMap.put("AElig",198); + charMap.put("Ccedil",199); + charMap.put("Egrave",200); + charMap.put("Eacute",201); + charMap.put("Ecirc",202); + charMap.put("Euml",203); + charMap.put("Igrave",204); + charMap.put("Iacute",205); + charMap.put("Icirc",206); + charMap.put("Iuml",207); + charMap.put("ETH",208); + charMap.put("Ntilde",209); + charMap.put("Ograve",210); + charMap.put("Oacute",211); + charMap.put("Ocirc",212); + charMap.put("Otilde",213); + charMap.put("Ouml",214); + charMap.put("times",215); + charMap.put("Oslash",216); + charMap.put("Ugrave",217); + charMap.put("Uacute",218); + charMap.put("Ucirc",219); + charMap.put("Uuml",220); + charMap.put("Yacute",221); + charMap.put("THORN",222); + charMap.put("szlig",223); + charMap.put("agrave",224); + charMap.put("aacute",225); + charMap.put("acirc",226); + charMap.put("atilde",227); + charMap.put("auml",228); + charMap.put("aring",229); + charMap.put("aelig",230); + charMap.put("ccedil",231); + charMap.put("egrave",232); + charMap.put("eacute",233); + charMap.put("ecirc",234); + charMap.put("euml",235); + charMap.put("igrave",236); + charMap.put("iacute",237); + charMap.put("icirc",238); + charMap.put("iuml",239); + charMap.put("eth",240); + charMap.put("ntilde",241); + charMap.put("ograve",242); + charMap.put("oacute",243); + charMap.put("ocirc",244); + charMap.put("otilde",245); + charMap.put("ouml",246); + charMap.put("divide",247); + charMap.put("oslash",248); + charMap.put("ugrave",249); + charMap.put("uacute",250); + charMap.put("ucirc",251); + charMap.put("uuml",252); + charMap.put("yacute",253); + charMap.put("thorn",254); + charMap.put("yuml",255); + charMap.put("OElig",338); + charMap.put("oelig",339); + charMap.put("Scaron",352); + charMap.put("scaron",353); + charMap.put("Yuml",376); + charMap.put("fnof",402); + charMap.put("circ",710); + charMap.put("tilde",732); + charMap.put("Alpha",913); + charMap.put("Beta",914); + charMap.put("Gamma",915); + charMap.put("Delta",916); + charMap.put("Epsilon",917); + charMap.put("Zeta",918); + charMap.put("Eta",919); + charMap.put("Theta",920); + charMap.put("Iota",921); + charMap.put("Kappa",922); + charMap.put("Lambda",923); + charMap.put("Mu",924); + charMap.put("Nu",925); + charMap.put("Xi",926); + charMap.put("Omicron",927); + charMap.put("Pi",928); + charMap.put("Rho",929); + charMap.put("Sigma",931); + charMap.put("Tau",932); + charMap.put("Upsilon",933); + charMap.put("Phi",934); + charMap.put("Chi",935); + charMap.put("Psi",936); + charMap.put("Omega",937); + charMap.put("alpha",945); + charMap.put("beta",946); + charMap.put("gamma",947); + charMap.put("delta",948); + charMap.put("epsilon",949); + charMap.put("zeta",950); + charMap.put("eta",951); + charMap.put("theta",952); + charMap.put("iota",953); + charMap.put("kappa",954); + charMap.put("lambda",955); + charMap.put("mu",956); + charMap.put("nu",957); + charMap.put("xi",958); + charMap.put("omicron",959); + charMap.put("pi",960); + charMap.put("rho",961); + charMap.put("sigmaf",962); + charMap.put("sigma",963); + charMap.put("tau",964); + charMap.put("upsilon",965); + charMap.put("phi",966); + charMap.put("chi",967); + charMap.put("psi",968); + charMap.put("omega",969); + charMap.put("thetasym",977); + charMap.put("upsih",978); + charMap.put("piv",982); + charMap.put("ensp",8194); + charMap.put("emsp",8195); + charMap.put("thinsp",8201); + charMap.put("zwnj",8204); + charMap.put("zwj",8205); + charMap.put("lrm",8206); + charMap.put("rlm",8207); + charMap.put("ndash",8211); + charMap.put("mdash",8212); + charMap.put("lsquo",8216); + charMap.put("rsquo",8217); + charMap.put("sbquo",8218); + charMap.put("ldquo",8220); + charMap.put("rdquo",8221); + charMap.put("bdquo",8222); + charMap.put("dagger",8224); + charMap.put("Dagger",8225); + charMap.put("bull",8226); + charMap.put("hellip",8230); + charMap.put("permil",8240); + charMap.put("prime",8242); + charMap.put("Prime",8243); + charMap.put("lsaquo",8249); + charMap.put("rsaquo",8250); + charMap.put("oline",8254); + charMap.put("frasl",8260); + charMap.put("euro",8364); + charMap.put("image",8465); + charMap.put("weierp",8472); + charMap.put("real",8476); + charMap.put("trade",8482); + charMap.put("alefsym",8501); + charMap.put("larr",8592); + charMap.put("uarr",8593); + charMap.put("rarr",8594); + charMap.put("darr",8595); + charMap.put("harr",8596); + charMap.put("crarr",8629); + charMap.put("lArr",8656); + charMap.put("uArr",8657); + charMap.put("rArr",8658); + charMap.put("dArr",8659); + charMap.put("hArr",8660); + charMap.put("forall",8704); + charMap.put("part",8706); + charMap.put("exist",8707); + charMap.put("empty",8709); + charMap.put("nabla",8711); + charMap.put("isin",8712); + charMap.put("notin",8713); + charMap.put("ni",8715); + charMap.put("prod",8719); + charMap.put("sum",8721); + charMap.put("minus",8722); + charMap.put("lowast",8727); + charMap.put("radic",8730); + charMap.put("prop",8733); + charMap.put("infin",8734); + charMap.put("ang",8736); + charMap.put("and",8743); + charMap.put("or",8744); + charMap.put("cap",8745); + charMap.put("cup",8746); + charMap.put("int",8747); + charMap.put("there4",8756); + charMap.put("sim",8764); + charMap.put("cong",8773); + charMap.put("asymp",8776); + charMap.put("ne",8800); + charMap.put("equiv",8801); + charMap.put("le",8804); + charMap.put("ge",8805); + charMap.put("sub",8834); + charMap.put("sup",8835); + charMap.put("nsub",8836); + charMap.put("sube",8838); + charMap.put("supe",8839); + charMap.put("oplus",8853); + charMap.put("otimes",8855); + charMap.put("perp",8869); + charMap.put("sdot",8901); + charMap.put("lceil",8968); + charMap.put("rceil",8969); + charMap.put("lfloor",8970); + charMap.put("rfloor",8971); + charMap.put("lang",9001); + charMap.put("rang",9002); + charMap.put("loz",9674); + charMap.put("spades",9824); + charMap.put("clubs",9827); + charMap.put("hearts",9829); + charMap.put("diams",9830); + + for( Entry<String, Integer> es: charMap.entrySet()) { + if(es.getValue()>=160); // save small space... note that no longer has amp, etc. + intMap.put(es.getValue(), es.getKey()); + } + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java new file mode 100644 index 00000000..68baebb6 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaDF.java @@ -0,0 +1,265 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.env; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; + +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.BaseDataFactory; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.DataFactory; +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.Data.TYPE; +import org.onap.aaf.misc.env.jaxb.JAXBmar; +import org.onap.aaf.misc.env.jaxb.JAXBumar; +import org.onap.aaf.misc.rosetta.InJson; +import org.onap.aaf.misc.rosetta.InXML; +import org.onap.aaf.misc.rosetta.JaxInfo; +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.OutXML; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.marshal.DocMarshal; + +public class RosettaDF<T> extends BaseDataFactory implements DataFactory<T> { + + static InJson inJSON = new InJson(); + InXML inXML; + + static OutJson outJSON = new OutJson(); + OutXML outXML; + static OutRaw outRAW = new OutRaw(); + + // Temporary until we write JAXB impl... + JAXBmar jaxMar; + JAXBumar jaxUmar; + + private Parse<Reader,?> defaultIn; + private Out defaultOut; + private RosettaEnv env; + private TYPE inType; + private TYPE outType; + private int defOption; + Marshal<T> marshal = null; + + + /** + * Private constructor to setup Type specific data manipulators + * @param schema + * @param rootNs + * @param cls + * @throws SecurityException + * @throws NoSuchFieldException + * @throws ClassNotFoundException + * @throws ParseException + * @throws JAXBException + */ + // package on purpose + RosettaDF(RosettaEnv env, Schema schema, String rootNs, Class<T> cls) throws APIException { + this.env = env; + try { + // Note: rootNs can be null, in order to derive content from Class. + JaxInfo ji = rootNs==null?JaxInfo.build(cls):JaxInfo.build(cls,rootNs); + // Note: JAXBmar sets qname to null if not exists + jaxMar = new JAXBmar(rootNs==null?null:new QName("xmlns",rootNs),cls); + // Note: JAXBumar sets schema to null if not exists + jaxUmar = new JAXBumar(schema, cls); + + defaultIn = inXML = new InXML(ji); + defaultOut = outXML = new OutXML(ji); + inType=outType=Data.TYPE.XML; + defOption = 0; + } catch (Exception e) { + throw new APIException(e); + } + } + + + // @Override + public RosettaData<T> newData() { + RosettaData<T> data = new RosettaData<T>(env, this) + .in(inType) + .out(outType) + .option(defOption); + return data; + } + + // @Override + public RosettaData<T> newData(Env trans) { + RosettaData<T> data = new RosettaData<T>(trans, this) + .in(inType) + .out(outType) + .option(defOption); + return data; + } + + @SuppressWarnings("unchecked") + // @Override + public Class<T> getTypeClass() { + return (Class<T>)jaxMar.getMarshalClass(); + } + + public RosettaDF<T> in(Data.TYPE type) { + inType = type; + defaultIn=getIn(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type); + return this; + } + + /** + * If exists, first option is "Pretty", second is "Fragment" + * + * @param options + * @return + */ + public RosettaDF<T> out(Data.TYPE type) { + outType = type; + defaultOut = getOut(type==Data.TYPE.DEFAULT?Data.TYPE.JSON:type); + return this; + } + + public Parse<Reader,?> getIn(Data.TYPE type) { + switch(type) { + case DEFAULT: + return defaultIn; + case JSON: + return inJSON; + case XML: + return inXML; + default: + return defaultIn; + } + } + + public Out getOut(Data.TYPE type) { + switch(type) { + case DEFAULT: + return defaultOut; + case JSON: + return outJSON; + case XML: + return outXML; + case RAW: + return outRAW; + default: + return defaultOut; + } + } + + public int logType(org.onap.aaf.misc.env.Data.TYPE ot) { + switch(ot) { + case JSON: + return Env.JSON; + default: + return Env.XML; + } + } + + + public RosettaEnv getEnv() { + return env; + } + + + public Data.TYPE getInType() { + return inType; + } + + public Data.TYPE getOutType() { + return outType; + } + + public RosettaDF<T> option(int option) { + defOption = option; + + return this; + } + + /** + * Assigning Root Marshal Object + * + * Will wrap with DocMarshal Object if not already + * + * @param marshal + * @return + */ + public RosettaDF<T> rootMarshal(Marshal<T> marshal) { + if(marshal instanceof DocMarshal) { + this.marshal = marshal; + } else { + this.marshal = DocMarshal.root(marshal); + } + return this; + } + + public void direct(Trans trans, T t, OutputStream os, boolean ... options) throws APIException, IOException { + Out out = getOut(outType); + TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env? + try { + if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction + StringWriter sw = new StringWriter(); + jaxMar.marshal(trans.debug(), t, sw, options); + out.extract(new StringReader(sw.toString()), new OutputStreamWriter(os), inXML,options); + } else { + out.extract(t, new OutputStreamWriter(os), marshal,options); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + public void direct(Trans trans, T t, Writer writer, boolean ... options) throws APIException, IOException { + Out out = getOut(outType); + TimeTaken tt = trans.start(out.logName(),logType(outType)); // determine from Out.. without dependency on Env? + try { + if(marshal==null) { // Unknown marshaller... do working XML marshal/extraction + StringWriter sw = new StringWriter(); + jaxMar.marshal(trans.debug(), t, sw, options); + out.extract(new StringReader(sw.toString()), writer, inXML,options); + } else { + out.extract(t, writer, marshal,options); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java new file mode 100644 index 00000000..446c3c9c --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java @@ -0,0 +1,312 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.env; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.Saved; + +public class RosettaData<T> implements Data<T>{ + private Env trans; + private RosettaDF<T> df; + private Saved saved; + private TYPE inType, outType; + // Note: This is an array of boolean in order to pass into other methods + private boolean options[] = new boolean[] {false, false}; + // Temp Storage of XML. Only when we must use JAXB to read in Objects + private String xml,json; + + // package on purpose + RosettaData(Env env, RosettaDF<T> rosettaDF) { + df = rosettaDF; + saved = new Saved(); // Note: Saved constructs storage as needed... + trans = env; + inType = df.getInType(); + outType = df.getOutType(); // take defaults + } + +// // @Override + public RosettaData<T> in(TYPE rosettaType) { + inType = rosettaType; + return this; + } + +// // @Override + public RosettaData<T> out(TYPE rosettaType) { + outType = rosettaType; + return this; + } + +// // @Override + public RosettaData<T> load(Reader rdr) throws APIException { + Parse<Reader,?> in = df.getIn(inType); + TimeTaken tt = in.start(trans); + try { + saved.extract(rdr, (Writer)null, in); + xml=json=null; + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + // @Override + public RosettaData<T> load(InputStream is) throws APIException { + Parse<Reader,?> in = df.getIn(inType); + TimeTaken tt = in.start(trans); + try { + saved.extract(new InputStreamReader(is), (Writer)null, in); + xml=json=null; + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + // @Override + public RosettaData<T> load(String str) throws APIException { + Parse<Reader,?> in = df.getIn(inType); + TimeTaken tt = in.start(trans); + try { + saved.extract(new StringReader(str), (Writer)null, in); + switch(inType) { + case XML: + xml = str; + break; + case JSON: + json = str; + break; + default: + + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + // @Override + public RosettaData<T> load(T t) throws APIException { + Parse<?,?> in = df.getIn(inType); + TimeTaken tt = in.start(trans); + try { + if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + StringWriter sw = new StringWriter(); + df.jaxMar.marshal(trans.debug(), t, sw, options); + saved.extract(new StringReader(xml = sw.toString()), (Writer)null, df.inXML); + } else { + saved.extract(t, (Writer)null, df.marshal); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + public Saved getEvents() { + return saved; + } + + // @Override + public T asObject() throws APIException { + Out out = df.getOut(TYPE.XML); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + //TODO Replace JAXB with Direct Object method!!! + StringWriter sw = new StringWriter(); + out.extract(null, sw, saved); + return df.jaxUmar.unmarshal(trans.debug(), sw.toString()); + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + // @Override + public String asString() throws APIException { + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + if(outType==TYPE.XML) { + if(xml==null) { + StringWriter sw = new StringWriter(); + out.extract(null, sw, saved, options); + xml = sw.toString(); + } + return xml; + } else { // is JSON + if(json==null) { + StringWriter sw = new StringWriter(); + out.extract(null, sw, saved, options); + json = sw.toString(); + } + return json; + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + + // @Override + public RosettaData<T> to(OutputStream os) throws APIException, IOException { + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + if(outType==TYPE.XML && xml!=null) { + os.write(xml.getBytes()); + } else if(outType==TYPE.JSON && json!=null) { + os.write(json.getBytes()); + } else { + out.extract(null, os, saved, options); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + // @Override + public RosettaData<T> to(Writer writer) throws APIException, IOException { + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + if(outType==TYPE.XML && xml!=null) { + writer.append(xml); + } else if(outType==TYPE.JSON && json!=null) { + writer.append(json); + } else { + out.extract(null, writer, saved, options); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + return this; + } + + // @Override + public Class<T> getTypeClass() { + return df.getTypeClass(); + } + + private static final boolean[] emptyOption = new boolean[0]; + + public void direct(InputStream is, OutputStream os) throws APIException, IOException { + direct(is,os,emptyOption); + } + + public void direct(Reader reader, Writer writer, boolean ... options) throws APIException, IOException { + Parse<Reader,?> in = df.getIn(inType); + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + out.extract(reader, writer, in,options); + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + public void direct(T t, Writer writer, boolean ... options) throws APIException, IOException { + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + StringWriter sw = new StringWriter(); + df.jaxMar.marshal(trans.debug(), t, sw, options); + out.extract(new StringReader(xml = sw.toString()), writer, df.inXML,options); + } else { + out.extract(t, writer, df.marshal,options); + } + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + public void direct(T t, OutputStream os, boolean ... options) throws APIException, IOException { + Out out = df.getOut(outType); + TimeTaken tt = trans.start(out.logName(),df.logType(outType)); // determine from Out.. without dependency on Env? + try { + if(df.marshal==null) { // Unknown marshaller... do working XML marshal/extraction + if(outType.equals(TYPE.XML)) { + df.jaxMar.marshal(trans.debug(), t, os, options); + } else { + StringWriter sw = new StringWriter(); + df.jaxMar.marshal(trans.debug(), t, sw, options); + out.extract(new StringReader(xml = sw.toString()), new OutputStreamWriter(os), df.inXML,options); + } + } else { + out.extract(t, new OutputStreamWriter(os), df.marshal,options); + } + + } catch (Exception e) { + throw new APIException(e); + } finally { + tt.done(); + } + } + + + public void direct(InputStream is, OutputStream os, boolean ... options) throws APIException, IOException { + direct(new InputStreamReader(is),new OutputStreamWriter(os), options); + } + + // // @Override + public RosettaData<T> option(int option) { + options[0] = (option&Data.PRETTY)==Data.PRETTY; + options[1] = (option&Data.FRAGMENT)==Data.FRAGMENT; + return this; + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java new file mode 100644 index 00000000..05c75b7e --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaEnv.java @@ -0,0 +1,89 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.env; + +import java.applet.Applet; +import java.util.Properties; + +import javax.xml.namespace.QName; +import javax.xml.validation.Schema; + +import org.onap.aaf.misc.env.APIException; + +/** + * An essential Implementation of Env, which will fully function, without any sort + * of configuration. + * + * Use as a basis for Group level Env, just overriding where needed. + * @author Jonathan + * + */ +public class RosettaEnv extends org.onap.aaf.misc.env.impl.BasicEnv { + + public RosettaEnv() { + super(); + } + + public RosettaEnv(Applet applet, String... tags) { + super(applet, tags); + } + + public RosettaEnv(String[] args) { + super(args); + } + + public RosettaEnv(String tag, String[] args) { + super(tag, args); + } + + public RosettaEnv(String tag, Properties props) { + super(tag, props); + } + + public RosettaEnv(Properties props) { + super(props); + } + + @SuppressWarnings("unchecked") + @Override + public <T> RosettaDF<T> newDataFactory(Class<?>... classes) throws APIException { + return new RosettaDF<T>(this, null, null, (Class<T>)classes[0]); + } + + @SuppressWarnings("unchecked") + @Override + public <T> RosettaDF<T> newDataFactory(Schema schema, Class<?>... classes) throws APIException { + return new RosettaDF<T>(this, schema, null, (Class<T>)classes[0]); + } + + @SuppressWarnings("unchecked") + @Override + public<T> RosettaDF<T> newDataFactory(QName qName, Class<?> ... classes) throws APIException { + return new RosettaDF<T>(this, null, qName.getNamespaceURI(),(Class<T>)classes[0]); + } + + @SuppressWarnings("unchecked") + @Override + public<T> RosettaDF<T> newDataFactory(Schema schema, QName qName, Class<?> ... classes) throws APIException { + return new RosettaDF<T>(this, schema,qName.getNamespaceURI(),(Class<T>)classes[0]); + } +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java new file mode 100644 index 00000000..1655928d --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DataWriter.java @@ -0,0 +1,139 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import javax.xml.datatype.XMLGregorianCalendar; + +import org.onap.aaf.misc.env.util.Chrono; + +/** + * We make these objects instead of static functions so they can be passed into + * FieldArray. + * + * @author Jonathan + * + * @param <T> + */ +public abstract class DataWriter<T> { + public abstract boolean write(T t, StringBuilder sb); + + public final static DataWriter<String> STRING = new DataWriter<String>() { + @Override + public boolean write(String s, StringBuilder sb) { + sb.append(s); + return true; + } + }; + + public final static DataWriter<Integer> INTEGER = new DataWriter<Integer>() { + @Override + public boolean write(Integer i, StringBuilder sb) { + sb.append(i); + return false; + } + }; + + public final static DataWriter<Long> LONG = new DataWriter<Long>() { + @Override + public boolean write(Long t, StringBuilder sb) { + sb.append(t); + return false; + } + }; + + public final static DataWriter<Byte> BYTE = new DataWriter<Byte>() { + @Override + public boolean write(Byte t, StringBuilder sb) { + sb.append(t); + return false; + } + }; + + public final static DataWriter<Character> CHAR = new DataWriter<Character>() { + @Override + public boolean write(Character t, StringBuilder sb) { + sb.append(t); + return true; + } + }; + + public final static DataWriter<Boolean> BOOL = new DataWriter<Boolean>() { + @Override + public boolean write(Boolean t, StringBuilder sb) { + sb.append(t); + return true; + } + }; + + + /* + public final static DataWriter<byte[]> BYTE_ARRAY = new DataWriter<byte[]>() { + @Override + public boolean write(byte[] ba, StringBuilder sb) { + ByteArrayInputStream bais = new ByteArrayInputStream(ba); + StringBuilderOutputStream sbos = new StringBuilderOutputStream(sb); +// try { + //TODO find Base64 +// Symm.base64noSplit().encode(bais, sbos); +// } catch (IOException e) { +// // leave blank +// } + return true; + } + + }; + */ + + public final static DataWriter<XMLGregorianCalendar> DATE = new DataWriter<XMLGregorianCalendar>() { + @Override + public boolean write(XMLGregorianCalendar t, StringBuilder sb) { + sb.append(Chrono.dateOnlyStamp(t)); + return true; + } + }; + + public final static DataWriter<XMLGregorianCalendar> DATE_TIME = new DataWriter<XMLGregorianCalendar>() { + @Override + public boolean write(XMLGregorianCalendar t, StringBuilder sb) { + sb.append(Chrono.dateTime(t)); + return true; + } + }; + + private static final char[] chars="0123456789ABCDEF".toCharArray(); + public final static DataWriter<byte[]> HEX_BINARY = new DataWriter<byte[]>() { + @Override + public boolean write(byte[] ba, StringBuilder sb) { + // FYI, doing this because don't want intermediate + // String in "HexString" or the processing in + // "String.format" + //sb.append("0x"); + for(int i=0;i<ba.length;++i) { + byte b = ba[i]; + sb.append(chars[((b&0xF0)>>4)]); + sb.append(chars[b&0xF]); + } + return true; + } + }; + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java new file mode 100644 index 00000000..5249a17a --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/DocMarshal.java @@ -0,0 +1,82 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import java.util.Iterator; + +import org.onap.aaf.misc.rosetta.Ladder; +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.Parsed; + +public class DocMarshal<T> extends Marshal<T> { + private Marshal<T> root; + + public DocMarshal(Marshal<T> root) { + this.root = root; + } + + @Override + public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException { + Ladder<Iterator<?>> ladder = parsed.state.ladder; + Iterator<?> iter = ladder.peek(); + if(iter==null) { + ladder.push(PENDING_ITERATOR); + parsed.event = START_DOC; + } else if (DONE_ITERATOR.equals(iter)) { + } else { + ladder.ascend(); // look at field info + Iterator<?> currFieldIter = ladder.peek(); + if(!DONE_ITERATOR.equals(currFieldIter)){ + parsed = root.parse(t, parsed); + } + ladder.descend(); + if(DONE_ITERATOR.equals(currFieldIter) || parsed.event==NONE) { + parsed.event = END_DOC; + ladder.push(DONE_ITERATOR); + } + } + return parsed; // if unchanged, then it will end process + + } + + public static final Iterator<Void> PENDING_ITERATOR = new Iterator<Void>() { + @Override + public boolean hasNext() { + return false; + } + + @Override + public Void next() { + return null; + } + + @Override + public void remove() { + } + }; + + public static<T> DocMarshal<T> root(Marshal<T> m) { + return (DocMarshal<T>)new DocMarshal<T>(m); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java new file mode 100644 index 00000000..3006f897 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldArray.java @@ -0,0 +1,92 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import java.util.Iterator; +import java.util.List; + +import org.onap.aaf.misc.rosetta.Ladder; +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.Parsed; + + +public abstract class FieldArray<T,S> extends Marshal<T> { + private DataWriter<S> dataWriter; + private String name; + + public FieldArray(String name, DataWriter<S> dw) { + this.name = name; + dataWriter = dw; + } + + @SuppressWarnings("unchecked") + @Override + public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException { + Ladder<Iterator<?>> ladder = parsed.state.ladder; + Iterator<?> iter = ladder.peek(); + if(iter==null) { + List<S> list = data(t); + if(list.isEmpty() && parsed.state.smallest) { + ladder.push(DONE_ITERATOR); + } else { + ladder.push(new ListIterator<S>(list)); + parsed.event = START_ARRAY; + parsed.name = name; + } + } else if (DONE_ITERATOR.equals(iter)) { + } else { + ladder.ascend(); // look at field info + Iterator<?> memIter = ladder.peek(); + ListIterator<S> mems = (ListIterator<S>)iter; + S mem; + if(memIter==null) { + mem=mems.next(); + } else if(!DONE_ITERATOR.equals(memIter)) { + mem=mems.peek(); + } else if(iter.hasNext()) { + mem=null; + ladder.push(null); + } else { + mem=null; + } + + if(mem!=null) { + parsed.isString=dataWriter.write(mem, parsed.sb); + parsed.event = NEXT; + } + ladder.descend(); + if(mem==null) { + if(iter.hasNext()) { + parsed.event = NEXT; + } else { + parsed.event = END_ARRAY; + ladder.push(DONE_ITERATOR); + } + } + } + return parsed; // if unchanged, then it will end process + } + + protected abstract List<S> data(T t); + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java new file mode 100644 index 00000000..1de14e82 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldBlob.java @@ -0,0 +1,38 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +public abstract class FieldBlob<T> extends FieldMarshal<T>{ + public FieldBlob(String name) { + super(name); + } + + protected abstract byte[] data(T t); + + @Override + protected boolean data(T t, StringBuilder sb) { + return false; + // unimplemented + //return DataWriter.BYTE_ARRAY.write(data(t),sb); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java new file mode 100644 index 00000000..b3632a14 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDate.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import javax.xml.datatype.XMLGregorianCalendar; + +public abstract class FieldDate<T> extends FieldMarshal<T> { + public FieldDate(String name) { + super(name); + } + + @Override + final protected boolean data(T t, StringBuilder sb) { + return DataWriter.DATE.write(data(t), sb); + } + + protected abstract XMLGregorianCalendar data(T t); +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java new file mode 100644 index 00000000..8aa29829 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldDateTime.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import javax.xml.datatype.XMLGregorianCalendar; + +public abstract class FieldDateTime<T> extends FieldMarshal<T> { + public FieldDateTime(String name) { + super(name); + } + + @Override + final protected boolean data(T t, StringBuilder sb) { + return DataWriter.DATE_TIME.write(data(t), sb); + } + + protected abstract XMLGregorianCalendar data(T t); +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java new file mode 100644 index 00000000..589d0920 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldHexBinary.java @@ -0,0 +1,35 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +public abstract class FieldHexBinary<T> extends FieldMarshal<T>{ + public FieldHexBinary(String name) { + super(name); + } + + protected abstract byte[] data(T t); + + @Override + protected boolean data(T t, StringBuilder sb) { + return DataWriter.HEX_BINARY.write(data(t), sb); + } +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java new file mode 100644 index 00000000..cb8b6557 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldMarshal.java @@ -0,0 +1,59 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + + +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.Parsed; + +public abstract class FieldMarshal<T> extends Marshal<T> { + private String name; + + public FieldMarshal(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public Parsed<State> parse(T t, Parsed<State> parsed) { + parsed.state.ladder.push(DONE_ITERATOR); + parsed.event = Parse.NEXT; + parsed.name = name; + parsed.isString = data(t,parsed.sb); + return parsed; + } + + /** + * Write Value to StringBuilder + * Return true if value looks like a String + * false if it is Numeric + * @param t + * @param sb + * @return + */ + protected abstract boolean data(T t, StringBuilder sb); + +}
\ No newline at end of file diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java new file mode 100644 index 00000000..aac9ac69 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldNumeric.java @@ -0,0 +1,36 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +public abstract class FieldNumeric<N,T> extends FieldMarshal<T> { + public FieldNumeric(String name) { + super(name); + } + + @Override + final protected boolean data(T t, StringBuilder sb) { + sb.append(data(t)); + return false; + } + + protected abstract N data(T t); +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java new file mode 100644 index 00000000..2337c3c9 --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/FieldString.java @@ -0,0 +1,36 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +public abstract class FieldString<T> extends FieldMarshal<T> { + public FieldString(String name) { + super(name); + } + + protected abstract String data(T t); + + @Override + final protected boolean data(T t, StringBuilder sb) { + return DataWriter.STRING.write(data(t), sb); + } + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java new file mode 100644 index 00000000..6045141d --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ListIterator.java @@ -0,0 +1,59 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import java.util.Iterator; +import java.util.List; + +/** + * Need an Iterator that can peek the current value without changing + * @author Jonathan + * + * @param <T> + */ +final class ListIterator<T> implements Iterator<T> { + private T curr; + private Iterator<T> delg; + public ListIterator(List<T> list) { + curr = null; + delg = list.iterator(); + } + @Override + public boolean hasNext() { + return delg.hasNext(); + } + + @Override + public T next() { + return curr = delg.hasNext()?delg.next():null; + } + + public T peek() { + return curr==null?next():curr; + } + + @Override + public void remove() { + delg.remove(); + } + +}
\ No newline at end of file diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java new file mode 100644 index 00000000..3d7d1b4e --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjArray.java @@ -0,0 +1,90 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import java.util.Iterator; +import java.util.List; + +import org.onap.aaf.misc.rosetta.Ladder; +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.Parsed; + + +public abstract class ObjArray<T,S> extends Marshal<T> { + private String name; + private Marshal<S> subMarshaller; + + public ObjArray(String name, Marshal<S> subMarshaller) { + this.name = name; + this.subMarshaller = subMarshaller; + } + + @SuppressWarnings("unchecked") + @Override + public Parsed<State> parse(T t, Parsed<State> parsed) throws ParseException { + Ladder<Iterator<?>> ladder = parsed.state.ladder; + Iterator<?> iter = ladder.peek(); + if(iter==null) { + List<S> list = data(t); + if(list.isEmpty() && parsed.state.smallest) { + ladder.push(DONE_ITERATOR); + } else { + ladder.push(new ListIterator<S>(list)); + parsed.event = START_ARRAY; + parsed.name = name; + } + } else if (DONE_ITERATOR.equals(iter)) { + } else { + ladder.ascend(); // look at field info + Iterator<?> memIter = ladder.peek(); + ListIterator<S> mems = (ListIterator<S>)iter; + S mem; + if(memIter==null) { + mem=mems.next(); + } else if(!DONE_ITERATOR.equals(memIter)) { + mem=mems.peek(); + } else if(iter.hasNext()) { + mem=null; + ladder.push(null); + } else { + mem=null; + } + + if(mem!=null) + parsed = subMarshaller.parse(mem, parsed); + ladder.descend(); + if(mem==null) { + if(iter.hasNext()) { + parsed.event = NEXT; + } else { + parsed.event = END_ARRAY; + ladder.push(DONE_ITERATOR); + } + } + } + return parsed; // if unchanged, then it will end process + } + + protected abstract List<S> data(T t); + +} diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java new file mode 100644 index 00000000..eaa7a74a --- /dev/null +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/marshal/ObjMarshal.java @@ -0,0 +1,128 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.marshal; + +import java.util.Iterator; + +import org.onap.aaf.misc.rosetta.Ladder; +import org.onap.aaf.misc.rosetta.Marshal; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.Parsed; + +/** + * Object Marshal + * Assumes has Fields and other Objects + * s + * @author Jonathan + * + * @param <T> + */ +public abstract class ObjMarshal<T> extends Marshal<T> { + // Note: Not Using List or ArrayList, because there is no "Peek" concept in their iterator. + private Marshal<T>[] pml; + private int end=0; + + /** + * @param pm + */ + @SuppressWarnings("unchecked") + protected void add(Marshal<T> pm) { + if(pml==null) { + pml = new Marshal[Ladder.DEFAULT_INIT_SIZE]; + } else if(end>pml.length) { + Object temp[] = pml; + pml = new Marshal[pml.length+Ladder.DEFAULT_INIT_SIZE]; + System.arraycopy(temp, 0, pml, 0, pml.length); + } + pml[end]=pm; + ++end; + } + + /* (non-Javadoc) + * @see org.onap.aaf.misc.rosetta.Parse#parse(java.lang.Object, org.onap.aaf.misc.rosetta.Parsed) + */ + @SuppressWarnings("unchecked") + @Override + public Parsed<State> parse(T in, Parsed<State> parsed) throws ParseException { + Ladder<Iterator<?>> ladder = parsed.state.ladder; + Iterator<Marshal<T>> iter = (Iterator<Marshal<T>>)ladder.peek(); + if(iter==null) { + if(pml.length>0) { + ladder.push(new FieldsIterator()); + parsed.event = START_OBJ; + } else { + ladder.push(DONE_ITERATOR); + } + } else if (DONE_ITERATOR.equals(iter)) { + } else { + FieldsIterator fields = (FieldsIterator)iter; + ladder.ascend(); // look at field info + Iterator<?> currFieldIter = ladder.peek(); + Marshal<T> marshal; + if(currFieldIter==null) { + marshal=fields.next(); + } else if(!DONE_ITERATOR.equals(currFieldIter)) { + marshal=fields.peek(); + if(marshal==null && fields.hasNext())marshal=fields.next(); + } else if(fields.hasNext()) { + marshal=fields.next(); + ladder.push(null); + } else { + marshal=null; + } + + if(marshal!=null) + parsed = marshal.parse(in, parsed); + ladder.descend(); + if(marshal==null || parsed.event==NONE) { + parsed.event = END_OBJ; + ladder.push(DONE_ITERATOR); + } + } + return parsed; // if unchanged, then it will end process + } + + private class FieldsIterator implements Iterator<Marshal<T>> { + private int idx = -1; + + @Override + public boolean hasNext() { + return idx<end; + } + + @Override + public Marshal<T> next() { + return pml[++idx]; + } + + public Marshal<T> peek() { + return idx<0?null:pml[idx]; + } + + @Override + public void remove() { + pml[idx]=null; + } + + } + +} diff --git a/misc/rosetta/src/main/xsd/inherit.xsd b/misc/rosetta/src/main/xsd/inherit.xsd new file mode 100644 index 00000000..e0a33fb4 --- /dev/null +++ b/misc/rosetta/src/main/xsd/inherit.xsd @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<xs:schema elementFormDefault="qualified" + targetNamespace="urn:inherit" + xmlns="urn:inherit" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + > + + <xs:complexType name="baseType"> + <xs:sequence> + <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" /> + <xs:element name="num" type="xs:short" minOccurs="0" maxOccurs="1" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="derivedA"> + <xs:annotation> + <xs:documentation>Select one of the items</xs:documentation> + </xs:annotation> + <xs:complexContent> + <xs:extension base="baseType"> + <xs:sequence> + <xs:element name="shortName" type="xs:string" minOccurs="0" maxOccurs="1" /> + <xs:element name="value" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="base" type="baseType" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema>
\ No newline at end of file diff --git a/misc/rosetta/src/main/xsd/s.xsd b/misc/rosetta/src/main/xsd/s.xsd new file mode 100644 index 00000000..b4d137e8 --- /dev/null +++ b/misc/rosetta/src/main/xsd/s.xsd @@ -0,0 +1,64 @@ +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<xs:schema elementFormDefault="qualified" + targetNamespace="urn:s:xsd" + xmlns:s="urn:s:xsd" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + > + + <xs:element name="SampleData"> + <xs:complexType> + <xs:sequence> + <xs:element name="id" type="xs:string" minOccurs="1" maxOccurs="1" /> + <xs:element name="date" type="xs:long"/> + <xs:element name="item" type="xs:string" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="LargerData"> + <xs:complexType> + <xs:sequence> + <xs:element ref="s:SampleData" minOccurs="1" maxOccurs="unbounded"/> + <xs:element name="fluff" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="LargerDatas"> + <xs:complexType> + <xs:sequence> + <xs:element ref="s:LargerData" minOccurs="1" maxOccurs = "unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + + <xs:element name="Multi"> + <xs:complexType> + <xs:sequence> + <xs:element name="f1" type="xs:string" minOccurs="0" maxOccurs = "unbounded"/> + <xs:element name="f2" type="xs:string" minOccurs="0" maxOccurs = "unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema>
\ No newline at end of file diff --git a/misc/rosetta/src/main/xsd/types.xsd b/misc/rosetta/src/main/xsd/types.xsd new file mode 100644 index 00000000..5533964b --- /dev/null +++ b/misc/rosetta/src/main/xsd/types.xsd @@ -0,0 +1,46 @@ +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<xs:schema elementFormDefault="qualified" + targetNamespace="urn:types:xsd" + xmlns:s="urn:types:xsd" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + > + <xs:element name="multi"> + <xs:complexType> + <xs:sequence> + <xs:element name="single" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="str" type="xs:string" minOccurs="1" maxOccurs="1" /> + <xs:element name="int" type="xs:int" minOccurs="1" maxOccurs="1" /> + <xs:element name="long" type="xs:long" minOccurs="1" maxOccurs="1" /> + <xs:element name="date" type="xs:date" minOccurs="1" maxOccurs="1" /> + <xs:element name="datetime" type="xs:dateTime" minOccurs="1" maxOccurs="1" /> + <xs:element name="binary" type="xs:hexBinary" minOccurs="1" maxOccurs="1" /> + <xs:element name="array" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema>
\ No newline at end of file diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java new file mode 100644 index 00000000..121deea0 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromJSON.java @@ -0,0 +1,268 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.Reader; +import java.io.StringReader; + +import org.junit.Test; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.impl.EnvFactory; +import org.onap.aaf.misc.env.jaxb.JAXBmar; +import org.onap.aaf.misc.env.util.IndentPrintWriter; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.rosetta.InJson; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.OutXML; + +import junit.framework.Assert; +import s.xsd.LargerData; +import s.xsd.SampleData; + +public class JU_FromJSON { + private static int ITERATIONS = 10000; + static String str = "{\"SampleData\":[" + + "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + + "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}"; + InJson inJSON = new InJson(); + + @Test + public void rawParse() throws Exception { + System.out.println("*** PARSE JSON -> RAW Dump ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(); + new OutRaw().extract(new StringReader(str),sbw,inJSON); + System.out.println(sbw.getBuffer()); + } + + @Test + public void parseJSON2Dump() throws Exception { + System.out.println("*** PARSE JSON -> Dump ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + new OutDump().extract(new StringReader(str), sbw, inJSON); + + System.out.println(sbw.getBuffer()); + } + + @Test + public void nonprettyJSON() throws Exception { + System.out.println("*** JSON -> (Intermediate Stream) -> Non-pretty JSON ***"); + System.out.println(str); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Out jout = new OutJson(); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + jout.extract(sr, sbw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + String result = sbw.toString(); + System.out.println(result); + Assert.assertEquals(result, str); + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void parseJSON2JSON() throws Exception { + System.out.println("*** JSON -> (Intermediate Stream) -> Pretty JSON ***"); + System.out.println(str); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Out jout = new OutJson(); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + jout.extract(sr, sbw, inJSON,true); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void parseJSON2XML() throws Exception { + System.out.println("*** PARSE JSON -> XML ***"); + System.out.println(str); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + xout.extract(sr, sbw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void parseJSON2PrettyXML() throws Exception { + System.out.println("*** PARSE JSON -> Pretty XML ***"); + System.out.println(str); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + IndentPrintWriter ipw = new IndentPrintWriter(sbw); + + Out xout = new OutXML("LargerData","xmlns=urn:s:xsd"); + Trans trans; + Report report = new Report(ITERATIONS,"JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(str); + TimeTaken tt = trans.start("Parse JSON", Env.JSON); + try { + xout.extract(sr, ipw, inJSON); + } finally { + tt.done(); + } + report.glean(trans,Env.JSON); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + + @Test + public void jaxbObj2XML() throws Exception { + System.out.println("*** JAXB Object -> XML ***"); + + LargerData ld = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"1\""); + sd.getItem().add("Item 1.1"); + sd.getItem().add("Item 1.2"); + ld.getSampleData().add(sd); + sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"2\""); + sd.getItem().add("Item 2.1"); + sd.getItem().add("Item 2.2"); + ld.getSampleData().add(sd); + ld.setFluff("MyFluff"); + + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken tt = trans.start("JAXB", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void jaxbObj2PrettyXML() throws Exception { + System.out.println("*** JAXB Object -> Pretty XML ***"); + + LargerData ld = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"1\""); + sd.getItem().add("Item 1.1"); + sd.getItem().add("Item 1.2"); + ld.getSampleData().add(sd); + sd = new SampleData(); + sd.setDate(System.currentTimeMillis()); + sd.setId("sd object \"2\""); + sd.getItem().add("Item 2.1"); + sd.getItem().add("Item 2.2"); + ld.getSampleData().add(sd); + ld.setFluff("MyFluff"); + + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken tt = trans.start("JAXB", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java new file mode 100644 index 00000000..58813621 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_FromXML.java @@ -0,0 +1,259 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.Reader; +import java.io.StringReader; + +import org.junit.Test; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.LogTarget; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.Trans.Metric; +import org.onap.aaf.misc.env.impl.EnvFactory; +import org.onap.aaf.misc.env.jaxb.JAXBmar; +import org.onap.aaf.misc.env.jaxb.JAXBumar; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.rosetta.InXML; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.OutXML; + +import s.xsd.LargerData; + +public class JU_FromXML { + private static int ITERATIONS = 1; + ; + + private final static String xml = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + + "<LargerData xmlns=\"urn:s:xsd\">\n" + + " <SampleData>\n" + + " <id>sd object 1</id>\n" + + " <date>1346765355134</date>\n" + + " <item>Item 1.1</item>\n" + + " <item>Item 1.2</item>\n" + + " </SampleData>\n" + + " <SampleData>\n" + + " <id>sd object 2</id>\n" + + " <date>1346765355134</date>\n" + + " <item>Item 2.1</item>\n" + + " <item>Item 2.2</item>\n" + + " </SampleData>\n" + + " <fluff>MyFluff</fluff>\n" + + "</LargerData>\n"; + + + @Test + public void test() throws Exception { + InXML inXML = new InXML(LargerData.class); + + System.out.println(xml); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Reader rdr = new StringReader(xml); + + new OutRaw().extract(rdr, sbw, inXML); + System.out.println(sbw.getBuffer()); + } + + + @Test + public void xml2JSON() throws Exception { + System.out.println("*** XML -> JSON (No Warm up) ***"); + Out jout = new OutJson(); + InXML inXML = new InXML(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(xml); + TimeTaken tt = trans.start("Parse XML", Env.XML); + try { + jout.extract(sr, sbw, inXML); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + @Test + public void xml2XML() throws Exception { + System.out.println("*** XML -> (Event Queue) -> XML (No Warm up) ***"); + Out xout = new OutXML("LargerData"); + InXML inXML = new InXML(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(xml); + TimeTaken tt = trans.start("Parse XML", Env.XML); + try { + xout.extract(sr, sbw, inXML); + } finally { + tt.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + + + @Test + public void warmup() throws Exception { + if(ITERATIONS>20) { + System.out.println("*** Warmup JAXB ***"); + + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + + LargerData ld; + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + } + } + @Test + public void xml2jaxb2xml() throws Exception { + System.out.println("*** XML -> JAXB Object -> XML ***"); + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + //jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + LargerData ld; + Trans trans; + Report report = new Report(ITERATIONS,"XML"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + report.glean(trans,Env.XML); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); } + + @Test + public void xml2jaxb2PrettyXml() throws Exception { + System.out.println("*** XML -> JAXB Object -> Pretty XML ***"); + JAXBumar jaxbUmar = new JAXBumar(LargerData.class); + JAXBmar jaxBmar = new JAXBmar(LargerData.class); + //jaxBmar.asFragment(true); + jaxBmar.pretty(true); + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans = EnvFactory.newTrans(); + LargerData ld; + for(int i=0;i<ITERATIONS;++i) { + sbw.reset(); + TimeTaken all = trans.start("Combo", Env.SUB); + try { + TimeTaken tt = trans.start("JAXB Unmarshal", Env.XML); + try { + ld = jaxbUmar.unmarshal(LogTarget.NULL, xml); + } finally { + tt.done(); + } + tt = trans.start("JAXB marshal", Env.XML); + try { + jaxBmar.marshal(LogTarget.NULL, ld, sbw); + } finally { + tt.done(); + } + } finally { + all.done(); + } + } + sbw.append('\n'); + Metric m; + if(ITERATIONS>20) { + m = trans.auditTrail(0,null); + } else { + m = trans.auditTrail(0, sbw.getBuffer()); + System.out.println(sbw.getBuffer()); + } + System.out.println(ITERATIONS + " entries, Total Time: " + m.total + "ms, Avg Time: " + m.total/ITERATIONS + "ms"); + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java new file mode 100644 index 00000000..2a48edc4 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_JSON.java @@ -0,0 +1,136 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; + +import junit.framework.Assert; + +import org.junit.Test; +import org.onap.aaf.misc.rosetta.InJson; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.ParseException; + +public class JU_JSON { + + @Test + public void test() throws IOException, ParseException { + InJson jin = new InJson(); + Out jout = new OutJson(); + + go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); + + go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\"],\"utc\":1360418381310}"); + go(jin, jout, "{\"id\":\"My ID 1\",\"desc\":\"My Description 1\",\"comment\":[\"My Comment 1\",\"My Comment 2\"],\"utc\":1360418381310}"); + + go(jin, jout, "{\"SampleData\":[" + + "{\"id\":\"sd object \\\"1\\\"\",\"date\":1316084944213,\"item\":[\"Item 1.1\",\"Item 1.2\"]}," + + "{\"id\":\"sd object \\\"2\\\"\",\"date\":1316084945343,\"item\":[\"Item 2.1\",\"Item 2.2\"]}],\"fluff\":\"MyFluff\"}" + ); + + go(jin, jout, "{\"SampleData\":[{\"date\":1316084945343}],\"fluff\":\"MyFluff\"}"); + + go(jin, jout, "{\"id\":\"Me,[}[eg[)(:x,\\\" Myself\",\"date\":1353094689100}"); + + // TODO: Clean out AT&T specific data + go(jin,jout, "{\"userid\":\"jg1555\",\"timestamp\":1353097388531,\"item\":[{\"tag\":\"color\",\"value\":\"Mauve\"},{\"tag\":\"shirtsize\",\"value\":\"Xtra Large\"}]}"); + //go() + //"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><vote xmlns=\"urn:poll.att.com\"><userid>jg1555</userid><timestamp>1353082669667</timestamp></vote>"); + + // 3/11/2015 Jonathan found a case with missing comma + go(jin,jout, "{\"start\":\"2015-03-11T18:18:05.580-05:00\",\"end\":\"2015-09-11-05:00\",\"force\":\"false\",\"perm\":{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myInstance\",\"action\":\"myAction\"}" + + ",\"role\":\"org.osaaf.myns.myrole\"}"); + + // 3/12/2015 Jonathan Kurt Schurenberg noticed an issue of object names in an array. This is valid code. + go(jin,jout, "{\"role\":[{\"name\":\"org.osaaf.myns.myrole\",\"perms\":[{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.mytype\",\"instance\":\"myOtherAction\"}]}" + + ",{\"name\":\"org.osaaf.myns.myOtherRole\",\"perms\":[{\"type\":\"org.osaaf.myns.myOtherType\",\"instance\":\"myAction\"},{\"type\":\"org.osaaf.myns.myOthertype\",\"instance\":\"myOtherAction\"}]}]}"); + + // 3/13/2015 - discovered with complex Response + go(jin,jout, "{\"meth\":\"GET\",\"path\":\"/authz/perms/:type\",\"desc\":\"GetPermsByType\",\"comments\":[\"List All Permissions that match :type listed\"]," + + "\"contentType\":[\"application/Permissions+json;q=1.0;charset=utf-8;version=1.1,application/json;q=1.0;version=1.1\"" + + ",\"application/Perms+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0\",\"application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0\"" + + ",\"application/Permissions+xml;q=1.0;charset=utf-8;version=1.1,text/xml;q=1.0;version=1.1\"]}"); + + + // Test a Windoze "Pretty Print", validate skipping of Windoze characters as well as other odd control characters listed + // in json.org + StringWriter sw = new StringWriter(); + jout.extract(new StringReader( + "{\b\f\n\r\t \"id\"" + + ":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100" + + "\b\f\n\r\t }" + ),sw,jin); + Assert.assertEquals("{\"id\":\"Me, \b\f\n\r\tMyself\",\"date\":1353094689100}",sw.toString()); + System.out.println(sw.toString()); + + // 10/01/2015 Jonathan AAF-703 Ron Gallagher, this response is ok + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"something\"}]}"); + // but when description:"" causes extra comma at end + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":\"myAction\"}]}"); + // Test other empty string scenarios + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"\"}]}","{\"perm\":[{}]}"); + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"\",\"description\":\"hi\"}]}","{\"perm\":[{\"description\":\"hi\"}]}"); + go(jin,jout, "{\"perm\":[{\"type\":\"\",\"action\":\"myAction\",\"description\":\"\"}]}","{\"perm\":[{\"action\":\"myAction\"}]}"); + + + go(jin,jout, "{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"action\":,\"description\":\"something\"}]}","{\"perm\":[{\"type\":\"org.osaaf.myns.myPerm\",\"description\":\"something\"}]}"); + + go(jin, jout, "{\"name\":\"\\\"hello\\\"\"}"); + + go(jin, jout, "{\"name\":\"\\\\\"}"); + + go(jin, jout, "{\"role\":\"org.osaaf.scamper.UserStory0152 7_IT-00323-a-admin\",\"perm\":{\"type\":\"org.osaaf.scamper.application\",\"instance\":\"_()`!@#\\\\$%^=+][{}<>/.-valid.app.name-is_good\",\"action\":\"Administrator\"}}"); + + + } + + + private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { + go(in,out,str,str); + } + + + private void go(Parse<Reader, ?> in, Out out, String str, String cmp) throws IOException, ParseException { + + System.out.println(str); + StringWriter sw = new StringWriter(1024); + out.extract(new StringReader(str), sw, in); + System.out.println(sw); + String result = sw.toString(); + + if(!result.equals(cmp)) { + sw.getBuffer().setLength(0); + new OutRaw().extract(new StringReader(str), sw, in); + System.out.println(sw); + } + + Assert.assertEquals(cmp,result); + System.out.println(); + + } +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java new file mode 100644 index 00000000..f72b6e69 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Ladder.java @@ -0,0 +1,76 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import org.junit.Test; +import org.onap.aaf.misc.rosetta.Ladder; + +import static org.junit.Assert.*; + +public class JU_Ladder { + + @Test + public void test() { + Ladder<String> ladder = new Ladder<String>(); + + for(int i=0;i<30;++i) { + for(int j=0;j<i;++j)ladder.ascend(); + String str = "Rung " + i; + assertEquals(ladder.peek(),null); + ladder.push(str); + assertEquals(str,ladder.peek()); + assertEquals(str,ladder.pop()); + assertEquals(null,ladder.peek()); + for(int j=0;j<i;++j)ladder.descend(); + } + assertEquals(ladder.height(),32); // Sizing, when naturally created is by 8 + + ladder.cutTo(8); + assertEquals(ladder.height(),8); + + for(int i=0;i<30;++i) { + ladder.jumpTo(i); + String str = "Rung " + i; + assertEquals(ladder.peek(),null); + ladder.push(str); + assertEquals(ladder.peek(),str); + } + + ladder.bottom(); + + for(int i=0;i<30;++i) { + assertEquals("Rung " + i,ladder.peek()); + ladder.ascend(); + } + + ladder.bottom(); + ladder.top(); + assertEquals("Rung 29",ladder.peek()); + + for(int i=0;i<30;++i) { + ladder.jumpTo(i); + assertEquals("Rung " + i,ladder.peek()); + } + + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java new file mode 100644 index 00000000..cff5b43a --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Nulls.java @@ -0,0 +1,70 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import junit.framework.Assert; + +import org.junit.AfterClass; +import org.junit.Test; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.rosetta.env.RosettaDF; +import org.onap.aaf.misc.rosetta.env.RosettaData; +import org.onap.aaf.misc.rosetta.env.RosettaEnv; + +import s.xsd.LargerData; +import s.xsd.SampleData; + +public class JU_Nulls { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Test + public void test() { + RosettaEnv env = new RosettaEnv(); + try { + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + df.out(Data.TYPE.JSON); + LargerData urr = new LargerData(); + SampleData sd = new SampleData(); + sd.setDate(1444125487798L); + sd.setId(null); + urr.getSampleData().add(sd); + urr.setFluff(null); + RosettaData<LargerData> data = df.newData(); +// StringWriter sw = new StringWriter(); +// df.direct(trans, urr, sw); +// System.out.println(sw.toString()); + data.load(urr); + System.out.println(data.asString()); + Assert.assertEquals("{\"SampleData\":[{\"date\":1444125487798}]}", data.asString()); + + System.out.println(data.out(Data.TYPE.RAW).asString()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java new file mode 100644 index 00000000..07c73196 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_RosettaDF.java @@ -0,0 +1,162 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.StringReader; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.Data.TYPE; +import org.onap.aaf.misc.env.impl.EnvFactory; +import org.onap.aaf.misc.env.jaxb.JAXBmar; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.rosetta.env.RosettaDF; +import org.onap.aaf.misc.rosetta.env.RosettaData; +import org.onap.aaf.misc.rosetta.env.RosettaEnv; + +import s.xsd.LargerData; +import s.xsd.Multi; +import s.xsd.SampleData; + +public class JU_RosettaDF { + public static int ITERATIONS = 1; + + @Test + public void testCached() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + JAXBmar jmar = new JAXBmar(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + Trans trans = EnvFactory.newTrans(); + + Report report = new Report(ITERATIONS,"Load JSON","Extract JAXB", "JAXB Marshal", "Cached to XML", "Cached to JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Data<LargerData> data; + TimeTaken tt = trans.start("Load JSON", 1); + try { + data = df.newData(trans).out(Data.TYPE.JSON).in(Data.TYPE.JSON).load(JU_FromJSON.str); + } finally { + tt.done(); + } + LargerData ld; + tt = trans.start("Extract JAXB", 2); + try { + ld = data.asObject(); + } finally { + tt.done(); + } + + tt = trans.start("JAXB marshal", 3); + try { + jmar.marshal(trans.debug(), ld, sbw); + } finally { + tt.done(); + } + sbw.append('\n'); + + tt = trans.start("To XML from Cache",4); + try { + data.out(Data.TYPE.XML).to(sbw); + } finally { + tt.done(); + } + + sbw.append('\n'); + + tt = trans.start("To JSON from Cache",5); + try { + data.out(Data.TYPE.JSON).to(sbw); + } finally { + tt.done(); + } + report.glean(trans, 1,2,3,4,5); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw); + + } + + @Test + public void testDirect() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<LargerData> df = env.newDataFactory(LargerData.class); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + Trans trans = EnvFactory.newTrans(); + + Report report = new Report(ITERATIONS); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + RosettaData<?> data = df.newData(trans).in(Data.TYPE.JSON).out(Data.TYPE.XML); + data.direct(new StringReader(JU_FromJSON.str), sbw); + report.glean(trans); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw); + + } + + @Test + public void testMulti() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<Multi> df = env.newDataFactory(Multi.class); + +// StringBuilderWriter sbw = new StringBuilderWriter(1024); +// Trans trans = EnvFactory.newTrans(); + + Multi m = new Multi(); + m.getF1().add("String1"); + m.getF2().add("String2"); + + System.out.println(df.newData().load(m).out(TYPE.RAW).asString()); + System.out.println(df.newData().load(m).out(TYPE.JSON).asString()); + + } + + @Test + public void testQuotes() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<SampleData> df = env.newDataFactory(SampleData.class); + + SampleData sd = new SampleData(); + sd.setId("\"AT&T Services, Inc.\""); + System.out.println(sd.getId()); + String out =df.newData().load(sd).out(TYPE.JSON).asString(); + System.out.println(out); + Assert.assertEquals( + "{\"id\":\"\\\"AT&T Services, Inc.\\\"\",\"date\":0}", + out); + + SampleData sd2 = df.newData().in(TYPE.JSON).load(out).asObject(); + System.out.println(sd2.getId()); + Assert.assertEquals(sd.getId(),sd2.getId()); + } +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java new file mode 100644 index 00000000..47953007 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Saved.java @@ -0,0 +1,104 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.Reader; +import java.io.StringReader; + +import org.junit.Test; +import org.onap.aaf.misc.env.TimeTaken; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.impl.EnvFactory; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.rosetta.InJson; +import org.onap.aaf.misc.rosetta.JaxInfo; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutXML; +import org.onap.aaf.misc.rosetta.Saved; + +import s.xsd.LargerData; + +public class JU_Saved<b> { + private static int ITERATIONS = 100000; + + @Test + public void test() throws Exception { + InJson inJSON = new InJson(); + OutDump dump = new OutDump(); + JaxInfo ji = JaxInfo.build(LargerData.class); + OutXML xml = new OutXML(ji);; + OutJson json = new OutJson(); + + Saved saved = new Saved(); + + StringBuilderWriter sbw = new StringBuilderWriter(1024); + + Trans trans; + Report report = new Report(ITERATIONS,"Save","Dump","XML ","JSON"); + do { + sbw.reset(); + trans = EnvFactory.newTrans(); + Reader sr = new StringReader(JU_FromJSON.str); + TimeTaken tt = trans.start("Parse Text, and Save", 1); + try { + saved.load(sr, inJSON); + } finally { + tt.done(); + } + +// sbw.append("==== Start Direct Raw =====\n"); +// new OutRaw().extract(new StringReader(JU_FromJSON.str), sbw, inJSON); +// +// sbw.append("==== Start Raw from Saved =====\n"); +// new OutRaw().extract(null,sbw,saved); + + sbw.append("==== Start Dump from Saved =====\n"); + tt = trans.start("Dump", 2); + try { + dump.extract(null,sbw,saved); + } finally { + tt.done(); + } + + sbw.append("\n==== Start XML =====\n"); + tt = trans.start("XML", 3); + try { + xml.extract(null,sbw,saved); + } finally { + tt.done(); + } + + sbw.append("\n==== Start JSON =====\n"); + tt = trans.start("JSON", 4); + try { + json.extract(null,sbw,saved); + } finally { + tt.done(); + } + report.glean(trans,1,2,3,4); + } while(report.go()); + + report.report(sbw); + System.out.println(sbw.toString()); + + } +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java new file mode 100644 index 00000000..6047c03c --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Stream2Obj.java @@ -0,0 +1,123 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import inherit.DerivedA; +import inherit.Root; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; + +import org.junit.Test; +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.DataFactory; +import org.onap.aaf.misc.env.EnvJAXB; +import org.onap.aaf.misc.env.impl.BasicEnv; +import org.onap.aaf.misc.rosetta.InJson; +import org.onap.aaf.misc.rosetta.InXML; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.OutXML; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.ParseException; + +public class JU_Stream2Obj { + + /* + <?xml version="1.0" encoding=Config.UTF-8 standalone="yes"?> + <root xmlns="urn:inherit"> + <base xsi:type="derivedA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <name>myDerivedA_1</name> + <num>1432</num> + <shortName>mda_1</shortName> + <value>value_1</value> + <value>value_2</value> + </base> + </root> + + {"base":[{"__extension":"derivedA","name":"myDerivedA_1","num":1432,"shortName":"mda_1","value":["value_1","value_2"]}]} + */ + + @Test + public void json2Obj() throws APIException, SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException, IOException { + DerivedA da = new DerivedA(); + da.setName("myDerivedA_1"); + da.setNum((short)1432); + da.setShortName("mda_1"); + da.getValue().add("value_1"); + da.getValue().add("value_2"); + + Root root = new Root(); + root.getBase().add(da); + + da = new DerivedA(); + da.setName("myDerivedA_2"); + da.setNum((short)1432); + da.setShortName("mda_2"); + da.getValue().add("value_2.1"); + da.getValue().add("value_2.2"); + root.getBase().add(da); + + EnvJAXB env = new BasicEnv(); + DataFactory<Root> rootDF = env.newDataFactory(Root.class); + + String xml = rootDF.newData(env).out(Data.TYPE.XML).load(root).option(Data.PRETTY).asString(); + System.out.println(xml); + + InXML inXML; + Parse<Reader,?> in = inXML = new InXML(Root.class); + Out out = new OutRaw(); + + StringWriter sw = new StringWriter(); + out.extract(new StringReader(xml), sw, in); + System.out.println(sw.toString()); + + + out = new OutJson(); + + sw = new StringWriter(); + out.extract(new StringReader(xml), sw, in); + String json; + System.out.println(json = sw.toString()); + + in = new InJson(); + out = new OutRaw(); + + sw = new StringWriter(); + out.extract(new StringReader(json), sw, in); + System.out.println(sw.toString()); + + out = new OutXML(inXML); + + sw = new StringWriter(); + out.extract(new StringReader(json), sw, in, true); + System.out.println(sw.toString()); + + System.out.flush(); + + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java new file mode 100644 index 00000000..1209e77d --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Struct.java @@ -0,0 +1,73 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import org.junit.Test; +import org.onap.aaf.misc.rosetta.JaxInfo; + +import s.xsd.LargerData; + +public class JU_Struct { + public final static String XML ="<LargerData xmlns=\"urn:s:xsd\">\n" + + "<SampleData>\n" + + "<id>sd object 1</id>\n" + + "<date>1346439215932</date>\n" + + "<item>Item 1.1</item>\n" + + "<item>Item 1.2</item>\n" + + "</SampleData>\n" + + "<SampleData>\n" + + "<id>sd object 2</id>\n" + + "<date>1346439215932</date>\n" + + "<item>Item 2.1</item>\n" + + "<item>Item 2.2</item>\n" + + "</SampleData>\n" + + "<fluff>MyFluff</fluff>\n" + + "</LargerData>\n"; + +// @Test +// public void test2() throws Exception { +// +// SampleData sd = new SampleData(); +// sd.setDate(new Date().getTime()); +// sd.setId("myId"); +// sd.getItem().add("Item 1.1"); +// +// InObj<SampleData> inObj = new InObj<SampleData>(SampleData.class); +// +// JaxSet<SampleData> jaxSet = JaxSet.get(SampleData.class); +// Setter<SampleData> setter = jaxSet.setter("id"); +// setter.set(sd, "Your ID"); +// +// for(Entry<String, Getter<SampleData>> es : jaxSet.getters()) { +// System.out.print(es.getKey()); +// System.out.print(' '); +// System.out.println(es.getValue().get(sd)); +// } +// } + + @Test + public void test() throws Exception { + JaxInfo ji = JaxInfo.build(LargerData.class); + System.out.println(ji); + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java new file mode 100644 index 00000000..5d76e3cb --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/JU_Types.java @@ -0,0 +1,301 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.StringWriter; + +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.junit.Test; +import org.onap.aaf.misc.env.Data; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.Data.TYPE; +import org.onap.aaf.misc.env.Trans.Metric; +import org.onap.aaf.misc.env.jaxb.JAXBmar; +import org.onap.aaf.misc.env.jaxb.JAXBumar; +import org.onap.aaf.misc.env.util.Chrono; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.rosetta.OutJson; +import org.onap.aaf.misc.rosetta.OutRaw; +import org.onap.aaf.misc.rosetta.OutXML; +import org.onap.aaf.misc.rosetta.env.RosettaDF; +import org.onap.aaf.misc.rosetta.env.RosettaData; +import org.onap.aaf.misc.rosetta.env.RosettaEnv; +import org.onap.aaf.misc.rosetta.marshal.DocMarshal; +import org.onap.aaf.misc.rosetta.test.obj.MultiMarshal; +import org.onap.aaf.misc.rosetta.test.obj.SingleMarshal; + +import types.xsd.Multi; +import types.xsd.Multi.Single; + +public class JU_Types { + + @Test + public void single() throws Exception { + Single single = setSData(); + SingleMarshal psingle = new SingleMarshal(); + + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Single","xmlns=urn:types:xsd"); + + + System.out.println("===== RAW ====="); + raw.extract(single, System.out, psingle); + + System.out.println("\n===== JSON ====="); + json.extract(single, System.out, psingle); + + System.out.println("\n\n===== Pretty JSON ====="); + json.extract(single, System.out, psingle, true); + + System.out.println("\n\n===== XML ====="); + xml.extract(single, System.out, psingle,false); + + System.out.println("\n\n===== Pretty XML ====="); + xml.extract(single, System.out, psingle, true); + + RosettaEnv env = new RosettaEnv(); + StringWriter sw = new StringWriter(); + xml.extract(single, sw, psingle, true); + JAXBumar jumar = new JAXBumar(single.getClass()); + JAXBmar jmar = new JAXBmar(new QName("Single","urn.types.xsd"),single.getClass()); + jmar.pretty(true); + sw = new StringWriter(); + jmar.marshal(env.info(), single, sw); + System.out.println(sw); + Single news = jumar.unmarshal(env.info(), sw.toString()); +// System.out.println(news.getDatetime()); +// sw = new StringWriter(); +// news.setDatetime(Chrono.timeStamp()); +// xml.extract(single, sw, psingle, true); + news = jumar.unmarshal(env.info(), sw.toString()); + System.out.println(sw.toString()); + + String sample = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + + "\n<ns2:urn.types.xsd xmlns:ns2=\"Single\" xmlns=\"urn:types:xsd\">" + + "\n<str>MyString</str>" + + "\n<int>2147483647</int>" + + "\n<long>9223372036854775807</long>" + + "\n<date>2015-05-27-05:00</date>" + + "\n<datetime>2015-05-27T07:05:04.234-05:00</datetime>" + + "\n<binary>FF00FF0E082507807F</binary>" + + "\n<array>String 1</array>" + + "\n<array>String 2</array>" + + "\n</ns2:urn.types.xsd>"; + System.out.println(sample); + news = jumar.unmarshal(env.info(), sample); + + System.out.println(news.getDatetime()); + + } + + @Test + public void multi() throws Exception { + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); + + Multi multi = new Multi(); + MultiMarshal pmulti = new MultiMarshal(); + + for(int i=0;i<10;++i) { + System.out.println("===== Multi Iteration " + i + " ====="); + if(i>0) { + multi.getSingle().add(setSData()); + } + System.out.println(" ===== RAW ====="); + raw.extract(multi, System.out, pmulti); + + System.out.println("\n ===== JSON ====="); + json.extract(multi, System.out, pmulti); + + System.out.println("\n\n ===== Pretty JSON ====="); + json.extract(multi, System.out, pmulti, true); + + System.out.println("\n\n ===== XML ====="); + xml.extract(multi, System.out, pmulti,false); + + System.out.println("\n\n ===== Pretty XML ====="); + xml.extract(multi, System.out, pmulti, true); + } + } + + @Test + public void doc() throws Exception { + OutRaw raw = new OutRaw(); + OutJson json = new OutJson(); + OutXML xml = new OutXML("Multi","xmlns=urn:types:xsd"); + + Multi multi = new Multi(); + DocMarshal<Multi> doc = DocMarshal.root(new MultiMarshal()); + + for(int i=0;i<3;++i) { + System.out.println("===== Multi Iteration " + i + " ====="); + if(i>0) { + multi.getSingle().add(setSData()); + } + System.out.println(" ===== RAW ====="); + raw.extract(multi, System.out, doc); + + System.out.println("\n ===== JSON ====="); + json.extract(multi, System.out, doc); + + System.out.println("\n\n ===== Pretty JSON ====="); + json.extract(multi, System.out, doc, true); + + System.out.println("\n\n ===== XML ====="); + xml.extract(multi, System.out, doc,false); + + System.out.println("\n\n ===== Pretty XML ====="); + xml.extract(multi, System.out, doc, true); + } + } + + +// @Test +// public void saved() throws Exception { +// Saved saved = new Saved(); +// saved.extract(in, ignore, parser, options); +// } + + @Test + public void df() throws Exception { + RosettaEnv env = new RosettaEnv(); + RosettaDF<Multi> df = env.newDataFactory(Multi.class); + df.out(TYPE.JSON).option(Data.PRETTY); + + Multi multi = new Multi(); + multi.getSingle().add(setSData()); + + + System.out.println("========== Original loading"); + Trans trans = env.newTrans(); + RosettaData<Multi> data = df.newData(trans); + // Prime pump + for(int i=0;i<100;++i) { + data.load(multi); + } + trans = env.newTrans(); + data = df.newData(trans); + + int iters = 10000; + for(int i=0;i<iters;++i) { + data.load(multi); + } + Metric metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(data.asString()); + System.out.println(metrics.total/iters + "ms avg"); + + System.out.println("========== New loading"); + // With new + df.rootMarshal(DocMarshal.root(new MultiMarshal())); + trans = env.newTrans(); + data = df.newData(trans); + + // Prime pump + for(int i=0;i<100;++i) { + data.load(multi); + } + trans = env.newTrans(); + data = df.newData(trans); + + for(int i=0;i<iters;++i) { + data.load(multi); + } + metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(data.asString()); + System.out.println(metrics.total/iters + "ms avg"); + + // Assert.assertEquals(first, second); + + System.out.println("========== Direct Object to JSON String"); + trans = env.newTrans(); + data = df.newData(trans); + StringBuilderWriter sbw = new StringBuilderWriter(256); + // Prime pump + for(int i=0;i<100;++i) { + sbw.reset(); + data.direct(multi, sbw, true); + } + trans = env.newTrans(); + data = df.newData(trans); + + for(int i=0;i<iters;++i) { + sbw.reset(); + data.direct(multi, sbw, true); + } + + metrics = trans.auditTrail(0, null,Env.JSON,Env.XML); + System.out.println(sbw.toString()); + System.out.println(metrics.total/iters + "ms avg"); + + } + + private Single setSData() { + Single s = new Single(); + s.setStr("MyString"); + s.setInt(Integer.MAX_VALUE); + s.setLong(Long.MAX_VALUE); + XMLGregorianCalendar ts = Chrono.timeStamp(); + s.setDate(ts); + s.setDatetime(ts); + byte[] bytes= new byte[] {-1,0,(byte)0XFF,0xE,0x8,0x25,0x7,Byte.MIN_VALUE,Byte.MAX_VALUE}; + s.setBinary(bytes); + s.getArray().add("String 1"); + s.getArray().add("String 2"); + return s; + } + +// @Test +// public void jsonInOut() throws IOException, ParseException { +// Parse<?> jin = new InJson(); +// Out jout = new OutJson(); +// +//// go(jin, jout, "{\"id\":\"Me, Myself\",\"date\":1353094689100}"); +// +// } + + + /* + private void go(Parse<Reader,?> in, Out out, String str) throws IOException, ParseException { + + System.out.println(str); + StringWriter sw = new StringWriter(1024); + out.extract(new StringReader(str), sw, in); + System.out.println(sw); + String result = sw.toString(); + + if(!result.equals(str)) { + sw.getBuffer().setLength(0); + new OutRaw().extract(new StringReader(str), sw, in); + System.out.println(sw); + } + + Assert.assertEquals(str,result); + System.out.println(); + + } + */ +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java new file mode 100644 index 00000000..ab0c921a --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/OutDump.java @@ -0,0 +1,91 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.IOException; +import java.io.Writer; + +import org.onap.aaf.misc.env.util.IndentPrintWriter; +import org.onap.aaf.misc.rosetta.Out; +import org.onap.aaf.misc.rosetta.Parse; +import org.onap.aaf.misc.rosetta.ParseException; +import org.onap.aaf.misc.rosetta.Parsed; + +public class OutDump extends Out{ + + @Override + public<IN, S> void extract(IN in, Writer writer, Parse<IN,S> prs, boolean ... options) throws IOException, ParseException { + IndentPrintWriter ipw = writer instanceof IndentPrintWriter?(IndentPrintWriter)writer:new IndentPrintWriter(writer); + + Parsed<S> p = prs.newParsed(); + + while((p = prs.parse(in,p.reuse())).valid()) { + switch(p.event) { + case Parse.START_OBJ: + ipw.append("Start Object "); + ipw.append(p.name); + ipw.inc(); + break; + case Parse.END_OBJ: + printData(ipw,p); + ipw.dec(); + ipw.append("End Object "); + ipw.append(p.name); + break; + case Parse.START_ARRAY: + ipw.inc(); + ipw.append("Start Array "); + ipw.append(p.name); + ipw.append('\n'); + break; + case Parse.END_ARRAY: + printData(ipw,p); + ipw.dec(); + ipw.append("End Array "); + ipw.append('\n'); + break; + case Parse.NEXT: + printData(ipw,p); + break; + } + } + } + + private void printData(IndentPrintWriter ipw, Parsed<?> parsed) { + if(parsed.hasData()) { + ipw.append("Data:["); + if(parsed.hasName()) { + ipw.append(parsed.name); + ipw.append(" : "); + } + ipw.append(parsed.sb); + ipw.append("]"); + ipw.append('\n'); + } + } + + @Override + public String logName() { + return "Rosetta OutDump"; + } + +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java new file mode 100644 index 00000000..5c709adc --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/Report.java @@ -0,0 +1,67 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test; + +import java.io.IOException; +import java.io.Writer; + +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.Trans.Metric; + +public class Report { + float total; + float buckets[]; + String[] names; + private int iterations; + private int count; + + public Report(int iters, String ... names) { + iterations = iters; + buckets = new float[names.length]; + this.names = names; + total=0; + count = 0; + } + + public void glean(Trans trans, int ... type) { + Metric m = trans.auditTrail(0, null, type); + total+=m.total; + int min = Math.min(buckets.length, m.buckets.length); + for(int b=0;b<min;++b) { + buckets[b]+=m.buckets[b]; + } + } + + public boolean go() { + return ++count<iterations; + } + + + public void report(Writer sbw) throws IOException { + sbw.append("\n"+count + " entries, Total Time: " + total + "ms, Avg Time: " + total/count + "ms\n"); + int min = Math.min(buckets.length, names.length); + for(int i=0;i<min;++i) { + sbw.append(" Time: " + names[i] + ' ' + buckets[i] + "ms, Avg Time: " + buckets[i]/count + "ms\n"); + } + + } +} diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java new file mode 100644 index 00000000..5e96a379 --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/MultiMarshal.java @@ -0,0 +1,41 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test.obj; + +import java.util.List; + +import org.onap.aaf.misc.rosetta.marshal.ObjArray; +import org.onap.aaf.misc.rosetta.marshal.ObjMarshal; + +import types.xsd.Multi; +import types.xsd.Multi.Single; + +public class MultiMarshal extends ObjMarshal<Multi> { + public MultiMarshal() { + add(new ObjArray<Multi,Single>("single",new SingleMarshal()) { + @Override + protected List<Single> data(Multi t) { + return t.getSingle(); + } + }); + } +}
\ No newline at end of file diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java new file mode 100644 index 00000000..932277de --- /dev/null +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/test/obj/SingleMarshal.java @@ -0,0 +1,91 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.rosetta.test.obj; + +import java.util.List; + +import javax.xml.datatype.XMLGregorianCalendar; + +import org.onap.aaf.misc.rosetta.marshal.DataWriter; +import org.onap.aaf.misc.rosetta.marshal.FieldArray; +import org.onap.aaf.misc.rosetta.marshal.FieldDate; +import org.onap.aaf.misc.rosetta.marshal.FieldDateTime; +import org.onap.aaf.misc.rosetta.marshal.FieldHexBinary; +import org.onap.aaf.misc.rosetta.marshal.FieldNumeric; +import org.onap.aaf.misc.rosetta.marshal.FieldString; +import org.onap.aaf.misc.rosetta.marshal.ObjMarshal; + +import types.xsd.Multi.Single; + +public class SingleMarshal extends ObjMarshal<Single> { + public SingleMarshal() { + add(new FieldString<Single>("str") { + @Override + protected String data(Single t) { + return t.getStr(); + } + }); + + add(new FieldNumeric<Integer, Single>("int") { + @Override + protected Integer data(Single t) { + return t.getInt(); + } + }); + + add(new FieldNumeric<Long,Single>("long") { + @Override + protected Long data(Single t) { + return t.getLong(); + } + }); + + add(new FieldDate<Single>("date") { + @Override + protected XMLGregorianCalendar data(Single t) { + return t.getDate(); + } + }); + + add(new FieldDateTime<Single>("datetime") { + @Override + protected XMLGregorianCalendar data(Single t) { + return t.getDate(); + } + }); + + add(new FieldHexBinary<Single>("binary") { + @Override + protected byte[] data(Single t) { + return t.getBinary(); + } + }); + + add(new FieldArray<Single,String>("array", DataWriter.STRING) { + @Override + protected List<String> data(Single t) { + return t.getArray(); + } + }); + + } +}
\ No newline at end of file diff --git a/misc/xgen/.gitignore b/misc/xgen/.gitignore new file mode 100644 index 00000000..75472cfd --- /dev/null +++ b/misc/xgen/.gitignore @@ -0,0 +1,4 @@ +/target/ +/.classpath +/.settings/ +/.project diff --git a/misc/xgen/pom.xml b/misc/xgen/pom.xml new file mode 100644 index 00000000..982920a7 --- /dev/null +++ b/misc/xgen/pom.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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==================================================== + * +--> +<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.onap.aaf.misc</groupId> + <artifactId>parent</artifactId> + <version>1.3.0-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>aaf-misc-xgen</artifactId> + <name>AAF Misc XGen</name> + <packaging>jar</packaging> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>org.onap.aaf.misc</groupId> + <artifactId>aaf-misc-env</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> <version>2.6</version> <configuration> + <skip>false</skip> </configuration> </plugin> </plugins> </build> <distributionManagement> + <repository> <id>nexus</id> <name>attarch-releases</name> <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases</url> + </repository> <snapshotRepository> <id>nexus</id> <name>attarch-snapshots</name> + <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots</url> + </snapshotRepository> </distributionManagement> --> +</project> diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java new file mode 100644 index 00000000..71c10aa4 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Back.java @@ -0,0 +1,34 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +public class Back { + public String str; + public boolean dec; + public boolean cr; + + public Back(String string, boolean decrement, boolean newline) { + str = string; + dec = decrement; + cr = newline; + } +}
\ No newline at end of file diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java new file mode 100644 index 00000000..2a9ee674 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Cache.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + + +public interface Cache<G extends XGen<G>> { + public void dynamic(G hgen, Code<G> code); + + public static class Null<N extends XGen<N>> implements Cache<N> { + @Override + public void dynamic(N hgen, Code<N> code) {} // NO_OP, no matter what type + + @SuppressWarnings("rawtypes") + private static Null<?> singleton = new Null(); + public static Null<?> singleton() { return singleton;} + } + +}
\ No newline at end of file diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java new file mode 100644 index 00000000..aa3d1fed --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/CacheGen.java @@ -0,0 +1,131 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.ArrayList; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.xgen.html.State; +import org.onap.aaf.misc.xgen.html.Thematic; + + +public abstract class CacheGen<G extends XGen<G>> { + public static final int NO_FLAGS = 0x0; + public final static int PRETTY = 0x1; + public final static int XML = 0x2; + public final static int HTML4 = 0x4; + public final static int HTML5 = 0x8; + + + private ArrayList<Section<G>> sections = new ArrayList<Section<G>>(); + private int flags; + private final Thematic thematic; + + public CacheGen(int flags, Code<G> code) throws APIException, IOException { + this.flags = flags; + final XGenBuff<G> buff = new XGenBuff<G>(flags,this); + // Run to gather Strings and Code Class Segments + buff.run(new Cache<G>() { + @Override + public void dynamic(G hgen, Code<G> code) { + sections.add(buff.newSection()); + sections.add(new Dynamic(hgen.getIndent(),code)); + } + },code); + sections.add(buff.newSection()); + + // If Code implements thematic, set for later + thematic = code instanceof Thematic?(Thematic)code:null; + + } + + public abstract G create(int htmlStyle, Writer w); + + public void replay(State<Env> state, Trans trans, OutputStream os, String theme) throws IOException, APIException { + replay(state, trans, new OutputStreamWriter(os), theme); + } + + public void replay(State<Env> state, Trans trans,Writer w, String theme) throws IOException, APIException { + if(thematic!=null) { + theme = thematic.themeResolve(theme); + } + /* Theme + trans.setTheme(theme); + int htmlStyle = state.htmlVer(theme); + */ + + XGenBuff<G> buff = new XGenBuff<G>(flags,this); + + // forward + int indent = 0; + Section<G> s; + int i=0; + @SuppressWarnings("unchecked") + Section<G>[] reverse = new Section[sections.size()]; + for(Section<G> section : sections) { + s = section.use(state, trans, buff); // note, doesn't change cached, only dynamic, which is created for thread + int tempIndent = s.getIndent(); + s.setIndent(indent); + s.forward(w); + s.setIndent(tempIndent); + indent = tempIndent; + reverse[i++]=s; + } + + for(--i;i>=0;--i) { + reverse[i].back(w); + } + w.flush(); + } + + private class Dynamic extends Section<G> { + private Code<G> code; + + public Dynamic(int indent, Code<G> code) { + this.code = code; + this.indent = indent; + } + + @SuppressWarnings("unchecked") + public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException { + // Clone Dynamic to make Thread Safe + Dynamic d = new Dynamic(indent,code); + buff.setIndent(indent); + if(code instanceof DynamicCode) { + buff.run(state,trans,Cache.Null.singleton(), (DynamicCode<G,?,? extends Trans>)code); + } else { + buff.run((Cache<G>)Cache.Null.singleton(), code); + } + Section<G> s = buff.newSection(); + d.indent = s.indent; + d.forward = s.forward; + d.backward = s.backward; + return d; + } + } +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java new file mode 100644 index 00000000..96418df6 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Code.java @@ -0,0 +1,30 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.IOException; + +import org.onap.aaf.misc.env.APIException; + +public interface Code<G extends XGen<G>> { + public void code(Cache<G> cache, G xgen) throws APIException, IOException; +}
\ No newline at end of file diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java new file mode 100644 index 00000000..1b798fb6 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/DynamicCode.java @@ -0,0 +1,44 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.IOException; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.xgen.html.State; + +/** + * Special Code Interface to gain access to Transaction + * and State information + * @author Jonathan + * + */ +public abstract class DynamicCode<G extends XGen<G>, AS extends State<Env>, TRANS extends Trans> implements Code<G> { + public abstract void code(final AS state, final TRANS trans, final Cache<G> cache, final G xgen) throws APIException, IOException; + + // We expect not to have this section of the code engaged at any time + public void code(final Cache<G> cache, final G xgen) throws APIException, IOException { + code(null, null,cache,xgen); + } +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java new file mode 100644 index 00000000..92dc5b96 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Mark.java @@ -0,0 +1,40 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +public class Mark { + // package on purpose + int spot = 0; + public String comment; + + public Mark() { + comment = null; + } + + public Mark(String string) { + comment = string; + } + + public void spot(int spot) { + this.spot = spot; + } +}
\ No newline at end of file diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java new file mode 100644 index 00000000..8eb98ff6 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/Section.java @@ -0,0 +1,61 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.IOException; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.xgen.html.State; + +public class Section<G extends XGen<G>> { + protected int indent; + protected String forward; + protected String backward; + + // Default is to use the set Strings (static) + public Section<G> use(State<Env> state, Trans trans, XGenBuff<G> buff) throws APIException, IOException { + return this; + } + + public int getIndent() { + return indent; + } + + public void setIndent(int indent) { + this.indent = indent; + } + + public void forward(Writer w) throws IOException { + w.write(forward); + } + + public void back(Writer w) throws IOException { + w.write(backward); + } + + public String toString() { + return forward; + } +}
\ No newline at end of file diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java new file mode 100644 index 00000000..09c03111 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGen.java @@ -0,0 +1,296 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.PrintWriter; +import java.io.Writer; +import java.util.Stack; + +import org.onap.aaf.misc.env.util.IndentPrintWriter; +import org.onap.aaf.misc.env.util.StringBuilderWriter; + +public class XGen<RT extends XGen<RT>> { + + public static int COMMENT_COLUMN = 40; + private StringBuilder backSB = new StringBuilder(); + private Stack<Back> backStack = new Stack<Back>(); + + protected XGen(Writer w) { + forward = new IndentPrintWriter(w); + } + + public int pushBack(Back b) { + int rv = backStack.size(); + backStack.push(b); + return rv; + } + + public boolean pretty = false; + protected IndentPrintWriter forward; + + public IndentPrintWriter getWriter() { + return forward; + } + + protected PrintWriter back = new PrintWriter( + new StringBuilderWriter(backSB)); + + @SuppressWarnings("unchecked") + public RT pretty() { + pretty = true; + return (RT) this; + } + + protected void prettyln(PrintWriter pw) { + if(pretty)pw.println(); + } + + public RT leaf(Mark mark, String tag, String ... args) { + mark.spot = backStack.size(); + return leaf(tag, args); + } + + @SuppressWarnings("unchecked") + public RT leaf(String tag, String ... attrs) { + forward.append('<'); + forward.append(tag); + addAttrs(attrs); + forward.append('>'); + back.append("</"); + back.append(tag); + back.append('>'); + backStack.push(new Back(backSB.toString(), false, true)); + backSB.setLength(0); + return (RT)this; + } + + public RT incr(String tag, String ... args) { + return incr(null, tag, false, args); + } + + public RT incr(String tag, boolean oneLine, String ... args) { + return incr(null, tag, oneLine, args); + } + + public RT incr(Mark mark) { + return incr(mark,mark.comment, false, new String[0]); + } + + public RT incr(Mark mark, String tag, String ... attrs) { + return incr(mark, tag, false, attrs); + } + + @SuppressWarnings("unchecked") + public RT incr(Mark mark, String tag, boolean oneLine, String ... attrs) { + forward.append('<'); + forward.append(tag); + addAttrs(attrs); + forward.append('>'); + + back.append("</"); + back.append(tag); + back.append('>'); + + if(pretty) { + if(mark!=null && mark.comment!=null) { + int fi = forward.getIndent()*IndentPrintWriter.INDENT; + for(int i = fi+backSB.length();i<=COMMENT_COLUMN;++i) { + back.append(' '); + } + back.append("<!-- end "); + back.append(mark.comment); + back.append(" -->"); + + forward.toCol(COMMENT_COLUMN); + forward.append("<!-- begin "); + forward.append(mark.comment); + forward.append(" -->"); + } + forward.inc(); + if(!oneLine) { + forward.println(); + } + back.println(); + } + if(mark!=null)mark.spot = backStack.size(); + backStack.push(new Back(backSB.toString(),true, false)); + backSB.setLength(0); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT tagOnly(String tag, String ... attrs) { + forward.append('<'); + forward.append(tag); + addAttrs(attrs); + forward.append(" />"); + if(pretty) { + forward.println(); + } + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT text(String txt) { + forward.append(txt); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT xml(String txt) { + for(int i=0; i<txt.length();++i) { + char c = txt.charAt(i); + switch(c) { + case '<': + forward.append("<"); + break; + case '>': + forward.append(">"); + break; + case '&': + forward.append("&"); + break; + default: + forward.append(c); + } + } + return (RT)this; + } + + + @SuppressWarnings("unchecked") + public RT textCR(int tabs, String txt) { + for(int i=0;i<tabs;++i) { + forward.append(" "); + } + forward.append(txt); + if(pretty)forward.println(); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT value() { + Mark mark = new Mark(); + mark.spot = backStack.size()-1; + end(mark); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT value(String txt) { + forward.append(txt); + Mark mark = new Mark(); + mark.spot = backStack.size()-1; + end(mark); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT value(String txt, int levels) { + forward.append(txt); + Mark mark = new Mark(); + mark.spot = backStack.size()-levels; + end(mark); + return (RT)this; + } + + @SuppressWarnings("unchecked") + public RT end(Mark mark) { + int size = backStack.size(); + Back c; + boolean println = false; + for(int i=mark==null?0:mark.spot;i<size;++i) { + c = backStack.pop(); + if(c.dec)forward.dec(); + forward.append(c.str); + println = c.cr; + } + if(pretty && println) { + forward.println(); + } + return (RT)this; + } + + public RT end() { + Mark mark = new Mark(); + mark.spot=backStack.size()-1; + if(mark.spot<0)mark.spot=0; + return end(mark); + } + + public RT end(int i) { + Mark mark = new Mark(); + mark.spot=backStack.size()-i; + if(mark.spot<0)mark.spot=0; + return end(mark); + } + + public void endAll() { + end(new Mark()); + forward.flush(); + } + + protected void addAttrs(String[] attrs) { + if(attrs!=null) { + for(String attr : attrs) { + if(attr!=null && attr.length()>0) { + forward.append(' '); + String[] split = attr.split("=",2); + switch(split.length) { + case 0: + break; + case 1: + forward.append(split[0]); +// forward.append("=\"\""); + break; + default: + forward.append(split[0]); + forward.append("=\""); + forward.append(split[1]); + forward.append('"'); + break; + } + } + } + } + } + + @SuppressWarnings("unchecked") + public RT comment(String string) { + if(pretty) { + forward.print("<!-- "); + forward.print(string); + forward.println(" -->"); + } + return (RT)this; + } + + public void setIndent(int indent) { + forward.setIndent(indent); + forward.toIndent(); + } + + public int getIndent() { + return forward.getIndent(); + } + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java new file mode 100644 index 00000000..95c4060b --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/XGenBuff.java @@ -0,0 +1,86 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen; + +import java.io.IOException; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; +import org.onap.aaf.misc.env.Trans; +import org.onap.aaf.misc.env.util.StringBuilderWriter; +import org.onap.aaf.misc.xgen.html.State; + +public class XGenBuff<G extends XGen<G>> { + private G xgen; + private StringBuilder sb; + // private String forward, backward; + + public XGenBuff(int flags, CacheGen<G> cg) { + sb = new StringBuilder(); + xgen = cg.create(flags, new StringBuilderWriter(sb)); + } + + /** + * Normal case of building up Cached HTML without transaction info + * + * @param cache + * @param code + * @throws APIException + * @throws IOException + */ + public void run(Cache<G> cache, Code<G> code) throws APIException, IOException { + code.code(cache, xgen); + } + + /** + * Special Case where code is dynamic, so give access to State and Trans info + * + * @param state + * @param trans + * @param cache + * @param code + * @throws APIException + * @throws IOException + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void run(State<Env> state, Trans trans, Cache cache, DynamicCode code) throws APIException, IOException { + code.code(state, trans, cache, xgen); + } + + public int getIndent() { + return xgen.getIndent(); + } + + public void setIndent(int indent) { + xgen.setIndent(indent); + } + + public Section<G> newSection() { + Section<G> s = new Section<G>(); + s.indent = xgen.getIndent(); + s.forward = sb.toString(); + sb.setLength(0); + s.backward = sb.toString(); + sb.setLength(0); + return s; + } +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java new file mode 100644 index 00000000..dfab12cb --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML4Gen.java @@ -0,0 +1,143 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.io.Writer; + +import org.onap.aaf.misc.xgen.Mark; + +public class HTML4Gen extends HTMLGen { + private final static String DOCTYPE = + /* + "<!DOCTYPE HTML PUBLIC " + + "\"-//W3C//DTD HTML 4.01 Transitional//EN\" " + + "\"http://www.w3.org/TR/html3/loose.dtd\">"; + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; + */ + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" + + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"; + + public HTML4Gen(Writer w) { + super(w); + } + + @Override + public HTMLGen html(String ... attrib) { + forward.println(DOCTYPE); + return incr("html","xmlns=http://www.w3.org/1999/xhtml","xml:lang=en","lang=en"); + + } + + @Override + public Mark head() { + Mark head = new Mark("head"); + incr(head); + return head; + } + + @Override + public Mark body(String ... attrs) { + Mark body = new Mark("body"); + incr(body,"body",attrs); + return body; + } + + @Override + public HTML4Gen charset(String charset) { + forward.append("<meta http-equiv=\"Content-type\" content=\"text.hml; charset="); + forward.append(charset); + forward.append("\">"); + prettyln(forward); + return this; + } + + @Override + public Mark header(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="header"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + + @Override + public Mark footer(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="footer"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + + @Override + public Mark section(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="section"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + + @Override + public Mark article(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="attrib"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + + @Override + public Mark aside(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="aside"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + + @Override + public Mark nav(String ... attribs) { + String[] a = new String[attribs.length+1]; + a[0]="nav"; + System.arraycopy(attribs, 0, a, 1, attribs.length); + return divID(a); + } + +// @Override +// protected void importCSS(Imports imports) { +// if(imports.css.size()==1) { +// cssInline(imports.css.get(0)); +// } else { +// text("<style type=\"text/css\">"); +// prettyln(forward); +// forward.inc(); +// for(String str : imports.css) { +// forward.print("@import url(\""); +// forward.print(imports.themePath(null)); +// forward.print(str); +// forward.print("\");"); +// prettyln(forward); +// } +// forward.dec(); +// forward.print("</style>"); +// prettyln(forward); +// } +// } + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java new file mode 100644 index 00000000..d83004e8 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTML5Gen.java @@ -0,0 +1,155 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.io.Writer; + +import org.onap.aaf.misc.xgen.Mark; + +public class HTML5Gen extends HTMLGen { + public HTML5Gen(Writer w) { + super(w); + } + + @Override + public HTMLGen html(String ... attrib) { + //forward.println("<!DOCTYPE html>"); + incr("html",attrib); + return this; + } + + @Override + public Mark head() { + Mark head = new Mark("head"); + incr(head).directive("meta","charset=utf-8"); + return head; + } + + @Override + public Mark body(String ... attrs) { + Mark body = new Mark("body"); + incr(body,"body",attrs); + //chromeFrame(); + return body; + } + + @Override + public HTML5Gen charset(String charset) { + forward.append("<meta charset=\""); + forward.append(charset); + forward.append("\">"); + prettyln(forward); + return this; + } + + @Override + public Mark header(String ... attribs) { + Mark mark = new Mark("header"); + incr(mark, mark.comment, attribs); + return mark; + } + + @Override + public Mark footer(String ... attribs) { + Mark mark = new Mark("footer"); + incr(mark, mark.comment, attribs); + return mark; + } + + @Override + public Mark section(String ... attribs) { + Mark mark = new Mark("section"); + incr(mark, mark.comment,attribs); + return mark; + } + + @Override + public Mark article(String ... attribs) { + Mark mark = new Mark("article"); + incr(mark, mark.comment,attribs); + return mark; + } + + @Override + public Mark aside(String ... attribs) { + Mark mark = new Mark("aside"); + incr(mark, mark.comment,attribs); + return mark; + } + + @Override + public Mark nav(String ... attribs) { + Mark mark = new Mark("nav"); + incr(mark, mark.comment,attribs); + return mark; + } + + +// @Override +// protected void importCSS(Imports imports) { +// if(imports.css.size() == 1) { +// cssInline(imports.css.get(0)); +// } else { +// for(String str : imports.css) { +// forward.print("<link rel=\"stylesheet\" href=\""); +// forward.print(imports.themePath(null)); +// forward.print(str); +// forward.println("\">"); +// } +// } +// } +// + + /* + public void chromeFrame() { + this.textCR(0,"<!--[if IE]>"); + Mark mark = new Mark(); + this.leaf(mark, "script","type=text/javascript","src=http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js") + .end(mark); + this.incr(mark, "style") + .textCR(0,".chromeFrameInstallDefaultStyle {") + .textCR(1,"width: 100%; /* default is 800px * /") + .textCR(1,"border: 5px solid blue;") + .textCR(0,"}") + .end(mark); + + this.incr(mark,"div","id=prompt"); // auto comment would break IE specific Script + // "if IE without GCF, prompt goes here" + this.text("Please load this plugin to run ClientSide Websockets") + .end(mark); + + this.incr(mark, "script") + .textCR(0, "// The conditional ensures that this code will only execute in IE,") + .textCR(0, "// Therefore we can use the IE-specific attachEvent without worry") + .textCR(0, "window.attachEvent('onload', function() {") + .textCR(1,"CFInstall.check({") + .textCR(2,"mode: 'inline', // the default") + .textCR(2,"node: 'prompt'") + .textCR(1, "});") + .textCR(0, "});") + .end(mark); + + this.textCR(0,"<![endif]-->"); + } + */ + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java new file mode 100644 index 00000000..8fba1555 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLCacheGen.java @@ -0,0 +1,59 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.io.IOException; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.xgen.CacheGen; +import org.onap.aaf.misc.xgen.Code; + +public class HTMLCacheGen extends CacheGen<HTMLGen> { + protected int flags; + + public HTMLCacheGen(int flags, Code<HTMLGen> code) throws APIException,IOException { + super(flags, code); + this.flags = flags; + } + + @Override + public HTMLGen create(int htmlStyle, Writer w) { + HTMLGen hg; + switch(htmlStyle&(CacheGen.HTML4|CacheGen.HTML5)) { + case CacheGen.HTML4: + hg = new HTML4Gen(w); + break; + case CacheGen.HTML5: + default: + hg = new HTML5Gen(w); + break; + + } + hg.pretty = (htmlStyle&CacheGen.PRETTY)>0; + return hg; + } + + protected HTMLGen clone(Writer w) { + return create(flags,w); + } +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java new file mode 100644 index 00000000..92a89d7d --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/HTMLGen.java @@ -0,0 +1,240 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.io.Writer; + +import org.onap.aaf.misc.xgen.Mark; +import org.onap.aaf.misc.xgen.XGen; + +public abstract class HTMLGen extends XGen<HTMLGen> { + public static final String A = "a"; + public static final String P = "p"; + public static final String LI = "li"; + public static final String OL = "ol"; + public static final String UL = "ul"; + + + public static final String TABLE = "table"; + public static final String THEAD = "thead"; + public static final String TBODY = "tbody"; + public static final String TR = "tr"; + public static final String TH = "th"; + public static final String TD = "td"; + + public static final String TITLE = "title"; + public static final String H1 = "h1"; + public static final String H2 = "h2"; + public static final String H3 = "h3"; + public static final String H4 = "h4"; + public static final String H5 = "h5"; + + + + // --------------------------- HTML Version Specific ----------------------- + public abstract HTMLGen html(String ... attributes); + public abstract HTMLGen charset(String charset); + public abstract Mark head(); + public abstract Mark body(String ... attribs); + + + // HTML 5 has simplified sectioning + public abstract Mark header(String ... attribs); + public abstract Mark footer(String ... attribs); + public abstract Mark section(String ... attribs); + public abstract Mark article(String ... attribs); + public abstract Mark aside(String ... attribs); + public abstract Mark nav(String ... attribs); + + // --------------------------- HTML Version Specific ----------------------- + + public HTMLGen imports(Imports imports) { + //this.imports=imports; + for(String str : imports.css) { + forward.print("<link rel=\"stylesheet\" href=\""); + forward.print(imports.themePath(null)); + forward.print(str); + forward.println("\">"); + } + + for(String str : imports.js) { + forward.print("<script type=\"text/javascript\" src=\""); + forward.print(imports.themePath(null)); + forward.print(str); + forward.println("\"></script>"); + } + return this; + } + + public HTMLGen jsVars(String ... attrs) { + forward.println("<script type=text/javascript>"); + if(attrs!=null) { + for(int i=0; i<attrs.length;++i) { + forward.append(' '); + String[] split = attrs[i].split("=",2); + switch(split.length) { + case 2: + forward.print(" var "); + forward.append(split[0]); + forward.append("='"); + forward.append(split[1]); + forward.println("';"); + break; + } + } + } + forward.println("</script>"); + return this; + } + + public HTMLGen(Writer w) { + super(w); + } + + /** + * Use "directive" to handle non-ended HTML tags like <meta ... > and <link ...> + * @param tag + * @param attrs + * @return + */ + public HTMLGen directive(String tag, String ... attrs) { + forward.append('<'); + forward.append(tag); + addAttrs(attrs); + forward.append('>'); + if(pretty) { + forward.println(); + } + return this; + } + + public Mark divID(String ... attrs) { + Mark div; + if(attrs.length>0) { + div = new Mark(attrs[0]); + attrs[0]="id="+attrs[0]; + } else { + div = new Mark(); + } + incr(div, "div", attrs); + return div; + } + + public HTMLGen img(String ... attrs) { + return tagOnly("img", attrs); + } + + /** + * Input Cheesecake... creates a Label and Field in the form of Table Rows. + * Make sure you create a table first, ie. incr(HTMLGen.TABLE); + * + * Setting Required to "true" will add required Attribute to both Label and Field. In HTML5, "required" in the input will + * validate there is data in the fields before submitting. "required" does nothing for label, but allows for + * easy CSS coding... "label[required] { ... }", so that colors can be changed + * + * @param id + * @param label + * @param required + * @param attrs + * @return + */ + public HTMLGen input(String id, String label, boolean required, String ... attrs) { + Mark mtr = new Mark(TR); + Mark mtd = new Mark(TD); + incr(mtr); + incr(mtd); + incr("label",true, "for="+id,required?"required":null).text(label).end(); + end(mtd); + String nattrs[] = new String[attrs.length+(required?3:2)]; + nattrs[0]="id="+id; + nattrs[1]="name="+id; + System.arraycopy(attrs, 0, nattrs, 2, attrs.length); + if(required) { + nattrs[nattrs.length-1]="required"; + } + incr(mtd); + tagOnly("input",nattrs); + end(mtr); + return this; + } + + // Common tags that do not have standard endings. These are here to help people who don't know to pick directive + public HTMLGen br() { + forward.append("<br>"); + if(pretty) { + forward.println(); + } + return this; + } + + public HTMLGen p(String ... text) { + forward.append("<p>"); + for(String s : text) { + forward.append(s); + } + if(pretty) { + forward.println(); + } + return this; + } + + public HTMLGen hr() { + forward.append("<hr>"); + if(pretty) { + forward.println(); + } + return this; + } + + public JSGen js(Mark mark) { + return new JSGen(mark, this); + } + + public JSGen js() { + return js(null); + } +// +// protected void cssInline(String filename) { +// File file = new File(imports.webDir,filename); +// try { +// String line; +// BufferedReader br = new BufferedReader(new FileReader(file)); +// try { +// forward.print("<style>"); +// prettyln(forward); +// while((line=br.readLine())!=null) { +// forward.print((pretty?line:line.trim())); +// prettyln(forward); +// } +// }finally { +// forward.print("</style>"); +// prettyln(forward); +// br.close(); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// // Can't read, suffice to import normally? +// // for now, just skip +// } +// } + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java new file mode 100644 index 00000000..90e82607 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Imports.java @@ -0,0 +1,98 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.util.ArrayList; +import java.util.List; + +public class Imports implements Thematic{ + List<String> css,js; + public final int backdots; +// public final File webDir; + private String theme; + + public Imports(int backdots) { +// this.webDir = webDir; + + css = new ArrayList<String>(); + js = new ArrayList<String>(); + this.backdots = backdots; + theme = ""; + } + + public Imports css(String str) { + css.add(str); + return this; + } + + public Imports js(String str) { + js.add(str); + return this; + } + + public Imports theme(String str) { + theme = str==null?"":str; + return this; + } + + /** + * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports + * + * @param theTheme + * @return + */ + @Override + public String themePath(String theTheme) { + StringBuilder src = dots(new StringBuilder()); + if(theTheme==null||theTheme.length()==0) { + src.append(theme); + if(theme.length()>0)src.append('/'); + } else { + src.append(theTheme); + src.append('/'); + } + + return src.toString(); + } + + /** + * Pass in a possible Theme. If it is "" or null, it will resolve to default Theme set in Imports + * + * @param theTheme + * @return + */ + @Override + public String themeResolve(String theTheme) { + return (theTheme==null||theTheme.length()==0) + ?theme + :theTheme; + } + + public StringBuilder dots(StringBuilder src) { + for(int i=0;i<backdots;++i) { + src.append("../"); + } + return src; + } + +}; + diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java new file mode 100644 index 00000000..be19a274 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/JSGen.java @@ -0,0 +1,204 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import org.onap.aaf.misc.env.util.IndentPrintWriter; +import org.onap.aaf.misc.xgen.Back; +import org.onap.aaf.misc.xgen.Mark; + + +public class JSGen { + private HTMLGen htmlGen; + private IndentPrintWriter ipw; + private Mark mark; + + public JSGen(Mark mark, HTMLGen hg) { + this.mark = mark==null?new Mark():mark; + hg.incr(this.mark, "script", "language=javascript", "type=text/javascript"); + htmlGen = hg; + ipw = hg.getWriter(); + } + + public JSGen inline(String filename, int tabstop) throws IOException { + BufferedReader br = new BufferedReader(new FileReader(filename)); + int indent = htmlGen.getIndent(); + try { + boolean pretty = htmlGen.pretty; + String line, el; + int l, end; + while((line=br.readLine())!=null) { + if(pretty) { + String[] elements = line.split("\t"); + + for(int i=0; i<elements.length;++i) { + el = elements[i]; + l = el.length(); + if(l==0) {// was a Tab + ipw.print(" "); + } else { + el = el.trim(); + l = l-el.length(); + end = l/tabstop; + for(int j=0;j<end;++j) { + ipw.print(" "); + } + end = l%tabstop; + for(int j=0;j<end;++j) { + ipw.print(' '); + } + if(i>0) ipw.print(' '); + ipw.print(el); + } + } + ipw.println(); + } else { + ipw.print(line.trim()); + } + } + } finally { + htmlGen.setIndent(indent); + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return this; + } + + public JSGen pst(String ... lines) { + return pst(null, lines); + } + + public JSGen pst(Mark jm, String ... lines) { + if(lines.length>0) ipw.append(lines[0]); + ipw.append('('); + for(int i=1;i<lines.length;++i) { + ipw.print(lines[i]); + ipw.print(", "); + } + Back back; + + if(htmlGen.pretty) { + back = new Back(");\n",false,false); + } else { + back = new Back(");",false,false); + } + int spot = htmlGen.pushBack(back); + if(jm!=null)jm.spot(spot); + return this; + } + + public JSGen li(String ... lines) { + int current = ipw.getIndent(); + for(int i=0;i<lines.length;++i) { + if(i==1)ipw.inc(); + if(i>0)ipw.println(); + ipw.print(lines[i]); + } + ipw.setIndent(current); + ipw.append(';'); + if(htmlGen.pretty)ipw.println(); + return this; + } + + public JSGen text(String text) { + ipw.append(text); + if(htmlGen.pretty)ipw.println(); + return this; + } + + public JSGen function(String name, String ... params) { + return function(null, name, params); + } + + public JSGen jqfunc(Mark mark, String name, String ... params) { + pst(mark,"$").function(name, params); + return this; + } + + public JSGen function(Mark jm, String name, String ... params) { + ipw.print("function "); + ipw.print(name); + ipw.print('('); + for(int i=0;i<params.length;++i) { + if(i!=0)ipw.print(", "); + ipw.print(params[i]); + } + ipw.print(") {"); + if(htmlGen.pretty) { + ipw.println(); + ipw.inc(); + } + int spot = htmlGen.pushBack(new Back("}",true,true)); + if(jm!=null)jm.spot(spot); + return this; + } + + public JSGen cb(String ... lines) { + return cb(null,lines); + } + + public JSGen cb(Mark jm, String ... lines) { + int current = ipw.getIndent(); + for(int i=0;i<lines.length;++i) { + if(i==1)ipw.inc(); + if(i>0)ipw.println(); + ipw.print(lines[i]); + } + ipw.setIndent(current); + ipw.print('{'); + if(htmlGen.pretty) { + ipw.println(); + ipw.inc(); + } + int spot = htmlGen.pushBack(new Back("}",true,true)); + if(jm!=null)jm.spot(spot); + return this; + + } + + + public JSGen comment(String ... lines) { + if(htmlGen.pretty) { + for(int i=0;i<lines.length;++i) { + ipw.print("// "); + ipw.println(lines[i]); + } + } + return this; + } + + public JSGen end(Mark mark) { + htmlGen.end(mark); + return this; + } + + public HTMLGen done() { + return htmlGen.end(mark); + } + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/State.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/State.java new file mode 100644 index 00000000..93f6da1b --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/State.java @@ -0,0 +1,27 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +import org.onap.aaf.misc.env.Env; + +public interface State<ENV extends Env> { +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java new file mode 100644 index 00000000..98835dc5 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/html/Thematic.java @@ -0,0 +1,27 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.html; + +public interface Thematic { + String themePath(String theTheme); + String themeResolve(String theTheme); +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java new file mode 100644 index 00000000..16ce436b --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLCacheGen.java @@ -0,0 +1,45 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.xml; + +import java.io.IOException; +import java.io.Writer; + +import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.xgen.CacheGen; +import org.onap.aaf.misc.xgen.Code; + +public class XMLCacheGen extends CacheGen<XMLGen> { + + public XMLCacheGen(int flags, Code<XMLGen> code) throws APIException, + IOException { + super(flags, code); + } + + @Override + public XMLGen create(int style, Writer w) { + XMLGen xg = new XMLGen(w); + xg.pretty = (style & PRETTY)==PRETTY; + return xg; + } + +} diff --git a/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java new file mode 100644 index 00000000..18945672 --- /dev/null +++ b/misc/xgen/src/main/java/org/onap/aaf/misc/xgen/xml/XMLGen.java @@ -0,0 +1,44 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * =========================================================================== + * 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.misc.xgen.xml; + +import java.io.Writer; + +import org.onap.aaf.misc.xgen.XGen;; + +public class XMLGen extends XGen<XMLGen> { + private final String XML_TAG; + + public XMLGen(Writer w) { + this(w,"UTF-8"); + } + + public XMLGen(Writer w, String encoding) { + super(w); + XML_TAG="<?xml version=\"1.0\" encoding=\"" + encoding + "\" standalone=\"yes\"?>"; + } + + public XMLGen xml() { + forward.println(XML_TAG); + return this; + } +} @@ -371,22 +371,6 @@ </dependencies> <modules> - <!-- - <module> auth-client</module> - complile manually with mvn -N independently - --> - <module>authz-client</module> - <module>authz-core</module> - <module>authz-cass</module> - <module>authz-defOrg</module> - <module>authz-cmd</module> - <!-- <module>authz-batch</module>--> - <module>authz-test</module> - <!-- <module>authz-gui</module> --> - <module>authz-gw</module> - <module>authz-certman</module> - <module>authz-fs</module> - <module>authz-service</module> </modules> <dependencyManagement> |