<artifactId>aaf-auth-cass</artifactId>
</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>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>3.0</version>
+ <version>2.5</version>
</dependency>
<dependency>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>parent</artifactId>\r
- <version>1.0.1-SNAPSHOT</version>\r
- <relativePath>../pom.xml</relativePath>\r
- </parent>\r
- \r
- <artifactId>authz-certman</artifactId>\r
- <name>AAF Certification Managmenent</name>\r
- <description>Certificate Manager API</description>\r
- <url>https://github.com/att/AAF</url>\r
-\r
- <developers>\r
- <developer>\r
- <name>Jonathan Gathman</name>\r
- <email></email>\r
- <organization>ATT</organization>\r
- <organizationUrl></organizationUrl>\r
- </developer>\r
- </developers>\r
-\r
-\r
- <properties>\r
- <project.swmVersion>45</project.swmVersion>\r
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>\r
- <!-- SONAR -->\r
- <jacoco.version>0.7.7.201606060606</jacoco.version>\r
- <sonar.skip>true</sonar.skip>\r
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>\r
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>\r
- <!-- Default Sonar configuration -->\r
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>\r
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>\r
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->\r
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>\r
- <nexusproxy>https://nexus.onap.org</nexusproxy>\r
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>\r
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>\r
- </properties>\r
- \r
- <dependencies>\r
- <dependency>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>authz-core</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>authz-cass</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
-\r
- \r
- <dependency> \r
- <groupId>org.onap.aaf.cadi</groupId>\r
- <artifactId>cadi-aaf</artifactId>\r
- <version>${project.cadiVersion}</version>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>com.google.code.jscep</groupId>\r
- <artifactId>jscep</artifactId>\r
- <version>2.4.0</version>\r
- </dependency>\r
- <!-- TESTING -->\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- </dependency>\r
- </dependencies>\r
- \r
- <build>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-jar-plugin</artifactId>\r
- <configuration>\r
- <includes>\r
- <include>**/*.class</include>\r
- </includes>\r
- </configuration>\r
- <version>2.3.1</version>\r
- </plugin>\r
- \r
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->\r
- \r
- \r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-javadoc-plugin</artifactId>\r
- <version>2.10.4</version>\r
- <configuration>\r
- <failOnError>false</failOnError>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>attach-javadocs</id>\r
- <goals>\r
- <goal>jar</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- \r
- \r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-source-plugin</artifactId>\r
- <version>2.2.1</version>\r
- <executions>\r
- <execution>\r
- <id>attach-sources</id>\r
- <goals>\r
- <goal>jar-no-fork</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.sonatype.plugins</groupId>\r
- <artifactId>nexus-staging-maven-plugin</artifactId>\r
- <version>1.6.7</version>\r
- <extensions>true</extensions>\r
- <configuration>\r
- <nexusUrl>${nexusproxy}</nexusUrl>\r
- <stagingProfileId>176c31dfe190a</stagingProfileId>\r
- <serverId>ecomp-staging</serverId>\r
- </configuration>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.jacoco</groupId>\r
- <artifactId>jacoco-maven-plugin</artifactId>\r
- <version>${jacoco.version}</version>\r
- <configuration>\r
- <excludes>\r
- <exclude>**/gen/**</exclude>\r
- <exclude>**/generated-sources/**</exclude>\r
- <exclude>**/yang-gen/**</exclude>\r
- <exclude>**/pax/**</exclude>\r
- </excludes>\r
- </configuration>\r
- <executions>\r
-\r
- <execution>\r
- <id>pre-unit-test</id>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
- <propertyName>surefireArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
- \r
- \r
- <execution>\r
- <id>post-unit-test</id>\r
- <phase>test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
- </configuration>\r
- </execution>\r
- <execution>\r
- <id>pre-integration-test</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
-\r
- <propertyName>failsafeArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
-\r
- \r
- <execution>\r
- <id>post-integration-test</id>\r
- <phase>post-integration-test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin> \r
-\r
- </plugins>\r
- <pluginManagement>\r
- <plugins/>\r
- </pluginManagement>\r
- </build>\r
-<distributionManagement>\r
- <repository>\r
- <id>ecomp-releases</id>\r
- <name>AAF Release Repository</name>\r
- <url>${nexusproxy}${releaseNexusPath}</url>\r
- </repository>\r
- <snapshotRepository>\r
- <id>ecomp-snapshots</id>\r
- <name>AAF Snapshot Repository</name>\r
- <url>${nexusproxy}${snapshotNexusPath}</url>\r
- </snapshotRepository>\r
- <site>\r
- <id>ecomp-site</id>\r
- <url>dav:${nexusproxy}${sitePath}</url>\r
- </site>\r
- </distributionManagement>\r
-\r
-</project>\r
+++ /dev/null
-##
-## AUTHZ Certman (authz-certman) Properties
-##
-
-hostname=_HOSTNAME_
-
-## DISCOVERY (DME2) Parameters on the Command Line
-AFT_LATITUDE=_AFT_LATITUDE_
-AFT_LONGITUDE=_AFT_LONGITUDE_
-AFT_ENVIRONMENT=_AFT_ENVIRONMENT_
-DEPLOYED_VERSION=_ARTIFACT_VERSION_
-
-## Pull in common/security properties
-
-cadi_prop_files=_COMMON_DIR_/com.att.aaf.common.props;_COMMON_DIR_/com.att.aaf.props
-
-##DME2 related parameters
-DMEServiceName=service=com.att.authz.certman/version=_MAJOR_VER_._MINOR_VER_._PATCH_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_
-AFT_DME2_PORT_RANGE=_AUTHZ_CERTMAN_PORT_RANGE_
-
-# Turn on both AAF TAF & LUR 2.0
-aaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_
-
-
-
+++ /dev/null
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START====================================================\r
-# * org.onap.aaf\r
-# * ===========================================================================\r
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# * \r
-# * http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
-# * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-###############################################################################\r
-# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.\r
-###############################################################################\r
-#\r
-# Licensed to the Apache Software Foundation (ASF) under one\r
-# or more contributor license agreements. See the NOTICE file\r
-# distributed with this work for additional information\r
-# regarding copyright ownership. The ASF licenses this file\r
-# to you under the Apache License, Version 2.0 (the\r
-# "License"); you may not use this file except in compliance\r
-# with the License. You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing,\r
-# software distributed under the License is distributed on an\r
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
-# KIND, either express or implied. See the License for the\r
-# specific language governing permissions and limitations\r
-# under the License.\r
-#\r
-log4j.appender.INIT=org.apache.log4j.DailyRollingFileAppender \r
-log4j.appender.INIT.File=_LOG_DIR_/${LOG4J_FILENAME_init}\r
-log4j.appender.INIT.DatePattern='.'yyyy-MM-dd\r
-#log4j.appender.INIT.MaxFileSize=_MAX_LOG_FILE_SIZE_\r
-#log4j.appender.INIT.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_\r
-log4j.appender.INIT.layout=org.apache.log4j.PatternLayout \r
-log4j.appender.INIT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %m %n\r
-\r
-\r
-log4j.appender.CM=org.apache.log4j.DailyRollingFileAppender \r
-log4j.appender.CM.File=_LOG_DIR_/${LOG4J_FILENAME_cm}\r
-log4j.appender.CM.DatePattern='.'yyyy-MM-dd\r
-#log4j.appender.CM.MaxFileSize=_MAX_LOG_FILE_SIZE_\r
-#log4j.appender.CM.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_\r
-log4j.appender.CM.layout=org.apache.log4j.PatternLayout \r
-log4j.appender.CM.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %p [%c] %m %n\r
-\r
-log4j.appender.AUDIT=org.apache.log4j.DailyRollingFileAppender\r
-log4j.appender.AUDIT.File=_LOG_DIR_/${LOG4J_FILENAME_audit}\r
-log4j.appender.AUDIT.DatePattern='.'yyyy-MM-dd\r
-#log4j.appender.AUDIT.MaxFileSize=_MAX_LOG_FILE_SIZE_\r
-#log4j.appender.AUDIT.MaxBackupIndex=_MAX_LOG_FILE_BACKUP_COUNT_\r
-log4j.appender.AUDIT.layout=org.apache.log4j.PatternLayout \r
-log4j.appender.AUDIT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSSZ} %m %n\r
-\r
-\r
-# General Apache libraries\r
-log4j.rootLogger=INFO,CM\r
-log4j.logger.org.apache=WARN,INIT\r
-log4j.logger.dme2=WARN,INIT\r
-log4j.logger.init=INFO,INIT\r
-log4j.logger.authz=_LOG4J_LEVEL_,CM\r
-log4j.logger.audit=INFO,AUDIT\r
-log4j.category.org.jscep=INFO\r
-\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<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">\r
- <ns2:ManagedResource>\r
- <ResourceDescriptor>\r
- <ResourceName>com.att.authz._ARTIFACT_ID_</ResourceName>\r
- <ResourceVersion>\r
- <Major>_MAJOR_VER_</Major>\r
- <Minor>_MINOR_VER_</Minor>\r
- <Patch>_PATCH_VER_</Patch> \r
- </ResourceVersion>\r
- <RouteOffer>_ROUTE_OFFER_</RouteOffer>\r
- </ResourceDescriptor>\r
- <ResourceType>Java</ResourceType>\r
- <ResourcePath>com.att.authz.cm.service.CertManAPI</ResourcePath>\r
- <ResourceProps>\r
- <Tag>process.workdir</Tag>\r
- <Value>_ROOT_DIR_</Value>\r
- </ResourceProps> \r
- <ResourceProps>\r
- <Tag>jvm.version</Tag>\r
- <Value>1.8</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>jvm.args</Tag>\r
- <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>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>jvm.classpath</Tag>\r
- <Value>_ROOT_DIR_/etc:_ROOT_DIR_/lib/*:</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>jvm.heap.min</Tag>\r
- <Value>1024m</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>jvm.heap.max</Tag>\r
- <Value>2048m</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>start.class</Tag>\r
- <Value>com.att.authz.cm.service.CertManAPI</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>stdout.redirect</Tag>\r
- <Value>_ROOT_DIR_/logs/SystemOut.log</Value>\r
- </ResourceProps>\r
- <ResourceProps>\r
- <Tag>stderr.redirect</Tag>\r
- <Value>_ROOT_DIR_/logs/SystemErr.log</Value>\r
- </ResourceProps>\r
- <ResourceOSID>aft</ResourceOSID>\r
- <ResourceStartType>AUTO</ResourceStartType>\r
- <ResourceStartPriority>2</ResourceStartPriority>\r
- <ResourceMinCount>_RESOURCE_MIN_COUNT_</ResourceMinCount>\r
- <ResourceMaxCount>_RESOURCE_MAX_COUNT_</ResourceMaxCount> \r
- <ResourceRegistration>_RESOURCE_REGISTRATION_</ResourceRegistration>\r
- <ResourceSWMComponent>com.att.authz:_ARTIFACT_ID_</ResourceSWMComponent>\r
- <ResourceSWMComponentVersion>_ARTIFACT_VERSION_</ResourceSWMComponentVersion>\r
- </ns2:ManagedResource>\r
-</ns2:ManagedResourceList>\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.api;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.authz.cm.mapper.Mapper.API;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.cm.service.Code;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-\r
-/**\r
- * API Deployment Artifact Apis.. using Redirect for mechanism\r
- * \r
- *\r
- */\r
-public class API_Artifact {\r
- private static final String GET_ARTIFACTS = "Get Artifacts";\r
-\r
- /**\r
- * Normal Init level APIs\r
- * \r
- * @param cmAPI\r
- * @param facade\r
- * @throws Exception\r
- */\r
- public static void init(final CertManAPI cmAPI) throws Exception {\r
- cmAPI.route(HttpMethods.POST, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Create Artifacts") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.createArtifacts(trans, req, resp);\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.CREATED_201);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
- \r
- cmAPI.route(HttpMethods.GET, "/cert/artifacts/:mechid/:machine", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- \r
- Result<Void> r = context.readArtifacts(trans, resp, pathParam(req,":mechid"), pathParam(req,":machine"));\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.CREATED_201);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
-\r
- cmAPI.route(HttpMethods.GET, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.readArtifacts(trans, req, resp);\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.CREATED_201);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
-\r
- cmAPI.route(HttpMethods.PUT, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Update Artifacts") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.updateArtifacts(trans, req, resp);\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
-\r
- cmAPI.route(HttpMethods.DELETE, "/cert/artifacts/:mechid/:machine", API.VOID, new Code(cmAPI,"Delete Artifacts") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.deleteArtifacts(trans, resp, \r
- pathParam(req, ":mechid"), pathParam(req,":machine"));\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
- \r
-\r
- cmAPI.route(HttpMethods.DELETE, "/cert/artifacts", API.VOID, new Code(cmAPI,"Delete Artifacts") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.deleteArtifacts(trans, req, resp);\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- });\r
- \r
-\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.api;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.mapper.Mapper.API;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.cm.service.Code;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.inno.env.Slot;\r
-import org.onap.aaf.inno.env.TransStore;\r
-\r
-/**\r
- * API Apis.. using Redirect for mechanism\r
- * \r
- *\r
- */\r
-public class API_Cert {\r
- public static final String CERT_AUTH = "CertAuthority";\r
- private static Slot sCertAuth;\r
-\r
- /**\r
- * Normal Init level APIs\r
- * \r
- * @param cmAPI\r
- * @param facade\r
- * @throws Exception\r
- */\r
- public static void init(final CertManAPI cmAPI) throws Exception {\r
- // Check for Created Certificate Authorities in TRANS\r
- sCertAuth = ((TransStore) cmAPI.env).slot(CERT_AUTH);\r
- \r
- ////////\r
- // Overall APIs\r
- ///////\r
- cmAPI.route(HttpMethods.PUT,"/cert/:ca",API.CERT_REQ,new Code(cmAPI,"Request Certificate") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- String key = pathParam(req, ":ca");\r
- CA ca;\r
- if((ca = cmAPI.getCA(key))==null) {\r
- context.error(trans,resp,Result.ERR_BadData,"CA %s is not supported",key);\r
- } else {\r
- trans.put(sCertAuth, ca);\r
- \r
- Result<Void> r = context.requestCert(trans, req, resp, req.getParameter("withTrust")!=null);\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- context.error(trans,resp,r);\r
- }\r
- }\r
- }\r
- });\r
- \r
- /**\r
- * \r
- */\r
- cmAPI.route(HttpMethods.GET, "/cert/may/:perm", API.VOID, new Code(cmAPI,"Check Permission") {\r
- @Override\r
- public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {\r
- Result<Void> r = context.check(trans, resp, pathParam(req,"perm"));\r
- if(r.isOK()) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- trans.checkpoint(r.errorString());\r
- context.error(trans,resp,Result.err(Result.ERR_Denied,"%s does not have Permission.",trans.user()));\r
- }\r
- }\r
- });\r
-\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.ca;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.net.Authenticator;\r
-import java.net.MalformedURLException;\r
-import java.net.PasswordAuthentication;\r
-import java.net.URL;\r
-import java.security.cert.CertStore;\r
-import java.security.cert.CertStoreException;\r
-import java.security.cert.Certificate;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Date;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;\r
-import org.jscep.client.Client;\r
-import org.jscep.client.ClientException;\r
-import org.jscep.client.EnrollmentResponse;\r
-import org.jscep.client.verification.CertificateVerifier;\r
-import org.jscep.transaction.TransactionException;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.authz.cm.cert.StandardFields;\r
-import org.onap.aaf.authz.common.Define;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.cadi.routing.GreatCircle;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-import org.onap.aaf.inno.env.util.Split;\r
-\r
-public class AppCA extends CA {\r
- public static final String CA_PERM_TYPE = Define.ROOT_NS+".ca"; // Permission Type for validation\r
- private static final String AAF_DATA_DIR = "aaf_data_dir";\r
- private static final String CA_PREFIX = "http://";\r
- private static final String CA_POSTFIX="/certsrv/mscep_admin/mscep.dll";\r
-\r
- private final static String MS_PROFILE="1";\r
- private static final String CM_TRUST_CAS = "cm_trust_cas";\r
- private Clients clients;\r
-\r
- private static class AAFStdFields implements StandardFields {\r
- private final String env;\r
- public AAFStdFields(Trans trans) throws CertException {\r
- env = trans.getProperty(Config.AAF_ENV);\r
- if(env==null) {\r
- throw new CertException(Config.AAF_ENV + " must be set to create Certificates");\r
- }\r
- }\r
- @Override\r
- public void set(CSRMeta csr) {\r
- // Environment\r
- csr.environment(env);\r
- // Standard Fields\r
- csr.o("ATT Services,Inc.");\r
- csr.l("St Louis");\r
- csr.st("Missouri");\r
- csr.c("US");\r
- }\r
- }\r
-\r
- public AppCA(final Trans trans, final String name, final String urlstr, final String id, final String pw) throws IOException, CertificateException, CertException {\r
- super(name,new AAFStdFields(trans), CA_PERM_TYPE);\r
- \r
- clients = new Clients(trans,urlstr);\r
- \r
- \r
- // Set this for NTLM password Microsoft\r
- Authenticator.setDefault(new Authenticator() {\r
- public PasswordAuthentication getPasswordAuthentication () {\r
- return new PasswordAuthentication (\r
- id,\r
- trans.decryptor().decrypt(pw).toCharArray());\r
- }\r
- });\r
-\r
-\r
-\r
- try {\r
- StringBuilder sb = new StringBuilder("CA Reported Trusted Certificates");\r
- List<X509Certificate> trustCerts = new ArrayList<X509Certificate>();\r
- for(Client client : clients) {\r
- CertStore cs = client.getCaCertificate(MS_PROFILE);\r
- \r
- Collection<? extends Certificate> cc = cs.getCertificates(null);\r
- for(Certificate c : cc) {\r
- X509Certificate xc = (X509Certificate)c;\r
- // Avoid duplicate Certificates from multiple servers\r
- X509Certificate match = null;\r
- for(X509Certificate t : trustCerts) {\r
- if(t.getSerialNumber().equals(xc.getSerialNumber())) {\r
- match = xc;\r
- break;\r
- }\r
- }\r
- if(match==null && xc.getSubjectDN().getName().startsWith("CN=ATT ")) {\r
- sb.append("\n\t");\r
- sb.append(xc.getSubjectDN());\r
- sb.append("\n\t\tSerial Number: ");\r
- String bi = xc.getSerialNumber().toString(16);\r
- for(int i=0;i<bi.length();++i) {\r
- if(i>1 && i%2==0) {\r
- sb.append(':');\r
- }\r
- sb.append(bi.charAt(i));\r
- }\r
- sb.append("\n\t\tIssuer: ");\r
- sb.append(xc.getIssuerDN());\r
- sb.append("\n\t\tNot Before: ");\r
- sb.append(xc.getNotBefore());\r
- sb.append("\n\t\tNot After: ");\r
- sb.append(xc.getNotAfter());\r
- sb.append("\n\t\tSigAlgorithm: ");\r
- sb.append(xc.getSigAlgName());\r
- sb.append("\n\t\tType: ");\r
- sb.append(xc.getType());\r
- sb.append("\n\t\tVersion: ");\r
- sb.append(xc.getVersion());\r
-\r
- trustCerts.add(xc);\r
- }\r
- }\r
- }\r
- trans.init().log(sb);\r
- // Add Additional ones from Property\r
- String data_dir = trans.getProperty(AAF_DATA_DIR);\r
- if(data_dir!=null) {\r
- File data = new File(data_dir);\r
- if(data.exists()) {\r
- String trust_cas = trans.getProperty(CM_TRUST_CAS);\r
- byte[] bytes;\r
- if(trust_cas!=null) {\r
- for(String fname : Split.split(';', trust_cas)) {\r
- File crt = new File(data,fname);\r
- if(crt.exists()) {\r
- bytes = Factory.decode(crt);\r
- try {\r
- Collection<? extends Certificate> cc = Factory.toX509Certificate(bytes);\r
- for(Certificate c : cc) {\r
- trustCerts.add((X509Certificate)c);\r
- }\r
- } catch (CertificateException e) {\r
- throw new CertException(e);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- \r
- String[] trustChain = new String[trustCerts.size()];\r
- int i=-1;\r
- for( Certificate cert : trustCerts) {\r
- trustChain[++i]=BCFactory.toString(trans,cert);\r
- }\r
- \r
- setTrustChain(trustChain);\r
- } catch (ClientException | CertStoreException e) {\r
- // Note: Cannot validly start without all Clients, because we need to read all Issuing Certificates\r
- // This is acceptable risk for most things, as we're not real time in general\r
- throw new CertException(e);\r
- }\r
- }\r
-\r
-\r
- @Override\r
- public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {\r
- TimeTaken tt = trans.start("Generating CSR and Keys for New Certificate", Env.SUB);\r
- PKCS10CertificationRequest csr;\r
- try {\r
- csr = csrmeta.generateCSR(trans);\r
- if(trans.info().isLoggable()) {\r
- trans.info().log(BCFactory.toString(trans, csr));\r
- } \r
- if(trans.info().isLoggable()) {\r
- trans.info().log(csr);\r
- }\r
- } finally {\r
- tt.done();\r
- }\r
- \r
- tt = trans.start("Enroll CSR", Env.SUB);\r
- Client client = null;\r
- try {\r
- client = clients.best();\r
- EnrollmentResponse er = client.enrol(\r
- csrmeta.initialConversationCert(trans),\r
- csrmeta.keypair(trans).getPrivate(),\r
- csr,\r
- MS_PROFILE /* profile... MS can't deal with blanks*/);\r
- while(true) {\r
- if(er.isSuccess()) {\r
- for( Certificate cert : er.getCertStore().getCertificates(null)) {\r
- return (X509Certificate)cert;\r
- }\r
- break;\r
- } else if (er.isPending()) {\r
- trans.checkpoint("Polling, waiting on CA to complete");\r
- Thread.sleep(3000);\r
- } else if (er.isFailure()) {\r
- throw new CertException(er.getFailInfo().toString());\r
- }\r
- }\r
- } catch (ClientException e) {\r
- trans.error().log(e,"SCEP Client Error, Temporarily Invalidating Client");\r
- if(client!=null) {\r
- clients.invalidate(client);\r
- }\r
- } catch (InterruptedException|TransactionException|CertificateException|OperatorCreationException | CertStoreException e) {\r
- trans.error().log(e);\r
- } finally {\r
- tt.done();\r
- }\r
- \r
- return null;\r
- }\r
-\r
-\r
- private class Clients implements Iterable<Client>{\r
- /**\r
- * CSO Servers are in Dallas and St Louis\r
- * GEO_LOCATION LATITUDE LONGITUDE ZIPCODE TIMEZONE\r
- * ------------ -------- --------- ------- --------\r
- * DLLSTXCF 32.779295 -96.800014 75202 America/Chicago\r
- * STLSMORC 38.627345 -90.193774 63101 America/Chicago\r
- * \r
- * The online production issuing CA servers are:\r
- * AAF - CADI Issuing CA 01 135.41.45.152 MOSTLS1AAFXXA02\r
- * AAF - CADI Issuing CA 02 135.31.72.154 TXDLLS2AAFXXA02\r
- */\r
- \r
- private final Client[] client;\r
- private final Date[] failure;\r
- private int preferred;\r
-\r
- public Clients(Trans trans, String urlstr) throws MalformedURLException { \r
- String[] urlstrs = Split.split(',', urlstr);\r
- client = new Client[urlstrs.length];\r
- failure = new Date[urlstrs.length];\r
- double distance = Double.MAX_VALUE;\r
- String localLat = trans.getProperty("AFT_LATITUDE","39.833333"); //Note: Defaulting to GEO center of US\r
- String localLong = trans.getProperty("AFT_LONGITUDE","-98.583333");\r
- for(int i=0;i<urlstrs.length;++i) {\r
- String[] info = Split.split('/', urlstrs[i]);\r
- if(info.length<3) {\r
- throw new MalformedURLException("Configuration needs LAT and LONG, i.e. ip:port/lat/long");\r
- }\r
- client[i] = new Client(new URL(CA_PREFIX + info[0] + CA_POSTFIX), \r
- new CertificateVerifier() {\r
- @Override\r
- public boolean verify(X509Certificate cert) {\r
- return true;\r
- }\r
- }\r
- );\r
- double d = GreatCircle.calc(info[1],info[2],localLat,localLong);\r
- if(d<distance) {\r
- preferred = i;\r
- distance=d;\r
- }\r
- }\r
- trans.init().printf("Preferred Certificate Authority is %s",urlstrs[preferred]);\r
- for(int i=0;i<urlstrs.length;++i) {\r
- if(i!=preferred) {\r
- trans.init().printf("Alternate Certificate Authority is %s",urlstrs[i]);\r
- }\r
- }\r
- }\r
- private Client best() throws ClientException {\r
- if(failure[preferred]==null) {\r
- return client[preferred];\r
- } else {\r
- Client c=null;\r
- // See if Alternate available\r
- for(int i=0;i<failure.length;++i) {\r
- if(failure[i]==null) {\r
- c=client[i];\r
- }\r
- }\r
- \r
- // If not, see if any expirations can be cleared\r
- Date now = new Date();\r
- for(int i=0;i<failure.length;++i) {\r
- if(now.after(failure[i])) {\r
- failure[i]=null;\r
- if(c==null) {\r
- c=client[i];\r
- }\r
- }\r
- }\r
- \r
- // if still nothing found, then throw.\r
- if(c==null) {\r
- throw new ClientException("No available machines to call");\r
- } \r
- return c;\r
- }\r
- }\r
- \r
- public void invalidate(Client clt) {\r
- for(int i=0;i<client.length;++i) {\r
- if(client[i].equals(clt)) {\r
- failure[i]=new Date(System.currentTimeMillis()+180000 /* 3 mins */);\r
- }\r
- }\r
- }\r
- \r
- @Override\r
- public Iterator<Client> iterator() {\r
- return new Iterator<Client>() {\r
- private int iter = 0;\r
- @Override\r
- public boolean hasNext() {\r
- return iter < Clients.this.client.length;\r
- }\r
-\r
- @Override\r
- public Client next() {\r
- return Clients.this.client[iter++];\r
- }\r
- \r
- };\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.ca;\r
-\r
-import java.io.IOException;\r
-import java.security.MessageDigest;\r
-import java.security.cert.X509Certificate;\r
-\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.authz.cm.cert.StandardFields;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public abstract class CA {\r
- private final String name;\r
- private String[] trustChain;\r
- private final StandardFields stdFields;\r
- private MessageDigest messageDigest;\r
- private final String permType;\r
- \r
- protected CA(String name, StandardFields sf, String permType) {\r
- this.name = name;\r
- stdFields = sf;\r
- this.permType = permType;\r
- }\r
-\r
- /* \r
- * NOTE: These two functions must be called in Protected Constructors during their Construction.\r
- */\r
- protected void setTrustChain(String[] trustChain) {\r
- this.trustChain = trustChain;\r
- }\r
-\r
- protected void setMessageDigest(MessageDigest md) {\r
- messageDigest = md;\r
- }\r
-\r
- /*\r
- * End Required Constructor calls\r
- */\r
-\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- public String[] getTrustChain() {\r
- return trustChain;\r
- }\r
- \r
- public String getPermType() {\r
- return permType;\r
- }\r
- \r
- public StandardFields stdFields() {\r
- return stdFields;\r
- }\r
- \r
- public abstract X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException;\r
-\r
- public MessageDigest messageDigest() {\r
- return messageDigest;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.ca;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.math.BigInteger;\r
-import java.security.GeneralSecurityException;\r
-import java.security.KeyFactory;\r
-import java.security.cert.Certificate;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.X509Certificate;\r
-import java.security.interfaces.RSAPrivateKey;\r
-import java.security.spec.PKCS8EncodedKeySpec;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.List;\r
-import java.security.SecureRandom;\r
-\r
-import org.bouncycastle.asn1.ASN1Sequence;\r
-import org.bouncycastle.asn1.x500.X500Name;\r
-import org.bouncycastle.asn1.x500.X500NameBuilder;\r
-import org.bouncycastle.asn1.x500.style.BCStyle;\r
-import org.bouncycastle.asn1.x509.BasicConstraints;\r
-import org.bouncycastle.asn1.x509.ExtendedKeyUsage;\r
-import org.bouncycastle.asn1.x509.Extension;\r
-import org.bouncycastle.asn1.x509.GeneralName;\r
-import org.bouncycastle.asn1.x509.GeneralNames;\r
-import org.bouncycastle.asn1.x509.KeyPurposeId;\r
-import org.bouncycastle.asn1.x509.KeyUsage;\r
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;\r
-import org.bouncycastle.cert.X509v3CertificateBuilder;\r
-import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;\r
-import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.authz.cm.cert.StandardFields;\r
-import org.onap.aaf.authz.common.Define;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public class DevlCA extends CA {\r
- \r
- // Extensions\r
- private static final KeyPurposeId[] ASN_WebUsage = new KeyPurposeId[] {\r
- KeyPurposeId.id_kp_serverAuth, // WebServer\r
- KeyPurposeId.id_kp_clientAuth};// WebClient\r
- \r
- private X509Certificate caCert;\r
- private final RSAPrivateKey caKey;\r
- private final X500Name issuer;\r
- private final SecureRandom random = new SecureRandom();\r
- private byte[] serialish = new byte[24];\r
-\r
- public DevlCA(Trans trans, String name, String dirString) throws IOException, CertException {\r
- super(name, new StandardFields() {\r
- @Override\r
- public void set(CSRMeta csr) {\r
- // Standard Fields\r
- csr.o("ATT Services, Inc.");\r
- csr.l("St Louis");\r
- csr.st("Missouri");\r
- csr.c("US");\r
- }\r
- }, Define.ROOT_NS+".ca" // Permission Type for validation\r
- );\r
- File dir = new File(dirString);\r
- if(!dir.exists()) {\r
- throw new CertException(dirString + " does not exist");\r
- }\r
- \r
- File ca = new File(dir,"ca.crt");\r
- if(ca.exists()) {\r
- byte[] bytes = Factory.decode(ca);\r
- Collection<? extends Certificate> certs;\r
- try {\r
- certs = Factory.toX509Certificate(bytes);\r
- } catch (CertificateException e) {\r
- throw new CertException(e);\r
- }\r
- List<String> lTrust = new ArrayList<String>();\r
- caCert=null;\r
- for(Certificate c : certs) {\r
- if(caCert==null) {\r
- caCert = (X509Certificate)c;\r
- } else {\r
- lTrust.add(Factory.toString(trans,c));\r
- }\r
- break;\r
- }\r
- }\r
- \r
- this.setTrustChain(new String[]{Factory.toString(trans,caCert)});\r
- \r
- /*\r
- * Private key needs to be converted to "DER" format, with no password. \r
- * Use chmod 400 on key\r
- * \r
- * openssl pkcs8 -topk8 -outform DER -nocrypt -in ca.key -out ca.der\r
- *\r
- */\r
- ca = new File(dir,"ca.der");\r
- if(ca.exists()) {\r
- byte[] bytes = Factory.binary(ca);\r
- \r
-// EncryptedPrivateKeyInfo ekey=new EncryptedPrivateKeyInfo(bytes);\r
-// Cipher cip=Cipher.getInstance(ekey.getAlgName());\r
-// PBEKeySpec pspec=new PBEKeySpec("password".toCharArray());\r
-// SecretKeyFactory skfac=SecretKeyFactory.getInstance(ekey.getAlgName());\r
-// Key pbeKey=skfac.generateSecret(pspec);\r
-// AlgorithmParameters algParams=ekey.getAlgParameters();\r
-// cip.init(Cipher.DECRYPT_MODE,pbeKey,algParams);\r
- \r
- KeyFactory keyFactory;\r
- try {\r
- keyFactory = KeyFactory.getInstance("RSA");\r
- PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(bytes);\r
- \r
- caKey = (RSAPrivateKey) keyFactory.generatePrivate(privSpec);\r
- } catch (GeneralSecurityException e) {\r
- throw new CertException(e);\r
- }\r
- \r
- X500NameBuilder xnb = new X500NameBuilder();\r
- xnb.addRDN(BCStyle.C,"US");\r
- xnb.addRDN(BCStyle.ST,"Missouri");\r
- xnb.addRDN(BCStyle.L,"Arnold");\r
- xnb.addRDN(BCStyle.O,"ATT Services, Inc.");\r
- xnb.addRDN(BCStyle.OU,"AAF");\r
- xnb.addRDN(BCStyle.CN,"aaf.att.com");\r
- xnb.addRDN(BCStyle.EmailAddress,"DL-aaf-support@att.com");\r
- issuer = xnb.build();\r
- } else {\r
- throw new CertException(ca.getPath() + " does not exist");\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.cm.service.CA#sign(org.bouncycastle.pkcs.PKCS10CertificationRequest)\r
- */\r
- @Override\r
- public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {\r
- GregorianCalendar gc = new GregorianCalendar();\r
- Date start = gc.getTime();\r
- gc.add(GregorianCalendar.DAY_OF_MONTH, 1);\r
- Date end = gc.getTime();\r
- X509Certificate x509;\r
- TimeTaken tt = trans.start("Create/Sign Cert",Env.SUB);\r
- try {\r
- BigInteger bi;\r
- synchronized(serialish) {\r
- random.nextBytes(serialish);\r
- bi = new BigInteger(serialish);\r
- }\r
- \r
- X509v3CertificateBuilder xcb = new X509v3CertificateBuilder(\r
- issuer,\r
- bi, // replace with Serialnumber scheme\r
- start,\r
- end,\r
- csrmeta.x500Name(),\r
-// SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(caCert.getPublicKey().getEn)\r
- new SubjectPublicKeyInfo(ASN1Sequence.getInstance(caCert.getPublicKey().getEncoded()))\r
- );\r
- List<GeneralName> lsan = new ArrayList<GeneralName>();\r
- for(String s : csrmeta.sans()) {\r
- lsan.add(new GeneralName(GeneralName.dNSName,s));\r
- }\r
- GeneralName[] sans = new GeneralName[lsan.size()];\r
- lsan.toArray(sans);\r
-\r
- JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();\r
- xcb .addExtension(Extension.basicConstraints,\r
- false, new BasicConstraints(false))\r
- .addExtension(Extension.keyUsage,\r
- true, new KeyUsage(KeyUsage.digitalSignature\r
- | KeyUsage.keyEncipherment))\r
- .addExtension(Extension.extendedKeyUsage,\r
- true, new ExtendedKeyUsage(ASN_WebUsage))\r
-\r
- .addExtension(Extension.authorityKeyIdentifier,\r
- false, extUtils.createAuthorityKeyIdentifier(caCert))\r
- .addExtension(Extension.subjectKeyIdentifier,\r
- false, extUtils.createSubjectKeyIdentifier(caCert.getPublicKey()))\r
- .addExtension(Extension.subjectAlternativeName,\r
- false, new GeneralNames(sans))\r
- ;\r
- \r
- x509 = new JcaX509CertificateConverter().getCertificate(\r
- xcb.build(BCFactory.contentSigner(caKey)));\r
- } catch (GeneralSecurityException|OperatorCreationException e) {\r
- throw new CertException(e);\r
- } finally {\r
- tt.done();\r
- }\r
- return x509;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.cert;\r
-\r
-import java.io.File;\r
-import java.io.FileReader;\r
-import java.io.IOException;\r
-import java.lang.reflect.Field;\r
-import java.security.InvalidKeyException;\r
-import java.security.NoSuchAlgorithmException;\r
-import java.security.PrivateKey;\r
-import java.security.SignatureException;\r
-import java.util.List;\r
-\r
-import org.bouncycastle.asn1.ASN1Object;\r
-import org.bouncycastle.operator.ContentSigner;\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.validation.Validator;\r
-\r
-import org.onap.aaf.cadi.Symm;\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-/**\r
- * Additional Factory mechanisms for CSRs, and BouncyCastle. The main Factory\r
- * utilizes only Java abstractions, and is useful in Client code.\r
- * \r
-\r
- *\r
- */\r
-public class BCFactory extends Factory {\r
- private static final JcaContentSignerBuilder jcsb;\r
-\r
-\r
- static {\r
- // Bouncy\r
- jcsb = new JcaContentSignerBuilder(Factory.SIG_ALGO);\r
- }\r
- \r
- public static ContentSigner contentSigner(PrivateKey pk) throws OperatorCreationException {\r
- return jcsb.build(pk);\r
- }\r
- \r
- public static String toString(Trans trans, PKCS10CertificationRequest csr) throws IOException, CertException {\r
- TimeTaken tt = trans.start("CSR to String", Env.SUB);\r
- try {\r
- if(csr==null) {\r
- throw new CertException("x509 Certificate Request not built");\r
- }\r
- return textBuilder("CERTIFICATE REQUEST",csr.getEncoded());\r
- }finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- public static PKCS10CertificationRequest toCSR(Trans trans, File file) throws IOException {\r
- TimeTaken tt = trans.start("Reconstitute CSR", Env.SUB);\r
- try {\r
- FileReader fr = new FileReader(file);\r
- return new PKCS10CertificationRequest(decode(strip(fr)));\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- public static byte[] sign(Trans trans, ASN1Object toSign, PrivateKey pk) throws IOException, InvalidKeyException, SignatureException, NoSuchAlgorithmException {\r
- TimeTaken tt = trans.start("Encode Security Object", Env.SUB);\r
- try {\r
- return sign(trans,toSign.getEncoded(),pk);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- public static CSRMeta createCSRMeta(CA ca,final String args[]) throws IllegalArgumentException, IllegalAccessException, CertException {\r
- CSRMeta csr = new CSRMeta();\r
- ca.stdFields().set(csr);\r
- //TODO should we checkDigest?\r
-// digest = ca.messageDigest();\r
-\r
- Field[] fld = CSRMeta.class.getDeclaredFields();\r
- for(int i=0;i+1<args.length;++i) {\r
- if(args[i].charAt(0)=='-') {\r
- for(int j=0;j<fld.length;++j) {\r
- if(fld[j].getType().equals(String.class) && args[i].substring(1).equals(fld[j].getName())) {\r
- fld[j].set(csr,args[++i]);\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- String errs = validate(csr);\r
- if(errs!=null) {\r
- throw new CertException(errs);\r
- }\r
- return csr;\r
- }\r
- \r
- \r
- public static CSRMeta createCSRMeta(CA ca, String mechid, String sponsorEmail, List<String> fqdns) throws CertException {\r
- CSRMeta csr = new CSRMeta();\r
- boolean first = true;\r
- // Set CN (and SAN)\r
- for(String fqdn : fqdns) {\r
- if(first) {\r
- first = false;\r
- csr.cn(fqdn);\r
- } else {\r
- csr.san(fqdn);\r
- }\r
- }\r
- \r
- csr.challenge(new String(Symm.randomGen(24)));\r
- ca.stdFields().set(csr);\r
- csr.mechID(mechid);\r
- csr.email(sponsorEmail);\r
- String errs = validate(csr);\r
- if(errs!=null) {\r
- throw new CertException(errs);\r
- }\r
- return csr;\r
- }\r
-\r
- private static String validate(CSRMeta csr) {\r
- Validator v = new Validator();\r
- if(v.nullOrBlank("cn", csr.cn())\r
- .nullOrBlank("mechID", csr.mechID())\r
- .nullOrBlank("email", csr.email())\r
- .nullOrBlank("o",csr.o())\r
- .nullOrBlank("l",csr.l())\r
- .nullOrBlank("st",csr.st())\r
- .nullOrBlank("c",csr.c())\r
- .err()) {\r
- return v.errs();\r
- } else {\r
- return null;\r
- }\r
- }\r
- \r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.cert;\r
-\r
-import java.io.IOException;\r
-import java.math.BigInteger;\r
-import java.security.KeyPair;\r
-import java.security.SecureRandom;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.List;\r
-\r
-import org.bouncycastle.asn1.ASN1Sequence;\r
-import org.bouncycastle.asn1.DERPrintableString;\r
-import org.bouncycastle.asn1.pkcs.Attribute;\r
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;\r
-import org.bouncycastle.asn1.x500.X500Name;\r
-import org.bouncycastle.asn1.x500.X500NameBuilder;\r
-import org.bouncycastle.asn1.x500.style.BCStyle;\r
-import org.bouncycastle.asn1.x509.Extension;\r
-import org.bouncycastle.asn1.x509.Extensions;\r
-import org.bouncycastle.asn1.x509.GeneralName;\r
-import org.bouncycastle.asn1.x509.GeneralNames;\r
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;\r
-import org.bouncycastle.cert.X509v3CertificateBuilder;\r
-import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder;\r
-import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public class CSRMeta {\r
- private String environment;\r
- private String cn;\r
- private String mechID;\r
- private String email;\r
- private String o;\r
- private String l;\r
- private String st;\r
- private String c;\r
- private String challenge;\r
- \r
- private ArrayList<String> sanList = new ArrayList<String>();\r
-\r
- private KeyPair keyPair;\r
- private X500Name name = null;\r
- private SecureRandom random = new SecureRandom();\r
-\r
- public X500Name x500Name() throws IOException {\r
- if(name==null) {\r
- X500NameBuilder xnb = new X500NameBuilder();\r
- xnb.addRDN(BCStyle.CN,cn);\r
- xnb.addRDN(BCStyle.E,email);\r
- if(environment==null) {\r
- xnb.addRDN(BCStyle.OU,mechID);\r
- } else {\r
- xnb.addRDN(BCStyle.OU,mechID+':'+environment);\r
- }\r
- xnb.addRDN(BCStyle.O,o);\r
- xnb.addRDN(BCStyle.L,l);\r
- xnb.addRDN(BCStyle.ST,st);\r
- xnb.addRDN(BCStyle.C,c);\r
- name = xnb.build();\r
- }\r
- return name;\r
- }\r
- \r
- \r
- public PKCS10CertificationRequest generateCSR(Trans trans) throws IOException, CertException {\r
- PKCS10CertificationRequestBuilder builder = new JcaPKCS10CertificationRequestBuilder(x500Name(),keypair(trans).getPublic());\r
- if(challenge!=null) {\r
- DERPrintableString password = new DERPrintableString(challenge);\r
- builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword, password);\r
- }\r
- \r
- if(sanList.size()>0) {\r
- GeneralName[] gna = new GeneralName[sanList.size()];\r
- int i=-1;\r
- for(String s : sanList) {\r
- gna[++i]=new GeneralName(GeneralName.dNSName,s);\r
- }\r
- \r
- builder.addAttribute(\r
- PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,\r
- new Extensions(new Extension[] {\r
- new Extension(Extension.subjectAlternativeName,false,new GeneralNames(gna).getEncoded())\r
- })\r
- );\r
- }\r
-// builder.addAttribute(Extension.basicConstraints,new BasicConstraints(false))\r
-// .addAttribute(Extension.keyUsage, new KeyUsage(KeyUsage.digitalSignature\r
-// | KeyUsage.keyEncipherment));\r
- try {\r
- return builder.build(BCFactory.contentSigner(keypair(trans).getPrivate()));\r
- } catch (OperatorCreationException e) {\r
- throw new CertException(e);\r
- }\r
- }\r
- \r
- @SuppressWarnings("deprecation")\r
- public static void dump(PKCS10CertificationRequest csr) {\r
- Attribute[] certAttributes = csr.getAttributes();\r
- for (Attribute attribute : certAttributes) {\r
- if (attribute.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) {\r
- Extensions extensions = Extensions.getInstance(attribute.getAttrValues().getObjectAt(0));\r
-// Extension ext = extensions.getExtension(Extension.subjectAlternativeName);\r
- GeneralNames gns = GeneralNames.fromExtensions(extensions,Extension.subjectAlternativeName);\r
- GeneralName[] names = gns.getNames();\r
- for(int k=0; k < names.length; k++) {\r
- String title = "";\r
- if(names[k].getTagNo() == GeneralName.dNSName) {\r
- title = "dNSName";\r
- }\r
- else if(names[k].getTagNo() == GeneralName.iPAddress) {\r
- title = "iPAddress";\r
- // Deprecated, but I don't see anything better to use.\r
- names[k].toASN1Object();\r
- }\r
- else if(names[k].getTagNo() == GeneralName.otherName) {\r
- title = "otherName";\r
- }\r
- System.out.println(title + ": "+ names[k].getName());\r
- } \r
- }\r
- }\r
- }\r
- \r
- public X509Certificate initialConversationCert(Trans trans) throws IOException, CertificateException, OperatorCreationException {\r
- GregorianCalendar gc = new GregorianCalendar();\r
- Date start = gc.getTime();\r
- gc.add(GregorianCalendar.DAY_OF_MONTH,2);\r
- Date end = gc.getTime();\r
- X509v3CertificateBuilder xcb = new X509v3CertificateBuilder(\r
- x500Name(),\r
- new BigInteger(12,random), // replace with Serialnumber scheme\r
- start,\r
- end,\r
- x500Name(),\r
-// SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(caCert.getPublicKey().getEn)\r
- new SubjectPublicKeyInfo(ASN1Sequence.getInstance(keypair(trans).getPublic().getEncoded()))\r
- );\r
- return new JcaX509CertificateConverter().getCertificate(\r
- xcb.build(BCFactory.contentSigner(keypair(trans).getPrivate())));\r
- }\r
-\r
- public CSRMeta san(String v) {\r
- sanList.add(v);\r
- return this;\r
- }\r
-\r
- public List<String> sans() {\r
- return sanList;\r
- }\r
-\r
-\r
- public KeyPair keypair(Trans trans) {\r
- if(keyPair == null) {\r
- keyPair = Factory.generateKeyPair(trans);\r
- }\r
- return keyPair;\r
- }\r
-\r
- /**\r
- * @return the cn\r
- */\r
- public String cn() {\r
- return cn;\r
- }\r
-\r
-\r
- /**\r
- * @param cn the cn to set\r
- */\r
- public void cn(String cn) {\r
- this.cn = cn;\r
- }\r
-\r
- /**\r
- * Environment of Service MechID is good for\r
- */\r
- public void environment(String env) {\r
- environment = env;\r
- }\r
- \r
- /**\r
- * \r
- * @return\r
- */\r
- public String environment() {\r
- return environment;\r
- }\r
- \r
- /**\r
- * @return the mechID\r
- */\r
- public String mechID() {\r
- return mechID;\r
- }\r
-\r
-\r
- /**\r
- * @param mechID the mechID to set\r
- */\r
- public void mechID(String mechID) {\r
- this.mechID = mechID;\r
- }\r
-\r
-\r
- /**\r
- * @return the email\r
- */\r
- public String email() {\r
- return email;\r
- }\r
-\r
-\r
- /**\r
- * @param email the email to set\r
- */\r
- public void email(String email) {\r
- this.email = email;\r
- }\r
-\r
-\r
- /**\r
- * @return the o\r
- */\r
- public String o() {\r
- return o;\r
- }\r
-\r
-\r
- /**\r
- * @param o the o to set\r
- */\r
- public void o(String o) {\r
- this.o = o;\r
- }\r
-\r
- /**\r
- * \r
- * @return the l\r
- */\r
- public String l() {\r
- return l;\r
- }\r
- \r
- /**\r
- * @param l the l to set\r
- */\r
- public void l(String l) {\r
- this.l=l;\r
- }\r
-\r
- /**\r
- * @return the st\r
- */\r
- public String st() {\r
- return st;\r
- }\r
-\r
-\r
- /**\r
- * @param st the st to set\r
- */\r
- public void st(String st) {\r
- this.st = st;\r
- }\r
-\r
-\r
- /**\r
- * @return the c\r
- */\r
- public String c() {\r
- return c;\r
- }\r
-\r
-\r
- /**\r
- * @param c the c to set\r
- */\r
- public void c(String c) {\r
- this.c = c;\r
- }\r
-\r
-\r
- /**\r
- * @return the challenge\r
- */\r
- public String challenge() {\r
- return challenge;\r
- }\r
-\r
-\r
- /**\r
- * @param challenge the challenge to set\r
- */\r
- public void challenge(String challenge) {\r
- this.challenge = challenge;\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.cert;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-\r
-public interface StandardFields {\r
- public void set(CSRMeta csr) throws CertException;\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.data;\r
-\r
-public class CertDrop {\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.data;\r
-\r
-public class CertRenew {\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.data;\r
-\r
-import java.util.List;\r
-\r
-import javax.xml.datatype.XMLGregorianCalendar;\r
-\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-\r
-public class CertReq {\r
- // These cannot be null\r
- public CA certAuthority;\r
- public String mechid;\r
- public List<String> fqdns;\r
- // Notify\r
- public List<String> emails;\r
- \r
- \r
- // These may be null\r
- public String sponsor;\r
- public XMLGregorianCalendar start, end;\r
- \r
- public CSRMeta getCSRMeta() throws CertException {\r
- return BCFactory.createCSRMeta(certAuthority, mechid, sponsor,fqdns);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.data;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-import java.security.KeyPair;\r
-import java.security.cert.X509Certificate;\r
-\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public class CertResp {\r
- public CertResp(Trans trans, X509Certificate x509, CSRMeta csrMeta, String[] notes) throws IOException, GeneralSecurityException, CertException {\r
- keyPair = csrMeta.keypair(trans);\r
- privateKey = Factory.toString(trans, keyPair.getPrivate());\r
- certString = Factory.toString(trans,x509);\r
- challenge=csrMeta.challenge();\r
- this.notes = notes;\r
- }\r
- private KeyPair keyPair;\r
- private String challenge;\r
- \r
- private String privateKey, certString;\r
- private String[] notes;\r
- \r
- \r
- public String asCertString() {\r
- return certString;\r
- }\r
- \r
- public String privateString() throws IOException {\r
- return privateKey;\r
- }\r
- \r
- public String challenge() {\r
- return challenge==null?"":challenge;\r
- }\r
- \r
- public String[] notes() {\r
- return notes;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.facade;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.authz.cm.mapper.Mapper;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public interface Facade<REQ,CERT,ARTIFACTS,ERROR> {\r
-\r
-///////////////////// STANDARD ELEMENTS //////////////////\r
- /** \r
- * @param trans\r
- * @param response\r
- * @param result\r
- */\r
- void error(AuthzTrans trans, HttpServletResponse response, Result<?> result);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param response\r
- * @param status\r
- */\r
- void error(AuthzTrans trans, HttpServletResponse response, int status, String msg, String ... detail);\r
-\r
- /**\r
- * Permission checker\r
- *\r
- * @param trans\r
- * @param resp\r
- * @param perm\r
- * @return\r
- * @throws IOException \r
- */\r
- Result<Void> check(AuthzTrans trans, HttpServletResponse resp, String perm) throws IOException;\r
-\r
- /**\r
- * \r
- * @return\r
- */\r
- public Mapper<REQ,CERT,ARTIFACTS,ERROR> mapper();\r
-\r
-///////////////////// STANDARD ELEMENTS //////////////////\r
- \r
- /**\r
- * \r
- * @param trans\r
- * @param resp\r
- * @param rservlet\r
- * @return\r
- */\r
- public abstract Result<Void> requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- public abstract Result<Void> renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- public abstract Result<Void> dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- Result<Void> createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);\r
- \r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- Result<Void> readArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param resp\r
- * @param mechid\r
- * @param machine\r
- * @return\r
- */\r
- Result<Void> readArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- Result<Void> updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);\r
- \r
- /**\r
- * \r
- * @param trans\r
- * @param req\r
- * @param resp\r
- * @return\r
- */\r
- Result<Void> deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param resp\r
- * @param mechid\r
- * @param machine\r
- * @return\r
- */\r
- Result<Void> deleteArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine);\r
-\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.facade;\r
-\r
-import org.onap.aaf.authz.cm.mapper.Mapper;\r
-import org.onap.aaf.authz.cm.service.CMService;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-\r
-import aaf.v2_0.Error;\r
-import certman.v1_0.Artifacts;\r
-import certman.v1_0.BaseRequest;\r
-import certman.v1_0.CertInfo;\r
-\r
-/**\r
- *\r
- */\r
-public class Facade1_0 extends FacadeImpl<BaseRequest,CertInfo, Artifacts, Error> {\r
- public Facade1_0(CertManAPI certman, \r
- CMService service, \r
- Mapper<BaseRequest,CertInfo,Artifacts,Error> mapper, \r
- Data.TYPE type) throws APIException {\r
- super(certman, service, mapper, type);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.facade;\r
-\r
-import org.onap.aaf.authz.cm.mapper.Mapper1_0;\r
-import org.onap.aaf.authz.cm.service.CMService;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-\r
-\r
-public class FacadeFactory {\r
- public static Facade1_0 v1_0(CertManAPI certman, AuthzTrans trans, CMService service, Data.TYPE type) throws APIException {\r
- return new Facade1_0(\r
- certman,\r
- service,\r
- new Mapper1_0(),\r
- type); \r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.facade;\r
-\r
-import static org.onap.aaf.authz.layer.Result.ERR_ActionNotCompleted;\r
-import static org.onap.aaf.authz.layer.Result.ERR_BadData;\r
-import static org.onap.aaf.authz.layer.Result.ERR_ConflictAlreadyExists;\r
-import static org.onap.aaf.authz.layer.Result.ERR_Denied;\r
-import static org.onap.aaf.authz.layer.Result.ERR_NotFound;\r
-import static org.onap.aaf.authz.layer.Result.ERR_NotImplemented;\r
-import static org.onap.aaf.authz.layer.Result.ERR_Policy;\r
-import static org.onap.aaf.authz.layer.Result.ERR_Security;\r
-import static org.onap.aaf.authz.layer.Result.OK;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.authz.cm.api.API_Cert;\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.data.CertResp;\r
-import org.onap.aaf.authz.cm.mapper.Mapper;\r
-import org.onap.aaf.authz.cm.mapper.Mapper.API;\r
-import org.onap.aaf.authz.cm.service.CMService;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;\r
-import org.onap.aaf.dao.aaf.cass.Status;\r
-\r
-import org.onap.aaf.cadi.aaf.AAFPermission;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.Slot;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.util.Split;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-import org.onap.aaf.rosetta.env.RosettaData;\r
-\r
-/**\r
- * AuthzFacade\r
- * \r
- * This Service Facade encapsulates the essence of the API Service can do, and provides\r
- * a single created object for elements such as RosettaDF.\r
- *\r
- * The Responsibilities of this class are to:\r
- * 1) Interact with the Service Implementation (which might be supported by various kinds of Backend Storage)\r
- * 2) Validate incoming data (if applicable)\r
- * 3) Convert the Service response into the right Format, and mark the Content Type\r
- * a) In the future, we may support multiple Response Formats, aka JSON or XML, based on User Request.\r
- * 4) Log Service info, warnings and exceptions as necessary\r
- * 5) When asked by the API layer, this will create and write Error content to the OutputStream\r
- * \r
- * Note: This Class does NOT set the HTTP Status Code. That is up to the API layer, so that it can be \r
- * clearly coordinated with the API Documentation\r
- * \r
- *\r
- */\r
-public abstract class FacadeImpl<REQ,CERT,ARTIFACTS,ERROR> extends org.onap.aaf.authz.layer.FacadeImpl implements Facade<REQ,CERT,ARTIFACTS,ERROR> \r
- {\r
- private static final String REQUEST_CERT = "Request New Certificate";\r
- private static final String RENEW_CERT = "Renew Certificate";\r
- private static final String DROP_CERT = "Drop Certificate";\r
- private static final String CREATE_ARTIFACTS = "Create Deployment Artifact";\r
- private static final String READ_ARTIFACTS = "Read Deployment Artifact";\r
- private static final String UPDATE_ARTIFACTS = "Update Deployment Artifact";\r
- private static final String DELETE_ARTIFACTS = "Delete Deployment Artifact";\r
-\r
- private CMService service;\r
-\r
- private final RosettaDF<ERROR> errDF;\r
- private final RosettaDF<REQ> certRequestDF, certRenewDF, certDropDF;\r
- private final RosettaDF<CERT> certDF;\r
- private final RosettaDF<ARTIFACTS> artiDF;\r
- private Mapper<REQ, CERT, ARTIFACTS, ERROR> mapper;\r
- private Slot sCertAuth;\r
- private CertManAPI certman;\r
- private final String voidResp;\r
-\r
- public FacadeImpl(CertManAPI certman,\r
- CMService service, \r
- Mapper<REQ,CERT,ARTIFACTS,ERROR> mapper, \r
- Data.TYPE dataType) throws APIException {\r
- this.service = service;\r
- this.mapper = mapper;\r
- this.certman = certman;\r
- AuthzEnv env = certman.env;\r
- (errDF = env.newDataFactory(mapper.getClass(API.ERROR))).in(dataType).out(dataType);\r
- (certRequestDF = env.newDataFactory(mapper.getClass(API.CERT_REQ))).in(dataType).out(dataType);\r
- (certRenewDF = env.newDataFactory(mapper.getClass(API.CERT_RENEW))).in(dataType).out(dataType);\r
- (certDropDF = env.newDataFactory(mapper.getClass(API.CERT_DROP))).in(dataType).out(dataType);\r
- (certDF = env.newDataFactory(mapper.getClass(API.CERT))).in(dataType).out(dataType);\r
- (artiDF = env.newDataFactory(mapper.getClass(API.ARTIFACTS))).in(dataType).out(dataType);\r
- sCertAuth = env.slot(API_Cert.CERT_AUTH);\r
- if(artiDF.getOutType().name().contains("xml")) {\r
- voidResp = "application/Void+xml;charset=utf-8;version=1.0,application/xml;version=1.0,*/*";\r
- } else {\r
- voidResp = "application/Void+json;charset=utf-8;version=1.0,application/json;version=1.0,*/*";\r
- }\r
- }\r
- \r
- public Mapper<REQ,CERT,ARTIFACTS,ERROR> mapper() {\r
- return mapper;\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.att.authz.facade.AuthzFacade#error(org.onap.aaf.authz.env.AuthzTrans, javax.servlet.http.HttpServletResponse, int)\r
- * \r
- * Note: Conforms to AT&T TSS RESTful Error Structure\r
- */\r
- @Override\r
- public void error(AuthzTrans trans, HttpServletResponse response, Result<?> result) {\r
- error(trans, response, result.status,\r
- result.details==null?"":result.details.trim(),\r
- result.variables==null?new String[0]:result.variables);\r
- }\r
- \r
- @Override\r
- public void error(AuthzTrans trans, HttpServletResponse response, int status, final String _msg, final String ... _detail) {\r
- String msgId;\r
- String prefix;\r
- switch(status) {\r
- case 202:\r
- case ERR_ActionNotCompleted:\r
- msgId = "SVC1202";\r
- prefix = "Accepted, Action not complete";\r
- response.setStatus(/*httpstatus=*/202);\r
- break;\r
-\r
- case 403:\r
- case ERR_Policy:\r
- case ERR_Security:\r
- case ERR_Denied:\r
- msgId = "SVC1403";\r
- prefix = "Forbidden";\r
- response.setStatus(/*httpstatus=*/403);\r
- break;\r
- \r
- case 404:\r
- case ERR_NotFound:\r
- msgId = "SVC1404";\r
- prefix = "Not Found";\r
- response.setStatus(/*httpstatus=*/404);\r
- break;\r
-\r
- case 406:\r
- case ERR_BadData:\r
- msgId="SVC1406";\r
- prefix = "Not Acceptable";\r
- response.setStatus(/*httpstatus=*/406);\r
- break;\r
- \r
- case 409:\r
- case ERR_ConflictAlreadyExists:\r
- msgId = "SVC1409";\r
- prefix = "Conflict Already Exists";\r
- response.setStatus(/*httpstatus=*/409);\r
- break;\r
- \r
- case 501:\r
- case ERR_NotImplemented:\r
- msgId = "SVC1501";\r
- prefix = "Not Implemented"; \r
- response.setStatus(/*httpstatus=*/501);\r
- break;\r
- \r
-\r
- default:\r
- msgId = "SVC1500";\r
- prefix = "General Service Error";\r
- response.setStatus(/*httpstatus=*/500);\r
- break;\r
- }\r
-\r
- try {\r
- StringBuilder holder = new StringBuilder();\r
- errDF.newData(trans).load(\r
- mapper().errorFromMessage(holder, msgId,prefix + ": " + _msg,_detail)).to(response.getOutputStream());\r
- \r
- holder.append(']');\r
- trans.checkpoint(\r
- "ErrResp [" + \r
- holder,\r
- Env.ALWAYS);\r
- } catch (Exception e) {\r
- trans.error().log(e,"unable to send response for",_msg);\r
- }\r
- }\r
-\r
- @Override\r
- public Result<Void> check(AuthzTrans trans, HttpServletResponse resp, String perm) throws IOException {\r
- String[] p = Split.split('|',perm);\r
- if(p.length!=3) {\r
- return Result.err(Result.ERR_BadData,"Invalid Perm String");\r
- }\r
- AAFPermission ap = new AAFPermission(p[0],p[1],p[2]);\r
- if(certman.aafLurPerm.fish(trans.getUserPrincipal(), ap)) {\r
- resp.setContentType(voidResp);\r
- resp.getOutputStream().write(0);\r
- return Result.ok();\r
- } else {\r
- return Result.err(Result.ERR_Denied,"%s does not have %s",trans.user(),ap.getKey());\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.auth.certman.facade.Facade#requestCert(org.onap.aaf.authz.env.AuthzTrans, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)\r
- */\r
- @Override\r
- public Result<Void> requestCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) {\r
- TimeTaken tt = trans.start(REQUEST_CERT, Env.SUB|Env.ALWAYS);\r
- try {\r
- REQ request;\r
- try {\r
- Data<REQ> rd = certRequestDF.newData().load(req.getInputStream());\r
- request = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,REQUEST_CERT);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- Result<CertResp> rcr = service.requestCert(trans,mapper.toReq(trans,request));\r
- if(rcr.notOK()) {\r
- return Result.err(rcr);\r
- }\r
- \r
- CA certAuth = trans.get(sCertAuth,null);\r
- Result<CERT> rc = mapper.toCert(trans, rcr, withTrust?certAuth.getTrustChain():null);\r
- switch(rc.status) {\r
- case OK: \r
- RosettaData<CERT> data = certDF.newData(trans).load(rc.value);\r
- data.to(resp.getOutputStream());\r
-\r
- setContentType(resp,certDF.getOutType());\r
- return Result.ok();\r
- default:\r
- return Result.err(rc);\r
- }\r
-\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,REQUEST_CERT);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
- \r
- @Override\r
- public Result<Void> renewCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, boolean withTrust) {\r
- TimeTaken tt = trans.start(RENEW_CERT, Env.SUB|Env.ALWAYS);\r
- try {\r
- REQ request;\r
- try {\r
- Data<REQ> rd = certRenewDF.newData().load(req.getInputStream());\r
- request = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,RENEW_CERT);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- String certAuth = trans.get(sCertAuth,null);\r
- Result<CertResp> rcr = service.renewCert(trans,mapper.toRenew(trans,request));\r
- Result<CERT> rc = mapper.toCert(trans, rcr, certman.getTrustChain(certAuth));\r
-\r
- switch(rc.status) {\r
- case OK: \r
- RosettaData<CERT> data = certDF.newData(trans).load(rc.value);\r
- data.to(resp.getOutputStream());\r
-\r
- setContentType(resp,certDF.getOutType());\r
- return Result.ok();\r
- default:\r
- return Result.err(rc);\r
- }\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,RENEW_CERT);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
-\r
- }\r
-\r
- @Override\r
- public Result<Void> dropCert(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {\r
- TimeTaken tt = trans.start(DROP_CERT, Env.SUB|Env.ALWAYS);\r
- try {\r
- REQ request;\r
- try {\r
- Data<REQ> rd = certDropDF.newData().load(req.getInputStream());\r
- request = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,DROP_CERT);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- Result<Void> rv = service.dropCert(trans,mapper.toDrop(trans, request));\r
- switch(rv.status) {\r
- case OK: \r
- setContentType(resp,certRequestDF.getOutType());\r
- return Result.ok();\r
- default:\r
- return Result.err(rv);\r
- }\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,DROP_CERT);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- ////////////////////////////\r
- // Artifacts\r
- ////////////////////////////\r
- @Override\r
- public Result<Void> createArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {\r
- TimeTaken tt = trans.start(CREATE_ARTIFACTS, Env.SUB);\r
- try {\r
- ARTIFACTS arti;\r
- try {\r
- Data<ARTIFACTS> rd = artiDF.newData().load(req.getInputStream());\r
- arti = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,CREATE_ARTIFACTS);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- return service.createArtifact(trans,mapper.toArtifact(trans,arti));\r
- } catch (Exception e) {\r
-\r
- trans.error().log(e,IN,CREATE_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- @Override\r
- public Result<Void> readArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {\r
- TimeTaken tt = trans.start(READ_ARTIFACTS, Env.SUB);\r
- try {\r
- String mechid = req.getParameter("mechid");\r
- String machine = req.getParameter("machine");\r
- \r
- Result<ARTIFACTS> ra;\r
- if( machine !=null && mechid == null) {\r
- ra = mapper.fromArtifacts(service.readArtifactsByMachine(trans, machine));\r
- } else if(mechid!=null && machine==null) {\r
- ra = mapper.fromArtifacts(service.readArtifactsByMechID(trans, mechid));\r
- } else if(mechid!=null && machine!=null) {\r
- ArtiDAO.Data add = new ArtiDAO.Data();\r
- add.mechid = mechid;\r
- add.machine = machine;\r
- ra = mapper.fromArtifacts(service.readArtifacts(trans,add));\r
- } else {\r
- ra = Result.err(Status.ERR_BadData,"Invalid request inputs");\r
- }\r
- \r
- if(ra.isOK()) {\r
- RosettaData<ARTIFACTS> data = artiDF.newData(trans).load(ra.value);\r
- data.to(resp.getOutputStream());\r
- setContentType(resp,artiDF.getOutType());\r
- return Result.ok();\r
- } else {\r
- return Result.err(ra);\r
- }\r
-\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,READ_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- @Override\r
- public Result<Void> readArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine) {\r
- TimeTaken tt = trans.start(READ_ARTIFACTS, Env.SUB);\r
- try {\r
- ArtiDAO.Data add = new ArtiDAO.Data();\r
- add.mechid = mechid;\r
- add.machine = machine;\r
- Result<ARTIFACTS> ra = mapper.fromArtifacts(service.readArtifacts(trans,add));\r
- if(ra.isOK()) {\r
- RosettaData<ARTIFACTS> data = artiDF.newData(trans).load(ra.value);\r
- data.to(resp.getOutputStream());\r
- setContentType(resp,artiDF.getOutType());\r
- return Result.ok();\r
- } else {\r
- return Result.err(ra);\r
- }\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,READ_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
-\r
- @Override\r
- public Result<Void> updateArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {\r
- TimeTaken tt = trans.start(UPDATE_ARTIFACTS, Env.SUB);\r
- try {\r
- ARTIFACTS arti;\r
- try {\r
- Data<ARTIFACTS> rd = artiDF.newData().load(req.getInputStream());\r
- arti = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,UPDATE_ARTIFACTS);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- return service.updateArtifact(trans,mapper.toArtifact(trans,arti));\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,UPDATE_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- @Override\r
- public Result<Void> deleteArtifacts(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) {\r
- TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB);\r
- try {\r
- ARTIFACTS arti;\r
- try {\r
- Data<ARTIFACTS> rd = artiDF.newData().load(req.getInputStream());\r
- arti = rd.asObject();\r
- } catch(APIException e) {\r
- trans.error().log("Invalid Input",IN,DELETE_ARTIFACTS);\r
- return Result.err(Result.ERR_BadData,"Invalid Input");\r
- }\r
- \r
- Result<Void> rv = service.deleteArtifact(trans,mapper.toArtifact(trans,arti));\r
- switch(rv.status) {\r
- case OK: \r
- setContentType(resp,artiDF.getOutType());\r
- } \r
- return rv;\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,DELETE_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
- @Override\r
- public Result<Void> deleteArtifacts(AuthzTrans trans, HttpServletResponse resp, String mechid, String machine) {\r
- TimeTaken tt = trans.start(DELETE_ARTIFACTS, Env.SUB);\r
- try {\r
- Result<Void> rv = service.deleteArtifact(trans, mechid, machine);\r
- switch(rv.status) {\r
- case OK: \r
- setContentType(resp,artiDF.getOutType());\r
- } \r
- return rv;\r
- } catch (Exception e) {\r
- trans.error().log(e,IN,DELETE_ARTIFACTS);\r
- return Result.err(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.mapper;\r
-\r
-import java.io.IOException;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.cm.data.CertDrop;\r
-import org.onap.aaf.authz.cm.data.CertRenew;\r
-import org.onap.aaf.authz.cm.data.CertReq;\r
-import org.onap.aaf.authz.cm.data.CertResp;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;\r
-\r
-public interface Mapper<REQ,CERT,ARTIFACTS,ERROR>\r
-{\r
- public enum API{ERROR,VOID,CERT,CERT_REQ,CERT_RENEW,CERT_DROP,ARTIFACTS};\r
- \r
- public Class<?> getClass(API api);\r
- public<A> A newInstance(API api);\r
-\r
- public ERROR errorFromMessage(StringBuilder holder, String msgID, String text, String... detail);\r
- \r
- public Result<CERT> toCert(AuthzTrans trans, Result<CertResp> in, String[] trustChain) throws IOException;\r
- public Result<CertReq> toReq(AuthzTrans trans, REQ req);\r
- public Result<CertRenew> toRenew(AuthzTrans trans, REQ req);\r
- public Result<CertDrop> toDrop(AuthzTrans trans, REQ req);\r
- \r
- public List<ArtiDAO.Data> toArtifact(AuthzTrans trans, ARTIFACTS arti);\r
- public Result<ARTIFACTS> fromArtifacts(Result<List<ArtiDAO.Data>> readArtifactsByMachine);\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.mapper;\r
-\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.cm.data.CertDrop;\r
-import org.onap.aaf.authz.cm.data.CertRenew;\r
-import org.onap.aaf.authz.cm.data.CertReq;\r
-import org.onap.aaf.authz.cm.data.CertResp;\r
-import org.onap.aaf.authz.cm.validation.Validator;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO.Data;\r
-\r
-import aaf.v2_0.Error;\r
-import certman.v1_0.Artifacts;\r
-import certman.v1_0.Artifacts.Artifact;\r
-import certman.v1_0.BaseRequest;\r
-import certman.v1_0.CertInfo;\r
-import certman.v1_0.CertificateDrop;\r
-import certman.v1_0.CertificateRenew;\r
-import certman.v1_0.CertificateRequest;\r
-\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFCon;\r
-import org.onap.aaf.cadi.util.Vars;\r
-\r
-\r
-public class Mapper1_0 implements Mapper<BaseRequest,CertInfo,Artifacts,Error> {\r
- \r
- @Override\r
- public Class<?> getClass(API api) {\r
- switch(api) {\r
- case CERT_REQ: return CertificateRequest.class;\r
- case CERT_RENEW: return CertificateRenew.class;\r
- case CERT_DROP: return CertificateDrop.class;\r
- case CERT: return CertInfo.class;\r
- case ARTIFACTS: return Artifacts.class;\r
- case ERROR: return Error.class;\r
- case VOID: return Void.class;\r
- }\r
- return null;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public <A> A newInstance(API api) {\r
- switch(api) {\r
- case CERT_REQ: return (A) new CertificateRequest();\r
- case CERT_RENEW: return (A) new CertificateRenew();\r
- case CERT_DROP: return (A) new CertificateDrop();\r
- case CERT: return (A) new CertInfo();\r
- case ARTIFACTS: return (A) new Artifacts();\r
- case ERROR: return (A)new Error();\r
- case VOID: return null;\r
- }\r
- return null;\r
- }\r
-\r
- ////////////// Mapping Functions /////////////\r
- @Override\r
- public Error errorFromMessage(StringBuilder holder, String msgID, String text, String... var) {\r
- Error err = new Error();\r
- err.setMessageId(msgID);\r
- // AT&T Restful Error Format requires numbers "%" placements\r
- err.setText(Vars.convert(holder, text, var));\r
- for(String s : var) {\r
- err.getVariables().add(s);\r
- }\r
- return err;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.authz.certman.mapper.Mapper#toCert(org.onap.aaf.authz.env.AuthzTrans, org.onap.aaf.authz.layer.Result)\r
- */\r
- @Override\r
- public Result<CertInfo> toCert(AuthzTrans trans, Result<CertResp> in, String[] trustChain) throws IOException {\r
- if(in.isOK()) {\r
- CertResp cin = in.value;\r
- CertInfo cout = newInstance(API.CERT);\r
- cout.setPrivatekey(cin.privateString());\r
- String value;\r
- if((value=cin.challenge())!=null) {\r
- cout.setChallenge(value);\r
- }\r
- cout.getCerts().add(cin.asCertString());\r
- if(trustChain!=null) {\r
- for(String c : trustChain) {\r
- cout.getCerts().add(c);\r
- }\r
- }\r
- if(cin.notes()!=null) {\r
- boolean first = true;\r
- StringBuilder sb = new StringBuilder();\r
- for(String n : cin.notes()) {\r
- if(first) {\r
- first = false;\r
- } else {\r
- sb.append('\n');\r
- }\r
- sb.append(n);\r
- }\r
- cout.setNotes(sb.toString());\r
- }\r
- return Result.ok(cout);\r
- } else {\r
- return Result.err(in);\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.authz.certman.mapper.Mapper#toReq(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object)\r
- */\r
- @Override\r
- public Result<CertReq> toReq(AuthzTrans trans, BaseRequest req) {\r
- CertificateRequest in;\r
- try {\r
- in = (CertificateRequest)req;\r
- } catch(ClassCastException e) {\r
- return Result.err(Result.ERR_BadData,"Request is not a CertificateRequest");\r
- }\r
-\r
- CertReq out = new CertReq();\r
- Validator v = new Validator();\r
- if(v.isNull("CertRequest", req)\r
- .nullOrBlank("MechID", out.mechid=in.getMechid())\r
- .nullBlankMin("FQDNs", out.fqdns=in.getFqdns(),1)\r
- .err()) {\r
- return Result.err(Result.ERR_BadData, v.errs());\r
- }\r
- out.emails = in.getEmail();\r
- out.sponsor=in.getSponsor();\r
- out.start = in.getStart();\r
- out.end = in.getEnd();\r
- return Result.ok(out);\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.authz.certman.mapper.Mapper#toRenew(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object)\r
- */\r
- @Override\r
- public Result<CertRenew> toRenew(AuthzTrans trans, BaseRequest req) {\r
- return Result.err(Result.ERR_NotImplemented,"Not Implemented... yet");\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.authz.certman.mapper.Mapper#toDrop(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object)\r
- */\r
- @Override\r
- public Result<CertDrop> toDrop(AuthzTrans trans, BaseRequest req) {\r
- return Result.err(Result.ERR_NotImplemented,"Not Implemented... yet");\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.cm.mapper.Mapper#toArtifact(org.onap.aaf.authz.env.AuthzTrans, java.lang.Object)\r
- */\r
- @Override\r
- public List<ArtiDAO.Data> toArtifact(AuthzTrans trans, Artifacts artifacts) {\r
- List<ArtiDAO.Data> ladd = new ArrayList<ArtiDAO.Data>();\r
- for(Artifact arti : artifacts.getArtifact()) {\r
- ArtiDAO.Data data = new ArtiDAO.Data();\r
- data.mechid = arti.getMechid();\r
- data.machine = arti.getMachine();\r
- data.type(true).addAll(arti.getType());\r
- data.ca = arti.getCa();\r
- data.dir = arti.getDir();\r
- data.os_user = arti.getOsUser();\r
- // Optional (on way in)\r
- data.appName = arti.getAppName();\r
- data.renewDays = arti.getRenewDays();\r
- data.notify = arti.getNotification();\r
- \r
- // Ignored on way in for create/update\r
- data.sponsor = arti.getSponsor();\r
- data.expires = null;\r
- \r
- // Derive Optional Data from Machine (Domain) if exists\r
- if(data.machine!=null) {\r
- if(data.ca==null) {\r
- if(data.machine.endsWith(".att.com")) {\r
- data.ca = "aaf"; // default\r
- }\r
- }\r
- if(data.appName==null ) {\r
- data.appName=AAFCon.reverseDomain(data.machine);\r
- }\r
- }\r
-\r
- ladd.add(data);\r
- }\r
- return ladd;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.cm.mapper.Mapper#fromArtifacts(org.onap.aaf.authz.layer.Result)\r
- */\r
- @Override\r
- public Result<Artifacts> fromArtifacts(Result<List<Data>> lArtiDAO) {\r
- if(lArtiDAO.isOK()) {\r
- Artifacts artis = new Artifacts();\r
- for(ArtiDAO.Data arti : lArtiDAO.value) {\r
- Artifact a = new Artifact();\r
- a.setMechid(arti.mechid);\r
- a.setMachine(arti.machine);\r
- a.setSponsor(arti.sponsor);\r
- a.setAppName(arti.appName);\r
- a.setCa(arti.ca);\r
- a.setDir(arti.dir);\r
- a.getType().addAll(arti.type(false));\r
- a.setOsUser(arti.os_user);\r
- a.setRenewDays(arti.renewDays);\r
- a.setNotification(arti.notify);\r
- artis.getArtifact().add(a);\r
- }\r
- return Result.ok(artis);\r
- } else {\r
- return Result.err(lArtiDAO);\r
- }\r
- }\r
- \r
- \r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.service;\r
-\r
-import java.io.IOException;\r
-import java.net.InetAddress;\r
-import java.net.UnknownHostException;\r
-import java.nio.ByteBuffer;\r
-import java.security.NoSuchAlgorithmException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.cm.api.API_Cert;\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.authz.cm.data.CertDrop;\r
-import org.onap.aaf.authz.cm.data.CertRenew;\r
-import org.onap.aaf.authz.cm.data.CertReq;\r
-import org.onap.aaf.authz.cm.data.CertResp;\r
-import org.onap.aaf.authz.cm.validation.Validator;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.authz.org.Organization;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.authz.org.Organization.Identity;\r
-import org.onap.aaf.dao.CassAccess;\r
-import org.onap.aaf.dao.DAO;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;\r
-import org.onap.aaf.dao.aaf.cass.CacheInfoDAO;\r
-import org.onap.aaf.dao.aaf.cass.CertDAO;\r
-import org.onap.aaf.dao.aaf.cass.CredDAO;\r
-import org.onap.aaf.dao.aaf.cass.HistoryDAO;\r
-import org.onap.aaf.dao.aaf.cass.Status;\r
-import org.onap.aaf.dao.aaf.hl.Question;\r
-\r
-import org.onap.aaf.cadi.Hash;\r
-import org.onap.aaf.cadi.aaf.AAFPermission;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFCon;\r
-import org.onap.aaf.cadi.cm.Factory;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Slot;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-import com.datastax.driver.core.Cluster;\r
-\r
-\r
-public class CMService {\r
- // If we add more CAs, may want to parameterize\r
- private static final int STD_RENEWAL = 30;\r
- private static final int MAX_RENEWAL = 60;\r
- private static final int MIN_RENEWAL = 10;\r
- \r
- public static final String REQUEST = "request";\r
- public static final String RENEW = "renew";\r
- public static final String DROP = "drop";\r
- public static final String SANS = "san";\r
- \r
- private static final String[] NO_NOTES = new String[0];\r
- private Slot sCertAuth;\r
- private final CertDAO certDAO;\r
- private final CredDAO credDAO;\r
- private final ArtiDAO artiDAO;\r
- private DAO<AuthzTrans, ?>[] daos;\r
-\r
- @SuppressWarnings("unchecked")\r
- public CMService(AuthzTrans trans, CertManAPI certman) throws APIException, IOException {\r
-\r
- sCertAuth = certman.env.slot(API_Cert.CERT_AUTH);\r
- Cluster cluster;\r
- try {\r
- cluster = org.onap.aaf.dao.CassAccess.cluster(certman.env,null);\r
- } catch (IOException e) {\r
- throw new APIException(e);\r
- }\r
-\r
- // jg 4/2015 SessionFilter unneeded... DataStax already deals with Multithreading well\r
- \r
- HistoryDAO hd = new HistoryDAO(trans, cluster, CassAccess.KEYSPACE);\r
- CacheInfoDAO cid = new CacheInfoDAO(trans, hd);\r
- certDAO = new CertDAO(trans, hd, cid);\r
- credDAO = new CredDAO(trans, hd, cid);\r
- artiDAO = new ArtiDAO(trans, hd, cid);\r
- \r
- daos =(DAO<AuthzTrans, ?>[]) new DAO<?,?>[] {\r
- hd,cid,certDAO,credDAO,artiDAO\r
- };\r
-\r
- // Setup Shutdown Hooks for Cluster and Pooled Sessions\r
- Runtime.getRuntime().addShutdownHook(new Thread() {\r
- @Override\r
- public void run() {\r
- for(DAO<AuthzTrans,?> dao : daos) {\r
- dao.close(trans);\r
- }\r
-\r
-// sessionFilter.destroy();\r
- cluster.close();\r
- }\r
- }); \r
- }\r
- \r
- public Result<CertResp> requestCert(AuthzTrans trans,Result<CertReq> req) {\r
- if(req.isOK()) {\r
- CA ca = trans.get(sCertAuth, null);\r
- if(ca==null) {\r
- return Result.err(Result.err(Result.ERR_BadData, "Invalid Cert Authority requested"));\r
- }\r
-\r
- // Allow only AAF CA without special permission\r
- if(!ca.getName().equals("aaf") && !trans.fish( new AAFPermission(ca.getPermType(), ca.getName(), REQUEST))) {\r
- return Result.err(Status.ERR_Denied, "'%s' does not have permission to request Certificates from Certificate Authority '%s'", \r
- trans.user(),ca.getName());\r
- }\r
-\r
- List<String> notes = null;\r
- List<String> fqdns;\r
- String email = null;\r
-\r
- try {\r
- Organization org = trans.org();\r
- \r
- // Policy 1: Requests are only by Pre-Authorized Configurations\r
- ArtiDAO.Data add = null;\r
- try {\r
- for(InetAddress ia : InetAddress.getAllByName(trans.ip())) {\r
- Result<List<ArtiDAO.Data>> ra = artiDAO.read(trans, req.value.mechid,ia.getHostName());\r
- if(ra.isOKhasData()) {\r
- add = ra.value.get(0);\r
- break;\r
- }\r
- }\r
- } catch (UnknownHostException e1) {\r
- return Result.err(Result.ERR_BadData,"There is no host for %s",trans.ip());\r
- }\r
- \r
- if(add==null) {\r
- return Result.err(Result.ERR_BadData,"There is no configuration for %s",req.value.mechid);\r
- }\r
- \r
- // Policy 2: If Config marked as Expired, do not create or renew\r
- Date now = new Date();\r
- if(add.expires!=null && now.after(add.expires)) {\r
- return Result.err(Result.ERR_Policy,"Configuration for %s %s is expired %s",add.mechid,add.machine,Chrono.dateFmt.format(add.expires));\r
- }\r
- \r
- // Policy 3: MechID must be current\r
- Identity muser = org.getIdentity(trans, add.mechid);\r
- if(muser == null) {\r
- return Result.err(Result.ERR_Policy,"MechID must exist in %s",org.getName());\r
- }\r
- \r
- // Policy 4: Sponsor must be current\r
- Identity ouser = muser.owner();\r
- if(ouser==null) {\r
- return Result.err(Result.ERR_Policy,"%s does not have a current sponsor at %s",add.mechid,org.getName());\r
- } else if(!ouser.isFound() || !ouser.isResponsible()) {\r
- return Result.err(Result.ERR_Policy,"%s reports that %s cannot be responsible for %s",org.getName(),trans.user());\r
- }\r
- \r
- // Set Email from most current Sponsor\r
- email = ouser.email();\r
- \r
- // Policy 5: keep Artifact data current\r
- if(!ouser.fullID().equals(add.sponsor)) {\r
- add.sponsor = ouser.fullID();\r
- artiDAO.update(trans, add);\r
- }\r
- \r
- // Policy 6: Requester must be granted Change permission in Namespace requested\r
- String mechNS = AAFCon.reverseDomain(req.value.mechid);\r
- if(mechNS==null) {\r
- return Result.err(Status.ERR_Denied, "%s does not reflect a valid AAF Namespace",req.value.mechid);\r
- }\r
- \r
- // Policy 7: Caller must be the MechID or have specifically delegated permissions\r
- if(!trans.user().equals(req.value.mechid) && !trans.fish(new AAFPermission(mechNS + ".certman", ca.getName() , "request"))) {\r
- return Result.err(Status.ERR_Denied, "%s must have access to modify x509 certs in NS %s",trans.user(),mechNS);\r
- }\r
- \r
- \r
- // Policy 8: SANs only allowed by Exception... need permission\r
- fqdns = new ArrayList<String>();\r
- fqdns.add(add.machine); // machine is first\r
- if(req.value.fqdns.size()>1 && !trans.fish(new AAFPermission(ca.getPermType(), ca.getName(), SANS))) {\r
- if(notes==null) {notes = new ArrayList<String>();}\r
- notes.add("Warning: Subject Alternative Names only allowed by Permission: Get CSO Exception. This Certificate will be created, but without SANs");\r
- } else {\r
- for(String m : req.value.fqdns) {\r
- if(!add.machine.equals(m)) {\r
- fqdns.add(m);\r
- }\r
- }\r
- }\r
- \r
- } catch (Exception e) {\r
- trans.error().log(e);\r
- return Result.err(Status.ERR_Denied,"MechID Sponsorship cannot be determined at this time. Try later");\r
- }\r
- \r
- CSRMeta csrMeta;\r
- try {\r
- csrMeta = BCFactory.createCSRMeta(\r
- ca, \r
- req.value.mechid, \r
- email, \r
- fqdns);\r
- X509Certificate x509 = ca.sign(trans, csrMeta);\r
- if(x509==null) {\r
- return Result.err(Result.ERR_ActionNotCompleted,"x509 Certificate not signed by CA");\r
- }\r
- CertDAO.Data cdd = new CertDAO.Data();\r
- cdd.ca=ca.getName();\r
- cdd.serial=x509.getSerialNumber();\r
- cdd.id=req.value.mechid;\r
- cdd.x500=x509.getSubjectDN().getName();\r
- cdd.x509=Factory.toString(trans, x509);\r
- certDAO.create(trans, cdd);\r
- \r
- CredDAO.Data crdd = new CredDAO.Data();\r
- crdd.other = Question.random.nextInt();\r
- crdd.cred=getChallenge256SaltedHash(csrMeta.challenge(),crdd.other);\r
- crdd.expires = x509.getNotAfter();\r
- crdd.id = req.value.mechid;\r
- crdd.ns = Question.domain2ns(crdd.id);\r
- crdd.type = CredDAO.CERT_SHA256_RSA;\r
- credDAO.create(trans, crdd);\r
- \r
- CertResp cr = new CertResp(trans,x509,csrMeta, compileNotes(notes));\r
- return Result.ok(cr);\r
- } catch (Exception e) {\r
- trans.error().log(e);\r
- return Result.err(Result.ERR_ActionNotCompleted,e.getMessage());\r
- }\r
- } else {\r
- return Result.err(req);\r
- }\r
- }\r
-\r
- public Result<CertResp> renewCert(AuthzTrans trans, Result<CertRenew> renew) {\r
- if(renew.isOK()) {\r
- return Result.err(Result.ERR_NotImplemented,"Not implemented yet");\r
- } else {\r
- return Result.err(renew);\r
- } \r
- }\r
-\r
- public Result<Void> dropCert(AuthzTrans trans, Result<CertDrop> drop) {\r
- if(drop.isOK()) {\r
- return Result.err(Result.ERR_NotImplemented,"Not implemented yet");\r
- } else {\r
- return Result.err(drop);\r
- } \r
- }\r
-\r
- ///////////////\r
- // Artifact\r
- //////////////\r
- public Result<Void> createArtifact(AuthzTrans trans, List<ArtiDAO.Data> list) {\r
- Validator v = new Validator().artisRequired(list, 1);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
- for(ArtiDAO.Data add : list) {\r
- try {\r
- // Policy 1: MechID must exist in Org\r
- Identity muser = trans.org().getIdentity(trans, add.mechid);\r
- if(muser == null) {\r
- return Result.err(Result.ERR_Denied,"%s is not valid for %s", add.mechid,trans.org().getName());\r
- }\r
- \r
- // Policy 2: MechID must have valid Organization Owner\r
- Identity ouser = muser.owner();\r
- if(ouser == null) {\r
- return Result.err(Result.ERR_Denied,"%s is not a valid Sponsor for %s at %s",\r
- trans.user(),add.mechid,trans.org().getName());\r
- }\r
- \r
- // Policy 3: Calling ID must be MechID Owner\r
- if(!trans.user().equals(ouser.fullID())) {\r
- return Result.err(Result.ERR_Denied,"%s is not the Sponsor for %s at %s",\r
- trans.user(),add.mechid,trans.org().getName());\r
- }\r
-\r
- // Policy 4: Renewal Days are between 10 and 60 (constants, may be parameterized)\r
- if(add.renewDays<MIN_RENEWAL) {\r
- add.renewDays = STD_RENEWAL;\r
- } else if(add.renewDays>MAX_RENEWAL) {\r
- add.renewDays = MAX_RENEWAL;\r
- }\r
- \r
- // Policy 5: If Notify is blank, set to Owner's Email\r
- if(add.notify==null || add.notify.length()==0) {\r
- add.notify = "mailto:"+ouser.email();\r
- }\r
-\r
- // Set Sponsor from Golden Source\r
- add.sponsor = ouser.fullID();\r
- \r
- \r
- } catch (OrganizationException e) {\r
- return Result.err(e);\r
- }\r
- // Add to DB\r
- Result<ArtiDAO.Data> rv = artiDAO.create(trans, add);\r
- // TODO come up with Partial Reporting Scheme, or allow only one at a time.\r
- if(rv.notOK()) {\r
- return Result.err(rv);\r
- }\r
- }\r
- return Result.ok();\r
- }\r
-\r
- public Result<List<ArtiDAO.Data>> readArtifacts(AuthzTrans trans, ArtiDAO.Data add) throws OrganizationException {\r
- Validator v = new Validator().keys(add);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
- String ns = AAFCon.reverseDomain(add.mechid);\r
- \r
- if( trans.user().equals(add.mechid)\r
- || trans.fish(new AAFPermission(ns + ".access", "*", "read"))\r
- || (trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,add.mechid))==null) {\r
- return artiDAO.read(trans, add);\r
- } else {\r
- return Result.err(Result.ERR_Denied,"%s is not %s, is not the sponsor, and doesn't have delegated permission.",trans.user(),add.mechid); // note: reason is set by 2nd case, if 1st case misses\r
- }\r
-\r
- }\r
-\r
- public Result<List<ArtiDAO.Data>> readArtifactsByMechID(AuthzTrans trans, String mechid) throws OrganizationException {\r
- Validator v = new Validator().nullOrBlank("mechid", mechid);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
- String ns = AAFCon.reverseDomain(mechid);\r
- \r
- String reason;\r
- if(trans.fish(new AAFPermission(ns + ".access", "*", "read"))\r
- || (reason=trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,mechid))==null) {\r
- return artiDAO.readByMechID(trans, mechid);\r
- } else {\r
- return Result.err(Result.ERR_Denied,reason); // note: reason is set by 2nd case, if 1st case misses\r
- }\r
-\r
- }\r
-\r
- public Result<List<ArtiDAO.Data>> readArtifactsByMachine(AuthzTrans trans, String machine) {\r
- Validator v = new Validator().nullOrBlank("machine", machine);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
- \r
- // TODO do some checks?\r
-\r
- Result<List<ArtiDAO.Data>> rv = artiDAO.readByMachine(trans, machine);\r
- return rv;\r
- }\r
-\r
- public Result<Void> updateArtifact(AuthzTrans trans, List<ArtiDAO.Data> list) throws OrganizationException {\r
- Validator v = new Validator().artisRequired(list, 1);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
- \r
- // Check if requesting User is Sponsor\r
- //TODO - Shall we do one, or multiples?\r
- for(ArtiDAO.Data add : list) {\r
- // Policy 1: MechID must exist in Org\r
- Identity muser = trans.org().getIdentity(trans, add.mechid);\r
- if(muser == null) {\r
- return Result.err(Result.ERR_Denied,"%s is not valid for %s", add.mechid,trans.org().getName());\r
- }\r
- \r
- // Policy 2: MechID must have valid Organization Owner\r
- Identity ouser = muser.owner();\r
- if(ouser == null) {\r
- return Result.err(Result.ERR_Denied,"%s is not a valid Sponsor for %s at %s",\r
- trans.user(),add.mechid,trans.org().getName());\r
- }\r
-\r
- // Policy 3: Renewal Days are between 10 and 60 (constants, may be parameterized)\r
- if(add.renewDays<MIN_RENEWAL) {\r
- add.renewDays = STD_RENEWAL;\r
- } else if(add.renewDays>MAX_RENEWAL) {\r
- add.renewDays = MAX_RENEWAL;\r
- }\r
-\r
- // Policy 4: Data is always updated with the latest Sponsor\r
- // Add to Sponsor, to make sure we are always up to date.\r
- add.sponsor = ouser.fullID();\r
-\r
- // Policy 5: If Notify is blank, set to Owner's Email\r
- if(add.notify==null || add.notify.length()==0) {\r
- add.notify = "mailto:"+ouser.email();\r
- }\r
-\r
- // Policy 4: only Owner may update info\r
- if(trans.user().equals(add.sponsor)) {\r
- return artiDAO.update(trans, add);\r
- } else {\r
- return Result.err(Result.ERR_Denied,"%s may not update info for %s",trans.user(),muser.fullID());\r
- }\r
- \r
- }\r
- return Result.err(Result.ERR_BadData,"No Artifacts to update");\r
- }\r
- \r
- public Result<Void> deleteArtifact(AuthzTrans trans, String mechid, String machine) throws OrganizationException {\r
- Validator v = new Validator()\r
- .nullOrBlank("mechid", mechid)\r
- .nullOrBlank("machine", machine);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
-\r
- Result<List<ArtiDAO.Data>> rlad = artiDAO.read(trans, mechid, machine);\r
- if(rlad.notOKorIsEmpty()) {\r
- return Result.err(Result.ERR_NotFound,"Artifact for %s %s does not exist.",mechid,machine);\r
- }\r
- \r
- return deleteArtifact(trans,rlad.value.get(0));\r
- }\r
- \r
- private Result<Void> deleteArtifact(AuthzTrans trans, ArtiDAO.Data add) throws OrganizationException {\r
- // Policy 1: Record should be delete able only by Existing Sponsor. \r
- String sponsor=null;\r
- Identity muser = trans.org().getIdentity(trans, add.mechid);\r
- if(muser != null) {\r
- Identity ouser = muser.owner();\r
- if(ouser!=null) {\r
- sponsor = ouser.fullID();\r
- }\r
- }\r
- // Policy 1.a: If Sponsorship is deleted in system of Record, then \r
- // accept deletion by sponsor in Artifact Table\r
- if(sponsor==null) {\r
- sponsor = add.sponsor;\r
- }\r
- \r
- String ns = AAFCon.reverseDomain(add.mechid);\r
-\r
- if(trans.fish(new AAFPermission(ns + ".access", "*", "write"))\r
- || trans.user().equals(sponsor)) {\r
- return artiDAO.delete(trans, add, false);\r
- }\r
- return null;\r
- }\r
-\r
- public Result<Void> deleteArtifact(AuthzTrans trans, List<ArtiDAO.Data> list) {\r
- Validator v = new Validator().artisRequired(list, 1);\r
- if(v.err()) {\r
- return Result.err(Result.ERR_BadData,v.errs());\r
- }\r
-\r
- try {\r
- boolean partial = false;\r
- Result<Void> result=null;\r
- for(ArtiDAO.Data add : list) {\r
- result = deleteArtifact(trans, add);\r
- if(result.notOK()) {\r
- partial = true;\r
- }\r
- }\r
- if(result == null) {\r
- result = Result.err(Result.ERR_BadData,"No Artifacts to delete"); \r
- } else if(partial) {\r
- result.partialContent(true);\r
- }\r
- return result;\r
- } catch(Exception e) {\r
- return Result.err(e);\r
- }\r
- }\r
-\r
- private String[] compileNotes(List<String> notes) {\r
- String[] rv;\r
- if(notes==null) {\r
- rv = NO_NOTES;\r
- } else {\r
- rv = new String[notes.size()];\r
- notes.toArray(rv);\r
- }\r
- return rv;\r
- }\r
-\r
- private ByteBuffer getChallenge256SaltedHash(String challenge, int salt) throws NoSuchAlgorithmException {\r
- ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE + challenge.length());\r
- bb.putInt(salt);\r
- bb.put(challenge.getBytes());\r
- byte[] hash = Hash.hashSHA256(bb.array());\r
- return ByteBuffer.wrap(hash);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.service;\r
-\r
-import java.lang.reflect.Constructor;\r
-import java.util.ArrayList;\r
-import java.util.EnumSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.TreeMap;\r
-\r
-import org.onap.aaf.authz.cm.api.API_Artifact;\r
-import org.onap.aaf.authz.cm.api.API_Cert;\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.facade.Facade1_0;\r
-import org.onap.aaf.authz.cm.facade.FacadeFactory;\r
-import org.onap.aaf.authz.cm.mapper.Mapper.API;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.env.AuthzTransFilter;\r
-import org.onap.aaf.authz.server.AbsServer;\r
-import org.onap.aaf.cache.Cache;\r
-import org.onap.aaf.cache.Cache.Dated;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import com.att.aft.dme2.api.DME2Exception;\r
-//import com.att.aft.dme2.api.DME2FilterHolder;\r
-//import com.att.aft.dme2.api.DME2FilterHolder.RequestDispatcherType;\r
-import com.att.aft.dme2.api.DME2Manager;\r
-import com.att.aft.dme2.api.DME2Server;\r
-import com.att.aft.dme2.api.DME2ServerProperties;\r
-import com.att.aft.dme2.api.DME2ServiceHolder;\r
-import com.att.aft.dme2.api.util.DME2FilterHolder;\r
-import com.att.aft.dme2.api.util.DME2FilterHolder.RequestDispatcherType;\r
-import com.att.aft.dme2.api.util.DME2ServletHolder;\r
-import org.onap.aaf.cadi.Access;\r
-import org.onap.aaf.cadi.Access.Level;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.TrustChecker;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFCon;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.Trans;\r
-import org.onap.aaf.inno.env.util.Split;\r
-\r
-public class CertManAPI extends AbsServer {\r
-\r
- private static final String USER_PERMS = "userPerms";\r
- private static final Map<String,CA> certAuths = new TreeMap<String,CA>();\r
- private static final String AAF_CERTMAN_CA_PREFIX = null;\r
- public Facade1_0 facade1_0; // this is the default Facade\r
- public Facade1_0 facade1_0_XML; // this is the XML Facade\r
- public Map<String, Dated> cacheUser;\r
- public AAFAuthn<?> aafAuthn;\r
- public AAFLurPerm aafLurPerm;\r
-\r
- private String[] EMPTY;\r
- private AAFCon<?> aafcon;\r
- \r
- /**\r
- * Construct AuthzAPI with all the Context Supporting Routes that Authz needs\r
- * \r
- * @param env\r
- * @param si \r
- * @param dm \r
- * @param decryptor \r
- * @throws APIException \r
- */\r
- public CertManAPI(AuthzEnv env) throws Exception {\r
- super(env,"CertMan");\r
- env.setLog4JNames("log4j.properties","authz","cm","audit","init","trace");\r
- \r
- //aafcon = new AAFConHttp(env);\r
- \r
- aafLurPerm = aafcon.newLur();\r
- // Note: If you need both Authn and Authz construct the following:\r
- aafAuthn = aafcon.newAuthn(aafLurPerm);\r
-\r
- String aaf_env = env.getProperty(Config.AAF_ENV);\r
- if(aaf_env==null) {\r
- throw new APIException("aaf_env needs to be set");\r
- }\r
- \r
- // Initialize Facade for all uses\r
- AuthzTrans trans = env.newTrans();\r
- \r
- // Load Supported Certificate Authorities by property \r
- for(String key : env.existingStaticSlotNames()) {\r
- if(key.startsWith(AAF_CERTMAN_CA_PREFIX)) {\r
- int idx = key.indexOf('.');\r
- String[] params = Split.split(';', env.getProperty(key));\r
- if(params.length>1) {\r
- @SuppressWarnings("unchecked")\r
- Class<CA> cac = (Class<CA>)Class.forName((String)params[0]);\r
- Class<?> ptype[] = new Class<?>[params.length+1];\r
- ptype[0]=Trans.class;\r
- ptype[1]=String.class;\r
- Object pinst[] = new Object[params.length+1];\r
- pinst[0]=trans;\r
- pinst[1]= key.substring(idx+1);\r
- for(int i=1;i<params.length;++i) {\r
- idx = i+1;\r
- ptype[idx]=String.class;\r
- pinst[idx]=params[i];\r
- }\r
- Constructor<CA> cons = cac.getConstructor(ptype);\r
- CA ca = cons.newInstance(pinst);\r
- certAuths.put(ca.getName(),ca);\r
- }\r
- }\r
- }\r
- if(certAuths.size()==0) {\r
- throw new APIException("No Certificate Authorities have been configured in CertMan");\r
- }\r
- \r
- CMService service = new CMService(trans, this);\r
- // note: Service knows how to shutdown Cluster on Shutdown, etc. See Constructor\r
- facade1_0 = FacadeFactory.v1_0(this,trans, service,Data.TYPE.JSON); // Default Facade\r
- facade1_0_XML = FacadeFactory.v1_0(this,trans,service,Data.TYPE.XML); \r
- \r
-\r
- synchronized(env) {\r
- if(cacheUser == null) {\r
- cacheUser = Cache.obtain(USER_PERMS);\r
- Cache.startCleansing(env, USER_PERMS);\r
- Cache.addShutdownHook(); // Setup Shutdown Hook to close cache\r
- }\r
- }\r
- \r
- ////////////////////////////////////////////////////////////////////////////\r
- // APIs\r
- ////////////////////////////////////////////////////////////////////////\r
- API_Cert.init(this);\r
- API_Artifact.init(this);\r
- \r
- StringBuilder sb = new StringBuilder();\r
- trans.auditTrail(2, sb);\r
- trans.init().log(sb);\r
- }\r
- \r
- public CA getCA(String key) {\r
- return certAuths.get(key);\r
- }\r
-\r
- public String[] getTrustChain(String key) {\r
- CA ca = certAuths.get(key);\r
- if(ca==null) {\r
- return EMPTY;\r
- } else {\r
- return ca.getTrustChain();\r
- }\r
- }\r
-\r
- /**\r
- * Setup XML and JSON implementations for each supported Version type\r
- * \r
- * We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties\r
- * to do Versions and Content switches\r
- * \r
- */\r
- public void route(HttpMethods meth, String path, API api, Code code) throws Exception {\r
- String version = "1.0";\r
- // Get Correct API Class from Mapper\r
- Class<?> respCls = facade1_0.mapper().getClass(api); \r
- if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());\r
- // setup Application API HTML ContentTypes for JSON and Route\r
- String application = applicationJSON(respCls, version);\r
- route(env,meth,path,code,application,"application/json;version="+version,"*/*");\r
-\r
- // setup Application API HTML ContentTypes for XML and Route\r
- application = applicationXML(respCls, version);\r
- route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version);\r
- \r
- // Add other Supported APIs here as created\r
- }\r
- \r
- public void routeAll(HttpMethods meth, String path, API api, Code code) throws Exception {\r
- route(env,meth,path,code,""); // this will always match\r
- }\r
-\r
-\r
- /**\r
- * Start up AuthzAPI as DME2 Service\r
- * @param env\r
- * @param props\r
- * @throws DME2Exception\r
- * @throws CadiException \r
- */\r
- public void startDME2(Properties props) throws DME2Exception, CadiException {\r
- DME2Manager dme2 = new DME2Manager("AAF Certman DME2Manager", props);\r
-\r
-\r
- DME2ServiceHolder svcHolder;\r
- List<DME2ServletHolder> slist = new ArrayList<DME2ServletHolder>();\r
- svcHolder = new DME2ServiceHolder();\r
- String serviceName = env.getProperty("DMEServiceName",null);\r
- if(serviceName!=null) {\r
- svcHolder.setServiceURI(serviceName);\r
- svcHolder.setManager(dme2);\r
- svcHolder.setContext("/");\r
- \r
- \r
- \r
- DME2ServletHolder srvHolder = new DME2ServletHolder(this, new String[]{"/cert"});\r
- srvHolder.setContextPath("/*");\r
- slist.add(srvHolder);\r
- \r
- EnumSet<RequestDispatcherType> edlist = EnumSet.of(\r
- RequestDispatcherType.REQUEST,\r
- RequestDispatcherType.FORWARD,\r
- RequestDispatcherType.ASYNC\r
- );\r
-\r
- ///////////////////////\r
- // Apply Filters\r
- ///////////////////////\r
- List<DME2FilterHolder> flist = new ArrayList<DME2FilterHolder>();\r
- \r
- // Secure all GUI interactions with AuthzTransFilter\r
- flist.add(new DME2FilterHolder(\r
- new AuthzTransFilter(env,aafcon,TrustChecker.NOTRUST),\r
- "/*", edlist));\r
- \r
-\r
- svcHolder.setFilters(flist);\r
- svcHolder.setServletHolders(slist);\r
- \r
- DME2Server dme2svr = dme2.getServer();\r
- DME2ServerProperties dsprops = dme2svr.getServerProperties();\r
- dsprops.setGracefulShutdownTimeMs(1000);\r
- \r
- env.init().log("Starting AAF Certman Jetty/DME2 server...");\r
- dme2svr.start();\r
- try {\r
-// if(env.getProperty("NO_REGISTER",null)!=null)\r
- dme2.bindService(svcHolder);\r
- env.init().log("DME2 is available as HTTP"+(dsprops.isSslEnable()?"/S":""),"on port:",dsprops.getPort());\r
- while(true) { // Per DME2 Examples...\r
- Thread.sleep(5000);\r
- }\r
- } catch(InterruptedException e) {\r
- env.init().log("AAF Jetty Server interrupted!");\r
- } catch(Exception e) { // Error binding service doesn't seem to stop DME2 or Process\r
- env.init().log(e,"DME2 Initialization Error");\r
- dme2svr.stop();\r
- System.exit(1);\r
- }\r
- } else {\r
- env.init().log("Properties must contain DMEServiceName");\r
- }\r
- }\r
-\r
- public static void main(String[] args) {\r
- setup(CertManAPI.class, "certman.props");\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.service;\r
-\r
-import org.onap.aaf.authz.cm.facade.Facade1_0;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.cssa.rserv.HttpCode;\r
-\r
-public abstract class Code extends HttpCode<AuthzTrans,Facade1_0> implements Cloneable {\r
-\r
- public Code(CertManAPI cma, String description, String ... roles) {\r
- super(cma.facade1_0, description, roles);\r
- // Note, the first "Code" will be created with default Facade, "JSON".\r
- // use clone for another Code with XML\r
- }\r
- \r
-\r
- public <D extends Code> D clone(Facade1_0 facade) throws Exception {\r
- @SuppressWarnings("unchecked")\r
- D d = (D)clone();\r
- d.context = facade;\r
- return d;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.validation;\r
-\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO;\r
-import org.onap.aaf.dao.aaf.cass.ArtiDAO.Data;\r
-\r
-/**\r
- * Validator\r
- * Consistently apply content rules for content (incoming)\r
- * \r
- * Note: We restrict content for usability in URLs (because RESTful service), and avoid \r
- * issues with Regular Expressions, and other enabling technologies. \r
- *\r
- */\r
-public class Validator {\r
- // Repeated Msg fragments\r
- private static final String MECHID = "mechid";\r
- private static final String MACHINE = "machine";\r
- private static final String ARTIFACT_LIST_IS_NULL = "Artifact List is null.";\r
- private static final String Y = "y.";\r
- private static final String IES = "ies.";\r
- private static final String ENTR = " entr";\r
- private static final String MUST_HAVE_AT_LEAST = " must have at least ";\r
- private static final String IS_NULL = " is null.";\r
- private static final String ARTIFACTS_MUST_HAVE_AT_LEAST = "Artifacts must have at least ";\r
- private StringBuilder msgs;\r
-\r
- public Validator nullOrBlank(String name, String str) {\r
- if(str==null) {\r
- msg(name + IS_NULL);\r
- } else if(str.length()==0) {\r
- msg(name + " is blank.");\r
- }\r
- return this;\r
- }\r
- \r
- private void msg(String ... strs) {\r
- if(msgs==null) {\r
- msgs=new StringBuilder();\r
- }\r
- for(String str : strs) {\r
- msgs.append(str);\r
- }\r
- msgs.append('\n');\r
- }\r
- \r
- public boolean err() {\r
- return msgs!=null;\r
- }\r
- \r
- public String errs() {\r
- return msgs.toString();\r
- }\r
-\r
- public Validator notOK(Result<?> res) {\r
- if(res==null) {\r
- msgs.append("Result object is blank");\r
- } else if(res.notOK()) {\r
- msgs.append(res.getClass().getSimpleName() + " is not OK");\r
- }\r
- return this;\r
- }\r
-\r
- public Validator isNull(String name, Object obj) {\r
- if(obj==null) {\r
- msg(name + IS_NULL);\r
- } \r
- return this;\r
- }\r
-\r
- public Validator nullBlankMin(String name, List<String> list, int min) {\r
- if(list==null) {\r
- msg(name + IS_NULL);\r
- } else {\r
- if(list.size()<min) {\r
- msg(name + MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));\r
- } else {\r
- for(String s : list) {\r
- nullOrBlank("List Item",s);\r
- }\r
- }\r
- }\r
- return this;\r
- }\r
-\r
- public Validator artisRequired(List<ArtiDAO.Data> list, int min) {\r
- if(list==null) {\r
- msg(ARTIFACT_LIST_IS_NULL);\r
- } else {\r
- if(list.size()<min) {\r
- msg(ARTIFACTS_MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));\r
- } else {\r
- for(ArtiDAO.Data a : list) {\r
- allRequired(a);\r
- }\r
- }\r
- }\r
- return this;\r
- }\r
-\r
- public Validator artisKeys(List<ArtiDAO.Data> list, int min) {\r
- if(list==null) {\r
- msg(ARTIFACT_LIST_IS_NULL);\r
- } else {\r
- if(list.size()<min) {\r
- msg(ARTIFACTS_MUST_HAVE_AT_LEAST + min + ENTR + (min==1?Y:IES));\r
- } else {\r
- for(ArtiDAO.Data a : list) {\r
- keys(a);\r
- }\r
- }\r
- }\r
- return this;\r
- }\r
-\r
-\r
- public Validator keys(ArtiDAO.Data add) {\r
- if(add==null) {\r
- msg("Artifact is null.");\r
- } else {\r
- nullOrBlank(MECHID, add.mechid);\r
- nullOrBlank(MACHINE, add.machine);\r
- }\r
- return this;\r
- }\r
- \r
- private Validator allRequired(Data a) {\r
- if(a==null) {\r
- msg("Artifact is null.");\r
- } else {\r
- nullOrBlank(MECHID, a.mechid);\r
- nullOrBlank(MACHINE, a.machine);\r
- nullOrBlank("ca",a.ca);\r
- nullOrBlank("dir",a.dir);\r
- nullOrBlank("os_user",a.os_user);\r
- // Note: AppName, Notify & Sponsor are currently not required\r
- }\r
- return this;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.api;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.api.API_Artifact;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_API_Artifact {\r
- \r
- @Mock\r
- private static API_Artifact api;\r
- \r
- @Mock\r
- private static CertManAPI certManApi;\r
- \r
- private static CertManAPI noMockAPI;\r
- private static API_Artifact api_1;\r
- \r
- private static HttpServletRequest req;\r
- private static HttpServletResponse res;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- AuthzTrans trans = mock(AuthzTrans.class);\r
- req = mock(HttpServletRequest.class);\r
- trans.setProperty("testTag", "UserValue");\r
- trans.set(req);\r
- }\r
- \r
- @Rule\r
- public ExpectedException thrown= ExpectedException.none();\r
- \r
- @Test\r
- public void init_bothValued() {\r
- try {\r
- api.init(certManApi);\r
- } catch (Exception e) {\r
- thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_Null_() {\r
- try {\r
- api.init(null);\r
- } catch (Exception e) {\r
- //thrown.expect(Exception.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_NMC_Null() {\r
- try {\r
- api_1.init(null);\r
- } catch (Exception e) {\r
- //thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_NMC() {\r
- try {\r
- api_1.init(noMockAPI);\r
- } catch (Exception e) {\r
- //thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.api;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.api.API_Cert;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_API_Cert {\r
- \r
- @Mock\r
- private static API_Cert api;\r
- \r
- @Mock\r
- private static CertManAPI certManApi;\r
- \r
- private static CertManAPI noMockAPI;\r
- private static API_Cert api_1;\r
- \r
- private static HttpServletRequest req;\r
- private static HttpServletResponse res;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- AuthzTrans trans = mock(AuthzTrans.class);\r
- req = mock(HttpServletRequest.class);\r
- trans.setProperty("testTag", "UserValue");\r
- trans.set(req);\r
- }\r
- \r
- @Rule\r
- public ExpectedException thrown= ExpectedException.none();\r
- \r
- @Test\r
- public void init_bothValued() {\r
- try {\r
- api.init(certManApi);\r
- } catch (Exception e) {\r
- //thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_Null_() {\r
- try {\r
- api.init(null);\r
- } catch (Exception e) {\r
- //thrown.expect(Exception.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_NMC_Null() {\r
- try {\r
- api_1.init(null);\r
- } catch (Exception e) {\r
- //thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void init_NMC() {\r
- try {\r
- api_1.init(noMockAPI);\r
- } catch (Exception e) {\r
- //thrown.expect(NullPointerException.class);\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.ca;\r
-\r
-import static org.mockito.Mockito.CALLS_REAL_METHODS;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-import java.math.BigInteger;\r
-import java.security.InvalidKeyException;\r
-import java.security.NoSuchAlgorithmException;\r
-import java.security.NoSuchProviderException;\r
-import java.security.Principal;\r
-import java.security.PublicKey;\r
-import java.security.SignatureException;\r
-import java.security.cert.CertificateEncodingException;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.CertificateExpiredException;\r
-import java.security.cert.CertificateNotYetValidException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.Date;\r
-import java.util.Set;\r
-\r
-import javax.security.auth.x500.X500Principal;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.ca.AppCA;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.dao.aaf.cached.CachedCertDAO;\r
-import org.onap.aaf.dao.aaf.cass.CertDAO;\r
-\r
-import com.att.aft.dme2.api.http.HttpResponse;\r
-import com.att.aft.dme2.request.HttpRequest;\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_AppCA {\r
- \r
- @Mock\r
- private static CachedCertDAO certDAO;\r
- \r
- @Mock\r
- private static HttpServletRequest req;\r
- \r
- @Mock\r
- private static CSRMeta csrMeta;\r
- \r
- static Trans trans;\r
- \r
- static X509Certificate cert;\r
- static byte [] name = {1,23,4,54,6,56};\r
- \r
- private static AppCA appCA;\r
- \r
- @BeforeClass\r
- public static void setUp() throws CertificateException, CertException, IOException {\r
- String str = "core java api";\r
- byte[] b = str.getBytes();\r
- Principal prc = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US");\r
- req = mock(HttpServletRequest.class);\r
- appCA = mock(AppCA.class);\r
- X509Certificate cert = new X509Certificate() {\r
- \r
- @Override\r
- public boolean hasUnsupportedCriticalExtension() {\r
- return false;\r
- }\r
- \r
- @Override\r
- public Set<String> getNonCriticalExtensionOIDs() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getExtensionValue(String oid) {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Set<String> getCriticalExtensionOIDs() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException,\r
- InvalidKeyException, NoSuchProviderException, SignatureException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,\r
- NoSuchProviderException, SignatureException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public String toString() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public PublicKey getPublicKey() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getEncoded() throws CertificateEncodingException {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public int getVersion() {\r
- \r
- return 0;\r
- }\r
- \r
- @Override\r
- public byte[] getTBSCertificate() throws CertificateEncodingException {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getSubjectUniqueID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Principal getSubjectDN() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getSignature() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getSigAlgParams() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public String getSigAlgOID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public String getSigAlgName() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public BigInteger getSerialNumber() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Date getNotBefore() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Date getNotAfter() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getKeyUsage() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getIssuerUniqueID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Principal getIssuerDN() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public int getBasicConstraints() {\r
- \r
- return 0;\r
- }\r
- \r
- @Override\r
- public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {\r
- \r
- }\r
- };\r
- when(appCA.sign(Mockito.any(Trans.class), Mockito.any(CSRMeta.class))).thenReturn(cert);\r
- certDAO = mock(CachedCertDAO.class, CALLS_REAL_METHODS);\r
- }\r
- \r
- @Test\r
- public void identity_True() throws CertificateException, IOException, CertException {\r
- assertNotNull(appCA.sign(trans, csrMeta));\r
- }\r
- \r
- \r
- @Test\r
- public void identityNull() throws CertificateException {\r
- try {\r
- assertNotNull(appCA.sign(null, csrMeta));\r
- } catch (IOException e) {\r
- \r
- e.printStackTrace();\r
- } catch (CertException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void identityBothNull() throws CertificateException {\r
- try {\r
- assertNotNull(appCA.sign(null, null));\r
- } catch (IOException e) {\r
- \r
- e.printStackTrace();\r
- } catch (CertException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.ca;\r
-\r
-import static org.mockito.Mockito.CALLS_REAL_METHODS;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-import java.math.BigInteger;\r
-import java.security.InvalidKeyException;\r
-import java.security.NoSuchAlgorithmException;\r
-import java.security.NoSuchProviderException;\r
-import java.security.Principal;\r
-import java.security.PublicKey;\r
-import java.security.SignatureException;\r
-import java.security.cert.CertificateEncodingException;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.CertificateExpiredException;\r
-import java.security.cert.CertificateNotYetValidException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.Date;\r
-import java.util.Set;\r
-\r
-import javax.security.auth.x500.X500Principal;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.InjectMocks;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.ca.DevlCA;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.dao.aaf.cached.CachedCertDAO;\r
-import org.onap.aaf.dao.aaf.cass.CertDAO;\r
-\r
-import com.att.aft.dme2.api.http.HttpResponse;\r
-import com.att.aft.dme2.request.HttpRequest;\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_DevlCA {\r
- \r
- @Mock\r
- private static CachedCertDAO certDAO;\r
- \r
- @Mock\r
- private static HttpServletRequest req;\r
- \r
- @Mock\r
- private static CSRMeta csrMeta;\r
- \r
- static Trans trans;\r
- \r
- static X509Certificate cert;\r
- static byte [] name = {1,23,4,54,6,56};\r
- \r
- private static DevlCA devICA;\r
- \r
- @BeforeClass\r
- public static void setUp() throws CertificateException, CertException, IOException {\r
- String str = "core java api";\r
- byte[] b = str.getBytes();\r
- Principal prc = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US");\r
- req = mock(HttpServletRequest.class);\r
- devICA = mock(DevlCA.class);\r
- X509Certificate cert = new X509Certificate() {\r
- \r
- @Override\r
- public boolean hasUnsupportedCriticalExtension() {\r
- return false;\r
- }\r
- \r
- @Override\r
- public Set<String> getNonCriticalExtensionOIDs() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getExtensionValue(String oid) {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Set<String> getCriticalExtensionOIDs() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException,\r
- InvalidKeyException, NoSuchProviderException, SignatureException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException,\r
- NoSuchProviderException, SignatureException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public String toString() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public PublicKey getPublicKey() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getEncoded() throws CertificateEncodingException {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public int getVersion() {\r
- \r
- return 0;\r
- }\r
- \r
- @Override\r
- public byte[] getTBSCertificate() throws CertificateEncodingException {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getSubjectUniqueID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Principal getSubjectDN() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getSignature() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public byte[] getSigAlgParams() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public String getSigAlgOID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public String getSigAlgName() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public BigInteger getSerialNumber() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Date getNotBefore() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Date getNotAfter() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getKeyUsage() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public boolean[] getIssuerUniqueID() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public Principal getIssuerDN() {\r
- \r
- return null;\r
- }\r
- \r
- @Override\r
- public int getBasicConstraints() {\r
- \r
- return 0;\r
- }\r
- \r
- @Override\r
- public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException {\r
- \r
- \r
- }\r
- \r
- @Override\r
- public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {\r
- \r
- }\r
- };\r
- when(devICA.sign(Mockito.any(Trans.class), Mockito.any(CSRMeta.class))).thenReturn(cert);\r
- certDAO = mock(CachedCertDAO.class, CALLS_REAL_METHODS);\r
- }\r
- \r
- @Test\r
- public void identity_True() throws CertificateException, IOException, CertException {\r
- assertNotNull(devICA.sign(trans, csrMeta));\r
- }\r
- \r
- \r
- @Test\r
- public void identityNull() throws CertificateException {\r
- try {\r
- assertNotNull(devICA.sign(null, csrMeta));\r
- } catch (IOException e) {\r
- \r
- e.printStackTrace();\r
- } catch (CertException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void identityBothNull() throws CertificateException {\r
- try {\r
- assertNotNull(devICA.sign(null, null));\r
- } catch (IOException e) {\r
- \r
- e.printStackTrace();\r
- } catch (CertException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.cert;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.security.Key;\r
-import java.security.PrivateKey;\r
-import java.security.PublicKey;\r
-\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;\r
-import org.junit.BeforeClass;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_BCFactory {\r
- \r
- private static BCFactory bcFactory = new BCFactory();\r
- \r
- private static BCFactory bcFact;\r
- \r
- private static PrivateKey pk;\r
- \r
- \r
- private static Trans trans;\r
- \r
- \r
- private static PKCS10CertificationRequest req;\r
- \r
- @BeforeClass\r
- public static void setUp() throws IOException {\r
- pk = new XYZKey();\r
- trans = mock(Trans.class);\r
- req = mock(PKCS10CertificationRequest.class);\r
- when(req.getEncoded()).thenReturn(new byte[1]);\r
- when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken(null, 0) {\r
- \r
- @Override\r
- public void output(StringBuilder sb) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
- });\r
- bcFact = mock(BCFactory.class);\r
- }\r
- \r
- @Test\r
- public void toStrin() throws OperatorCreationException, IOException, CertException {\r
- assertNotNull(bcFactory.toString(trans, req));\r
- }\r
- \r
- @Test\r
- public void toStrinMoc() throws OperatorCreationException, IOException, CertException {\r
- assertNotNull(bcFact.toString(trans, req));\r
- }\r
- \r
- @Rule\r
- public ExpectedException thrown= ExpectedException.none();\r
- \r
- @Test\r
- public void toCSR() {\r
- try {\r
- assertNotNull(bcFactory.toCSR(trans, new File("/random/path")));\r
- thrown.expect(FileNotFoundException.class);\r
- } catch (IOException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
- \r
-}\r
-\r
-class XYZKey implements Key, PublicKey, PrivateKey {\r
- \r
- int rotValue;\r
- public XYZKey() {\r
- rotValue = 1200213;\r
- }\r
- public String getAlgorithm() {\r
- return "XYZ";\r
- }\r
-\r
- public String getFormat() {\r
- return "XYZ Special Format";\r
- }\r
-\r
- public byte[] getEncoded() {\r
- byte b[] = new byte[4];\r
- b[3] = (byte) ((rotValue << 24) & 0xff);\r
- b[2] = (byte) ((rotValue << 16) & 0xff);\r
- b[1] = (byte) ((rotValue << 8) & 0xff);\r
- b[0] = (byte) ((rotValue << 0) & 0xff);\r
- return b;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.cert;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.io.IOException;\r
-import java.security.cert.CertificateException;\r
-import java.security.cert.X509Certificate;\r
-\r
-import org.bouncycastle.asn1.x500.X500Name;\r
-import org.bouncycastle.operator.OperatorCreationException;\r
-import org.bouncycastle.pkcs.PKCS10CertificationRequest;\r
-import org.junit.BeforeClass;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_CSRMeta {\r
- \r
- private static CSRMeta csrmeta;\r
- private static Trans trans;\r
- private static PKCS10CertificationRequest req;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- trans = mock(Trans.class);\r
- csrmeta = new CSRMeta();\r
- csrmeta.cn("CN");\r
- csrmeta.email("pupleti@ht.com");\r
- csrmeta.mechID("HAKJH787");\r
- csrmeta.o("O");\r
- csrmeta.l("L");\r
- csrmeta.st("ST");\r
- csrmeta.c("C");\r
- csrmeta.challenge("Challenge");\r
- csrmeta.san("CA");\r
- }\r
- \r
- @Test\r
- public void x500Name() throws IOException {\r
- \r
- X500Name x500 = csrmeta.x500Name();\r
- assertEquals(x500.toString(),"CN=CN,E=pupleti@ht.com,OU=HAKJH787,O=O,L=L,ST=ST,C=C");\r
- }\r
- \r
- @Test\r
- public void initialConversationCert() throws CertificateException, OperatorCreationException, IOException {\r
- X509Certificate cert = csrmeta.initialConversationCert(trans);\r
- assertEquals(cert.getBasicConstraints(),-1);\r
- }\r
- \r
- @Test\r
- public void generateCSR() throws IOException, CertException {\r
- req = csrmeta.generateCSR(trans);\r
- assertNotNull(req);\r
- }\r
- \r
- @Rule\r
- public ExpectedException thrown= ExpectedException.none();\r
- \r
- @Test\r
- public void dump() throws IOException, CertException {\r
- req = csrmeta.generateCSR(trans);\r
- csrmeta.dump(req);\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.data;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.IOException;\r
-import java.security.cert.X509Certificate;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.ca.CA;\r
-import org.onap.aaf.authz.cm.cert.BCFactory;\r
-import org.onap.aaf.authz.cm.cert.CSRMeta;\r
-import org.onap.aaf.authz.cm.cert.StandardFields;\r
-import org.onap.aaf.authz.cm.data.CertReq;\r
-\r
-import org.onap.aaf.cadi.cm.CertException;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_CertReq {\r
- \r
- private static BCFactory bcFact;\r
- \r
- private static CSRMeta value;\r
- \r
- private static CertReq req;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- bcFact = mock(BCFactory.class);\r
- value = mock(CSRMeta.class);\r
- req = mock(CertReq.class);\r
- \r
- }\r
- \r
- @Test\r
- public void getCSRMeta() throws CertException {\r
- //req = new CertReq();\r
- req.mechid = "1213";\r
- List<String> fqdnsas = new ArrayList<String>();\r
- fqdnsas.add("String1");\r
- List<String> emails = new ArrayList<String>();\r
- emails.add("pupleti@hotmail.com");\r
- req.emails = emails;\r
- req.fqdns = fqdnsas;\r
- StandardFields sf = mock(StandardFields.class);\r
- req.certAuthority = new CA("testName", sf, "ALL") {\r
- \r
- @Override\r
- public X509Certificate sign(Trans trans, CSRMeta csrmeta) throws IOException, CertException {\r
- \r
- return null;\r
- }\r
- };\r
- req.sponsor = "asa@df.co";\r
- assertNull(req.getCSRMeta());\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.cm.facade;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.CALLS_REAL_METHODS;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.ServletOutputStream;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import javax.xml.namespace.QName;\r
-import javax.xml.validation.Schema;\r
-\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.cm.facade.FacadeImpl;\r
-import org.onap.aaf.authz.cm.mapper.Mapper;\r
-import org.onap.aaf.authz.cm.service.CMService;\r
-import org.onap.aaf.authz.cm.service.CertManAPI;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-\r
-import org.onap.aaf.cadi.aaf.AAFPermission;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data;\r
-import org.onap.aaf.inno.env.LogTarget;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-import org.onap.aaf.rosetta.env.RosettaData;\r
-\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_FacadeImpl<REQ,CERT,ARTIFACTS,ERROR> {\r
- \r
- private static AuthzTrans trans;\r
- private static HttpServletResponse resp;\r
- private static CertManAPI certman;\r
- private static FacadeImpl hImpl;\r
- private static CMService service;\r
- private Mapper<REQ,CERT,ARTIFACTS,ERROR> mapper;\r
- private Data.TYPE dataType;\r
- private static AuthzEnv env;\r
- \r
- private static FacadeImpl fImpl;\r
- private static HttpServletRequest req;\r
- \r
- @Before\r
- public void setUp() throws APIException, IOException {\r
- fImpl = mock(FacadeImpl.class);\r
- env = mock(AuthzEnv.class);\r
- resp = mock(HttpServletResponse.class);\r
- req = mock(HttpServletRequest.class);\r
- hImpl = mock(FacadeImpl.class, CALLS_REAL_METHODS);\r
- Result<Void> rvd = (Result) mock(Result.class);\r
- trans = mock(AuthzTrans.class);\r
- when(trans.error()).thenReturn(new LogTarget() {\r
- \r
- @Override\r
- public void printf(String fmt, Object... vars) {}\r
- \r
- @Override\r
- public void log(Throwable e, Object... msgs) {\r
- e.getMessage();\r
- e.printStackTrace();\r
- msgs.toString();\r
- \r
- }\r
- \r
- @Override\r
- public void log(Object... msgs) {\r
- }\r
- \r
- @Override\r
- public boolean isLoggable() {\r
- \r
- return false;\r
- }\r
- });\r
- when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken("Now", 1) {\r
- \r
- @Override\r
- public void output(StringBuilder sb) {\r
- \r
- }\r
- });\r
- when(fImpl.check(Mockito.any(AuthzTrans.class), Mockito.any(HttpServletResponse.class), Mockito.anyString())).thenReturn(rvd);\r
- when(resp.getOutputStream()).thenReturn(new ServletOutputStream() {\r
- \r
- @Override\r
- public void write(int b) throws IOException {\r
- \r
- \r
- }\r
- });\r
- \r
- }\r
- \r
- @Test\r
- public void check() throws IOException {\r
- AAFPermission ap = new AAFPermission("str1","str3","str2");\r
- String perms = ap.getInstance();\r
- assertNotNull(hImpl.check(trans, resp, perms));\r
- }\r
- \r
- @Test\r
- public void checkNull() throws IOException {\r
- AAFPermission ap = new AAFPermission(null,"Str3","str2");\r
- String perms = ap.getInstance();\r
- assertNotNull(hImpl.check(trans, resp, perms));\r
- }\r
- \r
- @Test\r
- public void checkTwoNull() throws IOException {\r
- AAFPermission ap = new AAFPermission(null,null,"str2");\r
- String perms = ap.getInstance();\r
- assertNotNull(fImpl.check(trans, resp, perms));\r
- }\r
- \r
- @Test\r
- public void checkAllNull() throws IOException {\r
- AAFPermission ap = new AAFPermission(null,null,null);\r
- String perms = ap.getInstance();\r
- assertNotNull(fImpl.check(trans, resp, perms));\r
- }\r
- \r
- @Test\r
- public void checkTrans_null() throws IOException {\r
- AAFPermission ap = new AAFPermission("str1","str3","str2");\r
- String perms = ap.getInstance();\r
- assertNotNull(hImpl.check(null, resp, perms));\r
- }\r
- \r
- @Test\r
- public void checkRespNull() throws IOException {\r
- AAFPermission ap = new AAFPermission("str1","str3","str2");\r
- String perms = ap.getInstance();\r
- assertNotNull(hImpl.check(trans, null, perms));\r
- }\r
- \r
- @Test\r
- public void requestCert() { \r
- assertNotNull(hImpl.requestCert(trans, req, resp, true));\r
- }\r
- \r
- @Test\r
- public void renewCert() { \r
- assertNotNull(hImpl.renewCert(trans, req, resp, true));\r
- }\r
- \r
- @Test\r
- public void dropCert() { \r
- assertNotNull(hImpl.renewCert(trans, req, resp, true));\r
- }\r
- \r
- @Test\r
- public void createArtifacts() { \r
- assertNotNull(hImpl.createArtifacts(trans, req, resp));\r
- }\r
- \r
- @Test\r
- public void readArtifacts() { \r
- assertNotNull(hImpl.readArtifacts(trans, req, resp));\r
- }\r
-}\r
+++ /dev/null
-DIR=`pwd`
-#DME2REG=$DIR/../dme2reg
-DME2REG=/opt/dme2reg
-#CLASSPATH=etc:target/authz-cmd-1.0.0-SNAPSHOT-jar-with-dependencies.jar
-
-#java -cp $CLASSPATH \
- #-Dcadi_prop_files=../authz-service/src/main/sample/authAPI.props \
- #-DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG \
- #com.att.cmd.AAFcli $*
-
-CLASSPATH=/opt/app/aaf/authz-service/etc:/opt/app/aaf/authz-service/lib/authz-cmd-1.0.1-SNAPSHOT-jar-with-dependencies.jar
-#java -cp $CLASSPATH -Dcadi_prop_files=../authz-service/src/main/sample/authAPI.props -DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG com.att.cmd.AAFcli $*
-java -cp $CLASSPATH -Dcadi_prop_files=/opt/app/aaf/authz-service/etc/authAPI.props -DDME2_EP_REGISTRY_CLASS=DME2FS -DAFT_DME2_EP_REGISTRY_FS_DIR=$DME2REG org.onap.aaf.cmd.AAFcli $*
+++ /dev/null
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START====================================================\r
-# * org.onap.aaf\r
-# * ===========================================================================\r
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# * \r
-# * http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
-# * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-###############################################################################\r
-# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.\r
-###############################################################################\r
-#\r
-# Licensed to the Apache Software Foundation (ASF) under one\r
-# or more contributor license agreements. See the NOTICE file\r
-# distributed with this work for additional information\r
-# regarding copyright ownership. The ASF licenses this file\r
-# to you under the Apache License, Version 2.0 (the\r
-# "License"); you may not use this file except in compliance\r
-# with the License. You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing,\r
-# software distributed under the License is distributed on an\r
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
-# KIND, either express or implied. See the License for the\r
-# specific language governing permissions and limitations\r
-# under the License.\r
-#\r
-\r
-log4j.appender.SVR=org.apache.log4j.RollingFileAppender \r
-log4j.appender.SVR.File=${user.home}/.aaf/authz-cmd.log\r
-log4j.appender.SVR.MaxFileSize=10000KB\r
-log4j.appender.SVR.MaxBackupIndex=1\r
-log4j.appender.SVR.layout=org.apache.log4j.PatternLayout \r
-log4j.appender.SVR.layout.ConversionPattern=%d %p [%c] %m %n\r
-\r
-# General Apache libraries\r
-log4j.rootLogger=WARN,SVR\r
-\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>parent</artifactId>\r
- <version>1.0.1-SNAPSHOT</version>\r
- <relativePath>../pom.xml</relativePath>\r
- </parent>\r
- \r
- <artifactId>authz-cmd</artifactId>\r
- <name>Authz Command</name>\r
- <description>Command Line Processor for Authz</description>\r
- <packaging>jar</packaging>\r
- <url>https://github.com/att/AAF</url>\r
-\r
- <developers>\r
- <developer>\r
- <name>Jonathan Gathman</name>\r
- <email></email>\r
- <organization>ATT</organization>\r
- <organizationUrl></organizationUrl>\r
- </developer>\r
- </developers>\r
-\r
- <properties>\r
- <maven.test.failure.ignore>false</maven.test.failure.ignore>\r
- <project.swmVersion>21</project.swmVersion>\r
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>\r
- <!-- SONAR -->\r
- <jacoco.version>0.7.7.201606060606</jacoco.version>\r
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>\r
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>\r
- <!-- Default Sonar configuration -->\r
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>\r
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>\r
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->\r
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>\r
- <nexusproxy>https://nexus.onap.org</nexusproxy>\r
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>\r
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>\r
- </properties>\r
- \r
- <dependencies>\r
- <dependency>\r
- <groupId>org.onap.aaf.cadi</groupId>\r
- <artifactId>cadi-aaf</artifactId>\r
- <version>${project.cadiVersion}</version>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>authz-core</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
- \r
- <dependency> \r
- <groupId>jline</groupId> \r
- <artifactId>jline</artifactId> \r
- <version>2.14.2</version> \r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- </dependency>\r
-\r
- </dependencies>\r
-\r
- <build>\r
- <plugins>\r
- <plugin>\r
- <artifactId>maven-assembly-plugin</artifactId>\r
- <version>2.4</version>\r
- <configuration>\r
- <classifier>tests</classifier>\r
- <archive>\r
- <manifestEntries>\r
- <Sealed>true</Sealed>\r
- </manifestEntries>\r
- </archive>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>full</id>\r
- <phase>package</phase>\r
- <goals>\r
- <goal>single</goal>\r
- </goals>\r
- <configuration>\r
- <descriptors>\r
- <descriptor>src/main/assemble/authz-cmd.xml</descriptor>\r
- </descriptors>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin>\r
- \r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-javadoc-plugin</artifactId>\r
- <version>2.10.4</version>\r
- <configuration>\r
- <failOnError>false</failOnError>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>attach-javadocs</id>\r
- <goals>\r
- <goal>jar</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- \r
- \r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-source-plugin</artifactId>\r
- <version>2.2.1</version>\r
- <executions>\r
- <execution>\r
- <id>attach-sources</id>\r
- <goals>\r
- <goal>jar-no-fork</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.sonatype.plugins</groupId>\r
- <artifactId>nexus-staging-maven-plugin</artifactId>\r
- <version>1.6.7</version>\r
- <extensions>true</extensions>\r
- <configuration>\r
- <nexusUrl>${nexusproxy}</nexusUrl>\r
- <stagingProfileId>176c31dfe190a</stagingProfileId>\r
- <serverId>ecomp-staging</serverId>\r
- </configuration>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.jacoco</groupId>\r
- <artifactId>jacoco-maven-plugin</artifactId>\r
- <version>${jacoco.version}</version>\r
- <configuration>\r
- <excludes>\r
- <exclude>**/gen/**</exclude>\r
- <exclude>**/generated-sources/**</exclude>\r
- <exclude>**/yang-gen/**</exclude>\r
- <exclude>**/pax/**</exclude>\r
- </excludes>\r
- </configuration>\r
- <executions>\r
-\r
- <execution>\r
- <id>pre-unit-test</id>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
- <propertyName>surefireArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
- \r
- \r
- <execution>\r
- <id>post-unit-test</id>\r
- <phase>test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
- </configuration>\r
- </execution>\r
- <execution>\r
- <id>pre-integration-test</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
-\r
- <propertyName>failsafeArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
-\r
- \r
- <execution>\r
- <id>post-integration-test</id>\r
- <phase>post-integration-test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin> \r
-\r
- \r
- </plugins>\r
- <pluginManagement>\r
- <plugins/>\r
- </pluginManagement>\r
- </build>\r
-<distributionManagement>\r
- <repository>\r
- <id>ecomp-releases</id>\r
- <name>AAF Release Repository</name>\r
- <url>${nexusproxy}${releaseNexusPath}</url>\r
- </repository>\r
- <snapshotRepository>\r
- <id>ecomp-snapshots</id>\r
- <name>AAF Snapshot Repository</name>\r
- <url>${nexusproxy}${snapshotNexusPath}</url>\r
- </snapshotRepository>\r
- <site>\r
- <id>ecomp-site</id>\r
- <url>dav:${nexusproxy}${sitePath}</url>\r
- </site>\r
- </distributionManagement>\r
-\r
-</project>\r
+++ /dev/null
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">\r
- \r
- <id>jar-with-dependencies</id>\r
- <formats>\r
- <format>jar</format>\r
- </formats>\r
-\r
- <includeBaseDirectory>false</includeBaseDirectory>\r
- <dependencySets>\r
- <dependencySet>\r
- <unpack>true</unpack>\r
- <scope>compile</scope>\r
- </dependencySet>\r
- \r
- </dependencySets>\r
- <fileSets>\r
- <fileSet>\r
- <directory>src/main/xsd</directory>\r
- </fileSet>\r
- <fileSet>\r
- <directory>etc</directory>\r
- </fileSet>\r
- </fileSets>\r
-</assembly>\r
+++ /dev/null
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<assembly>\r
- <id>swm</id>\r
- <formats>\r
- <format>zip</format>\r
- </formats>\r
- <baseDirectory>${artifactId}</baseDirectory>\r
- <fileSets>\r
- <fileSet>\r
- <directory>target/swm</directory>\r
- </fileSet>\r
- </fileSets>\r
-</assembly>\r
+++ /dev/null
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START====================================================\r
-# * org.onap.aaf\r
-# * ===========================================================================\r
-# * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# * \r
-# * http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
-# * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-###############################################################################\r
-# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.\r
-###############################################################################\r
-#\r
-# Licensed to the Apache Software Foundation (ASF) under one\r
-# or more contributor license agreements. See the NOTICE file\r
-# distributed with this work for additional information\r
-# regarding copyright ownership. The ASF licenses this file\r
-# to you under the Apache License, Version 2.0 (the\r
-# "License"); you may not use this file except in compliance\r
-# with the License. You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing,\r
-# software distributed under the License is distributed on an\r
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
-# KIND, either express or implied. See the License for the\r
-# specific language governing permissions and limitations\r
-# under the License.\r
-#\r
-\r
-log4j.appender.SVR=org.apache.log4j.RollingFileAppender \r
-log4j.appender.SVR.File=${user.home}/.aaf/authz-cmd.log\r
-log4j.appender.SVR.MaxFileSize=10000KB\r
-log4j.appender.SVR.MaxBackupIndex=1\r
-log4j.appender.SVR.layout=org.apache.log4j.PatternLayout \r
-log4j.appender.SVR.layout.ConversionPattern=%d %p [%c] %m %n\r
-\r
-# General Apache libraries\r
-log4j.rootLogger=WARN,SVR\r
-\r
+++ /dev/null
-| ############################################################
-# Default Logging Configuration File
-#
-# You can use a different file by specifying a filename
-# with the java.util.logging.config.file system property.
-# For example java -Djava.util.logging.config.file=myfile
-############################################################
-
-############################################################
-# Global properties
-############################################################
-
-# "handlers" specifies a comma separated list of log Handler
-# classes. These handlers will be installed during VM startup.
-# Note that these classes must be on the system classpath.
-# By default we only configure a ConsoleHandler, which will only
-# show messages at the INFO and above levels.
-handlers=java.util.logging.FileHandler
-
-# Default global logging level.
-# This specifies which kinds of events are logged across
-# all loggers. For any given facility this global level
-# can be overriden by a facility specific level
-# Note that the ConsoleHandler also has a separate level
-# setting to limit messages printed to the console.
-.level=INFO
-
-############################################################
-# Handler specific properties.
-# Describes specific configuration info for Handlers.
-############################################################
-java.util.logging.FileHandler.properties=autoFlush,fileName,dataPattern,name
-java.util.logging.FileHandler.fileName=%h/.aaf/dme2.log
-java.util.logging.FileHandlerFileHandler.autoFlush=true
-java.util.logging.FileHandlerFileHandler.name=DailyRollingFileHandler
-java.util.logging.FileHandlerFileHandler.datePattern='.'yyyy-MM-dd
-com.att.aft.dme2.events.server.summary=WARN
-
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.Console;\r
-import java.io.File;\r
-import java.io.FileReader;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.InputStreamReader;\r
-import java.io.OutputStreamWriter;\r
-import java.io.PrintWriter;\r
-import java.io.Reader;\r
-import java.io.Writer;\r
-import java.net.HttpURLConnection;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Properties;\r
-\r
-import org.apache.log4j.PropertyConfigurator;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.cmd.mgmt.Mgmt;\r
-import org.onap.aaf.cmd.ns.NS;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import com.att.aft.dme2.api.DME2Manager;\r
-import org.onap.aaf.cadi.Access.Level;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.Locator;\r
-import org.onap.aaf.cadi.SecuritySetter;\r
-import org.onap.aaf.cadi.client.PropertyLocator;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.cadi.config.SecurityInfo;\r
-import org.onap.aaf.cadi.config.SecurityInfoC;\r
-import org.onap.aaf.cadi.dme2.DME2Locator;\r
-import org.onap.aaf.cadi.filter.AccessGetter;\r
-import org.onap.aaf.cadi.http.HBasicAuthSS;\r
-import org.onap.aaf.cadi.http.HMangr;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.impl.Log4JLogTarget;\r
-import org.onap.aaf.inno.env.util.Split;\r
-\r
-import jline.console.ConsoleReader;\r
-\r
-public class AAFcli {\r
-\r
- public static final String AAF_DEFAULT_REALM = "aaf_default_realm";\r
- protected static PrintWriter pw;\r
- protected HMangr hman;\r
- // Storage for last reused client. We can do this\r
- // because we're technically "single" threaded calls.\r
- public Retryable<?> prevCall;\r
-\r
- protected SecuritySetter<HttpURLConnection> ss;\r
- protected AuthzEnv env;\r
- private boolean close;\r
- private List<Cmd> cmds;\r
-\r
- // Lex State\r
- private ArrayList<Integer> expect = new ArrayList<Integer>();\r
- private boolean verbose = true;\r
- private int delay;\r
- private SecurityInfo si;\r
- private boolean request = false;\r
- private String force = null;\r
- private boolean gui = false;\r
-\r
- private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);\r
- private static boolean isConsole = false;\r
- private static boolean isTest = false;\r
- private static boolean showDetails = false;\r
- private static boolean ignoreDelay = false;\r
- private static int globalDelay=0;\r
- \r
- public static int timeout() {\r
- return TIMEOUT;\r
- }\r
-\r
- public AAFcli(AuthzEnv env, Writer wtr, HMangr hman, SecurityInfo si, SecuritySetter<HttpURLConnection> ss) throws APIException {\r
- this.env = env;\r
- this.ss = ss;\r
- this.hman = hman;\r
- this.si = si;\r
- if (wtr instanceof PrintWriter) {\r
- pw = (PrintWriter) wtr;\r
- close = false;\r
- } else {\r
- pw = new PrintWriter(wtr);\r
- close = true;\r
- }\r
-\r
-\r
- // client = new DRcli(new URI(aafurl), new\r
- // BasicAuth(user,toPass(pass,true)))\r
- // .apiVersion("2.0")\r
- // .timeout(TIMEOUT);\r
-\r
- /*\r
- * Create Cmd Tree\r
- */\r
- cmds = new ArrayList<Cmd>();\r
-\r
- Role role = new Role(this);\r
- cmds.add(new Help(this, cmds));\r
- cmds.add(new Version(this));\r
- cmds.add(new Perm(role));\r
- cmds.add(role);\r
- cmds.add(new User(this));\r
- cmds.add(new NS(this));\r
- cmds.add(new Mgmt(this));\r
- }\r
-\r
- public void verbose(boolean v) {\r
- verbose = v;\r
- }\r
-\r
- public void close() {\r
- if (hman != null) {\r
- hman.close();\r
- hman = null;\r
- }\r
- if (close) {\r
- pw.close();\r
- }\r
- }\r
-\r
- public boolean eval(String line) throws Exception {\r
- if (line.length() == 0) {\r
- return true;\r
- } else if (line.startsWith("#")) {\r
- pw.println(line);\r
- return true;\r
- }\r
-\r
- String[] largs = argEval(line);\r
- int idx = 0;\r
-\r
- // Variable replacement\r
- StringBuilder sb = null;\r
- while (idx < largs.length) {\r
- int e = 0;\r
- for (int v = largs[idx].indexOf("@["); v >= 0; v = largs[idx].indexOf("@[", v + 1)) {\r
- if (sb == null) {\r
- sb = new StringBuilder();\r
- }\r
- sb.append(largs[idx], e, v);\r
- if ((e = largs[idx].indexOf(']', v)) >= 0) {\r
- String p = env.getProperty(largs[idx].substring(v + 2, e++));\r
- if (p != null) {\r
- sb.append(p);\r
- }\r
- }\r
- }\r
- if (sb != null && sb.length() > 0) {\r
- sb.append(largs[idx], e, largs[idx].length());\r
- largs[idx] = sb.toString();\r
- sb.setLength(0);\r
- }\r
- ++idx;\r
- }\r
-\r
- idx = 0;\r
- boolean rv = true;\r
- while (rv && idx < largs.length) {\r
- // Allow Script to change Credential\r
- if (!gui) {\r
- if("as".equalsIgnoreCase(largs[idx])) {\r
- if (largs.length > ++idx) {\r
- // get Password from Props with ID as Key\r
- String user = largs[idx++];\r
- int colon = user.indexOf(':');\r
- String pass;\r
- if (colon > 0) {\r
- pass = user.substring(colon + 1);\r
- user = user.substring(0, colon);\r
- } else {\r
- pass = env.getProperty(user);\r
- }\r
- \r
- if (pass != null) {\r
- pass = env.decrypt(pass, false);\r
- env.setProperty(user, pass);\r
- ss = new HBasicAuthSS(user, pass,(SecurityInfoC<HttpURLConnection>) si);\r
- pw.println("as " + user);\r
- } else { // get Pass from System Properties, under name of\r
- // Tag\r
- pw.println("ERROR: No password set for " + user);\r
- rv = false;\r
- }\r
- continue;\r
- }\r
- } else if ("expect".equalsIgnoreCase(largs[idx])) {\r
- expect.clear();\r
- if (largs.length > idx++) {\r
- if (!"nothing".equals(largs[idx])) {\r
- for (String str : largs[idx].split(",")) {\r
- try {\r
- if ("Exception".equalsIgnoreCase(str)) {\r
- expect.add(-1);\r
- } else {\r
- expect.add(Integer.parseInt(str));\r
- }\r
- } catch (NumberFormatException e) {\r
- throw new CadiException("\"expect\" should be followed by Number");\r
- }\r
- }\r
- ++idx;\r
- }\r
- }\r
- continue;\r
- // Sleep, typically for reports, to allow DB to update\r
- // Milliseconds\r
- \r
- } else if ("sleep".equalsIgnoreCase(largs[idx])) {\r
- Integer t = Integer.parseInt(largs[++idx]);\r
- pw.println("sleep " + t);\r
- Thread.sleep(t);\r
- ++idx;\r
- continue;\r
- } else if ("delay".equalsIgnoreCase(largs[idx])) {\r
- delay = Integer.parseInt(largs[++idx]);\r
- pw.println("delay " + delay);\r
- ++idx;\r
- continue;\r
- } else if ("pause".equalsIgnoreCase(largs[idx])) {\r
- pw.println("Press <Return> to continue...");\r
- ++idx;\r
- new BufferedReader(new InputStreamReader(System.in)).readLine();\r
- continue;\r
- } else if ("exit".equalsIgnoreCase(largs[idx])) {\r
- pw.println("Exiting...");\r
- return false;\r
- }\r
-\r
- } \r
- \r
- if("REQUEST".equalsIgnoreCase(largs[idx])) {\r
- request=true;\r
- ++idx;\r
- } else if("FORCE".equalsIgnoreCase(largs[idx])) {\r
- force="true";\r
- ++idx;\r
- } else if ("set".equalsIgnoreCase(largs[idx])) {\r
- while (largs.length > ++idx) {\r
- int equals = largs[idx].indexOf('=');\r
- if (equals < 0) {\r
- break;\r
- }\r
- String tag = largs[idx].substring(0, equals);\r
- String value = largs[idx].substring(++equals);\r
- pw.println("set " + tag + ' ' + value);\r
- boolean isTrue = "TRUE".equalsIgnoreCase(value);\r
- if("FORCE".equalsIgnoreCase(tag)) {\r
- force = value;\r
- } else if("REQUEST".equalsIgnoreCase(tag)) {\r
- request = isTrue;\r
- } else if("DETAILS".equalsIgnoreCase(tag)) {\r
- showDetails = isTrue;\r
- } else {\r
- env.setProperty(tag, value);\r
- }\r
- }\r
- continue;\r
- // Allow Script to indicate if Failure is what is expected\r
- }\r
-\r
- int ret = 0;\r
- for (Cmd c : cmds) {\r
- if (largs[idx].equalsIgnoreCase(c.getName())) {\r
- if (verbose) {\r
- pw.println(line);\r
- if (expect.size() > 0) {\r
- pw.print("** Expect ");\r
- boolean first = true;\r
- for (Integer i : expect) {\r
- if (first) {\r
- first = false;\r
- } else {\r
- pw.print(',');\r
- }\r
- pw.print(i);\r
- }\r
- pw.println(" **");\r
- }\r
- }\r
- try {\r
- ret = c.exec(++idx, largs);\r
- if (delay+globalDelay > 0) {\r
- Thread.sleep(delay+globalDelay);\r
- }\r
- } catch (Exception e) {\r
- if (expect.contains(-1)) {\r
- pw.println(e.getMessage());\r
- ret = -1;\r
- } else {\r
- throw e;\r
- }\r
- } finally {\r
- clearSingleLineProperties();\r
- }\r
- rv = expect.isEmpty() ? true : expect.contains(ret);\r
- if (verbose) {\r
- if (rv) {\r
- pw.println();\r
- } else {\r
- pw.print("!!! Unexpected Return Code: ");\r
- pw.print(ret);\r
- pw.println(", VALIDATE OUTPUT!!!");\r
- }\r
- }\r
- return rv;\r
- }\r
- }\r
- pw.write("Unknown Instruction \"");\r
- pw.write(largs[idx]);\r
- pw.write("\"\n");\r
- idx = largs.length;// always end after one command\r
- }\r
- return rv;\r
- }\r
-\r
- private String[] argEval(String line) {\r
- StringBuilder sb = new StringBuilder();\r
- ArrayList<String> arr = new ArrayList<String>();\r
- boolean start = true;\r
- char quote = 0;\r
- for (int i = 0; i < line.length(); ++i) {\r
- char ch;\r
- if (Character.isWhitespace(ch = line.charAt(i))) {\r
- if (start) {\r
- continue; // trim\r
- } else if (quote != 0) {\r
- sb.append(ch);\r
- } else {\r
- arr.add(sb.toString());\r
- sb.setLength(0);\r
- start = true;\r
- }\r
- } else if (ch == '\'' || ch == '"') { // toggle\r
- if (quote == ch) {\r
- quote = 0;\r
- } else {\r
- quote = ch;\r
- }\r
- } else {\r
- start = false;\r
- sb.append(ch);\r
- }\r
- }\r
- if (sb.length() > 0) {\r
- arr.add(sb.toString());\r
- }\r
-\r
- String[] rv = new String[arr.size()];\r
- arr.toArray(rv);\r
- return rv;\r
- }\r
-\r
- public static void keyboardHelp() {\r
- System.out.println("'C-' means hold the ctrl key down while pressing the next key.");\r
- System.out.println("'M-' means hold the alt key down while pressing the next key.");\r
- System.out.println("For instance, C-b means hold ctrl key and press b, M-b means hold alt and press b\n");\r
-\r
- System.out.println("Basic Keybindings:");\r
- System.out.println("\tC-l - clear screen"); \r
- System.out.println("\tC-a - beginning of line");\r
- System.out.println("\tC-e - end of line");\r
- System.out.println("\tC-b - backward character (left arrow also works)");\r
- System.out.println("\tM-b - backward word");\r
- System.out.println("\tC-f - forward character (right arrow also works)");\r
- System.out.println("\tM-f - forward word");\r
- System.out.println("\tC-d - delete character under cursor");\r
- System.out.println("\tM-d - delete word forward");\r
- System.out.println("\tM-backspace - delete word backward");\r
- System.out.println("\tC-k - delete from cursor to end of line");\r
- System.out.println("\tC-u - delete entire line, regardless of cursor position\n");\r
-\r
- System.out.println("Command History:");\r
- System.out.println("\tC-r - search backward in history (repeating C-r continues the search)");\r
- System.out.println("\tC-p - move backwards through history (up arrow also works)");\r
- System.out.println("\tC-n - move forwards through history (down arrow also works)\n");\r
-\r
- }\r
-\r
- /**\r
- * @param args\r
- */\r
- public static void main(String[] args) {\r
- int rv = 0;\r
- // Cover for bash's need to escape *... (\\*)\r
- for (int i = 0; i < args.length; ++i) {\r
- if ("\\*".equals(args[i])) {\r
- args[i] = "*";\r
- }\r
- }\r
- \r
- System.setProperty("java.util.logging.config.file", "etc/logging.props");\r
- final AuthzEnv env = new AuthzEnv(System.getProperties());\r
- \r
- // Stop the (exceedingly annoying) DME2/other logs from printing console\r
- InputStream is;\r
-\r
- // Load Log4j too... sigh\r
- is = ClassLoader.getSystemResourceAsStream("log4j.properties");\r
- if(is==null) {\r
- env.log(Level.WARN, "Cannot find 'log4j.properties' in Classpath. Best option: add 'etc' directory to classpath");\r
- } else {\r
- try {\r
- Properties props = new Properties();\r
- props.load(is);\r
- PropertyConfigurator.configure(props);\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- } finally {\r
- try {\r
- is.close();\r
- } catch (IOException e) {\r
- env.debug().log(e); // only logging to avoid Sonar False positives.\r
- }\r
- }\r
- }\r
-\r
- env.loadFromSystemPropsStartsWith("AFT", "DME2", "aaf", "keyfile");\r
- try {\r
- Log4JLogTarget.setLog4JEnv("aaf", env);\r
- GetProp gp = new GetProp(env);\r
- String user = gp.get(false,Config.AAF_MECHID,"fully qualified id");\r
- String pass = gp.get(true, Config.AAF_MECHPASS, "password is hidden");\r
- if(env.getProperty(Config.AAF_URL)==null) {\r
- String p = env.getProperty("DMEServiceName");\r
- if(p!=null) {\r
- boolean https = "true".equalsIgnoreCase(env.getProperty("AFT_DME2_SSL_ENABLE"));\r
- env.setProperty(Config.AAF_URL, "http"+(https?"s":"")+"://DME2RESOLVE/"+p);\r
- }\r
- }\r
- String aafUrl = gp.get(false, Config.AAF_URL, "https://DME2RESOLVE or Direct URL:port");\r
-\r
- if(aafUrl!=null && aafUrl.contains("//DME2")) {\r
- //gp.set(Config.AFT_LATITUDE,"Lookup from a Map App or table");\r
- //gp.set(Config.AFT_LONGITUDE,"Lookup from a Map App or table");\r
- //gp.set(Config.AFT_ENVIRONMENT,"Check DME2 Installations");\r
- }\r
-\r
- if (gp.err() != null) {\r
- gp.err().append("to continue...");\r
- System.err.println(gp.err());\r
- System.exit(1);\r
- }\r
- \r
-\r
- Reader rdr = null;\r
- boolean exitOnFailure = true;\r
- /*\r
- * Check for "-" options anywhere in command line\r
- */\r
- StringBuilder sb = new StringBuilder();\r
- for (int i = 0; i < args.length; ++i) {\r
- if ("-i".equalsIgnoreCase(args[i])) {\r
- rdr = new InputStreamReader(System.in);\r
- // } else if("-o".equalsIgnoreCase(args[i])) {\r
- // // shall we do something different? Output stream is\r
- // already done...\r
- } else if ("-f".equalsIgnoreCase(args[i])) {\r
- if (args.length > i + 1) {\r
- rdr = new FileReader(args[++i]);\r
- }\r
- } else if ("-a".equalsIgnoreCase(args[i])) {\r
- exitOnFailure = false;\r
- } else if ("-c".equalsIgnoreCase(args[i])) {\r
- isConsole = true;\r
- } else if ("-s".equalsIgnoreCase(args[i]) && args.length > i + 1) {\r
- env.setProperty(Cmd.STARTDATE, args[++i]);\r
- } else if ("-e".equalsIgnoreCase(args[i]) && args.length > i + 1) {\r
- env.setProperty(Cmd.ENDDATE, args[++i]);\r
- } else if ("-t".equalsIgnoreCase(args[i])) {\r
- isTest = true;\r
- } else if ("-d".equalsIgnoreCase(args[i])) {\r
- showDetails = true;\r
- } else if ("-n".equalsIgnoreCase(args[i])) {\r
- ignoreDelay = true;\r
- } else {\r
- if (sb.length() > 0) {\r
- sb.append(' ');\r
- }\r
- sb.append(args[i]);\r
- }\r
- }\r
-\r
- SecurityInfo si = new SecurityInfo(env);\r
- env.loadToSystemPropsStartsWith("AAF", "DME2");\r
- Locator loc;\r
- if(aafUrl.contains("//DME2RESOLVE")) {\r
- DME2Manager dm = new DME2Manager("AAFcli DME2Manager", System.getProperties());\r
- loc = new DME2Locator(env, dm, aafUrl);\r
- } else {\r
- loc = new PropertyLocator(aafUrl);\r
- }\r
-\r
- //Config.configPropFiles(new AccessGetter(env), env);\r
- \r
- TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));\r
- HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0");\r
- \r
- //TODO: Consider requiring a default in properties\r
- env.setProperty(Config.AAF_DEFAULT_REALM, System.getProperty(Config.AAF_DEFAULT_REALM,Config.getDefaultRealm()));\r
-\r
- AAFcli aafcli = new AAFcli(env, new OutputStreamWriter(System.out), hman, si, \r
- new HBasicAuthSS(user, env.decrypt(pass,false), (SecurityInfoC<HttpURLConnection>) si));\r
- if(!ignoreDelay) {\r
- File delay = new File("aafcli.delay");\r
- if(delay.exists()) {\r
- BufferedReader br = new BufferedReader(new FileReader(delay));\r
- try {\r
- globalDelay = Integer.parseInt(br.readLine());\r
- } catch(Exception e) {\r
- env.debug().log(e);\r
- } finally {\r
- br.close();\r
- }\r
- }\r
- }\r
- try {\r
- if (isConsole) {\r
- System.out.println("Type 'help' for short help or 'help -d' for detailed help with aafcli commands");\r
- System.out.println("Type '?' for help with command line editing");\r
- System.out.println("Type 'q', 'quit', or 'exit' to quit aafcli\n");\r
-\r
- ConsoleReader reader = new ConsoleReader();\r
- try {\r
- reader.setPrompt("aafcli > ");\r
- \r
- String line;\r
- while ((line = reader.readLine()) != null) {\r
- showDetails = (line.contains("-d"))?true:false;\r
- \r
- if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("q") || line.equalsIgnoreCase("exit")) {\r
- break;\r
- } else if (line.equalsIgnoreCase("--help -d") || line.equalsIgnoreCase("help -d") \r
- || line.equalsIgnoreCase("help")) {\r
- line = "--help";\r
- } else if (line.equalsIgnoreCase("cls")) {\r
- reader.clearScreen();\r
- continue;\r
- } else if (line.equalsIgnoreCase("?")) {\r
- keyboardHelp();\r
- continue;\r
- }\r
- try {\r
- aafcli.eval(line);\r
- pw.flush();\r
- } catch (Exception e) {\r
- pw.println(e.getMessage());\r
- pw.flush();\r
- }\r
- }\r
- } finally {\r
- reader.close();\r
- }\r
- } else if (rdr != null) {\r
- BufferedReader br = new BufferedReader(rdr);\r
- String line;\r
- while ((line = br.readLine()) != null) {\r
- if (!aafcli.eval(line) && exitOnFailure) {\r
- rv = 1;\r
- break;\r
- }\r
- }\r
- } else { // just run the command line\r
- aafcli.verbose(false);\r
- if (sb.length() == 0) {\r
- sb.append("--help");\r
- }\r
- rv = aafcli.eval(sb.toString()) ? 0 : 1;\r
- }\r
- } finally {\r
- aafcli.close();\r
-\r
- // Don't close if No Reader, or it's a Reader of Standard In\r
- if (rdr != null && !(rdr instanceof InputStreamReader)) {\r
- rdr.close();\r
- }\r
- }\r
- } catch (MessageException e) {\r
- System.out.println("MessageException caught");\r
-\r
- System.err.println(e.getMessage());\r
- } catch (Exception e) {\r
- e.printStackTrace(System.err);\r
- }\r
- System.exit(rv);\r
-\r
- }\r
-\r
- private static class GetProp {\r
- private Console cons = System.console();\r
- private StringBuilder err = null;\r
- private AuthzEnv env;\r
- \r
- public GetProp(AuthzEnv env) {\r
- this.env = env;\r
- }\r
-\r
- public String get(final boolean pass, final String tag, final String other) {\r
- String data = env.getProperty(tag,null);\r
- if (data == null) {\r
- if(cons!=null) {\r
- if(pass) {\r
- char[] cp = System.console().readPassword("%s: ",tag);\r
- if(cp!=null) {\r
- data=String.valueOf(cp);\r
- }\r
- } else {\r
- cons.writer().format("%s: ", tag);\r
- cons.flush();\r
- data = cons.readLine();\r
- }\r
- }\r
- if(data==null) {\r
- if(err == null) {\r
- err = new StringBuilder("Add -D");\r
- } else {\r
- err.append(", -D");\r
- }\r
- err.append(tag);\r
- if(other!=null) {\r
- err.append("=<");\r
- err.append(other);\r
- err.append('>');\r
- }\r
- }\r
- }\r
- return data;\r
- }\r
- \r
- public void set(final String tag, final String other) {\r
- String data = env.getProperty(tag,null);\r
- if (data == null) {\r
- if(cons!=null) {\r
- cons.writer().format("%s: ", tag);\r
- cons.flush();\r
- data = cons.readLine();\r
- }\r
- if(data==null) {\r
- if(err == null) {\r
- err = new StringBuilder("Add -D");\r
- } else {\r
- err.append(", -D");\r
- }\r
- err.append(tag);\r
- if(other!=null) {\r
- err.append("=<");\r
- err.append(other);\r
- err.append('>');\r
- }\r
- }\r
- }\r
- if(data!=null) {\r
- System.setProperty(tag, data);\r
- }\r
- }\r
-\r
- public StringBuilder err() {\r
- return err;\r
- }\r
- }\r
-\r
- public boolean isTest() {\r
- return AAFcli.isTest;\r
- }\r
- \r
- public boolean isDetailed() {\r
- return AAFcli.showDetails;\r
- }\r
-\r
- public String typeString(Class<?> cls, boolean json) {\r
- return "application/" + cls.getSimpleName() + "+" + (json ? "json" : "xml") + ";version=" + hman.apiVersion();\r
- }\r
-\r
- public String forceString() {\r
- return force;\r
- }\r
-\r
- public boolean addRequest() {\r
- return request;\r
- }\r
-\r
- public void clearSingleLineProperties() {\r
- force = null;\r
- request = false;\r
- showDetails = false;\r
- }\r
-\r
- public void gui(boolean b) {\r
- gui = b;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-\r
-public class BaseCmd<CMD extends Cmd> extends Cmd {\r
- protected List<Cmd> cmds;\r
-\r
- public BaseCmd(AAFcli aafcli, String name, Param ... params) {\r
- super(aafcli, null, name, params);\r
- cmds = new ArrayList<Cmd>();\r
- }\r
- \r
- public BaseCmd(CMD parent, String name, Param ... params) {\r
- super(parent.aafcli, parent, name, params);\r
- cmds = new ArrayList<Cmd>();\r
- }\r
-\r
- \r
- @Override\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- if(args.length-idx<1) {\r
- pw().println(build(new StringBuilder(),null).toString());\r
- } else {\r
- String s = args[idx];\r
- String name;\r
- Cmd empty = null;\r
- for(Cmd c: cmds) {\r
- name = c.getName();\r
- if(name==null && empty==null) { // Mark with Command is null, and take the first one. \r
- empty = c;\r
- } else if(s.equalsIgnoreCase(c.getName()))\r
- return c.exec(idx+1, args);\r
- }\r
- if(empty!=null) {\r
- return empty.exec(idx, args); // If name is null, don't account for it on command line. jg 4-29\r
- }\r
- pw().println("Instructions not understood.");\r
- }\r
- return 0;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import java.io.IOException;\r
-\r
-import com.att.aft.dme2.api.DME2Client;\r
-import org.onap.aaf.cadi.SecuritySetter;\r
-import org.onap.aaf.cadi.Symm;\r
-\r
-public class BasicAuth implements SecuritySetter<DME2Client> {\r
- private String cred;\r
- private String user;\r
- \r
- public BasicAuth(String user, String pass) throws IOException {\r
- this.user = user;\r
- cred = "Basic " + Symm.base64.encode(user+':'+pass);\r
- }\r
- \r
- @Override\r
- public void setSecurity(DME2Client client) {\r
- client.addHeader("Authorization" , cred);\r
- }\r
-\r
- @Override\r
- public String getID() {\r
- return user;\r
- }\r
-\r
- //@Override\r
- public int setLastResponse(int respCode) {\r
- // TODO Auto-generated method stub\r
- return 0;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import java.io.PrintWriter;\r
-import java.io.StringReader;\r
-import java.sql.Date;\r
-import java.text.DateFormat;\r
-import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.Comparator;\r
-import java.util.GregorianCalendar;\r
-import java.util.List;\r
-import java.util.Stack;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.cadi.http.HMangr;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Data.TYPE;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-import org.onap.aaf.rosetta.env.RosettaEnv;\r
-\r
-import aaf.v2_0.Error;\r
-import aaf.v2_0.History;\r
-import aaf.v2_0.History.Item;\r
-import aaf.v2_0.Request;\r
-\r
-\r
-public abstract class Cmd {\r
- private static final String AAF_DEFAULT_REALM = "aaf_default_realm";\r
- \r
- private static final DateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");\r
- protected static final String BLANK = "";\r
- protected static final String COMMA = ","; // for use in splits\r
-\r
- protected static final int lineLength = 80;\r
-\r
- private final static String hformat = "%-23s %-5s %-20s %-35s\n";\r
-\r
- public static final String STARTDATE = "startdate";\r
- public static final String ENDDATE = "enddate";\r
- \r
- private String name;\r
- private final Param[] params;\r
- private int required;\r
- protected final Cmd parent;\r
- protected final List<Cmd> children;\r
- private final ConcurrentHashMap<Class<?>,RosettaDF<?>> dfs = new ConcurrentHashMap<Class<?>,RosettaDF<?>>();\r
- public final AAFcli aafcli;\r
- protected Env env;\r
-\r
- public Cmd(AAFcli aafcli, String name, Param ... params) {\r
- this(aafcli,null, name,params);\r
- }\r
-\r
- public Cmd(Cmd parent, String name, Param ... params) {\r
- this(parent.aafcli,parent, name,params);\r
- }\r
-\r
- Cmd(AAFcli aafcli, Cmd parent, String name, Param ... params) {\r
- this.parent = parent;\r
- this.aafcli = aafcli;\r
- this.env = aafcli.env;\r
- if(parent!=null) {\r
- parent.children.add(this);\r
- }\r
- children = new ArrayList<Cmd>();\r
- this.params = params;\r
- this.name = name;\r
- required=0;\r
- for(Param p : params) {\r
- if(p.required) {\r
- ++required;\r
- }\r
- }\r
- }\r
- \r
- public final int exec(int idx, String ... args) throws CadiException, APIException, LocatorException {\r
- if(args.length-idx<required) {\r
- throw new CadiException(build(new StringBuilder("Too few args: "),null).toString());\r
- }\r
- return _exec(idx,args);\r
- }\r
- \r
- protected abstract int _exec(int idx, final String ... args) throws CadiException, APIException, LocatorException;\r
- \r
- public void detailedHelp(int indent,StringBuilder sb) {\r
- }\r
-\r
- protected void detailLine(StringBuilder sb, int length, String s) {\r
- multiChar(sb,length,' ',0);\r
- sb.append(s);\r
- }\r
-\r
- public void apis(int indent,StringBuilder sb) {\r
- }\r
-\r
- protected void api(StringBuilder sb, int _indent, HttpMethods hmeth, String pathInfo, Class<?> cls,boolean head) {\r
- int indent = _indent;\r
- final String meth = hmeth.name();\r
- if(head) {\r
- sb.append('\n');\r
- detailLine(sb,indent,"APIs:");\r
- }\r
- indent+=2;\r
- multiChar(sb,indent,' ',0);\r
- sb.append(meth);\r
- sb.append(' ');\r
- sb.append(pathInfo);\r
- String cliString = aafcli.typeString(cls,true);\r
- if(indent+meth.length()+pathInfo.length()+cliString.length()+2>80) {\r
- sb.append(" ...");\r
- multiChar(sb,indent+3+meth.length(),' ',0);\r
- } else { // same line\r
- sb.append(' ');\r
- }\r
- sb.append(cliString);\r
- }\r
-\r
- protected void multiChar(StringBuilder sb, int length, char c, int indent) {\r
- sb.append('\n');\r
- for(int i=0;i<indent;++i)sb.append(' ');\r
- for(int i=indent;i<length;++i)sb.append(c);\r
- }\r
-\r
- public StringBuilder build(StringBuilder sb, StringBuilder detail) {\r
- if(name!=null) {\r
- sb.append(name);\r
- sb.append(' ');\r
- }\r
- int line = sb.lastIndexOf("\n")+1;\r
- if(line<0) {\r
- line=0;\r
- }\r
- int indent = sb.length()-line;\r
- for(Param p : params) {\r
- sb.append(p.required?'<':'[');\r
- sb.append(p.tag);\r
- sb.append(p.required?"> ": "] ");\r
- }\r
- \r
- boolean first = true;\r
- for(Cmd child : children) {\r
- if(first) {\r
- first = false;\r
- } else if(detail==null) {\r
- multiChar(sb,indent,' ',0);\r
- } else {\r
- // Write parents for Detailed Report\r
- Stack<String> stack = new Stack<String>();\r
- for(Cmd c = child.parent;c!=null;c=c.parent) {\r
- if(c.name!=null) {\r
- stack.push(c.name);\r
- }\r
- }\r
- if(!stack.isEmpty()) {\r
- sb.append(" ");\r
- while(!stack.isEmpty()) {\r
- sb.append(stack.pop());\r
- sb.append(' ');\r
- }\r
- }\r
- }\r
- child.build(sb,detail);\r
- if(detail!=null) {\r
- child.detailedHelp(4, detail);\r
- // If Child wrote something, then add, bracketing by lines\r
- if(detail.length()>0) {\r
- multiChar(sb,80,'-',2);\r
- sb.append(detail);\r
- sb.append('\n');\r
- multiChar(sb,80,'-',2);\r
- sb.append('\n');\r
- detail.setLength(0); // reuse\r
- } else {\r
- sb.append('\n');\r
- }\r
- }\r
- }\r
- return sb;\r
- }\r
- \r
- protected void error(Future<?> future) {\r
- StringBuilder sb = new StringBuilder("Failed");\r
- String desc = future.body();\r
- int code = future.code();\r
- if(desc==null || desc.length()==0) {\r
- withCode(sb,code);\r
- } else if(desc.startsWith("{")) {\r
- StringReader sr = new StringReader(desc);\r
- try {\r
- // Note: 11-18-2013. This rather convoluted Message Structure required by TSS Restful Specs, reflecting "Northbound" practices.\r
- Error err = getDF(Error.class).newData().in(TYPE.JSON).load(sr).asObject();\r
- sb.append(" [");\r
- sb.append(err.getMessageId());\r
- sb.append("]: ");\r
- String messageBody = err.getText();\r
- List<String> vars = err.getVariables();\r
- int pipe;\r
- for (int varCounter=0;varCounter<vars.size();) {\r
- String var = vars.get(varCounter);\r
- ++varCounter;\r
- if (messageBody.indexOf("%" + varCounter) >= 0) {\r
- if((pipe = var.indexOf('|'))>=0) { // In AAF, we use a PIPE for Choice\r
- if (aafcli.isTest()) {\r
- String expiresStr = var.substring(pipe);\r
- var = var.replace(expiresStr, "[Placeholder]");\r
- } else {\r
- StringBuilder varsb = new StringBuilder(var);\r
- varsb.deleteCharAt(pipe);\r
- var = varsb.toString();\r
- }\r
- messageBody = messageBody.replace("%" + varCounter, varCounter-1 + ") " + var);\r
- } else {\r
- messageBody = messageBody.replace("%" + varCounter, var);\r
- }\r
- }\r
- }\r
- sb.append(messageBody);\r
- } catch (Exception e) {\r
- withCode(sb,code);\r
- sb.append(" (Note: Details cannot be obtained from Error Structure)");\r
- }\r
- } else if(desc.startsWith("<html>")){ // Core Jetty, etc sends HTML for Browsers\r
- withCode(sb,code);\r
- } else {\r
- sb.append(" with code ");\r
- sb.append(code);\r
- sb.append(", ");\r
- sb.append(desc);\r
- }\r
- pw().println(sb);\r
- }\r
-\r
- \r
- private void withCode(StringBuilder sb, Integer code) {\r
- sb.append(" with code ");\r
- sb.append(code);\r
- switch(code) {\r
- case 401:\r
- sb.append(" (HTTP Not Authenticated)");\r
- break;\r
- case 403:\r
- sb.append(" (HTTP Forbidden)");\r
- break;\r
- case 404:\r
- sb.append(" (HTTP Not Found)");\r
- break;\r
- default:\r
- }\r
- }\r
-\r
- /**\r
- * Consistently set start and end dates from Requests (all derived from Request)\r
- * @param req\r
- */\r
- protected void setStartEnd(Request req) {\r
- // Set Start/End Dates, if exist\r
- String str;\r
- if((str = env.getProperty(Cmd.STARTDATE,null))!=null) {\r
- req.setStart(Chrono.timeStamp(Date.valueOf(str)));\r
- }\r
- \r
- if((str = env.getProperty(Cmd.ENDDATE,null))!=null) {\r
- req.setEnd(Chrono.timeStamp(Date.valueOf(str)));\r
- }\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- protected<T> RosettaDF<T> getDF(Class<T> cls) throws APIException {\r
- RosettaDF<T> rdf = (RosettaDF<T>)dfs.get(cls);\r
- if(rdf == null) {\r
- rdf = env().newDataFactory(cls);\r
- dfs.put(cls, rdf);\r
- }\r
- return rdf;\r
- }\r
-\r
- public void activity(History history, String header) {\r
- if (history.getItem().isEmpty()) {\r
- int start = header.indexOf('[');\r
- if (start >= 0) {\r
- pw().println("No Activity Found for " + header.substring(start));\r
- }\r
- } else {\r
- pw().println(header);\r
- for(int i=0;i<lineLength;++i)pw().print('-');\r
- pw().println();\r
- \r
- pw().format(hformat,"Date","Table","User","Memo");\r
- for(int i=0;i<lineLength;++i)pw().print('-');\r
- pw().println();\r
- \r
- // Save Server time by Sorting locally\r
- List<Item> items = history.getItem();\r
- java.util.Collections.sort(items, new Comparator<Item>() {\r
- @Override\r
- public int compare(Item o1, Item o2) {\r
- return o2.getTimestamp().compare(o1.getTimestamp());\r
- }\r
- });\r
- \r
- for(History.Item item : items) {\r
- GregorianCalendar gc = item.getTimestamp().toGregorianCalendar();\r
- pw().format(hformat,\r
- dateFmt.format(gc.getTime()),\r
- item.getTarget(),\r
- item.getUser(),\r
- item.getMemo());\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Turn String Array into a | delimited String\r
- * @param options\r
- * @return\r
- */\r
- public static String optionsToString(String[] options) {\r
- StringBuilder sb = new StringBuilder();\r
- boolean first = true;\r
- for(String s : options) {\r
- if(first) {\r
- first = false;\r
- } else {\r
- sb.append('|');\r
- }\r
- sb.append(s);\r
- }\r
- return sb.toString();\r
- }\r
- \r
- /**\r
- * return which index number the Option matches.\r
- * \r
- * throws an Exception if not part of this Option Set\r
- * \r
- * @param options\r
- * @param test\r
- * @return\r
- * @throws Exception\r
- */\r
- public int whichOption(String[] options, String test) throws CadiException {\r
- for(int i=0;i<options.length;++i) {\r
- if(options[i].equals(test)) {\r
- return i;\r
- }\r
- }\r
- throw new CadiException(build(new StringBuilder("Invalid Option: "),null).toString());\r
- }\r
-\r
- protected RosettaEnv env() {\r
- return aafcli.env;\r
- }\r
-\r
- protected HMangr hman() {\r
- return aafcli.hman;\r
- }\r
-\r
- public<RET> RET same(Retryable<RET> retryable) throws APIException, CadiException, LocatorException {\r
- // We're storing in AAFCli, because we know it's always the same, and single threaded\r
- if(aafcli.prevCall!=null) {\r
- retryable.item(aafcli.prevCall.item());\r
- retryable.lastClient=aafcli.prevCall.lastClient;\r
- }\r
- \r
- RET ret = aafcli.hman.same(aafcli.ss,retryable);\r
- \r
- // Store last call in AAFcli, because Cmds are all different instances.\r
- aafcli.prevCall = retryable;\r
- return ret;\r
- }\r
-\r
- public<RET> RET all(Retryable<RET> retryable) throws APIException, CadiException, LocatorException {\r
- this.setQueryParamsOn(retryable.lastClient);\r
- return aafcli.hman.all(aafcli.ss,retryable);\r
- }\r
-\r
- public<RET> RET oneOf(Retryable<RET> retryable,String host) throws APIException, CadiException, LocatorException {\r
- this.setQueryParamsOn(retryable.lastClient);\r
- return aafcli.hman.oneOf(aafcli.ss,retryable,true,host);\r
- }\r
-\r
- protected PrintWriter pw() {\r
- return AAFcli.pw;\r
- }\r
-\r
- public String getName() {\r
- return name;\r
- }\r
- \r
- public void reportHead(String ... str) {\r
- pw().println();\r
- boolean first = true;\r
- int i=0;\r
- for(String s : str) {\r
- if(first) {\r
- if(++i>1) {\r
- first = false;\r
- pw().print("[");\r
- }\r
- } else {\r
- pw().print("] [");\r
- }\r
- pw().print(s);\r
- }\r
- if(!first) {\r
- pw().print(']');\r
- }\r
- pw().println();\r
- reportLine();\r
- }\r
- \r
- public String reportColHead(String format, String ... args) {\r
- pw().format(format,(Object[])args);\r
- reportLine();\r
- return format;\r
- }\r
-\r
- public void reportLine() {\r
- for(int i=0;i<lineLength;++i)pw().print('-');\r
- pw().println();\r
- }\r
- \r
- protected void setQueryParamsOn(Rcli<?> rcli) {\r
- StringBuilder sb=null;\r
- String force;\r
- if((force=aafcli.forceString())!=null) {\r
- sb = new StringBuilder("force=");\r
- sb.append(force);\r
- }\r
- if(aafcli.addRequest()) {\r
- if(sb==null) {\r
- sb = new StringBuilder("request=true");\r
- } else {\r
- sb.append("&request=true");\r
- }\r
- }\r
- if(sb!=null && rcli!=null) {\r
- rcli.setQueryParams(sb.toString());\r
- }\r
- }\r
-//\r
-// /**\r
-// * If Force is set, will return True once only, then revert to "FALSE".\r
-// * \r
-// * @return\r
-// */\r
-// protected String checkForce() {\r
-// if(TRUE.equalsIgnoreCase(env.getProperty(FORCE, FALSE))) {\r
-// env.setProperty(FORCE, FALSE);\r
-// return "true";\r
-// }\r
-// return FALSE;\r
-// }\r
-\r
- public String toString() {\r
- StringBuilder sb = new StringBuilder();\r
- if(parent==null) { // ultimate parent\r
- build(sb,null);\r
- return sb.toString();\r
- } else {\r
- return parent.toString();\r
- }\r
- }\r
- \r
- public String getOrgRealm() {\r
- return env.getProperty(AAF_DEFAULT_REALM);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import java.util.List;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Help extends Cmd {\r
- private List<Cmd> cmds;\r
-\r
- public Help(AAFcli aafcli, List<Cmd> cmds) {\r
- super(aafcli, "--help", \r
- new Param("-d (more details)", false),\r
- new Param("command",false));\r
- this.cmds = cmds;\r
- }\r
-\r
- @Override\r
- public int _exec( int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- boolean first = true;\r
- StringBuilder sb = new StringBuilder("AAF Command Line Tool");\r
- StringBuilder details;\r
- if(aafcli.isDetailed() ){\r
- multiChar(sb, 21, '-',0);\r
- details=new StringBuilder();// use for temporary writing of details\r
- } else {\r
- multiChar(sb, 21, '-',0);\r
- details = null;\r
- }\r
- String comp = args.length>idx?args[idx++]:null;\r
- if("help".equalsIgnoreCase(comp)) {\r
- build(sb,null);\r
- detailedHelp(4, sb);\r
- sb.append('\n');\r
- } else {\r
- for(Cmd c : cmds) {\r
- if(comp!=null) {\r
- if(comp.equals(c.getName())) {\r
- multiChar(sb,2,' ',0);\r
- c.build(sb,details);\r
- }\r
- } else {\r
- if(first) {\r
- first=false;\r
- } else {\r
- multiChar(sb,80,'-',2);\r
- }\r
- multiChar(sb,2,' ',0);\r
- c.build(sb,details);\r
- if(details!=null) {\r
- c.detailedHelp(4, sb);\r
-// multiChar(sb,80,'-',2);\r
- }\r
- }\r
- }\r
- }\r
- pw().println(sb.toString());\r
- return HttpStatus.OK_200;\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"To print main help, enter \"aafcli\" or \"aafcli --help \"");\r
- detailLine(sb,indent,"To print narrow the help content, enter sub-entries after aafcli,");\r
- detailLine(sb,indent+2,"i.e. \"aafcli perm\"");\r
- detailLine(sb,indent,"To see version of AAF CLI, enter \"aafcli --version \"");\r
- sb.append('\n');\r
- detailLine(sb,indent,"State Commands: change variables or credentials between calls.");\r
- indent+=4;\r
- detailLine(sb,indent,"set <tag>=<value> - Set any System Property to a new value");\r
- detailLine(sb,indent,"as <id:password> - Change Credentials. Password may be encrypted");\r
- detailLine(sb,indent,"expect <int> [int]* - In test mode, check for proper HTTP Status Codes");\r
- detailLine(sb,indent,"sleep <int> - Wait for <int> seconds");\r
- sb.append('\n');\r
- detailLine(sb,indent-4,"CmdLine Arguments: change behavior of the aafcli program");\r
- detailLine(sb,indent,"-i - Read commands from Shell Standard Input");\r
- detailLine(sb,indent,"-f - Read commands from a file");\r
- detailLine(sb,indent,"-a - In test mode, do not stop execution on unexpected error");\r
- detailLine(sb,indent,"-t - Test Mode will not print variable fields that could break tc runs");\r
- detailLine(sb,indent+6,"such as expiration dates of a credential");\r
- detailLine(sb,indent,"-s - Request specific Start Date (not immediately)");\r
- detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.STARTDATE + "=<value>\"");\r
- detailLine(sb,indent,"-e - Set Expiration/End Date, where commands support");\r
- detailLine(sb,indent+6,"Format YYYY-MM-DD. Can also be set with \"set " + Cmd.ENDDATE + "=<value>\"");\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-/**\r
- * \r
- */\r
-package org.onap.aaf.cmd;\r
-\r
-/**\r
- * An Exception designed simply to give End User message, no stack trace\r
- * \r
- *\r
- */\r
-public class MessageException extends Exception {\r
- /**\r
- * \r
- */\r
- private static final long serialVersionUID = 8143933588878259048L;\r
-\r
- /**\r
- * @param Message\r
- */\r
- public MessageException(String msg) {\r
- super(msg);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-public class Param {\r
- public final String tag;\r
- public final boolean required;\r
- \r
- /**\r
- * \r
- * @param t\r
- * @param b\r
- */\r
- public Param(String t, boolean required) {\r
- tag = t;\r
- this.required=required;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Version extends Cmd {\r
-\r
-\r
- public Version(AAFcli aafcli) {\r
- super(aafcli, "--version");\r
- }\r
-\r
- @Override\r
- protected int _exec(int idx, String... args) throws CadiException, APIException, LocatorException {\r
- pw().println("AAF Command Line Tool");\r
- String version = this.env().getProperty(Config.AAF_DEPLOYED_VERSION, "N/A");\r
- pw().println("Version: " + version);\r
- return HttpStatus.OK_200;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Cache extends BaseCmd<Mgmt> {\r
- public Cache(Mgmt mgmt) throws APIException {\r
- super(mgmt, "cache");\r
- cmds.add(new Clear(this));\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.authz.common.Define;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class Clear extends Cmd {\r
- public Clear(Cache parent) {\r
- super(parent,"clear",\r
- new Param("name[,name]*",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- int rv=409;\r
- for(final String name : args[idx++].split(COMMA)) {\r
- rv = all(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws APIException, CadiException {\r
- int rv = 409;\r
- Future<Void> fp = client.delete(\r
- "/mgmt/cache/"+name, \r
- Void.class\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Cleared Cache for " + name + " on " + client);\r
- rv=200;\r
- } else {\r
- if(rv==409)rv = fp.code();\r
- error(fp);\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Clear the cache for certain tables");\r
- indent+=2;\r
- detailLine(sb,indent,"name - name of table or 'all'");\r
- detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\'');\r
- indent-=2;\r
- api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Deny extends BaseCmd<Mgmt> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Deny(Mgmt mgmt) throws APIException {\r
- super(mgmt, "deny");\r
- cmds.add(new DenySomething(this,"ip","ipv4or6[,ipv4or6]*"));\r
- cmds.add(new DenySomething(this,"id","identity[,identity]*"));\r
- }\r
- \r
- public class DenySomething extends Cmd {\r
-\r
- private boolean isID;\r
-\r
- public DenySomething(Deny deny, String type, String repeatable) {\r
- super(deny, type,\r
- new Param(optionsToString(options),true),\r
- new Param(repeatable,true));\r
- isID = "id".equals(type);\r
- }\r
-\r
- @Override\r
- protected int _exec(int _idx, String... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- String action = args[idx++];\r
- final int option = whichOption(options, action);\r
- int rv=409;\r
- for(final String name : args[idx++].split(COMMA)) {\r
- final String append;\r
- if(isID && name.indexOf("@")<0) {\r
- append='@'+ env.getProperty(AAFcli.AAF_DEFAULT_REALM);\r
- } else {\r
- append = "";\r
- }\r
- final String path = "/mgmt/deny/"+getName() + '/'+ name + append;\r
- rv = all(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws APIException, CadiException {\r
- int rv = 409;\r
- Future<Void> fp;\r
- String resp;\r
- switch(option) {\r
- case 0: \r
- fp = client.create(path, Void.class);\r
- resp = " added";\r
- break;\r
- default: \r
- fp = client.delete(path, Void.class);\r
- resp = " deleted";\r
- }\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println(name + append + resp + " on " + client);\r
- rv=fp.code();\r
- } else {\r
- if(rv==409)rv = fp.code();\r
- error(fp);\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
- return rv;\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.authz.common.Define;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Log extends BaseCmd<Mgmt> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Log(Mgmt mgmt) throws APIException {\r
- super(mgmt, "log",\r
- new Param(optionsToString(options),true),\r
- new Param("id[,id]*",true));\r
- }\r
- \r
- @Override\r
- public int _exec(int _idx, String ... args) throws CadiException, APIException, LocatorException {\r
- int rv=409;\r
- int idx = _idx;\r
- final int option = whichOption(options, args[idx++]);\r
-\r
- for(String name : args[idx++].split(COMMA)) {\r
- final String fname;\r
- if(name.indexOf("@")<0) {\r
- fname=name+'@'+ env.getProperty(AAFcli.AAF_DEFAULT_REALM);\r
- } else {\r
- fname = name;\r
- }\r
- \r
- \r
-\r
- rv = all(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws APIException, CadiException {\r
- int rv = 409;\r
- Future<Void> fp;\r
- String str = "/mgmt/log/id/"+fname;\r
- String msg;\r
- switch(option) {\r
- case 0: \r
- fp = client.create(str,Void.class);\r
- msg = "Added";\r
- break;\r
- case 1:\r
- fp = client.delete(str,Void.class);\r
- msg = "Deleted";\r
- break;\r
- default:\r
- fp = null;\r
- msg = "Ignored";\r
- }\r
- \r
- if(fp!=null) {\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println(msg + " Special Log for " + fname + " on " + client);\r
- rv=200;\r
- } else {\r
- if(rv==409)rv = fp.code();\r
- error(fp);\r
- }\r
- return rv;\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Clear the cache for certain tables");\r
- indent+=2;\r
- detailLine(sb,indent,"name - name of table or 'all'");\r
- detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\'');\r
- indent-=2;\r
- api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Mgmt extends BaseCmd<Mgmt> {\r
- public Mgmt(AAFcli aafcli) throws APIException {\r
- super(aafcli, "mgmt");\r
- cmds.add(new Cache(this));\r
- cmds.add(new Deny(this));\r
- cmds.add(new Log(this));\r
- cmds.add(new Session(this));\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.authz.common.Define;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class SessClear extends Cmd {\r
- public SessClear(Session parent) {\r
- super(parent,"clear",\r
- new Param("machine",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int idx, String ... args) throws CadiException, APIException, LocatorException {\r
- int rv=409;\r
- String machine = args[idx++];\r
- rv = oneOf(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws APIException, CadiException {\r
- int rv = 409;\r
- Future<Void> fp = client.delete(\r
- "/mgmt/dbsession", \r
- Void.class\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Cleared DBSession on " + client);\r
- rv=200;\r
- } else {\r
- if(rv==409)rv = fp.code();\r
- error(fp);\r
- }\r
- return rv;\r
- }\r
- },machine);\r
- return rv;\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Clear the cache for certain tables");\r
- indent+=2;\r
- detailLine(sb,indent,"name - name of table or 'all'");\r
- detailLine(sb,indent+14,"Must have admin rights to '" + Define.ROOT_NS + '\'');\r
- indent-=2;\r
- api(sb,indent,HttpMethods.DELETE,"mgmt/cache/:name",Void.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Session extends BaseCmd<Mgmt> {\r
- public Session(Mgmt mgmt) throws APIException {\r
- super(mgmt, "dbsession");\r
- cmds.add(new SessClear(this));\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Admin extends BaseCmd<NS> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Admin(NS ns) throws APIException {\r
- super(ns,"admin",\r
- new Param(optionsToString(options),true),\r
- new Param("name",true),\r
- new Param("id[,id]*",true)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final int option = whichOption(options, args[idx++]);\r
- final String ns = args[idx++];\r
- final String ids[] = args[idx++].split(",");\r
- final String realm = getOrgRealm();\r
-// int rv = 500;\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException { \r
- Future<Void> fp = null;\r
- for(String id : ids) {\r
- if (id.indexOf('@') < 0 && realm != null) id += '@' + realm;\r
- String verb;\r
- switch(option) {\r
- case 0: \r
- fp = client.create("/authz/ns/"+ns+"/admin/"+id,Void.class);\r
- verb = " added to ";\r
- break;\r
- case 1: \r
- fp = client.delete("/authz/ns/"+ns+"/admin/"+id,Void.class);\r
- verb = " deleted from ";\r
- break;\r
- default:\r
- throw new CadiException("Bad Argument");\r
- };\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().append("Admin ");\r
- pw().append(id);\r
- pw().append(verb);\r
- pw().println(ns);\r
- } else {\r
- error(fp);\r
- return fp.code();\r
- }\r
- \r
- }\r
- return fp==null?500:fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add or Delete Administrator to/from Namespace");\r
- indent+=4;\r
- detailLine(sb,indent,"name - Name of Namespace");\r
- detailLine(sb,indent,"id - Credential of Person(s) to be Administrator");\r
- sb.append('\n');\r
- detailLine(sb,indent,"aafcli will call API on each ID presented.");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.POST,"authz/ns/<ns>/admin/<id>",Void.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/admin/<id>",Void.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Attrib extends BaseCmd<NS> {\r
- private final static String[] options = {"add","upd","del"};\r
-\r
- public Attrib(NS ns) throws APIException {\r
- super(ns,"attrib",\r
- new Param(optionsToString(options),true),\r
- new Param("ns",true),\r
- new Param("key",true),\r
- new Param("value",false)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final int option = whichOption(options, args[idx]);\r
- final String ns = args[idx+1];\r
- final String key = args[idx+2];\r
- final String value;\r
- if(option!=2) {\r
- if(args.length<=idx+3) {\r
- throw new CadiException("Not added: Need more Data");\r
- }\r
- value = args[idx+3];\r
- } else {\r
- value = "";\r
- }\r
- \r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException { \r
- Future<Void> fp = null;\r
- String message;\r
- switch(option) {\r
- case 0: \r
- fp = client.create("/authz/ns/"+ns+"/attrib/"+key+'/'+value,Void.class);\r
- message = String.format("Add Attrib %s=%s to %s",\r
- key,value,ns);\r
- break;\r
- case 1: \r
- fp = client.update("/authz/ns/"+ns+"/attrib/"+key+'/'+value);\r
- message = String.format("Update Attrib %s=%s for %s",\r
- key,value,ns);\r
- break;\r
- case 2: \r
- fp = client.delete("/authz/ns/"+ns+"/attrib/"+key,Void.class);\r
- message = String.format("Attrib %s deleted from %s",\r
- key,ns);\r
- break;\r
- default:\r
- throw new CadiException("Bad Argument");\r
- };\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println(message);\r
- } else {\r
- error(fp);\r
- return fp.code();\r
- }\r
- \r
- return fp==null?500:fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add or Delete Administrator to/from Namespace");\r
- indent+=4;\r
- detailLine(sb,indent,"name - Name of Namespace");\r
- detailLine(sb,indent,"id - Credential of Person(s) to be Administrator");\r
- sb.append('\n');\r
- detailLine(sb,indent,"aafcli will call API on each ID presented.");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.POST,"authz/ns/<ns>/admin/<id>",Void.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/admin/<id>",Void.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.NsRequest;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class Create extends Cmd {\r
- private static final String COMMA = ",";\r
-\r
- public Create(NS parent) {\r
- super(parent,"create", \r
- new Param("name",true),\r
- new Param("responsible (id[,id]*)",true), \r
- new Param("admin (id[,id]*)",false));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
-\r
- final NsRequest nr = new NsRequest();\r
- \r
- String realm = getOrgRealm();\r
- \r
- nr.setName(args[idx++]);\r
- String[] responsible = args[idx++].split(COMMA);\r
- for(String s : responsible) {\r
- if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;\r
- nr.getResponsible().add(s);\r
- }\r
- String[] admin;\r
- if(args.length>idx) {\r
- admin = args[idx++].split(COMMA);\r
- } else {\r
- admin = responsible;\r
- }\r
- for(String s : admin) {\r
- if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;\r
- nr.getAdmin().add(s);\r
- }\r
- \r
- // Set Start/End commands\r
- setStartEnd(nr);\r
- \r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- // Requestable\r
- setQueryParamsOn(client);\r
- Future<NsRequest> fp = client.create(\r
- "/authz/ns", \r
- getDF(NsRequest.class),\r
- nr\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Created Namespace");\r
- } else {\r
- if(fp.code()==202) {\r
- pw().println("Namespace Creation Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Create a Namespace");\r
- indent+=2;\r
- detailLine(sb,indent,"name - Namespaces are dot-delimited, ex com.att.myapp");\r
- detailLine(sb,indent+14,"and must be created with parent credentials.");\r
- detailLine(sb,indent+14,"Ex: to create com.att.myapp, you must be admin for com.att");\r
- detailLine(sb,indent+14,"or com");\r
- detailLine(sb,indent,"responsible - This is the person(s) who receives Notifications and");\r
- detailLine(sb,indent+14,"approves Requests regarding this Namespace. Companies have");\r
- detailLine(sb,indent+14,"Policies as to who may take on this responsibility");\r
- detailLine(sb,indent,"admin - These are the people who are allowed to make changes on");\r
- detailLine(sb,indent+14,"the Namespace, including creating Roles, Permissions");\r
- detailLine(sb,indent+14,"and Credentials");\r
- sb.append('\n');\r
- detailLine(sb,indent,"Namespaces can be created even though there are Roles/Permissions which");\r
- detailLine(sb,indent,"start with the requested sub-namespace. They are reassigned to the");\r
- detailLine(sb,indent,"Child Namespace");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.POST,"authz/ns",NsRequest.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class Delete extends Cmd {\r
- public Delete(NS parent) {\r
- super(parent,"delete", \r
- new Param("name",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int index = idx;\r
- StringBuilder path = new StringBuilder("/authz/ns/");\r
- path.append(args[index++]);\r
- \r
- // Send "Force" if set\r
- setQueryParamsOn(client);\r
- Future<Void> fp = client.delete(path.toString(),Void.class);\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Deleted Namespace");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Delete a Namespace");\r
- indent+=4;\r
- detailLine(sb,indent,"Namespaces cannot normally be deleted when there are still credentials,");\r
- detailLine(sb,indent,"permissions or roles associated with them. These can be deleted");\r
- detailLine(sb,indent,"automatically by setting \"force\" property.");\r
- detailLine(sb,indent,"i.e. set force=true or just starting with \"force\"");\r
- detailLine(sb,indent," (note force is unset after first use)");\r
- sb.append('\n');\r
- detailLine(sb,indent,"If \"set force=move\" is set, credentials are deleted, but ");\r
- detailLine(sb,indent,"Permissions and Roles are assigned to the Parent Namespace instead of");\r
- detailLine(sb,indent,"being deleted. Similarly, Namespaces can be created even though there");\r
- detailLine(sb,indent,"are Roles/Perms whose type starts with the requested sub-namespace.");\r
- detailLine(sb,indent,"They are simply reassigned to the Child Namespace");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>[?force=true]",Void.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.NsRequest;\r
-\r
-public class Describe extends Cmd {\r
- private static final String NS_PATH = "/authz/ns";\r
- public Describe(NS parent) {\r
- super(parent,"describe", \r
- new Param("name",true),\r
- new Param("description",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String name = args[idx++];\r
- StringBuilder desc = new StringBuilder();\r
- while (idx < args.length) {\r
- desc.append(args[idx++] + ' ');\r
- }\r
- \r
- NsRequest nsr = new NsRequest();\r
- nsr.setName(name);\r
- nsr.setDescription(desc.toString());\r
- \r
- // Set Start/End commands\r
- setStartEnd(nsr);\r
- \r
- Future<NsRequest> fn = null;\r
- int rv;\r
-\r
- fn = client.update(\r
- NS_PATH,\r
- getDF(NsRequest.class),\r
- nsr\r
- );\r
-\r
- if(fn.get(AAFcli.timeout())) {\r
- rv=fn.code();\r
- pw().println("Description added to Namespace");\r
- } else {\r
- if((rv=fn.code())==202) {\r
- pw().print("Adding description");\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fn);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Add a description to a namespace");\r
- api(sb,indent,HttpMethods.PUT,"authz/ns",NsRequest.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-import aaf.v2_0.Nss.Ns.Attrib;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-public class List extends BaseCmd<NS> {\r
-\r
- public List(NS parent) {\r
- super(parent,"list");\r
- cmds.add(new ListByName(this));\r
- \r
-// TODO: uncomment when on cassandra 2.1.2 if we like cli command to get all ns's \r
-// a user is admin or responsible for \r
- cmds.add(new ListAdminResponsible(this));\r
- \r
- cmds.add(new ListActivity(this));\r
- cmds.add(new ListUsers(this));\r
- cmds.add(new ListChildren(this));\r
- cmds.add(new ListNsKeysByAttrib(this));\r
- }\r
-\r
- private static final String sformat = " %-72s\n";\r
- protected static final String kformat = " %-72s\n";\r
-\r
- \r
- public void report(Future<Nss> fp, String ... str) {\r
- reportHead(str);\r
- if(fp==null) {\r
- pw().println(" *** Namespace Not Found ***");\r
- }\r
- \r
- if(fp!=null && fp.value!=null) {\r
- for(Ns ns : fp.value.getNs()) {\r
- pw().println(ns.getName());\r
- if (this.aafcli.isDetailed()) {\r
- pw().println(" Description");\r
- pw().format(sformat,ns.getDescription()==null?"":ns.getDescription());\r
- }\r
- if(ns.getAdmin().size()>0) {\r
- pw().println(" Administrators");\r
- for(String admin : ns.getAdmin()) {\r
- pw().format(sformat,admin);\r
- }\r
- }\r
- if(ns.getResponsible().size()>0) {\r
- pw().println(" Responsible Parties");\r
- for(String responsible : ns.getResponsible()) {\r
- pw().format(sformat,responsible);\r
- }\r
- }\r
- if(ns.getAttrib().size()>0) {\r
- pw().println(" Namespace Attributes");\r
- for(Attrib attrib : ns.getAttrib()) {\r
- StringBuilder sb = new StringBuilder(attrib.getKey());\r
- if(attrib.getValue()==null || attrib.getValue().length()>0) {\r
- sb.append('=');\r
- sb.append(attrib.getValue());\r
- }\r
- pw().format(sformat,sb.toString());\r
- }\r
- \r
- }\r
- }\r
- }\r
- }\r
- \r
- public void reportName(Future<Nss> fp, String ... str) {\r
- reportHead(str);\r
- if(fp!=null && fp.value!=null) {\r
- java.util.List<Ns> nss = fp.value.getNs();\r
- Collections.sort(nss, new Comparator<Ns>() {\r
- @Override\r
- public int compare(Ns ns1, Ns ns2) {\r
- return ns1.getName().compareTo(ns2.getName());\r
- }\r
- });\r
- \r
- for(Ns ns : nss) {\r
- pw().println(ns.getName());\r
- if (this.aafcli.isDetailed() && ns.getDescription() != null) {\r
- pw().println(" " + ns.getDescription());\r
- }\r
- }\r
- }\r
- }\r
-\r
- public void reportRole(Future<Roles> fr) {\r
- if(fr!=null && fr.value!=null && fr.value.getRole().size()>0) {\r
- pw().println(" Roles");\r
- for(aaf.v2_0.Role r : fr.value.getRole()) {\r
- pw().format(sformat,r.getName());\r
- }\r
- }\r
- }\r
-\r
- private static final String pformat = " %-30s %-24s %-15s\n";\r
- public void reportPerm(Future<Perms> fp) {\r
- if(fp!=null && fp.value!=null && fp.value.getPerm().size()>0) {\r
- pw().println(" Permissions");\r
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {\r
- pw().format(pformat,p.getType(),p.getInstance(),p.getAction());\r
- }\r
- }\r
- }\r
- \r
- \r
- private static final String cformat = " %-30s %-6s %-24s\n";\r
- public void reportCred(Future<Users> fc) { \r
- if(fc!=null && fc.value!=null && fc.value.getUser().size()>0) {\r
- pw().println(" Credentials");\r
- java.util.List<User> users = fc.value.getUser();\r
- Collections.sort(users, new Comparator<User>() {\r
- @Override\r
- public int compare(User u1, User u2) {\r
- return u1.getId().compareTo(u2.getId());\r
- }\r
- });\r
- for(aaf.v2_0.Users.User u : users) {\r
- if (this.aafcli.isTest()) {\r
- pw().format(sformat,u.getId());\r
- } else {\r
- String type;\r
- switch(u.getType()) {\r
- case 1: type = "U/P"; break;\r
- case 10: type="Cert"; break;\r
- case 200: type="x509"; break;\r
- default: type = "";\r
- }\r
- pw().format(cformat,u.getId(),type,Chrono.niceDateStamp(u.getExpires()));\r
- }\r
- }\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.History;\r
-\r
-/**\r
- *\r
- */\r
-public class ListActivity extends Cmd {\r
- private static final String HEADER = "List Activity of Namespace";\r
- \r
- public ListActivity(List parent) {\r
- super(parent,"activity", \r
- new Param("name",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String ns = args[idx++];\r
- \r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<History> fp = client.read(\r
- "/authz/hist/ns/"+ns, \r
- getDF(History.class)\r
- );\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- activity(fp.value, HEADER + " [ " + ns + " ]");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/hist/ns/<ns>",History.class,true);\r
- }\r
-\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-\r
-public class ListAdminResponsible extends Cmd {\r
- private static final String HEADER="List Namespaces with ";\r
- private final static String[] options = {"admin","responsible"};\r
- \r
- public ListAdminResponsible(List parent) {\r
- super(parent,null, \r
- new Param(optionsToString(options),true),\r
- new Param("user",true)); \r
- }\r
-\r
- @Override\r
- protected int _exec(final int index, final String... args) throws CadiException, APIException, LocatorException {\r
-\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String title = args[idx++];\r
- String user = args[idx++];\r
- if (user.indexOf('@') < 0 && getOrgRealm() != null) user += '@' + getOrgRealm();\r
- \r
- Future<Nss> fn = client.read("/authz/nss/"+title+"/"+user,getDF(Nss.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- ((List)parent).reportName(fn,HEADER + title + " privileges for ",user);\r
- } else if(fn.code()==404) {\r
- ((List)parent).report(null,HEADER + title + " privileges for ",user);\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER + "admin or responsible priveleges for user");\r
- api(sb,indent,HttpMethods.GET,"authz/nss/<admin|responsible>/<user>",Nss.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-\r
-/**\r
- *\r
- */\r
-public class ListByName extends Cmd {\r
- private static final String HEADER="List Namespaces by Name";\r
- \r
- public ListByName(List parent) {\r
- super(parent,"name", \r
- new Param("ns",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String ns=args[idx++];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Nss> fn = client.read("/authz/nss/"+ns,getDF(Nss.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- ((List)parent).report(fn,HEADER,ns);\r
- if(fn.value!=null) {\r
- for(Ns n : fn.value.getNs()) {\r
- Future<Roles> fr = client.read("/authz/roles/ns/"+n.getName(), getDF(Roles.class));\r
- if(fr.get(AAFcli.timeout())) {\r
- ((List)parent).reportRole(fr);\r
- }\r
- }\r
- for(Ns n : fn.value.getNs()) {\r
- Future<Perms> fp = client.read("/authz/perms/ns/"+n.getName(), getDF(Perms.class));\r
- if(fp.get(AAFcli.timeout())) {\r
- ((List)parent).reportPerm(fp);\r
- }\r
- }\r
- for(Ns n : fn.value.getNs()) {\r
- Future<Users> fu = client.read("/authn/creds/ns/"+n.getName(), getDF(Users.class));\r
- if(fu.get(AAFcli.timeout())) {\r
- ((List)parent).reportCred(fu);\r
- }\r
- }\r
- }\r
- } else if(fn.code()==404) {\r
- ((List)parent).report(null,HEADER,ns);\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/nss/<ns>",Nss.class,true);\r
- detailLine(sb,indent,"Indirectly uses:");\r
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);\r
- api(sb,indent,HttpMethods.GET,"authn/creds/ns/<ns>",Users.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListChildren extends Cmd {\r
- private static final String HEADER="List Child Namespaces";\r
- \r
- public ListChildren(List parent) {\r
- super(parent,"children", \r
- new Param("ns",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String ns=args[idx++];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Nss> fn = client.read("/authz/nss/children/"+ns,getDF(Nss.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- parent.reportHead(HEADER);\r
- for(Ns ns : fn.value.getNs()) {\r
- pw().format(List.kformat, ns.getName());\r
- }\r
- } else if(fn.code()==404) {\r
- ((List)parent).report(null,HEADER,ns);\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/nss/children/<ns>",Nss.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Keys;\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListNsKeysByAttrib extends Cmd {\r
- private static final String HEADER="List Namespace Names by Attribute";\r
- \r
- public ListNsKeysByAttrib(List parent) {\r
- super(parent,"keys", \r
- new Param("attrib",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final String attrib=args[idx];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Keys> fn = client.read("/authz/ns/attrib/"+attrib,getDF(Keys.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- parent.reportHead(HEADER);\r
- for(String key : fn.value.getKey()) {\r
- pw().printf(List.kformat, key);\r
- }\r
- } else if(fn.code()==404) {\r
- parent.reportHead(HEADER);\r
- pw().println(" *** No Namespaces Found ***");\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/nss/<ns>",Nss.class,true);\r
- detailLine(sb,indent,"Indirectly uses:");\r
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);\r
- api(sb,indent,HttpMethods.GET,"authn/creds/ns/<ns>",Users.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import javax.xml.datatype.XMLGregorianCalendar;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import aaf.v2_0.Users.User;\r
-\r
-public class ListUsers extends BaseCmd<List> {\r
- \r
- public ListUsers(List parent) {\r
- super(parent,"user");\r
- cmds.add(new ListUsersWithPerm(this));\r
- cmds.add(new ListUsersInRole(this));\r
- }\r
-\r
- public void report(String header, String ns) {\r
- ((List)parent).report(null, header,ns);\r
- }\r
-\r
- public void report(String subHead) {\r
- pw().println(subHead);\r
- }\r
-\r
- private static final String uformat = "%s%-50s expires:%02d/%02d/%04d\n";\r
- public void report(String prefix, User u) {\r
- XMLGregorianCalendar xgc = u.getExpires();\r
- pw().format(uformat,prefix,u.getId(),xgc.getMonth()+1,xgc.getDay(),xgc.getYear());\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-import aaf.v2_0.Role;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListUsersInRole extends Cmd {\r
- private static final String HEADER="List Users in Roles of Namespace ";\r
- \r
- public ListUsersInRole(ListUsers parent) {\r
- super(parent,"role", \r
- new Param("ns",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String ns=args[idx++];\r
- final boolean detail = aafcli.isDetailed();\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- ((ListUsers)parent).report(HEADER,ns);\r
- Future<Nss> fn = client.read("/authz/nss/"+ns,getDF(Nss.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- if(fn.value!=null) {\r
- Set<String> uset = detail?null:new HashSet<String>();\r
- for(Ns n : fn.value.getNs()) {\r
- Future<Roles> fr = client.read("/authz/roles/ns/"+n.getName(), getDF(Roles.class));\r
- if(fr.get(AAFcli.timeout())) {\r
- for(Role r : fr.value.getRole()) {\r
- if(detail) {\r
- ((ListUsers)parent).report(r.getName());\r
- }\r
- Future<Users> fus = client.read(\r
- "/authz/users/role/"+r.getName(), \r
- getDF(Users.class)\r
- );\r
- if(fus.get(AAFcli.timeout())) {\r
- for(User u : fus.value.getUser()) {\r
- if(detail) {\r
- ((ListUsers)parent).report(" ",u);\r
- } else {\r
- uset.add(u.getId());\r
- }\r
- }\r
- } else if(fn.code()==404) {\r
- return 200;\r
- }\r
- }\r
- }\r
- }\r
- if(uset!=null) {\r
- for(String u : uset) {\r
- pw().print(" ");\r
- pw().println(u);\r
- }\r
- }\r
- }\r
- } else if(fn.code()==404) {\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=4;\r
- detailLine(sb,indent,"Report Users associated with this Namespace's Roles");\r
- sb.append('\n');\r
- detailLine(sb,indent,"If \"set details=true\" is specified, then all roles are printed ");\r
- detailLine(sb,indent,"with the associated users and expiration dates");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.GET,"authz/nss/<ns>",Nss.class,true);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/ns/<ns>",Roles.class,false);\r
- api(sb,indent,HttpMethods.GET,"authz/users/role/<ns>",Users.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Nss.Ns;\r
-import aaf.v2_0.Perm;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListUsersWithPerm extends Cmd {\r
- private static final String HEADER="List Users of Permissions of Namespace ";\r
- \r
- public ListUsersWithPerm(ListUsers parent) {\r
- super(parent,"perm", \r
- new Param("ns",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String ns=args[idx++];\r
- final boolean detail = aafcli.isDetailed();\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- ((ListUsers)parent).report(HEADER,ns);\r
- Future<Nss> fn = client.read("/authz/nss/"+ns,getDF(Nss.class));\r
- if(fn.get(AAFcli.timeout())) {\r
- if(fn.value!=null) {\r
- Set<String> uset = detail?null:new HashSet<String>();\r
- \r
- for(Ns n : fn.value.getNs()) {\r
- Future<Perms> fp = client.read("/authz/perms/ns/"+n.getName(), getDF(Perms.class));\r
- if(fp.get(AAFcli.timeout())) {\r
- for(Perm p : fp.value.getPerm()) {\r
- String perm = p.getType()+'/'+p.getInstance()+'/'+p.getAction();\r
- if(detail)((ListUsers)parent).report(perm);\r
- Future<Users> fus = client.read(\r
- "/authz/users/perm/"+perm, \r
- getDF(Users.class)\r
- );\r
- if(fus.get(AAFcli.timeout())) {\r
- for(User u : fus.value.getUser()) {\r
- if(detail)\r
- ((ListUsers)parent).report(" ",u);\r
- else \r
- uset.add(u.getId());\r
- }\r
- } else if(fn.code()==404) {\r
- return 200;\r
- }\r
- }\r
- }\r
- }\r
- if(uset!=null) {\r
- for(String u : uset) {\r
- pw().print(" ");\r
- pw().println(u);\r
- }\r
- }\r
- }\r
- } else if(fn.code()==404) {\r
- return 200;\r
- } else { \r
- error(fn);\r
- }\r
- return fn.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=4;\r
- detailLine(sb,indent,"Report Users associated with this Namespace's Permissions");\r
- sb.append('\n');\r
- detailLine(sb,indent,"If \"set detail=true\" is specified, then Permissions are printed with the associated");\r
- detailLine(sb,indent,"users and expiration dates");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.GET,"authz/nss/<ns>",Nss.class,true);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,false);\r
- api(sb,indent,HttpMethods.GET,"authz/users/perm/<type>/<instance>/<action>",Users.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class NS extends BaseCmd<NS> {\r
-// final Role role;\r
-\r
- public NS(AAFcli aafcli) throws APIException {\r
- super(aafcli, "ns");\r
-// this.role = role;\r
- \r
- cmds.add(new Create(this));\r
- cmds.add(new Delete(this));\r
- cmds.add(new Admin(this));\r
- cmds.add(new Responsible(this));\r
- cmds.add(new Describe(this));\r
- cmds.add(new Attrib(this));\r
- cmds.add(new List(this));\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Responsible extends BaseCmd<NS> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Responsible(NS ns) throws APIException {\r
- super(ns,"responsible",\r
- new Param(optionsToString(options),true),\r
- new Param("name",true),\r
- new Param("id[,id]*",true)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
-\r
- final int option = whichOption(options, args[idx++]);\r
- final String ns = args[idx++];\r
- final String ids[] = args[idx++].split(",");\r
- final String realm = getOrgRealm();\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Void> fp=null;\r
- for(String id : ids) {\r
- if (id.indexOf('@') < 0 && realm != null) id += '@' + realm;\r
- String verb;\r
- switch(option) {\r
- case 0: \r
- fp = client.create("/authz/ns/"+ns+"/responsible/"+id,Void.class);\r
- verb = " is now ";\r
- break;\r
- case 1: \r
- fp = client.delete("/authz/ns/"+ns+"/responsible/"+id,Void.class);\r
- verb = " is no longer ";\r
- break;\r
- default:\r
- throw new CadiException("Bad Argument");\r
- };\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().append(id);\r
- pw().append(verb);\r
- pw().append("responsible for ");\r
- pw().println(ns);\r
- } else {\r
- error(fp);\r
- return fp.code();\r
- }\r
- }\r
- return fp==null?500:fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add or Delete Responsible person to/from Namespace");\r
- indent+=2;\r
- detailLine(sb,indent,"Responsible persons receive Notifications and approve Requests ");\r
- detailLine(sb,indent,"regarding this Namespace. Companies have Policies as to who may");\r
- detailLine(sb,indent,"take on this responsibility");\r
-\r
- indent+=2;\r
- detailLine(sb,indent,"name - Name of Namespace");\r
- detailLine(sb,indent,"id - Credential of Person(s) to be made responsible");\r
- sb.append('\n');\r
- detailLine(sb,indent,"aafcli will call API on each ID presented.");\r
- indent-=4;\r
- api(sb,indent,HttpMethods.POST,"authz/ns/<ns>/responsible/<id>",Void.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>/responsible/<id>",Void.class,false);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.PermRequest;\r
-import aaf.v2_0.RoleRequest;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class Create extends Cmd {\r
- public Create(Perm parent) {\r
- super(parent,"create", \r
- new Param("type",true), \r
- new Param("instance",true),\r
- new Param("action", true),\r
- new Param("role[,role]* (to Grant to)", false)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- final PermRequest pr = new PermRequest(); \r
- pr.setType(args[idx++]);\r
- pr.setInstance(args[idx++]);\r
- pr.setAction(args[idx++]);\r
- String roleCommas = (args.length>idx)?args[idx++]:null;\r
- String[] roles = roleCommas==null?null:roleCommas.split("\\s*,\\s*");\r
- boolean force = aafcli.forceString()!=null;\r
- int rv;\r
- \r
- if(roles!=null && force) { // Make sure Roles are Created\r
- RoleRequest rr = new RoleRequest();\r
- for(String role : roles) {\r
- rr.setName(role);;\r
- Future<RoleRequest> fr = client.create(\r
- "/authz/role",\r
- getDF(RoleRequest.class),\r
- rr\r
- );\r
- fr.get(AAFcli.timeout());\r
- switch(fr.code()){\r
- case 201:\r
- pw().println("Created Role [" + role + ']');\r
- break;\r
- case 409:\r
- break;\r
- default: \r
- pw().println("Role [" + role + "] does not exist, and cannot be created.");\r
- return HttpStatus.PARTIAL_CONTENT_206;\r
- }\r
- }\r
- }\r
-\r
- // Set Start/End commands\r
- setStartEnd(pr);\r
- setQueryParamsOn(client);\r
- Future<PermRequest> fp = client.create(\r
- "/authz/perm",\r
- getDF(PermRequest.class),\r
- pr\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- rv = fp.code();\r
- pw().println("Created Permission");\r
- if(roles!=null) {\r
- if(aafcli.forceString()!=null) { // Make sure Roles are Created\r
- RoleRequest rr = new RoleRequest();\r
- for(String role : roles) {\r
- rr.setName(role);;\r
- Future<RoleRequest> fr = client.create(\r
- "/authz/role",\r
- getDF(RoleRequest.class),\r
- rr\r
- );\r
- fr.get(AAFcli.timeout());\r
- switch(fr.code()){\r
- case 201:\r
- case 409:break;\r
- default: \r
- \r
- }\r
- }\r
- }\r
- \r
- try {\r
- if(201!=(rv=((Perm)parent)._exec(0, \r
- new String[] {"grant",pr.getType(),pr.getInstance(),pr.getAction(),roleCommas}))) {\r
- rv = HttpStatus.PARTIAL_CONTENT_206;\r
- }\r
- } catch (LocatorException e) {\r
- throw new CadiException(e);\r
- }\r
- }\r
- } else {\r
- rv = fp.code();\r
- if(rv==409 && force) {\r
- rv = 201;\r
- } else if(rv==202) {\r
- pw().println("Permission Creation Accepted, but requires Approvals before actualizing");\r
- if (roles!=null)\r
- pw().println("You need to grant the roles after approval.");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Create a Permission with:");\r
- detailLine(sb,indent+=2,"type - A Namespace qualified identifier identifying the kind of");\r
- detailLine(sb,indent+11,"resource to be protected");\r
- detailLine(sb,indent,"instance - A name that distinguishes a particular instance of resource");\r
- detailLine(sb,indent,"action - What kind of action is allowed");\r
- detailLine(sb,indent,"role(s) - Perms granted to these Comma separated Role(s)");\r
- detailLine(sb,indent+11,"Nonexistent role(s) will be created, if in same namespace");\r
- sb.append('\n');\r
- detailLine(sb,indent+2,"Note: Instance and Action can be a an '*' (enter \\\\* on Unix Shell)");\r
- api(sb,indent,HttpMethods.POST,"authz/perm",PermRequest.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.PermRequest;\r
-\r
-/**\r
- *\r
- */\r
-public class Delete extends Cmd {\r
- public Delete(Perm parent) {\r
- super(parent,"delete", \r
- new Param("type",true), \r
- new Param("instance",true),\r
- new Param("action", true));\r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- // Object Style Delete\r
- PermRequest pk = new PermRequest();\r
- pk.setType(args[idx++]);\r
- pk.setInstance(args[idx++]);\r
- pk.setAction(args[idx++]);\r
- \r
- // Set "Force" if set\r
- setQueryParamsOn(client);\r
- Future<PermRequest> fp = client.delete(\r
- "/authz/perm", \r
- getDF(PermRequest.class),\r
- pk);\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Deleted Permission");\r
- } else {\r
- if(fp.code()==202) {\r
- pw().println("Permission Deletion Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Delete a Permission with type,instance and action");\r
- detailLine(sb,indent+4,"see Create for definitions");\r
- api(sb,indent,HttpMethods.DELETE,"authz/perm",PermRequest.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.PermRequest;\r
-\r
-public class Describe extends Cmd {\r
- private static final String PERM_PATH = "/authz/perm";\r
- public Describe(Perm parent) {\r
- super(parent,"describe", \r
- new Param("type",true),\r
- new Param("instance", true),\r
- new Param("action", true),\r
- new Param("description",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String type = args[idx++];\r
- String instance = args[idx++];\r
- String action = args[idx++];\r
- StringBuilder desc = new StringBuilder();\r
- while (idx < args.length) {\r
- desc.append(args[idx++] + ' ');\r
- }\r
- \r
- PermRequest pr = new PermRequest();\r
- pr.setType(type);\r
- pr.setInstance(instance);\r
- pr.setAction(action);\r
- pr.setDescription(desc.toString());\r
- \r
- // Set Start/End commands\r
- setStartEnd(pr);\r
- \r
- Future<PermRequest> fp = null;\r
- int rv;\r
-\r
- fp = client.update(\r
- PERM_PATH,\r
- getDF(PermRequest.class),\r
- pr\r
- );\r
-\r
- if(fp.get(AAFcli.timeout())) {\r
- rv=fp.code();\r
- pw().println("Description added to Permission");\r
- } else {\r
- if((rv=fp.code())==202) {\r
- pw().print("Adding description");\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Add a description to a permission");\r
- api(sb,indent,HttpMethods.PUT,"authz/perm",PermRequest.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Pkey;\r
-import aaf.v2_0.RolePermRequest;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class Grant extends Cmd {\r
- private final static String[] options = {"grant","ungrant","setTo"};\r
-\r
- public Grant(Perm parent) {\r
- super(parent,null,\r
- new Param(optionsToString(options),true),\r
- new Param("type",true),\r
- new Param("instance",true),\r
- new Param("action",true),\r
- new Param("role[,role]* (!REQ S)",false)\r
- ); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String action = args[idx++];\r
- int option = whichOption(options, action);\r
- \r
- RolePermRequest rpr = new RolePermRequest();\r
- Pkey pk = new Pkey();\r
- pk.setType(args[idx++]);\r
- pk.setInstance(args[idx++]);\r
- pk.setAction(args[idx++]);\r
- rpr.setPerm(pk);\r
- setStartEnd(rpr);\r
- \r
- Future<RolePermRequest> frpr = null;\r
- \r
- if (option != 2) {\r
- String[] roles = args[idx++].split(",");\r
- String strA,strB;\r
- for(String role : roles) {\r
- rpr.setRole(role);\r
- if(option==0) {\r
- // You can request to Grant Permission to a Role\r
- setQueryParamsOn(client);\r
- frpr = client.create(\r
- "/authz/role/perm", \r
- getDF(RolePermRequest.class),\r
- rpr\r
- );\r
- strA = "Granted Permission [";\r
- strB = "] to Role [";\r
- } else {\r
- // You can request to UnGrant Permission to a Role\r
- setQueryParamsOn(client);\r
- frpr = client.delete(\r
- "/authz/role/" + role + "/perm", \r
- getDF(RolePermRequest.class),\r
- rpr\r
- );\r
- strA = "UnGranted Permission [";\r
- strB = "] from Role [";\r
- }\r
- if(frpr.get(AAFcli.timeout())) {\r
- pw().println(strA + pk.getType() + '|' + pk.getInstance() + '|' + pk.getAction() \r
- + strB + role +']');\r
- } else {\r
- if (frpr.code()==202) {\r
- pw().print("Permission Role ");\r
- pw().print(option==0?"Granted":"Ungranted");\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(frpr);\r
- idx=Integer.MAX_VALUE;\r
- } \r
- }\r
- }\r
- } else {\r
- String allRoles = "";\r
- if (idx < args.length) \r
- allRoles = args[idx++];\r
- \r
- rpr.setRole(allRoles);\r
- frpr = client.update(\r
- "/authz/role/perm", \r
- getDF(RolePermRequest.class), \r
- rpr);\r
- if(frpr.get(AAFcli.timeout())) {\r
- pw().println("Set Permission's Roles to [" + allRoles + "]");\r
- } else {\r
- error(frpr);\r
- } \r
- } \r
- return frpr==null?0:frpr.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Grant a Permission to a Role or Roles OR");\r
- detailLine(sb,indent,"Ungrant a Permission from a Role or Roles OR");\r
- detailLine(sb,indent,"Set a Permission's roles to roles supplied.");\r
- detailLine(sb,indent+4,"WARNING: Roles supplied with setTo will be the ONLY roles attached to this permission");\r
- detailLine(sb,indent+8,"If no roles are supplied, permission's roles are reset.");\r
- detailLine(sb,indent,"see Create for definitions of type,instance and action");\r
- api(sb,indent,HttpMethods.POST,"authz/role/perm",RolePermRequest.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/role/<role>/perm",RolePermRequest.class,false);\r
- api(sb,indent,HttpMethods.PUT,"authz/role/perm",RolePermRequest.class,false);\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Perms;\r
-import aaf.v2_0.Pkey;\r
-\r
-\r
-public class List extends BaseCmd<Perm> {\r
-// private static final String LIST_PERM_DETAILS = "list permission details";\r
- \r
- public List(Perm parent) {\r
- super(parent,"list");\r
-\r
- cmds.add(new ListByUser(this));\r
- cmds.add(new ListByName(this));\r
- cmds.add(new ListByNS(this));\r
- cmds.add(new ListByRole(this));\r
- cmds.add(new ListActivity(this));\r
- }\r
- // Package Level on purpose\r
- abstract class ListPerms extends Retryable<Integer> {\r
- protected int list(Future<Perms> fp,Rcli<?> client, String header, String parentPerm) throws CadiException, APIException {\r
- if(fp.get(AAFcli.timeout())) { \r
- ArrayList<String> permNss = null;\r
- if (aafcli.isDetailed()) {\r
- permNss = new ArrayList<String>();\r
- String permNs = null;\r
- for(Pkey perm : fp.value.getPerm()) { \r
- if (permNs != null && perm.getType().contains(permNs)) {\r
- permNss.add(permNs);\r
- } else {\r
- Future<Nss> fpn = null;\r
- String permType = perm.getType();\r
- permNs = permType;\r
- do {\r
- permNs = permType.substring(0,permNs.lastIndexOf('.'));\r
- fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class));\r
- } while (!fpn.get(AAFcli.timeout()));\r
- permNss.add(permNs);\r
- }\r
- } \r
- } \r
- report(fp,permNss,header, parentPerm);\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- }\r
-\r
- private static final Comparator<aaf.v2_0.Perm> permCompare = new Comparator<aaf.v2_0.Perm>() {\r
- @Override\r
- public int compare(aaf.v2_0.Perm a, aaf.v2_0.Perm b) {\r
- int rc;\r
- if((rc=a.getType().compareTo(b.getType()))!=0) {\r
- return rc;\r
- }\r
- if((rc=a.getInstance().compareTo(b.getInstance()))!=0) {\r
- return rc;\r
- }\r
- return a.getAction().compareTo(b.getAction());\r
- }\r
- };\r
- \r
- void report(Future<Perms> fp, ArrayList<String> permNss, String ... str) {\r
- reportHead(str);\r
- if (this.aafcli.isDetailed()) { \r
- String format = reportColHead("%-20s %-15s %-30s %-15s\n %-75s\n","PERM NS","Type","Instance","Action", "Description");\r
- Collections.sort(fp.value.getPerm(),permCompare);\r
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {\r
- String permNs = permNss.remove(0);\r
- pw().format(format,\r
- permNs,\r
- p.getType().substring(permNs.length()+1),\r
- p.getInstance(),\r
- p.getAction(),\r
- p.getDescription()==null?"":p.getDescription());\r
- }\r
- pw().println();\r
- } else {\r
- String format = reportColHead("%-30s %-30s %-10s\n","PERM Type","Instance","Action");\r
-\r
- Collections.sort(fp.value.getPerm(),permCompare);\r
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {\r
- pw().format(format,\r
- p.getType(),\r
- p.getInstance(),\r
- p.getAction());\r
- }\r
- pw().println();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.History;\r
-\r
-/**\r
- *\r
- */\r
-public class ListActivity extends Cmd {\r
- private static final String HEADER = "List Activity of Permission";\r
- \r
- public ListActivity(List parent) {\r
- super(parent,"activity", \r
- new Param("type",true));\r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String type = args[idx++];\r
- Future<History> fp = client.read(\r
- "/authz/hist/perm/"+type, \r
- getDF(History.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- activity(fp.value, HEADER + " [ " + type + " ]");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/hist/perm/<type>",History.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Perms;\r
-\r
-/**\r
- * Return Perms by NS\r
- * \r
- *\r
- */\r
-public class ListByNS extends Cmd {\r
- private static final String HEADER = "List Perms by NS ";\r
- \r
- public ListByNS(List parent) {\r
- super(parent,"ns", \r
- new Param("name",true)); \r
- }\r
-\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final String ns=args[idx];\r
-\r
- return same(((List)parent).new ListPerms() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Perms> fp = client.read(\r
- "/authz/perms/ns/"+ns, \r
- getDF(Perms.class)\r
- );\r
- return list(fp,client, HEADER, ns);\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Perms;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class ListByName extends Cmd {\r
- private static final String HEADER = "List Child Permissions";\r
- \r
- public ListByName(List parent) {\r
- super(parent,"name", \r
- new Param("root perm name",true)); \r
- }\r
-\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(((List)parent).new ListPerms() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- String parentPerm=args[index];\r
- \r
- Future<Perms> fp = client.read(\r
- "/authz/perms/"+parentPerm, \r
- getDF(Perms.class) \r
- );\r
- return list(fp,client,HEADER,parentPerm);\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/<parent type>",Perms.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Perms;\r
-\r
-/**\r
- * Return Perms by Role\r
- * \r
- *\r
- */\r
-public class ListByRole extends Cmd {\r
- private static final String HEADER = "List Perms by Role ";\r
- \r
- public ListByRole(List parent) {\r
- super(parent,"role", \r
- new Param("name",true)); \r
- }\r
-\r
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final String role=args[idx];\r
-\r
- return same(((List)parent).new ListPerms() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
-\r
- Future<Perms> fp = client.read(\r
- "/authz/perms/role/"+role, \r
- getDF(Perms.class)\r
- );\r
- return list(fp,client, HEADER, role);\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/role/<role>",Perms.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Perms;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class ListByUser extends Cmd {\r
- private static final String HEADER = "List Permissions by User";\r
- public ListByUser(List parent) {\r
- super(parent,"user", \r
- new Param("id",true)); \r
- }\r
-\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- String user=args[idx];\r
- String realm = getOrgRealm();\r
- final String fullUser;\r
- if (user.indexOf('@') < 0 && realm != null) \r
- fullUser = user + '@' + realm;\r
- else\r
- fullUser = user;\r
- \r
- return same(((List)parent).new ListPerms() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Perms> fp = client.read(\r
- "/authz/perms/user/"+fullUser, \r
- getDF(Perms.class)\r
- );\r
- return list(fp, client, HEADER, fullUser);\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/perms/user/<user id>",Perms.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Perm extends BaseCmd<Perm> {\r
- Role role;\r
-\r
- public Perm(Role role) throws APIException {\r
- super(role.aafcli, "perm");\r
- this.role = role;\r
-\r
- cmds.add(new Create(this));\r
- cmds.add(new Delete(this));\r
- cmds.add(new Grant(this));\r
- cmds.add(new Rename(this));\r
- cmds.add(new Describe(this));\r
- cmds.add(new List(this));\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.PermRequest;\r
-\r
-public class Rename extends Cmd {\r
- public Rename(Perm parent) {\r
- super(parent,"rename", \r
- new Param("type",true), \r
- new Param("instance",true),\r
- new Param("action", true),\r
- new Param("new type",true), \r
- new Param("new instance",true),\r
- new Param("new action", true)\r
- );\r
- }\r
- \r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String origType = args[idx++];\r
- String origInstance = args[idx++];\r
- String origAction = args[idx++];\r
- \r
- //Create new permission\r
- PermRequest pr = new PermRequest();\r
- pr.setType(args[idx++]);\r
- pr.setInstance(args[idx++]);\r
- pr.setAction(args[idx++]);\r
- \r
- // Set Start/End commands\r
- setStartEnd(pr);\r
- Future<PermRequest> fp = client.update(\r
- "/authz/perm/"+origType+"/"+origInstance+"/"+origAction,\r
- getDF(PermRequest.class),\r
- pr\r
- );\r
- int rv;\r
- if(fp.get(AAFcli.timeout())) {\r
- rv = fp.code();\r
- pw().println("Updated Permission");\r
- } else {\r
- rv = fp.code();\r
- if(rv==202) {\r
- pw().println("Permission Update Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- \r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Rename a Permission from:");\r
- detailLine(sb,indent+2,"<type> <instance> <action>");\r
- detailLine(sb,indent,"to:");\r
- detailLine(sb,indent+2,"<new type> <new instance> <new action>");\r
- sb.append('\n');\r
- detailLine(sb,indent,"Namespace must be the same in <type> and <new type>");\r
- detailLine(sb,indent+4,"see Create for definitions of type,instance and action");\r
- api(sb,indent,HttpMethods.PUT,"authz/perm/<type>/<instance>/<action>",PermRequest.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.RoleRequest;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class CreateDelete extends Cmd {\r
- private static final String ROLE_PATH = "/authz/role";\r
- private final static String[] options = {"create","delete"};\r
- public CreateDelete(Role parent) {\r
- super(parent,null, \r
- new Param(optionsToString(options),true),\r
- new Param("name",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String action = args[idx++];\r
- int option = whichOption(options, action);\r
- \r
- RoleRequest rr = new RoleRequest();\r
- rr.setName(args[idx++]);\r
- \r
- // Set Start/End commands\r
- setStartEnd(rr);\r
- \r
- Future<RoleRequest> fp = null;\r
- String verb = null;\r
- int rv;\r
- switch(option) {\r
- case 0:\r
- fp = client.create(\r
- ROLE_PATH,\r
- getDF(RoleRequest.class),\r
- rr\r
- );\r
- verb = "Create";\r
- break;\r
- case 1:\r
- // Send "Force" if set\r
- setQueryParamsOn(client);\r
- fp = client.delete(\r
- ROLE_PATH, // +args[idx++], \r
- getDF(RoleRequest.class),\r
- rr\r
- );\r
- verb = "Delete";\r
- break;\r
- default: // note, if not an option, whichOption throws Exception\r
- break;\r
- \r
- }\r
- boolean rolesSupplied = (args.length>idx);\r
- if(fp.get(AAFcli.timeout())) {\r
- rv=fp.code();\r
- pw().print(verb);\r
- pw().println("d Role");\r
- if(rolesSupplied) {\r
- for(;args.length>idx;++idx ) {\r
- try {\r
- if(201!=(rv=((Role)parent)._exec(0,new String[] {"user","add",rr.getName(),args[idx]}))) {\r
- rv = HttpStatus.PARTIAL_CONTENT_206;\r
- }\r
- } catch (LocatorException e) {\r
- throw new CadiException(e);\r
- }\r
- }\r
- }\r
- } else {\r
- if((rv=fp.code())==202) {\r
- pw().print("Role ");\r
- pw().print(verb);\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Create OR Delete a Role");\r
- detailLine(sb,indent+2,"name - Name of Role to create");\r
- api(sb,indent,HttpMethods.POST,"authz/role",RoleRequest.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/role",RoleRequest.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.RoleRequest;\r
-\r
-public class Describe extends Cmd {\r
- private static final String ROLE_PATH = "/authz/role";\r
- public Describe(Role parent) {\r
- super(parent,"describe", \r
- new Param("name",true),\r
- new Param("description",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String role = args[idx++];\r
- StringBuilder desc = new StringBuilder();\r
- while (idx < args.length) {\r
- desc.append(args[idx++] + ' ');\r
- }\r
- \r
- RoleRequest rr = new RoleRequest();\r
- rr.setName(role);\r
- rr.setDescription(desc.toString());\r
- \r
- // Set Start/End commands\r
- setStartEnd(rr);\r
- \r
- Future<RoleRequest> fp = null;\r
- int rv;\r
-\r
- fp = client.update(\r
- ROLE_PATH,\r
- getDF(RoleRequest.class),\r
- rr\r
- );\r
-\r
- if(fp.get(AAFcli.timeout())) {\r
- rv=fp.code();\r
- pw().println("Description added to role");\r
- } else {\r
- if((rv=fp.code())==202) {\r
- pw().print("Adding description");\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Add a description to a role");\r
- api(sb,indent,HttpMethods.PUT,"authz/role",RoleRequest.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.HashMap;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Pkey;\r
-import aaf.v2_0.Roles;\r
-\r
-\r
-\r
-public class List extends BaseCmd<Role> {\r
- private static final String LIST_ROLES_BY_NAME = "list roles for role";\r
-\r
- public List(Role parent) {\r
- super(parent,"list");\r
- cmds.add(new ListByUser(this));\r
- cmds.add(new ListByRole(this));\r
- cmds.add(new ListByNS(this));\r
- cmds.add(new ListByNameOnly(this));\r
- cmds.add(new ListByPerm(this));\r
- cmds.add(new ListActivity(this));\r
- }\r
- \r
- // Package Level on purpose\r
- abstract class ListRoles extends Retryable<Integer> {\r
- protected int list(Future<Roles> fp,Rcli<?> client, String header) throws APIException, CadiException {\r
- if(fp.get(AAFcli.timeout())) {\r
- Future<Nss> fn = null;\r
- ArrayList<String> roleNss = null;\r
- ArrayList<String> permNss = null;\r
- if (aafcli.isDetailed()) {\r
- roleNss = new ArrayList<String>();\r
- permNss = new ArrayList<String>();\r
- for(aaf.v2_0.Role p : fp.value.getRole()) {\r
- String roleNs = p.getName();\r
- do {\r
- roleNs = p.getName().substring(0,roleNs.lastIndexOf('.'));\r
- fn = client.read("/authz/nss/"+roleNs,getDF(Nss.class));\r
- } while (!fn.get(AAFcli.timeout()));\r
- roleNss.add(roleNs);\r
- \r
- for(Pkey perm : p.getPerms()) {\r
- if (perm.getType().contains(roleNs))\r
- permNss.add(roleNs);\r
- else {\r
- Future<Nss> fpn = null;\r
- String permType = perm.getType();\r
- String permNs = permType;\r
- do {\r
- permNs = permType.substring(0,permNs.lastIndexOf('.'));\r
- fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class));\r
- } while (!fpn.get(AAFcli.timeout()));\r
- permNss.add(permNs);\r
- }\r
- }\r
- }\r
- }\r
- report(fp,roleNss,permNss,null,header);\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- }\r
-\r
- private final static String roleFormat = "%-50s\n";\r
- \r
- private static final Comparator<aaf.v2_0.Role> roleCompare = new Comparator<aaf.v2_0.Role>() {\r
- @Override\r
- public int compare(aaf.v2_0.Role a, aaf.v2_0.Role b) {\r
- return a.getName().compareTo(b.getName());\r
- }\r
- };\r
- public void report(Future<Roles> fp, ArrayList<String> roleNss, ArrayList<String> permNss,\r
- HashMap<String,Boolean> expiredMap, String ... str) {\r
- reportHead(str);\r
- if (fp != null && aafcli.isDetailed() && str[0].toLowerCase().contains(LIST_ROLES_BY_NAME)) {\r
- String description = fp.value.getRole().get(0).getDescription();\r
- if (description == null) description = "";\r
- reportColHead("%-80s\n","Description: " + description);\r
- } \r
-\r
- if(fp==null) {\r
- pw().println("<No Roles Found>");\r
- } else if (aafcli.isDetailed()){\r
- String permFormat = " %-20s %-15s %-30s %-15s\n";\r
- String fullFormat = roleFormat+permFormat;\r
- reportColHead(fullFormat,"[ROLE NS].Name","PERM NS","Type","Instance","Action");\r
- Collections.sort(fp.value.getRole(),roleCompare);\r
- for(aaf.v2_0.Role p : fp.value.getRole()) {\r
- String roleNs = roleNss.remove(0);\r
- pw().format(roleFormat, "["+roleNs+"]"+p.getName().substring(roleNs.length()));\r
- for(Pkey perm : p.getPerms()) {\r
- String permNs = permNss.remove(0);\r
- pw().format(permFormat, \r
- permNs,\r
- perm.getType().substring(permNs.length()+1),\r
- perm.getInstance(),\r
- perm.getAction());\r
- }\r
- }\r
- } else {\r
- String permFormat = " %-30s %-30s %-15s\n";\r
- String fullFormat = roleFormat+permFormat;\r
- reportColHead(fullFormat,"ROLE Name","PERM Type","Instance","Action");\r
- Collections.sort(fp.value.getRole(),roleCompare);\r
- for(aaf.v2_0.Role p : fp.value.getRole()) {\r
- if (expiredMap != null) {\r
- String roleName = p.getName();\r
- Boolean b = expiredMap.get(roleName);\r
- if (b != null && b.booleanValue())\r
- pw().format(roleFormat, roleName+"*");\r
- else {\r
- pw().format(roleFormat, roleName);\r
- for(Pkey perm : p.getPerms()) {\r
- pw().format(permFormat, \r
- perm.getType(),\r
- perm.getInstance(),\r
- perm.getAction());\r
- }\r
- }\r
- } else {\r
- pw().format(roleFormat, p.getName());\r
- for(Pkey perm : p.getPerms()) {\r
- pw().format(permFormat, \r
- perm.getType(),\r
- perm.getInstance(),\r
- perm.getAction());\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.History;\r
-\r
-/**\r
- *\r
- */\r
-public class ListActivity extends Cmd {\r
- private static final String HEADER = "List Activity of Role";\r
-\r
- public ListActivity(List parent) {\r
- super(parent,"activity", \r
- new Param("name",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String role = args[idx++];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<History> fp = client.read(\r
- "/authz/hist/role/"+role, \r
- getDF(History.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- activity(fp.value,HEADER + " [ " + role + " ]");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/hist/role/<role>",History.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Roles;\r
-\r
-/**\r
- * Return Roles by NS\r
- * \r
- *\r
- */\r
-public class ListByNS extends Cmd {\r
- private static final String HEADER = "List Roles by NS ";\r
- \r
- public ListByNS(List parent) {\r
- super(parent,"ns", \r
- new Param("name",true)); \r
- }\r
-\r
- @Override\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final String ns=args[idx];\r
-\r
- return same(((List)parent).new ListRoles() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Roles> fp = client.read(\r
- "/authz/roles/ns/"+ns, \r
- getDF(Roles.class)\r
- );\r
- return list(fp,client, HEADER+"["+ns+"]");\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/name/<ns>",Roles.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Roles;\r
-\r
-/**\r
- * Return Roles by NS\r
- * \r
- *\r
- */\r
-public class ListByNameOnly extends Cmd {\r
- private static final String HEADER = "List Roles by Name ";\r
- \r
- public ListByNameOnly(List parent) {\r
- super(parent,"name", \r
- new Param("name",true)); \r
- }\r
-\r
- @Override\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- final String name=args[idx];\r
-\r
- return same(((List)parent).new ListRoles() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Roles> fp = client.read(\r
- "/authz/roles/name/"+name, \r
- getDF(Roles.class)\r
- );\r
- return list(fp,client, HEADER+"["+name+"]");\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/name/<name>",Roles.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Roles;\r
-\r
-/**\r
- * Return Roles by NS\r
- * \r
- *\r
- */\r
-public class ListByPerm extends Cmd {\r
- private static final String HEADER = "List Roles by Perm ";\r
- \r
- public ListByPerm(List parent) {\r
- super(parent,"perm", \r
- new Param("type",true),\r
- new Param("instance", true),\r
- new Param("action", true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String type=args[idx];\r
- final String instance=args[++idx];\r
- final String action=args[++idx];\r
-\r
- return same(((List)parent).new ListRoles() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
-\r
- Future<Roles> fp = client.read(\r
- "/authz/roles/perm/"+type+'/'+instance+'/'+action, \r
- getDF(Roles.class)\r
- );\r
- return list(fp,client, HEADER+type+'|'+instance+'|'+action);\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/user/<user>",Roles.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Roles;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class ListByRole extends Cmd {\r
- private static final String HEADER="List Roles for Role";\r
- \r
- public ListByRole(List parent) {\r
- super(parent,"role", \r
- new Param("role",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(((List)parent).new ListRoles() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- String role=args[idx]; \r
- Future<Roles> fp = client.read(\r
- "/authz/roles/"+role, \r
- getDF(Roles.class) \r
- );\r
- return list(fp,client,HEADER+"["+role+"]");\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/<role>",Roles.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-\r
-import aaf.v2_0.Nss;\r
-import aaf.v2_0.Pkey;\r
-import aaf.v2_0.Roles;\r
-import aaf.v2_0.Users;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListByUser extends Cmd {\r
- private static final String HEADER = "List Roles for User ";\r
- \r
- public ListByUser(List parent) {\r
- super(parent,"user", \r
- new Param("id",true)); \r
- }\r
-\r
- @Override\r
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- String user=args[idx];\r
- String realm = getOrgRealm();\r
- final String fullUser;\r
- if (user.indexOf('@') < 0 && realm != null) {\r
- fullUser = user + '@' + realm;\r
- } else {\r
- fullUser = user;\r
- }\r
-\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
-\r
- Future<Roles> fp = client.read(\r
- "/authz/roles/user/"+fullUser, \r
- getDF(Roles.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- Future<Nss> fn = null;\r
- ArrayList<String> roleNss = null;\r
- ArrayList<String> permNss = null;\r
- HashMap<String, Boolean> expiredMap = new HashMap<String, Boolean>();\r
- if (aafcli.isDetailed()) {\r
- roleNss = new ArrayList<String>();\r
- permNss = new ArrayList<String>();\r
- for(aaf.v2_0.Role p : fp.value.getRole()) {\r
- String roleNs = p.getName();\r
- do {\r
- roleNs = p.getName().substring(0,roleNs.lastIndexOf('.'));\r
- fn = client.read("/authz/nss/"+roleNs,getDF(Nss.class));\r
- } while (!fn.get(AAFcli.timeout()));\r
- roleNss.add(roleNs);\r
- \r
- for(Pkey perm : p.getPerms()) {\r
- if (perm.getType().contains(roleNs)) {\r
- permNss.add(roleNs);\r
- } else {\r
- Future<Nss> fpn = null;\r
- String permType = perm.getType();\r
- String permNs = permType;\r
- do {\r
- permNs = permType.substring(0,permNs.lastIndexOf('.'));\r
- fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class));\r
- } while (!fpn.get(AAFcli.timeout()));\r
- permNss.add(permNs);\r
- }\r
- }\r
- }\r
- }\r
- \r
- if (fp.value != null) {\r
- for(aaf.v2_0.Role p : fp.value.getRole()) {\r
- Future<Users> fu = client.read(\r
- "/authz/userRole/"+fullUser+"/"+p.getName(), \r
- getDF(Users.class)\r
- );\r
- if (fu.get(5000)) {\r
- if(fu.value != null) {\r
- for (Users.User u : fu.value.getUser()) {\r
- if(u.getExpires().normalize().compare(Chrono.timeStamp().normalize()) > 0) {\r
- expiredMap.put(p.getName(), new Boolean(false));\r
- } else {\r
- expiredMap.put(p.getName(), new Boolean(true));\r
- }\r
- }\r
- }\r
- }\r
- } \r
- }\r
- \r
- ((List)parent).report(fp,roleNss,permNss,expiredMap,HEADER,fullUser);\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/roles/user/<user>",Roles.class,true);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class Role extends BaseCmd<Role> {\r
- public List list;\r
-\r
- public Role(AAFcli aafcli) throws APIException {\r
- super(aafcli, "role");\r
- cmds.add(new CreateDelete(this));\r
-// cmds.add(new Delete(this));\r
- cmds.add(new User(this));\r
- cmds.add(new Describe(this));\r
- cmds.add(list = new List(this));\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.UserRoleRequest;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class User extends Cmd {\r
- private final static String[] options = {"add","del","setTo","extend"};\r
- public User(Role parent) {\r
- super(parent,"user", \r
- new Param(optionsToString(options),true),\r
- new Param("role",true),\r
- new Param("id[,id]* (not required for setTo)",false)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String realm = getOrgRealm();\r
- String action = args[idx++];\r
- int option = whichOption(options, action);\r
- UserRoleRequest urr = new UserRoleRequest();\r
- urr.setRole(args[idx++]);\r
- // Set Start/End commands\r
- setStartEnd(urr);\r
- \r
- Future<?> fp = null;\r
- \r
- if (option != 2) {\r
- String[] ids = args[idx++].split(",");\r
- String verb=null,participle=null;\r
- // You can request to be added or removed from role.\r
- setQueryParamsOn(client);\r
-\r
- for(String id: ids) {\r
- if (id.indexOf('@') < 0 && realm != null) id += '@' + realm;\r
- urr.setUser(id);\r
- switch(option) {\r
- case 0:\r
- fp = client.create(\r
- "/authz/userRole", \r
- getDF(UserRoleRequest.class), \r
- urr);\r
- verb = "Added";\r
- participle = "] to Role [" ;\r
- break;\r
- case 1:\r
- fp = client.delete(\r
- "/authz/userRole/"+urr.getUser()+'/'+urr.getRole(), \r
- Void.class);\r
- verb = "Removed";\r
- participle = "] from Role [" ;\r
- break;\r
- case 3:\r
- fp = client.update("/authz/userRole/extend/" + urr.getUser() + '/' + urr.getRole());\r
- verb = "Extended";\r
- participle = "] in Role [" ;\r
- break;\r
-\r
- default: // actually, should never get here...\r
- throw new CadiException("Invalid action [" + action + ']');\r
- }\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().print(verb);\r
- pw().print(" User [");\r
- pw().print(urr.getUser());\r
- pw().print(participle);\r
- pw().print(urr.getRole());\r
- pw().println(']');\r
- } else {\r
- switch(fp.code()) {\r
- case 202:\r
- pw().print("User Role ");\r
- pw().print(action);\r
- pw().println(" is Accepted, but requires Approvals before actualizing");\r
- break;\r
- case 404:\r
- if(option==3) {\r
- pw().println("Failed with code 404: UserRole is not found, or you do not have permission to view");\r
- break;\r
- }\r
- default:\r
- error(fp);\r
- }\r
- }\r
- }\r
- } else {\r
- String allUsers = "";\r
- if (idx < args.length) \r
- allUsers = args[idx++];\r
- StringBuilder finalUsers = new StringBuilder(); \r
- for (String u : allUsers.split(",")) {\r
- if (u != "") {\r
- if (u.indexOf('@') < 0 && realm != null) u += '@' + realm;\r
- if (finalUsers.length() > 0) finalUsers.append(",");\r
- finalUsers.append(u);\r
- }\r
- }\r
-\r
- urr.setUser(finalUsers.toString());\r
- fp = client.update(\r
- "/authz/userRole/role", \r
- getDF(UserRoleRequest.class), \r
- urr);\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println("Set the Role to Users [" + allUsers + "]");\r
- } else {\r
- error(fp);\r
- } \r
- }\r
- return fp==null?0:fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,"Add OR Delete a User to/from a Role OR");\r
- detailLine(sb,indent,"Set a User's Roles to the roles supplied");\r
- detailLine(sb,indent+2,"role - Name of Role to create");\r
- detailLine(sb,indent+2,"id(s) - ID or IDs to add to the Role");\r
- sb.append('\n');\r
- detailLine(sb,indent+2,"Note: this is the same as \"user role add...\" except allows");\r
- detailLine(sb,indent+2,"assignment of role to multiple userss");\r
- detailLine(sb,indent+2,"WARNING: Users supplied with setTo will be the ONLY users attached to this role");\r
- detailLine(sb,indent+2,"If no users are supplied, the users attached to this role are reset.");\r
- api(sb,indent,HttpMethods.POST,"authz/userRole",UserRoleRequest.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authz/userRole/<user>/<role>",Void.class,false);\r
- api(sb,indent,HttpMethods.PUT,"authz/userRole/<role>",UserRoleRequest.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.CredRequest;\r
-\r
-public class Cred extends Cmd {\r
- private static final String CRED_PATH = "/authn/cred";\r
- private static final String[] options = {"add","del","reset","extend"/*,"clean"*/};\r
-// private Clean clean;\r
- public Cred(User parent) {\r
- super(parent,"cred",\r
- new Param(optionsToString(options),true),\r
- new Param("id",true),\r
- new Param("password (! D|E)",false),\r
- new Param("entry# (if multi)",false)\r
- );\r
-// clean = new Clean(this);\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException { \r
- int idx = _idx;\r
- String key = args[idx++];\r
- final int option = whichOption(options,key);\r
-\r
- final CredRequest cr = new CredRequest();\r
- cr.setId(args[idx++]);\r
- if(option!=1 && option!=3) {\r
- if(idx>=args.length) throw new CadiException("Password Required");\r
- cr.setPassword(args[idx++]);\r
- }\r
- if(args.length>idx)\r
- cr.setEntry(args[idx++]);\r
- \r
- // Set Start/End commands\r
- setStartEnd(cr);\r
-// final int cleanIDX = _idx+1;\r
- Integer ret = same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<CredRequest> fp=null;\r
- String verb =null;\r
- switch(option) {\r
- case 0:\r
- fp = client.create(\r
- CRED_PATH, \r
- getDF(CredRequest.class), \r
- cr\r
- );\r
- verb = "Added Credential [";\r
- break;\r
- case 1:\r
-// if(aafcli.addForce())cr.setForce("TRUE");\r
- setQueryParamsOn(client);\r
- fp = client.delete(CRED_PATH,\r
- getDF(CredRequest.class),\r
- cr\r
- );\r
- verb = "Deleted Credential [";\r
- break;\r
- case 2:\r
- fp = client.update(\r
- CRED_PATH,\r
- getDF(CredRequest.class),\r
- cr\r
- );\r
- verb = "Reset Credential [";\r
- break;\r
- case 3:\r
- fp = client.update(\r
- CRED_PATH+"/5",\r
- getDF(CredRequest.class),\r
- cr\r
- );\r
- verb = "Extended Credential [";\r
- break;\r
-// case 4:\r
-// return clean.exec(cleanIDX, args);\r
- }\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().print(verb);\r
- pw().print(cr.getId());\r
- pw().println(']');\r
- } else if(fp.code()==202) {\r
- pw().println("Credential Action Accepted, but requires Approvals before actualizing");\r
- } else if(fp.code()==406 && option==1) {\r
- pw().println("You cannot delete this Credential");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- if(ret==null)ret = -1;\r
- return ret;\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add, Delete or Reset Credential");\r
- indent+=2;\r
- detailLine(sb,indent,"id - the ID to create/delete/reset within AAF");\r
- detailLine(sb,indent,"password - Company Policy compliant Password (not required for Delete)");\r
- detailLine(sb,indent,"entry - selected option when deleting/resetting a cred with multiple entries");\r
- sb.append('\n');\r
- detailLine(sb,indent,"The Domain can be related to any Namespace you have access to *");\r
- detailLine(sb,indent,"The Domain is in reverse order of Namespace, i.e. ");\r
- detailLine(sb,indent+2,"NS of com.att.myapp can create user of XY1234@myapp.att.com");\r
- sb.append('\n');\r
- detailLine(sb,indent,"NOTE: AAF does support multiple creds with the same ID. Check with your org if you");\r
- detailLine(sb,indent+2,"have this implemented. (For example, this is implemented for MechIDs at AT&T)");\r
- sb.append('\n'); \r
- detailLine(sb,indent,"Delegates can be listed by the User or by the Delegate");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.POST,"authn/cred",CredRequest.class,true);\r
- api(sb,indent,HttpMethods.DELETE,"authn/cred",CredRequest.class,false);\r
- api(sb,indent,HttpMethods.PUT,"authn/cred",CredRequest.class,false);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import java.text.ParseException;\r
-import java.util.Date;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-import org.onap.aaf.rosetta.env.RosettaDF;\r
-\r
-import aaf.v2_0.DelgRequest;\r
-\r
-public class Delg extends BaseCmd<User> {\r
- static final String AUTHZ_DELG = "/authz/delegate";\r
- private final static String[] options = {"add","upd","del"};\r
-\r
- public Delg(User user) throws APIException {\r
- super(user,"delegate",\r
- new Param(optionsToString(options),true),\r
- new Param("from",true),\r
- new Param("to REQ A&U",false),\r
- new Param("until (YYYY-MM-DD) REQ A", false)\r
- );\r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String realm = getOrgRealm();\r
- DelgRequest dr = new DelgRequest();\r
- setStartEnd(dr);\r
- \r
- int option= whichOption(options, args[idx++]);\r
- String user = args[idx++];\r
- if (user.indexOf('@') < 0 && realm != null) user += '@' + realm;\r
- dr.setUser(user);\r
- if(option<2) {\r
- String delegate = args[idx++];\r
- if (delegate.indexOf('@') < 0 && realm != null) delegate += '@' + realm;\r
- dr.setDelegate(delegate);\r
- if(option<2 && args.length>idx) {\r
- Date date;\r
- try {\r
- date = Chrono.dateOnlyFmt.parse(args[idx++]);\r
- } catch (ParseException e) {\r
- throw new CadiException(e);\r
- }\r
- dr.setEnd(Chrono.timeStamp(date));\r
- }\r
- }\r
- \r
- Future<DelgRequest> fp;\r
- RosettaDF<DelgRequest> df = getDF(DelgRequest.class);\r
- String verb;\r
- setQueryParamsOn(client);\r
-\r
- switch(option) {\r
- case 0: \r
- fp = client.create(AUTHZ_DELG, df, dr);\r
- verb = "Added";\r
- break;\r
- case 1: \r
- fp = client.update(AUTHZ_DELG, df, dr); \r
- verb = "Updated";\r
- break;\r
- case 2: \r
- fp = client.delete(AUTHZ_DELG, df, dr); \r
- verb = "Deleted";\r
- break;\r
- default:\r
- throw new CadiException("Bad Argument");\r
- };\r
- \r
- if(fp.get(AAFcli.timeout())) {\r
- pw().append("Delegate ");\r
- pw().println(verb);\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,"Add, Update or Delete Delegate");\r
- indent+=2;\r
- detailLine(sb,indent,"A Delegate is a person who will temporarily cover the Approval and");\r
- detailLine(sb,indent,"Ownership questions on behalf of the person Responsible.");\r
- sb.append('\n');\r
- detailLine(sb,indent,"fromID - the person who is the Responsible person of record");\r
- detailLine(sb,indent,"toID - the person who will be delegated (required for Add/Update)");\r
- detailLine(sb,indent,"until - the end date for this delegation");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.POST,AUTHZ_DELG,DelgRequest.class,true);\r
- api(sb,indent,HttpMethods.DELETE,AUTHZ_DELG,DelgRequest.class,false);\r
- api(sb,indent,HttpMethods.PUT,AUTHZ_DELG,DelgRequest.class,false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-\r
-import aaf.v2_0.Approval;\r
-import aaf.v2_0.Approvals;\r
-import aaf.v2_0.Delg;\r
-import aaf.v2_0.Delgs;\r
-import aaf.v2_0.Users;\r
-\r
-public class List extends BaseCmd<User> {\r
-\r
- public List(User parent) {\r
- super(parent,"list");\r
- cmds.add(new ListForRoles(this));\r
- cmds.add(new ListForPermission(this));\r
- cmds.add(new ListForCreds(this));\r
- cmds.add(new ListDelegates(this));\r
- cmds.add(new ListApprovals(this));\r
- cmds.add(new ListActivity(this));\r
- }\r
-\r
- \r
- void report(Users users, boolean count, String ... str) {\r
- reportHead(str);\r
- String format = reportColHead("%-50s %-30s\n","User","Expires");\r
- String date = "XXXX-XX-XX";\r
- int idx = 0;\r
- java.util.List<aaf.v2_0.Users.User> sorted = users.getUser();\r
- Collections.sort(sorted, new Comparator<aaf.v2_0.Users.User>() {\r
- @Override\r
- public int compare(aaf.v2_0.Users.User u1, aaf.v2_0.Users.User u2) {\r
- if(u2==null || u2 == null) {\r
- return -1;\r
- }\r
- return u1.getId().compareTo(u2.getId());\r
- }\r
- });\r
- for(aaf.v2_0.Users.User user : sorted) {\r
- if(!aafcli.isTest()) \r
- date = Chrono.dateOnlyStamp(user.getExpires());\r
- \r
- pw().format(format, \r
- count? (Integer.valueOf(++idx) + ") " + user.getId()): user.getId(), \r
- date);\r
- }\r
- pw().println();\r
- }\r
-\r
- public void report(Approvals approvals, String title, String id) {\r
- reportHead(title,id);\r
- String format = reportColHead(" %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated");\r
- java.util.List<Approval> lapp = approvals.getApprovals();\r
- Collections.sort(lapp, new Comparator<Approval>() {\r
- @Override\r
- public int compare(Approval a1, Approval a2) {\r
- return a1.getTicket().compareTo(a2.getTicket());\r
- }\r
- } );\r
- String ticket = null, prev = null;\r
- for(Approval app : lapp ) {\r
- ticket = app.getTicket();\r
- if(!ticket.equals(prev)) {\r
- pw().print("Ticket: ");\r
- pw().println(ticket);\r
- }\r
- prev = ticket;\r
-\r
- pw().format(format,\r
- app.getUser(),\r
- app.getApprover(),\r
- app.getType(),\r
- app.getStatus(),\r
- Chrono.niceDateStamp(app.getUpdated())\r
- );\r
- }\r
- }\r
-\r
- public void report(Delgs delgs, String title, String id) {\r
- reportHead(title,id);\r
- String format = reportColHead(" %-25s %-25s %-10s\n","User","Delegate","Expires");\r
- String date = "XXXX-XX-XX";\r
- for(Delg delg : delgs.getDelgs()) {\r
- if(!this.aafcli.isTest()) \r
- date = Chrono.dateOnlyStamp(delg.getExpires());\r
- pw().printf(format, \r
- delg.getUser(),\r
- delg.getDelegate(),\r
- date\r
- );\r
- }\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.History;\r
-\r
-/**\r
- *\r
- */\r
-public class ListActivity extends Cmd {\r
- private static final String HEADER = "List Activity of User";\r
-\r
- public ListActivity(List parent) {\r
- super(parent,"activity", \r
- new Param("user",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- String user = args[idx++];\r
- String realm = getOrgRealm();\r
- final String fullUser = (user.indexOf('@') < 0 && realm != null)?user + '@' + realm:user;\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- \r
- Future<History> fp = client.read(\r
- "/authz/hist/user/"+fullUser, \r
- getDF(History.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- activity(fp.value,HEADER + " [ " + fullUser + " ]");\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb,indent,HEADER);\r
- api(sb,indent,HttpMethods.GET,"authz/hist/user/<user>",History.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Approvals;\r
-\r
-/**\r
- * \r
- *\r
- */\r
-public class ListApprovals extends Cmd {\r
- private static final String HEADER = "List Approvals"; \r
- private final static String[] options = {"user","approver","ticket"};\r
- public ListApprovals(List parent) {\r
- super(parent,"approvals", \r
- new Param(optionsToString(options),true),\r
- new Param("value",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String type = args[idx++];\r
- int option = whichOption(options,type);\r
- String value = args[idx++];\r
- final String fullValue;\r
- if (option != 2) {\r
- String realm = getOrgRealm();\r
- fullValue = (value.indexOf('@')<0 && realm != null)?value +'@'+realm:value;\r
- } else {\r
- fullValue = value;\r
- }\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Approvals> fp = client.read(\r
- "/authz/approval/"+type+'/'+fullValue, \r
- getDF(Approvals.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- ((List)parent).report(fp.value,HEADER + " by " + type,fullValue);\r
- if(fp.code()==404) {\r
- return 200;\r
- }\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=2;\r
- detailLine(sb,indent,"Approvals are used when the Requestor does not have the rights");\r
- detailLine(sb,indent,"to perform the action required. Approvers are those listed as");\r
- detailLine(sb,indent,"responsible for Namespace associated with the request, and those");\r
- detailLine(sb,indent,"required by the Company by Policy. This may be, for instance");\r
- detailLine(sb,indent,"the supervisor of the requestor");\r
- sb.append('\n');\r
- detailLine(sb,indent,"Delegates can be listed by User, Approver or Ticket.");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.GET,"authz/approval/user/<value>",Approvals.class,true);\r
- api(sb,indent,HttpMethods.GET,"authz/approval/approver/<value>",Approvals.class,false);\r
- api(sb,indent,HttpMethods.GET,"authz/approval/ticket/<value>",Approvals.class,false);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Delgs;\r
-\r
-/**\r
- *\r
- */\r
-public class ListDelegates extends Cmd {\r
- private static final String HEADER = "List Delegates"; \r
- private static final String[] options = {"user","delegate"};\r
- public ListDelegates(List parent) {\r
- super(parent,"delegates", \r
- new Param(optionsToString(options),true),\r
- new Param("id",true));\r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- String realm = getOrgRealm();\r
- int idx = _idx;\r
- final String key = args[idx++];\r
- //int option = whichOption(options,key);\r
- String id = args[idx++];\r
- final String fullID = (id.indexOf('@') < 0 && realm != null)? id + '@' + realm:id;\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- \r
- Future<Delgs> fp = client.read(\r
- "/authz/delegates/" + key + '/' + fullID, \r
- getDF(Delgs.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- ((List)parent).report(fp.value,HEADER + " by " + key, fullID);\r
- if(fp.code()==404)return 200;\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=2;\r
- detailLine(sb,indent,"Delegates are those people temporarily assigned to cover the");\r
- detailLine(sb,indent,"responsibility of Approving, etc, while the actual Responsible");\r
- detailLine(sb,indent,"Party is absent. Typically, this is for Vacation, or Business");\r
- detailLine(sb,indent,"Travel.");\r
- sb.append('\n');\r
- detailLine(sb,indent,"Delegates can be listed by the User or by the Delegate");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.GET,"authz/delegates/user/<id>",Delgs.class,true);\r
- api(sb,indent,HttpMethods.GET,"authz/delegates/delegate/<id>",Delgs.class,false);\r
- }\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-/**\r
- * List for Creds\r
- *\r
- */\r
-public class ListForCreds extends Cmd {\r
- private final static String[] options = {"ns","id"};\r
-\r
- private static final String HEADER = "List creds for ";\r
- public ListForCreds(List parent) {\r
- super(parent,"cred",\r
- new Param(optionsToString(options),true),\r
- new Param("value",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final int option = whichOption(options, args[idx++]);\r
- final String which = options[option];\r
- final String value = args[idx++];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Users> fp = client.read(\r
- "/authn/creds/"+which+'/'+value, \r
- getDF(Users.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- if (aafcli.isTest())\r
- Collections.sort(fp.value.getUser(), new Comparator<User>() {\r
- @Override\r
- public int compare(User u1, User u2) {\r
- return u1.getId().compareTo(u2.getId());\r
- } \r
- });\r
- ((org.onap.aaf.cmd.user.List)parent).report(fp.value,option==1,HEADER+which,value);\r
- if(fp.code()==404)return 200;\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=2;\r
- detailLine(sb,indent,"This report lists the users associated to Roles.");\r
- detailLine(sb,indent,"role - the Role name");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.GET,"authz/users/role/<role>",Users.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListForPermission extends Cmd {\r
- private static final String HEADER = "List Users for Permission";\r
- public ListForPermission(List parent) {\r
- super(parent,"perm", \r
- new Param("type",true),\r
- new Param("instance",true),\r
- new Param("action",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String type = args[idx++];\r
- String instance = args[idx++];\r
- if("\\*".equals(instance))instance="*";\r
- String action = args[idx++];\r
- if("\\*".equals(action))action="*";\r
- Future<Users> fp = client.read(\r
- "/authz/users/perm/"+type+'/'+instance+'/'+action, \r
- getDF(Users.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- if (aafcli.isTest())\r
- Collections.sort(fp.value.getUser(), new Comparator<User>() {\r
- @Override\r
- public int compare(User u1, User u2) {\r
- return u1.getId().compareTo(u2.getId());\r
- } \r
- });\r
- ((org.onap.aaf.cmd.user.List)parent).report(fp.value,false,HEADER,type+"|"+instance+"|"+action);\r
- if(fp.code()==404)return 200;\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=2;\r
- detailLine(sb,indent,"This report lists the users associated to Permissions. Since Users");\r
- detailLine(sb,indent,"are associated to Roles, and Roles have Permissions, this report");\r
- detailLine(sb,indent,"accomodates all these linkages.");\r
- sb.append('\n');\r
- detailLine(sb,indent,"The URL must contain the Permission's type,instance and action, and ");\r
- detailLine(sb,indent,"may include \"*\"s (type in as \\\\*).");\r
- detailLine(sb,indent,"See Perm Create Documentation for definitions.");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.GET,"authz/users/perm/<type>/<instance>/<action>",Users.class,true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.Users;\r
-import aaf.v2_0.Users.User;\r
-\r
-/**\r
- * p\r
- *\r
- */\r
-public class ListForRoles extends Cmd {\r
- private static final String HEADER = "List Users for Role";\r
- public ListForRoles(List parent) {\r
- super(parent,"role", new Param("role",true)); \r
- }\r
-\r
- @Override\r
- public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- final String role = args[idx++];\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- Future<Users> fp = client.read(\r
- "/authz/users/role/"+role, \r
- getDF(Users.class)\r
- );\r
- if(fp.get(AAFcli.timeout())) {\r
- if (aafcli.isTest())\r
- Collections.sort(fp.value.getUser(), new Comparator<User>() {\r
- @Override\r
- public int compare(User u1, User u2) {\r
- return u1.getId().compareTo(u2.getId());\r
- } \r
- });\r
- ((org.onap.aaf.cmd.user.List)parent).report(fp.value,false, HEADER,role);\r
- if(fp.code()==404)return 200;\r
- } else {\r
- error(fp);\r
- }\r
- return fp.code();\r
- }\r
- });\r
- }\r
- \r
- @Override\r
- public void detailedHelp(int _indent, StringBuilder sb) {\r
- int indent = _indent;\r
- detailLine(sb,indent,HEADER);\r
- indent+=2;\r
- detailLine(sb,indent,"This report lists the users associated to Roles.");\r
- detailLine(sb,indent,"role - the Role name");\r
- indent-=2;\r
- api(sb,indent,HttpMethods.GET,"authz/users/role/<role>",Users.class,true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Param;\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.UserRoleRequest;\r
-\r
-/**\r
- * p\r
- * \r
- *\r
- */\r
-public class Role extends Cmd {\r
- private static final String[] options = {"add", "del", "setTo","extend"};\r
- public Role(User parent) {\r
- super(parent, "role", new Param(optionsToString(options), true), new Param("user", true), new Param(\r
- "role[,role]* (!REQ S)", false));\r
- }\r
-\r
- @Override\r
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {\r
- return same(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws CadiException, APIException {\r
- int idx = index;\r
- String key = args[idx++];\r
- int option = whichOption(options, key);\r
- String user = args[idx++];\r
- String realm = getOrgRealm();\r
-\r
- UserRoleRequest urr = new UserRoleRequest();\r
- if (user.indexOf('@') < 0 && realm != null) user += '@' + realm;\r
- urr.setUser(user);\r
- // Set Start/End commands\r
- setStartEnd(urr);\r
-\r
- Future<?> fp = null;\r
-\r
- if (option != 2) {\r
- if (args.length < 5) {\r
- throw new CadiException(build(new StringBuilder("Too few args: "), null).toString()); \r
- }\r
- String[] roles = args[idx++].split(",");\r
- for (String role : roles) {\r
- String verb = null,participle=null;\r
- urr.setRole(role);\r
- // You can request to be added or removed from role.\r
- setQueryParamsOn(client);\r
- switch(option) {\r
- case 0:\r
- fp = client.create("/authz/userRole", getDF(UserRoleRequest.class), urr);\r
- verb = "Added";\r
- participle = "] to User [" ;\r
- break;\r
- case 1:\r
- fp = client.delete("/authz/userRole/" + urr.getUser() + '/' + urr.getRole(), Void.class);\r
- verb = "Removed";\r
- participle = "] from User [" ;\r
- break;\r
- case 3:\r
- fp = client.update("/authz/userRole/extend/" + urr.getUser() + '/' + urr.getRole());\r
- verb = "Extended";\r
- participle = "] to User [" ;\r
- break;\r
- default:\r
- throw new CadiException("Invalid action [" + key + ']');\r
- }\r
- if (fp.get(AAFcli.timeout())) {\r
- pw().print(verb);\r
- pw().print(" Role [");\r
- pw().print(urr.getRole());\r
- pw().print(participle);\r
- pw().print(urr.getUser());\r
- pw().println(']');\r
- } else {\r
- switch(fp.code()) {\r
- case 202:\r
- pw().print("UserRole ");\r
- pw().print(option == 0 ? "Creation" : option==1?"Deletion":"Extension");\r
- pw().println(" Accepted, but requires Approvals before actualizing");\r
- break;\r
- case 404:\r
- if(option==3) {\r
- pw().println("Failed with code 404: UserRole is not found, or you do not have permission to view");\r
- break;\r
- }\r
- default:\r
- error(fp);\r
- }\r
- }\r
- }\r
- } else {\r
- // option 2 is setTo command (an update call)\r
- String allRoles = "";\r
- if (idx < args.length)\r
- allRoles = args[idx++];\r
-\r
- urr.setRole(allRoles);\r
- fp = client.update("/authz/userRole/user", getDF(UserRoleRequest.class), urr);\r
- if (fp.get(AAFcli.timeout())) {\r
- pw().println("Set User's Roles to [" + allRoles + "]");\r
- } else {\r
- error(fp);\r
- }\r
- }\r
- return fp == null ? 0 : fp.code();\r
- }\r
- });\r
- }\r
-\r
- @Override\r
- public void detailedHelp(int indent, StringBuilder sb) {\r
- detailLine(sb, indent, "Add OR Delete a User to/from a Role OR");\r
- detailLine(sb, indent, "Set a User's Roles to the roles supplied");\r
- detailLine(sb, indent + 2, "user - ID of User");\r
- detailLine(sb, indent + 2, "role(s) - Role or Roles to which to add the User");\r
- sb.append('\n');\r
- detailLine(sb, indent + 2, "Note: this is the same as \"role user add...\" except allows");\r
- detailLine(sb, indent + 2, "assignment of user to multiple roles");\r
- detailLine(sb, indent + 2, "WARNING: Roles supplied with setTo will be the ONLY roles attached to this user");\r
- detailLine(sb, indent + 2, "If no roles are supplied, user's roles are reset.");\r
- api(sb, indent, HttpMethods.POST, "authz/userRole", UserRoleRequest.class, true);\r
- api(sb, indent, HttpMethods.DELETE, "authz/userRole/<user>/<role>", Void.class, false);\r
- api(sb, indent, HttpMethods.PUT, "authz/userRole/<user>", UserRoleRequest.class, false);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.BaseCmd;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class User extends BaseCmd<User> {\r
- public User(AAFcli aafcli) throws APIException {\r
- super(aafcli,"user");\r
- cmds.add(new Role(this));\r
- cmds.add(new Cred(this));\r
- cmds.add(new Delg(this));\r
- cmds.add(new List(this));\r
- }\r
-}\r
+++ /dev/null
-#!/bin/bash
-JAVA_HOME=_JAVA_HOME_
-JAVA=${JAVA_HOME}/bin/java
-DEFAULT_DOMAIN=XXX_DOMAIN
-###
-# Give some help hints if first run
-#
-if [ "`declare -f aaflogout`" = "" ] || [ "$1" = "-h" ]; then
- echo
- echo " COMMANDS:"
- echo " aaflogin -f = Redo Local Login"
- echo " aaflogout = Logout from Environment"
- echo " aaflogin -r = Reset Password on AAF Service"
- echo " aaflogin -h = Help"
- echo " aafcli = AAF Management Tool"
- echo
-fi
-
-if [ "$1" != "-h" ]; then
-
-
-###
-# Load User/Password for aafcli, and create in function.
-#
-# To use, source aaflogin
-#
-# ex: . ./aaflogin
-#
-# -f = force relogin
-# -r = reset password sequence
-#
-# see aaflogout to logout
-###
-
-###
-# Gather Classpath - warning, DME2 doesn't work with -Djava.ext.dirs
-###
-AAF_CP=_ROOT_DIR_/etc
-for JAR in `find _ROOT_DIR_/lib -name "*.jar"` ; do
- AAF_CP="$AAF_CP:$JAR"
-done
-
-###
-# Create Keyfile to use temporarily, if not exists
-###
-if [ ! -e $HOME/.aaf/keyfile ]; then
- mkdir -p $HOME/.aaf
- ${JAVA} -cp $AAF_CP org.onap.aaf.cadi.CmdLine keygen $HOME/.aaf/keyfile
- chmod 400 $HOME/.aaf/keyfile
-fi
-
-###
-# Obtain User ID from AAF_ID, or SUDO_USER or USER, that order
-###
-if [ "$AAF_ID" == "" ] || [ "$1" == "-f" ] ; then
- if [ "$AAF_ID" == "" ] ; then
- if [ "$SUDO_USER" != "" ] ; then
- AAF_ID=$SUDO_USER
- else if [ "$USER" != "" ] ; then
- AAF_ID=$USER
- fi
- fi
- fi
-
- echo -n "Enter AAF ID [$AAF_ID]: "
- read TEMP
- if [ "$TEMP" != "" ] ; then
- AAF_ID=$TEMP
- fi
- export AAF_ID
-fi
-
-###
-# Add Function to remove AAF Vars and Functions from the Shell
-#
-function aaflogout {
- unset AAF_ID
- unset AAF_PASS
- unset AAF_CP
- unset -f aafcli
- unset -f cmcli
- unset -f aaflogout
- rm -f $HOME/.aaf/keyfile
-}
-
-
-###
-# Load the Password
-###
-if [ "$AAF_PASS" == "" ] || [ "$1" == "-f" ] ; then
- # Ask for User and Password. Assuming Unix and availability of "stty"
- if [[ "$AAF_ID" == *"@$DEFAULT_DOMAIN" ]] || [[ "$AAF_ID" != *"@"* ]] ; then
- PASS_PROMPT="AT&T Global Login"
- AAF_DEFAULT_DOMAIN="-Daaf_default_domain=$DEFAULT_DOMAIN"
- else
- PASS_PROMPT="AAF"
- AAF_DEFAULT_DOMAIN=""
- fi
-
-
- read -ers -p "Enter "$PASS_PROMPT" Password for $AAF_ID: " AAF_PASS
- echo
- AAF_PASS=enc:`$JAVA -cp $AAF_CP $AAF_DEFAULT_DOMAIN org.onap.aaf.cadi.CmdLine digest "$AAF_PASS" $HOME/.aaf/keyfile`
- export AAF_PASS
-fi
-
-
-
-###
-# load aafcli function in the Shell
-###
-
-function aafcli {
- # for separating VM_ARGS in aafcli
- AAF_SPACE=" "
- THE_ID=$AAF_ID
- if [ "${AAF_ID}" = "${AAF_ID/@/%}" ]; then
- THE_ID+="@$DEFAULT_DOMAIN"
- fi
- _JAVA_HOME_/bin/java \
- -cp $AAF_CP \
- -Daaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ \
- -DAFT_LATITUDE=_AFT_LATITUDE_ \
- -DAFT_LONGITUDE=_AFT_LONGITUDE_ \
- -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ \
- -Daaf_id=$THE_ID \
- -Daaf_password=$AAF_PASS \
- -Daaf_dme_timeout=60000 \
- -Dcadi_keyfile=$HOME/.aaf/keyfile \
- -Daaf_default_realm=$DEFAULT_DOMAIN \
- -DDEPLOYED_VERSION=_ARTIFACT_VERSION_ \
- _DME2_FS_ \
- com.att.cmd.AAFcli $*
- unset THE_ID
- unset AAF_SPACE
-}
-
-###
-# load cmcli function in the Shell
-###
-
-function cmcli {
- # for separating VM_ARGS in cmcli
- AAF_SPACE=" "
- THE_ID=$AAF_ID
- if [ "${AAF_ID}" = "${AAF_ID/@/%}" ]; then
- THE_ID+="@$DEFAULT_DOMAIN"
- fi
- CM_URL=_CM_URL_
- if [ "${CM_URL}" = "" ]; then
- CM_URL=https://DME2RESOLVE/service=com.att.authz.Certman/version=_MAJOR_VER_._MINOR_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_
- fi
-
- _JAVA_HOME_/bin/java \
- -cp $AAF_CP \
- -DAFT_LATITUDE=_AFT_LATITUDE_ \
- -DAFT_LONGITUDE=_AFT_LONGITUDE_ \
- -DAFT_ENVIRONMENT=_AFT_ENVIRONMENT_ \
- -Daaf_dme_timeout=60000 \
- -Daaf_default_realm=$DEFAULT_DOMAIN \
- -DDEPLOYED_VERSION=_ARTIFACT_VERSION_ \
- _DME2_FS_ \
- org.onap.aaf.cadi.cm.CmAgent cm_url=${CM_URL} aaf_id=$THE_ID aaf_password="$AAF_PASS" \
- cadi_keyfile=$HOME/.aaf/keyfile $*
- unset THE_ID
- unset AAF_SPACE
- unset CM_URL
-}
-
-
-###
-# if "-r" the do Remote Password Reset
-###
-if [ "$1" == "-r" ] ; then
- # Ask for User and Password. Assuming Unix and availability of "stty"
- read -ers -p "Enter New AAF Password for $AAF_ID: " AAF_NEWPASS
- echo
- read -ers -p "Reenter New AAF Password for $AAF_ID: " AAF_NEWPASS2
- echo
- if [ "$AAF_NEWPASS" == "$AAF_NEWPASS2" ] ; then
- RESP=`aafcli user resetCred "$AAF_ID@aaf.att.com" $AAF_NEWPASS`
- echo $RESP
- if [ "$RESP" == "Reset Credential [$AAF_ID@aaf.att.com]" ] ; then
- export AAF_PASS=enc:`$JAVA -cp $AAF_CP org.onap.aaf.cadi.CmdLine digest $AAF_NEWPASS $HOME/.aaf/keyfile`
- fi
- else
- echo "Passwords don't match!"
- fi
-fi
-
-###
-# Export key variables for use in other Scripts
-###
-export AAF_ID
-export AAF_PASS
-export AAF_CP
-export -f aafcli
-export -f aaflogout
-fi
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertTrue;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.io.IOException;\r
-import java.io.OutputStreamWriter;\r
-import java.net.HttpURLConnection;\r
-import java.security.GeneralSecurityException;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.Locator;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.PropertyLocator;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.cadi.config.SecurityInfo;\r
-import org.onap.aaf.cadi.http.HBasicAuthSS;\r
-import org.onap.aaf.cadi.http.HMangr;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_AAFCli {\r
-\r
- private static AAFcli cli;\r
- private static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);\r
-\r
- @BeforeClass\r
- public static void setUp() throws Exception, Exception {\r
- cli = getAAfCli();\r
- }\r
-\r
- @Test\r
- public void eval() throws Exception {\r
- assertTrue(cli.eval("#startswith"));\r
- }\r
-\r
- @Test\r
- public void eval_empty() throws Exception {\r
- assertTrue(cli.eval(""));\r
- }\r
-\r
- @Test\r
- public void eval1() throws Exception {\r
- assertTrue(cli.eval("@[123"));\r
- }\r
-\r
- @Test\r
- public void eval2() throws Exception {\r
- assertFalse(cli.eval("as @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval3() throws Exception {\r
- try {\r
- cli.eval("expect @[ 123");\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- assertTrue(e instanceof CadiException);\r
- }\r
- }\r
-\r
- public void eval31() throws Exception {\r
- try {\r
- cli.eval("expect 1 @[ 123");\r
- } catch (Exception e) {\r
- // TODO Auto-generated catch block\r
- assertTrue(e instanceof CadiException);\r
- }\r
- }\r
-\r
- @Test\r
- public void eval4() throws Exception {\r
- try {\r
- cli.eval("sleep @[ 123");\r
- } catch (Exception e) {\r
- assertTrue(e instanceof NumberFormatException);\r
- }\r
- }\r
-\r
- @Test\r
- public void eval41() throws Exception {\r
- assertTrue(cli.eval("sleep 1 @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval5() throws Exception {\r
- try {\r
- cli.eval("delay @[ 123");\r
- } catch (Exception e) {\r
- assertTrue(e instanceof NumberFormatException);\r
- }\r
- }\r
-\r
- @Test\r
- public void eval51() throws Exception {\r
- assertTrue(cli.eval("delay 1 @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval7() throws Exception {\r
- assertFalse(cli.eval("exit @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval8() throws Exception {\r
- assertTrue(cli.eval("REQUEST @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval9() throws Exception {\r
- assertTrue(cli.eval("FORCE @[ 123"));\r
- }\r
-\r
- @Test\r
- public void eval10() throws Exception {\r
- assertTrue(cli.eval("set @[ 123"));\r
- }\r
-\r
- @Test\r
- public void keyboardHelp() throws Exception {\r
- boolean noError=true;\r
- try {\r
- cli.keyboardHelp();\r
- } catch (Exception e) {\r
- noError=false;\r
- }\r
- assertTrue(noError);\r
- }\r
- \r
-\r
- \r
- @Test\r
- public void setProp() throws Exception {\r
- boolean noError=true;\r
- try {\r
- cli.keyboardHelp();\r
- } catch (Exception e) {\r
- noError=false;\r
- }\r
- assertTrue(noError);\r
- }\r
- \r
- @Test\r
- public void eval_randomString() throws Exception {\r
- assertTrue(cli.eval("Some random string @#&*& to check complete 100 coverage"));\r
- }\r
-\r
- public static AAFcli getAAfCli() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- final AuthzEnv env = new AuthzEnv(System.getProperties());\r
- String aafUrl = "https://DME2RESOLVE";\r
- SecurityInfo si = new SecurityInfo(env);\r
- env.loadToSystemPropsStartsWith("AAF", "DME2");\r
- Locator loc;\r
- loc = new PropertyLocator(aafUrl);\r
- TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));\r
- HMangr hman = new HMangr(env, loc).readTimeout(TIMEOUT).apiVersion("2.0");\r
-\r
- // TODO: Consider requiring a default in properties\r
- env.setProperty(Config.AAF_DEFAULT_REALM,\r
- System.getProperty(Config.AAF_DEFAULT_REALM, Config.getDefaultRealm()));\r
- HBasicAuthSS ss = mock(HBasicAuthSS.class);\r
- return new AAFcli(env, new OutputStreamWriter(System.out), hman, si, ss);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-\r
-import javax.xml.datatype.DatatypeConfigurationException;\r
-import javax.xml.datatype.DatatypeFactory;\r
-import javax.xml.datatype.XMLGregorianCalendar;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cadi.client.Future;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-import aaf.v2_0.History;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_BaseCmd {\r
-\r
- private static AAFcli cli;\r
- private static BaseCmd bCmd;\r
-\r
- @BeforeClass\r
- public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- cli = JU_AAFCli.getAAfCli();\r
- bCmd = new BaseCmd<>(cli, "testString");\r
- }\r
-\r
- @Test\r
- public void exec() throws CadiException, APIException, LocatorException {\r
- assertEquals(bCmd._exec(4, "add", "del", "reset", "extend"), 0);\r
-\r
- }\r
- \r
- @Test\r
- public void exec1() throws CadiException, APIException, LocatorException {\r
- assertEquals(bCmd._exec(0, "add", "del", "reset", "extend"), 0);\r
-\r
- }\r
-\r
- @Test\r
- public void error() throws CadiException, APIException, LocatorException {\r
- boolean noError = true;\r
- Future<String> future = new Future<String>() {\r
-\r
- @Override\r
- public boolean get(int timeout) throws CadiException {\r
- // TODO Auto-generated method stub\r
- return false;\r
- }\r
-\r
- @Override\r
- public int code() {\r
- // TODO Auto-generated method stub\r
- return 0;\r
- }\r
-\r
- @Override\r
- public String body() {\r
- // TODO Auto-generated method stub\r
- return "{%}";\r
- }\r
-\r
- @Override\r
- public String header(String tag) {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
- };\r
- try {\r
- bCmd.error(future);\r
- } catch (Exception e) {\r
- noError = false;\r
- }\r
- assertEquals(noError, true);\r
-\r
- }\r
-\r
-\r
-\r
- @Test\r
- public void activity() throws DatatypeConfigurationException {\r
- boolean noError = true;\r
- History history = new History();\r
- History.Item item = new History.Item();\r
- item.setTarget("target");\r
- item.setUser("user");\r
- item.setMemo("memo");\r
-\r
- GregorianCalendar c = new GregorianCalendar();\r
- c.setTime(new Date());\r
- XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);\r
- item.setTimestamp(date);\r
- history.getItem().add(item);\r
- try {\r
- bCmd.activity(history, "history");\r
- } catch (Exception e) {\r
- noError = false;\r
- }\r
- assertEquals(noError, true);\r
-\r
- }\r
-\r
- @Test\r
- public void activity1() throws DatatypeConfigurationException {\r
- boolean noError = true;\r
- History history = new History();\r
- History.Item item = new History.Item();\r
- item.setTarget("target");\r
- item.setUser("user");\r
- item.setMemo("memo");\r
-\r
- GregorianCalendar c = new GregorianCalendar();\r
- c.setTime(new Date());\r
- XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);\r
- item.setTimestamp(date);\r
- history.getItem().add(item);\r
- try {\r
- bCmd.activity(history, "1[]");\r
- } catch (Exception e) {\r
- noError = false;\r
- }\r
- assertEquals(noError, true);\r
-\r
- }\r
- \r
-\r
-\r
- @Test\r
- public void error1() {\r
- boolean noError = true;\r
- Future<String> future = new Future<String>() {\r
-\r
- @Override\r
- public boolean get(int timeout) throws CadiException {\r
- // TODO Auto-generated method stub\r
- return false;\r
- }\r
-\r
- @Override\r
- public int code() {\r
- // TODO Auto-generated method stub\r
- return 0;\r
- }\r
-\r
- @Override\r
- public String body() {\r
- // TODO Auto-generated method stub\r
- return "{<html><code>1</code></html>";\r
- }\r
-\r
- @Override\r
- public String header(String tag) {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
- };\r
- try {\r
- bCmd.error(future);\r
- } catch (Exception e) {\r
- noError = false;\r
- }\r
- assertEquals(noError, true);\r
-\r
- }\r
-\r
- @Test\r
- public void error2() {\r
- boolean noError = true;\r
- Future<String> future = new Future<String>() {\r
-\r
- @Override\r
- public boolean get(int timeout) throws CadiException {\r
- // TODO Auto-generated method stub\r
- return false;\r
- }\r
-\r
- @Override\r
- public int code() {\r
- // TODO Auto-generated method stub\r
- return 0;\r
- }\r
-\r
- @Override\r
- public String body() {\r
- // TODO Auto-generated method stub\r
- return "other";\r
- }\r
-\r
- @Override\r
- public String header(String tag) {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
- };\r
- try {\r
- bCmd.error(future);\r
- } catch (Exception e) {\r
- noError = false;\r
- }\r
- assertEquals(noError, true);\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.BasicAuth;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_BasicAuth {\r
- \r
- @Test\r
- public void getID () {\r
- try {\r
- BasicAuth bAuth = new BasicAuth("testUser", "nopass");\r
- assertEquals(bAuth.getID(), "testUser");\r
- System.out.println(bAuth.getID());\r
- } catch (IOException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- \r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.Help;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Help {\r
- \r
- private static AAFcli cli;\r
- private static Help help;\r
- \r
- @Mock\r
- private static List<Cmd> cmds;\r
- \r
- @BeforeClass\r
- public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- cli = JU_AAFCli.getAAfCli();\r
- cmds = new ArrayList<>();\r
- help = new Help(cli, cmds);\r
- }\r
- \r
- @Test\r
- public void exec_HTTP_200() {\r
- try {\r
- assertEquals(help._exec(1, "helps"), HttpStatus.OK_200);\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void exec_HTTP_200_1() {\r
- try {\r
- assertEquals(help._exec(1, "helps","help"), HttpStatus.OK_200);\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void detailhelp() {\r
- boolean hasError=false;\r
- try {\r
- help.detailedHelp(2, new StringBuilder("detail help test"));\r
- } catch (Exception e) {\r
- hasError=true;\r
- }\r
- assertEquals(hasError,false);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Version;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Version {\r
- \r
- private static AAFcli cli;\r
- private static Version version;\r
- \r
- @BeforeClass\r
- public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- cli = JU_AAFCli.getAAfCli();\r
- version = new Version(cli);\r
- }\r
- \r
- @Test\r
- public void exec_HTTP_200() throws CadiException, APIException, LocatorException {\r
- assertEquals(version._exec(0, "Version"), HttpStatus.OK_200);\r
-\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.mgmt.Clear;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Clear {\r
- \r
- private static Clear clr;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- clr = mock(Clear.class);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(clr._exec(0, "clear"), 0);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.mgmt.Log;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Log {\r
- \r
- private static Log log;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- log = mock(Log.class);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(log._exec(0, "session clear"), 0);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.mgmt;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.mgmt.SessClear;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_SessClear {\r
- \r
- private static SessClear sessclr;\r
- \r
- @BeforeClass\r
- public static void setUp() {\r
- sessclr = mock(SessClear.class);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(sessclr._exec(0, "session clear"), 0);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Admin {\r
-\r
- private static Admin admin;\r
-\r
- @BeforeClass\r
- public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- admin = new Admin(ns);\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(admin._exec(0, "add", "del", "reset", "extend"), 500);\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- admin.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Attrib {\r
-\r
- private static Attrib attrib;\r
-\r
- @BeforeClass\r
- public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- attrib = new Attrib(ns);\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- attrib._exec(0, "add", "del", "reset", "extend");\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- attrib.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Create {\r
-\r
- private static Create create;\r
-\r
- @BeforeClass\r
- public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- create = new Create(ns);\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(create._exec(0, "add", "del", "reset", "extend"), 500);\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- create.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class JU_Delete {\r
-\r
- private static Delete delete;\r
-\r
- @BeforeClass\r
- public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- delete = new Delete(ns);\r
-\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- delete._exec(0, "del", "del", "del");\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- delete.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.mockito.Mockito.CALLS_REAL_METHODS;\r
-import static org.mockito.Mockito.mock;\r
-\r
-import java.lang.reflect.Field;\r
-import java.lang.reflect.Modifier;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.Describe;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Describe {\r
- \r
- private static Describe desc;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- desc = new Describe(ns);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(desc._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.List;\r
-import org.onap.aaf.cmd.ns.ListActivity;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListActivity {\r
- \r
- private static ListActivity lsActivity;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- lsActivity = new ListActivity(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsActivity._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.List;\r
-import org.onap.aaf.cmd.ns.ListAdminResponsible;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListAdminResponsible {\r
- \r
- private static ListAdminResponsible lsAdminRes;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- lsAdminRes = new ListAdminResponsible(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsAdminRes._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.List;\r
-import org.onap.aaf.cmd.ns.ListByName;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByName {\r
- \r
- private static ListByName lsByName;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- lsByName = new ListByName(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByName._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.List;\r
-import org.onap.aaf.cmd.ns.ListChildren;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListChildren {\r
- \r
- private static ListChildren lsChildren;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- lsChildren = new ListChildren(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsChildren._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.ns.List;\r
-import org.onap.aaf.cmd.ns.ListNsKeysByAttrib;\r
-import org.onap.aaf.cmd.ns.NS;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListNsKeysByAttrib {\r
- \r
- private static ListNsKeysByAttrib lsNsKeys;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- lsNsKeys = new ListNsKeysByAttrib(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsNsKeys._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListUsersInRole {\r
-\r
- private static ListUsersInRole lsUserinRole;\r
-\r
- @BeforeClass\r
- public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- ListUsers lsU = new ListUsers(ls);\r
- lsUserinRole = new ListUsersInRole(lsU);\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsUserinRole._exec(0, "add", "del", "reset", "extend"), 500);\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- lsUserinRole.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListUsersWithPerm {\r
-\r
- private static ListUsersWithPerm lsUserWithPerm;\r
-\r
- @BeforeClass\r
- public static void setUp() throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- List ls = new List(ns);\r
- ListUsers lsU = new ListUsers(ls);\r
- lsUserWithPerm = new ListUsersWithPerm(lsU);\r
- }\r
-\r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsUserWithPerm._exec(0, "add", "del", "reset", "extend"), 500);\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- lsUserWithPerm.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.ns;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.security.GeneralSecurityException;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public class JU_Responsible {\r
-\r
- private static Responsible responsible;\r
-\r
- @BeforeClass\r
- public static void setUp() throws APIException, LocatorException, GeneralSecurityException, IOException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- NS ns = new NS(cli);\r
- responsible = new Responsible(ns);\r
-\r
- }\r
-\r
- @Test\r
- public void exec1() {\r
- try {\r
- responsible._exec(0, "del", "del", "del");\r
- } catch (Exception e) {\r
- assertEquals(e.getMessage(), "java.net.UnknownHostException: DME2RESOLVE");\r
- }\r
- }\r
-\r
- @Test\r
- public void detailedHelp() {\r
- boolean hasNoError = true;\r
- try {\r
- responsible.detailedHelp(1, new StringBuilder("test"));\r
- } catch (Exception e) {\r
- hasNoError = false;\r
- }\r
- assertEquals(hasNoError, true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Create;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Create {\r
- \r
- private static Create create;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- create = new Create(perm);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(create._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Delete;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Delete {\r
- \r
- private static Delete del;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- del = new Delete(perm);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(del._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Describe;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Describe {\r
- \r
- private static Describe desc;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- desc = new Describe(perm);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(desc._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Grant;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Grant {\r
- \r
- private static Grant grant;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- grant = new Grant(perm);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(grant._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.List;\r
-import org.onap.aaf.cmd.perm.ListActivity;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListActivity {\r
- \r
- private static ListActivity lsActivity;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- List ls = new List(perm);\r
- lsActivity = new ListActivity(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsActivity._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.List;\r
-import org.onap.aaf.cmd.perm.ListByNS;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByNS {\r
- \r
- private static ListByNS lsByNS;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- List ls = new List(perm);\r
- lsByNS = new ListByNS(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByNS._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.List;\r
-import org.onap.aaf.cmd.perm.ListByName;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByName {\r
- \r
- private static ListByName lsByName;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- List ls = new List(perm);\r
- lsByName = new ListByName(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByName._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.List;\r
-import org.onap.aaf.cmd.perm.ListByRole;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByRole {\r
- \r
- private static ListByRole lsByRole;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- List ls = new List(perm);\r
- lsByRole = new ListByRole(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByRole._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.List;\r
-import org.onap.aaf.cmd.perm.ListByUser;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByUser {\r
- \r
- private static ListByUser lsByName;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- List ls = new List(perm);\r
- lsByName = new ListByUser(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByName._exec(0, "add","del","reset","extend"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.perm;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.perm.Rename;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Rename {\r
- \r
- private static Rename rename;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- Perm perm = new Perm(role);\r
- rename = new Rename(perm);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(rename._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.CreateDelete;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_CreateDelete {\r
- \r
- private static CreateDelete createDel;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- createDel = new CreateDelete(role);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(createDel._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.Describe;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Describe {\r
- \r
- private static Describe desc;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- desc = new Describe(role);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(desc._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListActivity;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListActivity {\r
- \r
- private static ListActivity lsActivity;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsActivity = new ListActivity(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsActivity._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListByNS;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByNS {\r
- \r
- private static ListByNS lsByNS;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsByNS = new ListByNS(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByNS._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListByNameOnly;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByNameOnly {\r
- \r
- private static ListByNameOnly lsByName;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsByName = new ListByNameOnly(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByName._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListByPerm;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByPerm {\r
- \r
- private static ListByPerm lsByPerm;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsByPerm = new ListByPerm(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByPerm._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListByRole;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByRole {\r
- \r
- private static ListByRole lsByRole;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsByRole = new ListByRole(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByRole._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.role.List;\r
-import org.onap.aaf.cmd.role.ListByUser;\r
-import org.onap.aaf.cmd.role.Role;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListByUser {\r
- \r
- private static ListByUser lsByUser;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- List ls = new List(role);\r
- lsByUser = new ListByUser(ls);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsByUser._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.role;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.perm.Perm;\r
-import org.onap.aaf.cmd.role.Role;\r
-import org.onap.aaf.cmd.role.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_User {\r
- \r
- private static User user;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- Role role = new Role(cli);\r
- user = new User(role);\r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(user._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.mockito.Mockito.mock;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.io.FileNotFoundException;\r
-import java.io.PrintWriter;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mockito;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.Cmd;\r
-import org.onap.aaf.cmd.user.Cred;\r
-import org.onap.aaf.cmd.user.User;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Cred {\r
-\r
- private static Cred testCred;\r
- private static User testUser;\r
- private static AuthzEnv env;\r
-\r
-\r
- @BeforeClass\r
- public static void setUp() throws FileNotFoundException, APIException {\r
- \r
- testCred = mock(Cred.class);\r
- testUser = mock(User.class);\r
- env = mock(AuthzEnv.class);\r
- Mockito.when(env.getProperty(Cmd.STARTDATE,null)).thenReturn(null);\r
- Mockito.when(env.getProperty(Cmd.ENDDATE,null)).thenReturn(null);\r
- \r
- }\r
-\r
- @Test\r
- public void exec() throws CadiException, APIException, LocatorException, FileNotFoundException {\r
- boolean isNullpointer=false;\r
- AAFcli aaFcli= new AAFcli(env, new PrintWriter("temp"), null, null, null);\r
- User user= new User(aaFcli);\r
- Cred testCred= new Cred(user);\r
- try {\r
- testCred._exec(0, "add", "del", "reset", "extend");\r
- } catch (Exception e) {\r
- isNullpointer=true;\r
- } \r
- assertEquals(isNullpointer, true);\r
- }\r
-\r
-\r
- @Test\r
- public void exec_add() { \r
- try {\r
- assertNotNull(testCred._exec(0, "zeroed","add","del","reset","extend"));\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void exec_del() { \r
- try {\r
- assertNotNull(testCred._exec(1, "zeroed","add","del","reset","extend"));\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void exec_reset() { \r
- try {\r
- assertNotNull(testCred._exec(2, "zeroed","add","del","reset","extend"));\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void exec_extend() { \r
- try {\r
- assertNotNull(testCred._exec(3, "zeroed","add","del","reset","extend"));\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.mockito.Mockito.mock;\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.user.Delg;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Delg {\r
- \r
- private static User testUser;\r
- private static Delg delg;\r
- \r
- @BeforeClass\r
- public static void setUp() throws APIException {\r
- testUser = mock(User.class);\r
- delg = mock(Delg.class);\r
- }\r
- \r
- @Test\r
- public void exec_add() {\r
- try {\r
- assertEquals(delg._exec(0, "zero","add","upd","del"), 0);\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void exec_upd() {\r
- try {\r
- assertEquals(delg._exec(1, "zero","add","upd","del"), 0);\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void exec_del() {\r
- try {\r
- assertEquals(delg._exec(2, "zero","add","upd","del"), 0);\r
- } catch (CadiException | APIException | LocatorException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListActivity;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListActivity {\r
- \r
- private static ListActivity lsActivity;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsActivity = new ListActivity(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsActivity._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListApprovals;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListApprovals {\r
- \r
- private static ListApprovals lsApprovals;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsApprovals = new ListApprovals(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsApprovals._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListDelegates;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListDelegates {\r
- \r
- private static ListDelegates lsDelegates;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsDelegates = new ListDelegates(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsDelegates._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListForCreds;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListForCreds {\r
- \r
- private static ListForCreds lsForCreds;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsForCreds = new ListForCreds(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsForCreds._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListForPermission;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListForPermission {\r
- \r
- private static ListForPermission lsForPermission;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsForPermission = new ListForPermission(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsForPermission._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.List;\r
-import org.onap.aaf.cmd.user.ListForRoles;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_ListForRoles {\r
- \r
- private static ListForRoles lsForRoles;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- List parent = new List(usr);\r
- lsForRoles = new ListForRoles(parent);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(lsForRoles._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cmd.user;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.cmd.AAFcli;\r
-import org.onap.aaf.cmd.JU_AAFCli;\r
-import org.onap.aaf.cmd.user.Role;\r
-import org.onap.aaf.cmd.user.User;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_Role {\r
- \r
- private static Role role;\r
- \r
- @BeforeClass\r
- public static void setUp () throws NoSuchFieldException, SecurityException, Exception, IllegalAccessException {\r
- AAFcli cli = JU_AAFCli.getAAfCli();\r
- User usr = new User(cli);\r
- role = new Role(usr);\r
- \r
- }\r
- \r
- @Test\r
- public void exec() {\r
- try {\r
- assertEquals(role._exec(0, "add","del","reset","extend","clear", "rename", "create"),500);\r
- } catch (CadiException e) {\r
- \r
- e.printStackTrace();\r
- } catch (APIException e) {\r
- \r
- e.printStackTrace();\r
- } catch (LocatorException e) {\r
- \r
- e.printStackTrace();\r
- }\r
- }\r
-}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>parent</artifactId>\r
- <version>1.0.1-SNAPSHOT</version>\r
- <relativePath>../pom.xml</relativePath>\r
- </parent>\r
- \r
- <artifactId>authz-core</artifactId>\r
- <name>Authz Core</name>\r
- <description>Core Libraries for Authz</description>\r
- <packaging>jar</packaging>\r
- <url>https://github.com/att/AAF</url>\r
- \r
- <developers>\r
- <developer>\r
- <name>Jonathan Gathman</name>\r
- <email></email>\r
- <organization>ATT</organization>\r
- <organizationUrl></organizationUrl>\r
- </developer>\r
- </developers>\r
-<properties>\r
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>\r
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>\r
- <!-- SONAR -->\r
- <jacoco.version>0.7.7.201606060606</jacoco.version>\r
- <sonar.skip>true</sonar.skip>\r
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>\r
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>\r
- <!-- Default Sonar configuration -->\r
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>\r
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>\r
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->\r
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>\r
- <nexusproxy>https://nexus.onap.org</nexusproxy>\r
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>\r
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>\r
-</properties>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.onap.aaf.inno</groupId>\r
- <artifactId>env</artifactId>\r
- <version>${project.innoVersion}</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.onap.aaf.inno</groupId>\r
- <artifactId>log4j</artifactId>\r
- <version>${project.innoVersion}</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.onap.aaf.inno</groupId>\r
- <artifactId>rosetta</artifactId>\r
- <version>${project.innoVersion}</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.onap.aaf.cadi</groupId>\r
- <artifactId>cadi-aaf</artifactId>\r
- <version>${project.cadiVersion}</version>\r
- <exclusions>\r
- <exclusion> \r
- <groupId>javax.servlet</groupId>\r
- <artifactId>servlet-api</artifactId>\r
- </exclusion>\r
- </exclusions> \r
- \r
- </dependency>\r
- <dependency>\r
- <groupId>javax.servlet</groupId>\r
- <artifactId>servlet-api</artifactId>\r
- </dependency>\r
-\r
- </dependencies>\r
-\r
- <build>\r
- <plugins>\r
- </plugins>\r
- <pluginManagement>\r
- <plugins>\r
-\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-javadoc-plugin</artifactId>\r
- <version>2.10.4</version>\r
- <configuration>\r
- <failOnError>false</failOnError>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>attach-javadocs</id>\r
- <goals>\r
- <goal>jar</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- \r
- \r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-source-plugin</artifactId>\r
- <version>2.2.1</version>\r
- <executions>\r
- <execution>\r
- <id>attach-sources</id>\r
- <goals>\r
- <goal>jar-no-fork</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin>\r
- \r
- <plugin>\r
- <groupId>org.sonatype.plugins</groupId>\r
- <artifactId>nexus-staging-maven-plugin</artifactId>\r
- <version>1.6.7</version>\r
- <extensions>true</extensions>\r
- <configuration>\r
- <nexusUrl>${nexusproxy}</nexusUrl>\r
- <stagingProfileId>176c31dfe190a</stagingProfileId>\r
- <serverId>ecomp-staging</serverId>\r
- </configuration>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.jacoco</groupId>\r
- <artifactId>jacoco-maven-plugin</artifactId>\r
- <version>${jacoco.version}</version>\r
- <configuration>\r
- <excludes>\r
- <exclude>**/gen/**</exclude>\r
- <exclude>**/generated-sources/**</exclude>\r
- <exclude>**/yang-gen/**</exclude>\r
- <exclude>**/pax/**</exclude>\r
- </excludes>\r
- </configuration>\r
- <executions>\r
-\r
- <execution>\r
- <id>pre-unit-test</id>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
- <propertyName>surefireArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
- \r
- \r
- <execution>\r
- <id>post-unit-test</id>\r
- <phase>test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
- </configuration>\r
- </execution>\r
- <execution>\r
- <id>pre-integration-test</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
-\r
- <propertyName>failsafeArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
-\r
- \r
- <execution>\r
- <id>post-integration-test</id>\r
- <phase>post-integration-test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- \r
- </plugins>\r
- </pluginManagement>\r
- </build>\r
- <distributionManagement>\r
- <repository>\r
- <id>ecomp-releases</id>\r
- <name>AAF Release Repository</name>\r
- <url>${nexusproxy}${releaseNexusPath}</url>\r
- </repository>\r
- <snapshotRepository>\r
- <id>ecomp-snapshots</id>\r
- <name>AAF Snapshot Repository</name>\r
- <url>${nexusproxy}${snapshotNexusPath}</url>\r
- </snapshotRepository>\r
- <site>\r
- <id>ecomp-site</id>\r
- <url>dav:${nexusproxy}${sitePath}</url>\r
- </site>\r
- </distributionManagement>\r
-\r
- \r
-</project>\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.common;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.inno.env.Env;\r
-\r
-public class Define {\r
- public static String ROOT_NS="org.openecomp";\r
- public static String ROOT_COMPANY=ROOT_NS;\r
-\r
- public static void set(Env env) throws CadiException {\r
- ROOT_NS = env.getProperty(Config.AAF_ROOT_NS);\r
- if(ROOT_NS==null) {\r
- throw new CadiException(Config.AAF_ROOT_NS + " property is required.");\r
- }\r
- ROOT_COMPANY = env.getProperty(Config.AAF_ROOT_COMPANY);\r
- if(ROOT_COMPANY==null) {\r
- int last = ROOT_NS.lastIndexOf('.');\r
- if(last>=0) {\r
- ROOT_COMPANY = ROOT_NS.substring(0, last);\r
- } else {\r
- throw new CadiException(Config.AAF_ROOT_COMPANY + " or " + Config.AAF_ROOT_NS + " property with 3 positions is required.");\r
- }\r
- }\r
- env.init().log("AAF Root NS is " + ROOT_NS + ", and AAF Root Company is " +ROOT_COMPANY);\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.Map.Entry;\r
-import java.util.Properties;\r
-\r
-import org.onap.aaf.cadi.Access;\r
-import org.onap.aaf.cadi.Symm;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Decryptor;\r
-import org.onap.aaf.inno.env.Encryptor;\r
-import org.onap.aaf.inno.env.impl.Log4JLogTarget;\r
-import org.onap.aaf.inno.env.log4j.LogFileNamer;\r
-import org.onap.aaf.rosetta.env.RosettaEnv;\r
-\r
-\r
-/**\r
- * AuthzEnv is the Env tailored to Authz Service\r
- * \r
- * Most of it is derived from RosettaEnv, but it also implements Access, which\r
- * is an Interface that Allows CADI to interact with Container Logging\r
- * \r
- *\r
- */\r
-public class AuthzEnv extends RosettaEnv implements Access {\r
- private long[] times = new long[20];\r
- private int idx = 0;\r
- //private int mask = Level.AUDIT.maskOf();\r
-\r
- public AuthzEnv() {\r
- super();\r
- }\r
-\r
- public AuthzEnv(String ... args) {\r
- super(args);\r
- }\r
-\r
- public AuthzEnv(Properties props) {\r
- super(Config.CADI_PROP_FILES,props);\r
- }\r
- \r
-\r
- @Override\r
- public AuthzTransImpl newTrans() {\r
- synchronized(this) {\r
- times[idx]=System.currentTimeMillis();\r
- if(++idx>=times.length)idx=0;\r
- }\r
- return new AuthzTransImpl(this);\r
- }\r
-\r
- /**\r
- * Create a Trans, but do not include in Weighted Average\r
- * @return\r
- */\r
- public AuthzTrans newTransNoAvg() {\r
- return new AuthzTransImpl(this);\r
- }\r
-\r
- public long transRate() {\r
- int count = 0;\r
- long pot = 0;\r
- long prev = 0;\r
- for(int i=idx;i<times.length;++i) {\r
- if(times[i]>0) {\r
- if(prev>0) {\r
- ++count;\r
- pot += times[i]-prev;\r
- }\r
- prev = times[i]; \r
- }\r
- }\r
- for(int i=0;i<idx;++i) {\r
- if(times[i]>0) {\r
- if(prev>0) {\r
- ++count;\r
- pot += times[i]-prev;\r
- }\r
- prev = times[i]; \r
- }\r
- }\r
-\r
- return count==0?300000L:pot/count; // Return Weighted Avg, or 5 mins, if none avail.\r
- }\r
- \r
- @Override\r
- public ClassLoader classLoader() {\r
- return getClass().getClassLoader();\r
- }\r
-\r
- @Override\r
- public void load(InputStream is) throws IOException {\r
- Properties props = new Properties();\r
- props.load(is);\r
- for(Entry<Object, Object> es : props.entrySet()) {\r
- String key = es.getKey().toString();\r
- String value =es.getValue().toString();\r
- put(staticSlot(key==null?null:key.trim()),value==null?null:value.trim());\r
- }\r
- }\r
-\r
- @Override\r
- public void log(Level lvl, Object... msgs) {\r
-// if(lvl.inMask(mask)) {\r
-// switch(lvl) {\r
-// case INIT:\r
-// init().log(msgs);\r
-// break;\r
-// case AUDIT:\r
-// audit().log(msgs);\r
-// break;\r
-// case DEBUG:\r
-// debug().log(msgs);\r
-// break;\r
-// case ERROR:\r
-// error().log(msgs);\r
-// break;\r
-// case INFO:\r
-// info().log(msgs);\r
-// break;\r
-// case WARN:\r
-// warn().log(msgs);\r
-// break;\r
-// case NONE:\r
-// break;\r
-// }\r
-// }\r
- }\r
-\r
- @Override\r
- public void log(Exception e, Object... msgs) {\r
- error().log(e,msgs);\r
- }\r
-\r
- //@Override\r
- public void printf(Level level, String fmt, Object... elements) {\r
- if(willLog(level)) {\r
- log(level,String.format(fmt, elements));\r
- }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.cadi.Access#willLog(org.onap.aaf.cadi.Access.Level)\r
- */\r
- @Override\r
- public boolean willLog(Level level) {\r
- \r
-// if(level.inMask(mask)) {\r
-// switch(level) {\r
-// case INIT:\r
-// return init().isLoggable();\r
-// case AUDIT:\r
-// return audit().isLoggable();\r
-// case DEBUG:\r
-// return debug().isLoggable();\r
-// case ERROR:\r
-// return error().isLoggable();\r
-// case INFO:\r
-// return info().isLoggable();\r
-// case WARN:\r
-// return warn().isLoggable();\r
-// case NONE:\r
-// return false;\r
-// }\r
-// }\r
- return false;\r
- }\r
-\r
- @Override\r
- public void setLogLevel(Level level) {\r
- super.debug().isLoggable();\r
- //level.toggle(mask);\r
- }\r
-\r
- public void setLog4JNames(String path, String root, String _service, String _audit, String _init, String _trace) throws APIException {\r
- LogFileNamer lfn = new LogFileNamer(root);\r
- if(_service==null) {\r
- throw new APIException("AuthzEnv.setLog4JNames \"_service\" required (as default). Others can be null");\r
- }\r
- String service=_service=lfn.setAppender(_service); // when name is split, i.e. authz|service, the Appender is "authz", and "service"\r
- String audit=_audit==null?service:lfn.setAppender(_audit); // is part of the log-file name\r
- String init=_init==null?service:lfn.setAppender(_init);\r
- String trace=_trace==null?service:lfn.setAppender(_trace);\r
- //TODO Validate path on Classpath\r
- lfn.configure(path);\r
- super.fatal = new Log4JLogTarget(service,org.apache.log4j.Level.FATAL);\r
- super.error = new Log4JLogTarget(service,org.apache.log4j.Level.ERROR);\r
- super.warn = new Log4JLogTarget(service,org.apache.log4j.Level.WARN);\r
- super.audit = new Log4JLogTarget(audit,org.apache.log4j.Level.WARN);\r
- super.init = new Log4JLogTarget(init,org.apache.log4j.Level.WARN);\r
- super.info = new Log4JLogTarget(service,org.apache.log4j.Level.INFO);\r
- super.debug = new Log4JLogTarget(service,org.apache.log4j.Level.DEBUG);\r
- super.trace = new Log4JLogTarget(trace,org.apache.log4j.Level.TRACE);\r
- }\r
- \r
- private static final byte[] ENC="enc:???".getBytes();\r
- public String decrypt(String encrypted, final boolean anytext) throws IOException {\r
- if(encrypted==null) {\r
- throw new IOException("Password to be decrypted is null");\r
- }\r
- if(anytext || encrypted.startsWith("enc:")) {\r
- if(decryptor.equals(Decryptor.NULL) && getProperty(Config.CADI_KEYFILE)!=null) {\r
- final Symm s = Symm.obtain(this);\r
- decryptor = new Decryptor() {\r
- private Symm symm = s;\r
- @Override\r
- public String decrypt(String encrypted) {\r
- try {\r
- return (encrypted!=null && (anytext || encrypted.startsWith(Symm.ENC)))\r
- ? symm.depass(encrypted)\r
- : encrypted;\r
- } catch (IOException e) {\r
- return "";\r
- }\r
- }\r
- };\r
- encryptor = new Encryptor() {\r
- @Override\r
- public String encrypt(String data) {\r
- ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
- try {\r
- baos.write(ENC);\r
- return "enc:???"+s.enpass(data);\r
- } catch (IOException e) {\r
- return "";\r
- }\r
- }\r
- \r
- };\r
- }\r
- return decryptor.decrypt(encrypted);\r
- } else {\r
- return encrypted;\r
- }\r
- }\r
- \r
- \r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.security.Principal;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.authz.org.Organization;\r
-\r
-import org.onap.aaf.cadi.Lur;\r
-import org.onap.aaf.cadi.Permission;\r
-import org.onap.aaf.inno.env.LogTarget;\r
-import org.onap.aaf.inno.env.TransStore;\r
-\r
-public interface AuthzTrans extends TransStore {\r
- public abstract AuthzTrans set(HttpServletRequest req);\r
-\r
- public abstract void setUser(Principal p);\r
- \r
- public abstract String user();\r
-\r
- public abstract Principal getUserPrincipal();\r
-\r
- public abstract String ip();\r
-\r
- public abstract int port();\r
-\r
- public abstract String meth();\r
-\r
- public abstract String path();\r
-\r
- public abstract String agent();\r
- \r
- public abstract AuthzEnv env();\r
-\r
- public abstract void setLur(Lur lur);\r
-\r
- public abstract boolean fish(Permission p);\r
- \r
- public abstract boolean forceRequested();\r
- \r
- public abstract Organization org();\r
-\r
- public abstract boolean moveRequested();\r
-\r
- public abstract boolean futureRequested();\r
- \r
- public abstract void logAuditTrail(LogTarget lt);\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.security.Principal;\r
-\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.cssa.rserv.TransFilter;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.Connector;\r
-import org.onap.aaf.cadi.TrustChecker;\r
-import org.onap.aaf.cadi.principal.BasicPrincipal;\r
-import org.onap.aaf.cadi.principal.TrustPrincipal;\r
-import org.onap.aaf.cadi.principal.X509Principal;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.Slot;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans.Metric;\r
-\r
-public class AuthzTransFilter extends TransFilter<AuthzTrans> {\r
- private AuthzEnv env;\r
- public Metric serviceMetric;\r
- public static Slot transIDslot;\r
-\r
- public static final String TRANS_ID_SLOT = "TRANS_ID_SLOT";\r
- public static final int BUCKETSIZE = 2;\r
-\r
- public AuthzTransFilter(AuthzEnv env, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException {\r
- super(env,con, tc, additionalTafLurs);\r
- this.env = env;\r
- serviceMetric = new Metric();\r
- serviceMetric.buckets = new float[BUCKETSIZE];\r
- if(transIDslot==null) {\r
- transIDslot = env.slot(TRANS_ID_SLOT);\r
- }\r
- }\r
- \r
- @Override\r
- protected AuthzTrans newTrans() {\r
- AuthzTrans at = env.newTrans();\r
- at.setLur(getLur());\r
- return at;\r
- }\r
-\r
- @Override\r
- protected TimeTaken start(AuthzTrans trans, ServletRequest request) {\r
- trans.set((HttpServletRequest)request);\r
- return trans.start("Trans " + //(context==null?"n/a":context.toString()) +\r
- " IP: " + trans.ip() +\r
- " Port: " + trans.port()\r
- , Env.SUB);\r
- }\r
-\r
- @Override\r
- protected void authenticated(AuthzTrans trans, Principal p) {\r
- trans.setUser(p);\r
- }\r
-\r
- @Override\r
- protected void tallyHo(AuthzTrans trans) {\r
- if(trans.info().isLoggable()) {\r
- // Transaction is done, now post\r
- StringBuilder sb = new StringBuilder("AuditTrail\n");\r
- // We'll grabAct sub-metrics for Remote Calls and JSON\r
- // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!!\r
- Metric m = trans.auditTrail(1, sb, Env.REMOTE,Env.JSON);\r
-\r
- // Add current Metrics to total metrics\r
- serviceMetric.total+= m.total;\r
- for(int i=0;i<serviceMetric.buckets.length;++i) {\r
- serviceMetric.buckets[i]+=m.buckets[i];\r
- }\r
- \r
- // Log current info\r
- sb.append(" Total: ");\r
- sb.append(m.total);\r
- sb.append(" Remote: ");\r
- sb.append(m.buckets[0]);\r
- sb.append(" JSON: ");\r
- sb.append(m.buckets[1]);\r
- trans.info().log(sb);\r
- } else {\r
- // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!!\r
- StringBuilder content = new StringBuilder(); \r
- Metric m = trans.auditTrail(1, content, Env.REMOTE,Env.JSON);\r
- // Add current Metrics to total metrics\r
- serviceMetric.total+= m.total;\r
- for(int i=0;i<serviceMetric.buckets.length;++i) {\r
- serviceMetric.buckets[i]+=m.buckets[i];\r
- }\r
- \r
- StringBuilder sb = new StringBuilder();\r
- sb.append("user=");\r
- Principal p = trans.getUserPrincipal();\r
- if(p==null) {\r
- sb.append("n/a");\r
- } else {\r
- sb.append(p.getName());\r
- if(p instanceof TrustPrincipal) {\r
- sb.append('(');\r
- sb.append(((TrustPrincipal)p).getOrigName());\r
- sb.append(')');\r
- } else {\r
- sb.append('[');\r
- if(p instanceof X509Principal) {\r
- sb.append("x509");\r
- } else if(p instanceof BasicPrincipal) {\r
- sb.append("BAth");\r
- } else {\r
- sb.append(p.getClass().getSimpleName());\r
- }\r
- sb.append(']');\r
- }\r
- }\r
- sb.append(",ip=");\r
- sb.append(trans.ip());\r
- sb.append(",port=");\r
- sb.append(trans.port());\r
- sb.append(",ms=");\r
- sb.append(m.total);\r
- sb.append(",meth=");\r
- sb.append(trans.meth());\r
- sb.append(",path=");\r
- sb.append(trans.path());\r
-\r
- Long tsi;\r
- if((tsi=trans.get(transIDslot, null))!=null) {\r
- sb.append(",traceID=");\r
- sb.append(Long.toHexString(tsi));\r
- }\r
- \r
- if(content.length()>0) {\r
- sb.append(",msg=\"");\r
- sb.append(content);\r
- sb.append('"');\r
- }\r
- \r
- trans.warn().log(sb);\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.security.Principal;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.authz.org.Organization;\r
-import org.onap.aaf.authz.org.OrganizationFactory;\r
-\r
-import org.onap.aaf.cadi.Lur;\r
-import org.onap.aaf.cadi.Permission;\r
-import org.onap.aaf.inno.env.LogTarget;\r
-import org.onap.aaf.inno.env.impl.BasicTrans;\r
-\r
-public class AuthzTransImpl extends BasicTrans implements AuthzTrans {\r
- private static final String TRUE = "true";\r
- private Principal user;\r
- private String ip,agent,meth,path;\r
- private int port;\r
- private Lur lur;\r
- private Organization org;\r
- private String force;\r
- private boolean futureRequested;\r
-\r
- public AuthzTransImpl(AuthzEnv env) {\r
- super(env);\r
- ip="n/a";\r
- org=null;\r
- }\r
-\r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#set(javax.servlet.http.HttpServletRequest)\r
- */\r
- @Override\r
- public AuthzTrans set(HttpServletRequest req) {\r
- user = req.getUserPrincipal();\r
- ip = req.getRemoteAddr();\r
- port = req.getRemotePort();\r
- agent = req.getHeader("User-Agent");\r
- meth = req.getMethod();\r
- path = req.getPathInfo();\r
- force = req.getParameter("force");\r
- futureRequested = TRUE.equalsIgnoreCase(req.getParameter("request"));\r
- org=null;\r
- return this;\r
- }\r
- \r
- @Override\r
- public void setUser(Principal p) {\r
- user = p;\r
- }\r
-\r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#user()\r
- */\r
- @Override\r
- public String user() {\r
- return user==null?"n/a":user.getName();\r
- }\r
- \r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#getUserPrincipal()\r
- */\r
- @Override\r
- public Principal getUserPrincipal() {\r
- return user;\r
- }\r
-\r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#ip()\r
- */\r
- @Override\r
- public String ip() {\r
- return ip;\r
- }\r
-\r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#port()\r
- */\r
- @Override\r
- public int port() {\r
- return port;\r
- }\r
-\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.env.AuthzTrans#meth()\r
- */\r
- @Override\r
- public String meth() {\r
- return meth;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.env.AuthzTrans#path()\r
- */\r
- @Override\r
- public String path() {\r
- return path;\r
- }\r
-\r
- /**\r
- * @see org.onap.aaf.authz.env.AuthTrans#agent()\r
- */\r
- @Override\r
- public String agent() {\r
- return agent;\r
- }\r
-\r
- @Override\r
- public AuthzEnv env() {\r
- return (AuthzEnv)delegate;\r
- }\r
- \r
- @Override\r
- public boolean forceRequested() {\r
- return TRUE.equalsIgnoreCase(force);\r
- }\r
- \r
- public void forceRequested(boolean force) {\r
- this.force = force?TRUE:"false";\r
- }\r
- \r
- @Override\r
- public boolean moveRequested() {\r
- return "move".equalsIgnoreCase(force);\r
- }\r
-\r
- @Override\r
- public boolean futureRequested() {\r
- return futureRequested;\r
- }\r
- \r
-\r
- @Override\r
- public void setLur(Lur lur) {\r
- this.lur = lur;\r
- }\r
- \r
- @Override\r
- public boolean fish(Permission p) {\r
- if(lur!=null) {\r
- return lur.fish(user, p);\r
- }\r
- return false;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.env.AuthzTrans#org()\r
- */\r
- @Override\r
- public Organization org() {\r
- if(org==null) {\r
- try {\r
- if((org = OrganizationFactory.obtain(env(), user()))==null) {\r
- org = Organization.NULL;\r
- }\r
- } catch (Exception e) {\r
- org = Organization.NULL;\r
- }\r
- } \r
- return org;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see org.onap.aaf.authz.env.AuthzTrans#logAuditTrailOnly(org.onap.aaf.inno.env.LogTarget)\r
- */\r
- @Override\r
- public void logAuditTrail(LogTarget lt) {\r
- if(lt.isLoggable()) {\r
- StringBuilder sb = new StringBuilder();\r
- auditTrail(1, sb);\r
- lt.log(sb);\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.security.Principal;\r
-\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.cssa.rserv.TransOnlyFilter;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans.Metric;\r
-\r
-public class AuthzTransOnlyFilter extends TransOnlyFilter<AuthzTrans> {\r
- private AuthzEnv env;\r
- public Metric serviceMetric;\r
-\r
- public static final int BUCKETSIZE = 2;\r
-\r
- public AuthzTransOnlyFilter(AuthzEnv env) {\r
- this.env = env;\r
- serviceMetric = new Metric();\r
- serviceMetric.buckets = new float[BUCKETSIZE]; \r
- }\r
- \r
- @Override\r
- protected AuthzTrans newTrans() {\r
- return env.newTrans();\r
- }\r
-\r
- @Override\r
- protected TimeTaken start(AuthzTrans trans, ServletRequest request) {\r
- trans.set((HttpServletRequest)request);\r
- return trans.start("Trans " + //(context==null?"n/a":context.toString()) +\r
- " IP: " + trans.ip() +\r
- " Port: " + trans.port()\r
- , Env.SUB);\r
- }\r
-\r
- @Override\r
- protected void authenticated(AuthzTrans trans, Principal p) {\r
- trans.setUser(p);\r
- }\r
-\r
- @Override\r
- protected void tallyHo(AuthzTrans trans) {\r
- // Transaction is done, now post\r
- StringBuilder sb = new StringBuilder("AuditTrail\n");\r
- // We'll grab sub-metrics for Remote Calls and JSON\r
- // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!!\r
- Metric m = trans.auditTrail(1, sb, Env.REMOTE,Env.JSON);\r
- // Add current Metrics to total metrics\r
- serviceMetric.total+= m.total;\r
- for(int i=0;i<serviceMetric.buckets.length;++i) {\r
- serviceMetric.buckets[i]+=m.buckets[i];\r
- }\r
- // Log current info\r
- sb.append(" Total: ");\r
- sb.append(m.total);\r
- sb.append(" Remote: ");\r
- sb.append(m.buckets[0]);\r
- sb.append(" JSON: ");\r
- sb.append(m.buckets[1]);\r
- trans.info().log(sb);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import java.security.Principal;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.authz.org.Organization;\r
-\r
-import org.onap.aaf.cadi.Lur;\r
-import org.onap.aaf.cadi.Permission;\r
-import org.onap.aaf.inno.env.Decryptor;\r
-import org.onap.aaf.inno.env.Encryptor;\r
-import org.onap.aaf.inno.env.LogTarget;\r
-import org.onap.aaf.inno.env.Slot;\r
-import org.onap.aaf.inno.env.StaticSlot;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-\r
-/**\r
- * A NULL implementation of AuthzTrans, for use in DirectAAF Taf/Lurs\r
- */\r
-public class NullTrans implements AuthzTrans {\r
- private static final AuthzTrans singleton = new NullTrans();\r
- \r
- public static final AuthzTrans singleton() {\r
- return singleton;\r
- }\r
- \r
- public void checkpoint(String text) {}\r
- public void checkpoint(String text, int additionalFlag) {}\r
- public Metric auditTrail(int indent, StringBuilder sb, int... flag) {return null;}\r
- public LogTarget fatal() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget error() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget audit() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see com.att.env.Env#init()\r
- */\r
- @Override\r
- public LogTarget init() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget warn() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget info() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget debug() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public LogTarget trace() {\r
- return LogTarget.NULL;\r
- }\r
-\r
- public TimeTaken start(String name, int flag) {\r
- return new TimeTaken(name,flag) {\r
- public void output(StringBuilder sb) {\r
- sb.append(name);\r
- sb.append(' ');\r
- sb.append(millis());\r
- sb.append("ms");\r
- }\r
- };\r
- }\r
-\r
- @Override\r
- public String setProperty(String tag, String value) {\r
- return value;\r
- }\r
-\r
- @Override\r
- public String getProperty(String tag) {\r
- return tag;\r
- }\r
-\r
- @Override\r
- public String getProperty(String tag, String deflt) {\r
- return deflt;\r
- }\r
-\r
- @Override\r
- public Decryptor decryptor() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Encryptor encryptor() {\r
- return null;\r
- }\r
- @Override\r
- public AuthzTrans set(HttpServletRequest req) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String user() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Principal getUserPrincipal() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String ip() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public int port() {\r
- return 0;\r
- }\r
- @Override\r
- public String meth() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String path() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public void put(Slot slot, Object value) {\r
- }\r
- @Override\r
- public <T> T get(Slot slot, T deflt) {\r
- return null;\r
- }\r
- @Override\r
- public <T> T get(StaticSlot slot, T dflt) {\r
- return null;\r
- }\r
- @Override\r
- public void setUser(Principal p) {\r
- }\r
- @Override\r
- public Slot slot(String name) {\r
- return null;\r
- }\r
- @Override\r
- public AuthzEnv env() {\r
- return null;\r
- }\r
- @Override\r
- public String agent() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public void setLur(Lur lur) {\r
- }\r
-\r
- @Override\r
- public boolean fish(Permission p) {\r
- return false;\r
- }\r
-\r
- @Override\r
- public boolean forceRequested() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public boolean futureRequested() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public boolean moveRequested() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public Organization org() {\r
- return Organization.NULL;\r
- }\r
-\r
- @Override\r
- public void logAuditTrail(LogTarget lt) {\r
- }\r
-\r
- @Override\r
- public Metric auditTrail(LogTarget lt, int indent, StringBuilder sb, int... flag) {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
-}\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.layer;\r
-\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.inno.env.Data;\r
-import org.onap.aaf.inno.env.Data.TYPE;\r
-\r
-\r
-\r
-public abstract class FacadeImpl {\r
- protected static final String IN = "in";\r
-\r
- protected void setContentType(HttpServletResponse response, TYPE type) {\r
- response.setContentType(type==Data.TYPE.JSON?"application/json":"text.xml");\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.layer;\r
-\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-\r
-/**\r
- * It would be nice if Java Enums were extensible, but they're not.\r
- * \r
- *\r
- */\r
-public class Result<RV> {\r
- private static final String SUCCESS = "Success";\r
- public static final String[] EMPTY_VARS = new String[0];\r
-\r
- public final static int OK=0,\r
- ERR_Security = 1,\r
- ERR_Denied = 2,\r
- ERR_Policy = 3,\r
- ERR_BadData = 4,\r
- ERR_NotImplemented = 5,\r
- ERR_NotFound = 6,\r
- ERR_ConflictAlreadyExists = 7,\r
- ERR_ActionNotCompleted = 8,\r
- ERR_Backend = 9,\r
- ERR_General = 20;\r
- \r
- public final RV value;\r
- public final int status;\r
- public final String details;\r
- public final String[] variables;\r
- \r
- protected Result(RV value, int status, String details, String[] variables) {\r
- this.value = value;\r
- if(value==null) {\r
- specialCondition|=EMPTY_LIST;\r
- }\r
- this.status = status;\r
- this.details = details;\r
- if(variables==null) {\r
- this.variables = EMPTY_VARS;\r
- } else {\r
- this.variables=variables;\r
- }\r
- }\r
- \r
- /**\r
- * Create a Result class with "OK" status and "Success" for details\r
- * \r
- * This is the easiest to use\r
- * \r
- * @param value\r
- * @param status\r
- * @return\r
- */\r
- public static<R> Result<R> ok(R value) {\r
- return new Result<R>(value,OK,SUCCESS,null);\r
- }\r
-\r
- /**\r
- * Accept Arrays and mark as empty or not\r
- * @param value\r
- * @return\r
- */\r
- public static<R> Result<R[]> ok(R value[]) {\r
- return new Result<R[]>(value,OK,SUCCESS,null).emptyList(value.length==0);\r
- }\r
-\r
- /**\r
- * Accept Sets and mark as empty or not\r
- * @param value\r
- * @return\r
- */\r
- public static<R> Result<Set<R>> ok(Set<R> value) {\r
- return new Result<Set<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);\r
- }\r
-\r
- /**\r
- * Accept Lists and mark as empty or not\r
- * @param value\r
- * @return\r
- */\r
- public static<R> Result<List<R>> ok(List<R> value) {\r
- return new Result<List<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);\r
- }\r
-\r
- /**\r
- * Accept Collections and mark as empty or not\r
- * @param value\r
- * @return\r
- */\r
- public static<R> Result<Collection<R>> ok(Collection<R> value) {\r
- return new Result<Collection<R>>(value,OK,SUCCESS,null).emptyList(value.size()==0);\r
- }\r
-\r
-\r
- /**\r
- * Special Case for Void Type\r
- * @return\r
- */\r
- public static Result<Void> ok() {\r
- return new Result<Void>(null,OK,SUCCESS,null);\r
- }\r
-\r
- /**\r
- * Create a Status (usually non OK, with a details statement \r
- * @param value\r
- * @param status\r
- * @param details\r
- * @return\r
- */\r
-// public static<R> Result<R> err(int status, String details) {\r
-// return new Result<R>(null,status,details,null);\r
-// }\r
- \r
- /**\r
- * Create a Status (usually non OK, with a details statement and variables supported\r
- * @param status\r
- * @param details\r
- * @param variables\r
- * @return\r
- */\r
- public static<R> Result<R> err(int status, String details, String ... variables) {\r
- return new Result<R>(null,status,details,variables);\r
- }\r
-\r
- /**\r
- * Create Error from status and Details of previous Result (and not data)\r
- * @param pdr\r
- * @return\r
- */\r
- public static<R> Result<R> err(Result<?> pdr) {\r
- return new Result<R>(null,pdr.status,pdr.details,pdr.variables);\r
- }\r
-\r
- /**\r
- * Create General Error from Exception\r
- * @param e\r
- * @return\r
- */\r
- public static<R> Result<R> err(Exception e) {\r
- return new Result<R>(null,ERR_General,e.getMessage(),EMPTY_VARS);\r
- }\r
-\r
- /**\r
- * Create a Status (usually non OK, with a details statement \r
- * @param value\r
- * @param status\r
- * @param details\r
- * @return\r
- */\r
- public static<R> Result<R> create(R value, int status, String details, String ... vars) {\r
- return new Result<R>(value,status,details,vars);\r
- }\r
-\r
- /**\r
- * Create a Status from a previous status' result/details \r
- * @param value\r
- * @param status\r
- * @param details\r
- * @return\r
- */\r
- public static<R> Result<R> create(R value, Result<?> result) {\r
- return new Result<R>(value,result.status,result.details,result.variables);\r
- }\r
-\r
- private static final int PARTIAL_CONTENT = 0x001;\r
- private static final int EMPTY_LIST = 0x002;\r
- \r
- /**\r
- * AAF Specific problems, etc \r
- * \r
- *\r
- */\r
-\r
- /**\r
- * specialCondition is a bit field to enable multiple conditions, e.g. PARTIAL_CONTENT\r
- */\r
- private int specialCondition = 0;\r
-\r
-\r
- /**\r
- * Is result set only partial results, i.e. the DAO clipped the real result set to a smaller number.\r
- * @return true iff result returned PARTIAL_CONTENT\r
- */\r
- public boolean partialContent() {\r
- return (specialCondition & PARTIAL_CONTENT) == PARTIAL_CONTENT;\r
- }\r
-\r
- /**\r
- * Set fact that result set only returned partial results, i.e. the DAO clipped the real result set to a smaller number.\r
- * @param hasPartialContent set true iff result returned PARTIAL_CONTENT\r
- * @return this Result object, so you can chain calls, in builder style\r
- */\r
- public Result<RV> partialContent(boolean hasPartialContent) {\r
- if (hasPartialContent) {\r
- specialCondition |= PARTIAL_CONTENT;\r
- } else {\r
- specialCondition &= (~PARTIAL_CONTENT);\r
- }\r
- return this;\r
- }\r
-\r
- /**\r
- * When Result is a List, you can check here to see if it's empty instead of looping\r
- * \r
- * @return\r
- */\r
- public boolean isEmpty() {\r
- return (specialCondition & EMPTY_LIST) == EMPTY_LIST;\r
- }\r
-\r
- /**\r
- * A common occurrence is that data comes back, but list is empty. If set, you can skip looking\r
- * at list at the outset.\r
- * \r
- * @param emptyList\r
- * @return\r
- */\r
- public Result<RV> emptyList(boolean emptyList) {\r
- if (emptyList) {\r
- specialCondition |= EMPTY_LIST;\r
- } else {\r
- specialCondition &= (~EMPTY_LIST);\r
- }\r
- return this;\r
- }\r
-\r
- \r
- /** \r
- * Convenience function. Checks OK, and also if List is not Empty\r
- * Not valid if Data is not a List\r
- * @return\r
- */\r
- public boolean isOK() {\r
- return status == OK;\r
- }\r
-\r
- /** \r
- * Convenience function. Checks OK, and also if List is not Empty\r
- * Not valid if Data is not a List\r
- * @return\r
- */\r
- public boolean notOK() {\r
- return status != OK;\r
- }\r
-\r
- /** \r
- * Convenience function. Checks OK, and also if List is not Empty\r
- * Not valid if Data is not a List\r
- * @return\r
- */\r
- public boolean isOKhasData() {\r
- return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;\r
- }\r
-\r
-\r
- /** \r
- * Convenience function. Checks OK, and also if List is not Empty\r
- * Not valid if Data is not a List\r
- * @return\r
- */\r
- public boolean notOKorIsEmpty() {\r
- return status != OK || (specialCondition & EMPTY_LIST) == EMPTY_LIST;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- if(status==0) {\r
- return details;\r
- } else {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append(status);\r
- sb.append(':');\r
- sb.append(String.format(details,((Object[])variables)));\r
- if(isEmpty()) {\r
- sb.append("{empty}");\r
- }\r
- sb.append('-');\r
- sb.append(value.toString());\r
- return sb.toString();\r
- }\r
- }\r
- \r
- public String errorString() {\r
- StringBuilder sb = new StringBuilder();\r
- switch(status) {\r
- case 1: sb.append("Security"); break;\r
- case 2: sb.append("Denied"); break;\r
- case 3: sb.append("Policy"); break;\r
- case 4: sb.append("BadData"); break;\r
- case 5: sb.append("NotImplemented"); break;\r
- case 6: sb.append("NotFound"); break;\r
- case 7: sb.append("AlreadyExists"); break;\r
- case 8: sb.append("ActionNotComplete"); break;\r
- default: sb.append("Error");\r
- }\r
- sb.append(" - ");\r
- sb.append(String.format(details, (Object[])variables));\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.local;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.io.RandomAccessFile;\r
-import java.util.Iterator;\r
-\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.local.DataFile.Token;\r
-import org.onap.aaf.authz.local.DataFile.Token.Field;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-\r
-public abstract class AbsData implements Iterable<String> {\r
- protected DataFile data;\r
- protected TextIndex ti;\r
- private File dataf,idxf,lockf;\r
- private String name;\r
- private char delim;\r
- private int maxLineSize;\r
- private int fieldOffset;\r
- private int skipLines;\r
-\r
- public AbsData(File dataf,char sepChar, int maxLineSize, int fieldOffset) {\r
- File dir = dataf.getParentFile();\r
- int dot = dataf.getName().lastIndexOf('.');\r
- if(dot>=0) {\r
- name = dataf.getName().substring(0,dot);\r
- }\r
-\r
- this.dataf=dataf;\r
- this.delim = sepChar;\r
- this.maxLineSize = maxLineSize;\r
- this.fieldOffset = fieldOffset;\r
- idxf = new File(dir,name.concat(".idx"));\r
- lockf = new File(dir,name.concat(".lock"));\r
- \r
- \r
- data = new DataFile(dataf,"r");\r
- ti = new TextIndex(idxf);\r
- skipLines=0;\r
- }\r
- \r
- public void skipLines(int lines) {\r
- skipLines=lines;\r
- }\r
- \r
- public String name() {\r
- return name;\r
- }\r
- \r
- public void open(AuthzTrans trans, long timeout) throws IOException {\r
- TimeTaken tt = trans.start("Open Data File", Env.SUB);\r
- boolean opened = false, first = true;\r
- try {\r
- if(!dataf.exists()) {\r
- throw new FileNotFoundException("Data File Missing:" + dataf.getCanonicalPath());\r
- }\r
- long begin = System.currentTimeMillis();\r
- long end = begin+timeout;\r
- boolean exists;\r
- while((exists=lockf.exists()) && begin<end) {\r
- if(first) {\r
- trans.warn().log("Waiting for",lockf.getCanonicalPath(),"to close");\r
- first = false;\r
- } \r
- try {\r
- Thread.sleep(200);\r
- } catch (InterruptedException e) {\r
- break;\r
- }\r
- begin = System.currentTimeMillis();\r
- }\r
- if(exists) {\r
- throw new IOException(lockf.getCanonicalPath() + "exists. May not open Datafile");\r
- }\r
- data.open();\r
- try {\r
- ensureIdxGood(trans);\r
- } catch (IOException e) {\r
- data.close();\r
- throw e;\r
- }\r
- ti.open();\r
- opened = true;\r
- \r
- } finally {\r
- tt.done();\r
- }\r
- if(!opened) {\r
- throw new IOException("DataFile pair for " + name + " was not able to be opened in " + timeout + "ms");\r
- }\r
- }\r
- \r
- private synchronized void ensureIdxGood(AuthzTrans trans) throws IOException {\r
- if(!idxf.exists() || idxf.length()==0 || dataf.lastModified()>idxf.lastModified()) {\r
- trans.warn().log(idxf.getCanonicalPath(),"is missing, empty or out of date, creating");\r
- RandomAccessFile raf = new RandomAccessFile(lockf, "rw");\r
- try {\r
- ti.create(trans, data, maxLineSize, delim, fieldOffset, skipLines);\r
- if(!idxf.exists() || (idxf.length()==0 && dataf.length()!=0)) {\r
- throw new IOException("Data Index File did not create correctly");\r
- }\r
- } finally {\r
- raf.close();\r
- lockf.delete();\r
- }\r
- }\r
- }\r
-\r
- public void close(AuthzTrans trans) throws IOException {\r
- ti.close();\r
- data.close();\r
- }\r
- \r
- public class Reuse {\r
- private Token tokenData;\r
- private Field fieldData;\r
-\r
- private Reuse(int size,char delim) {\r
- tokenData = data.new Token(size);\r
- fieldData = getTokenData().new Field(delim);\r
- }\r
- \r
- public void reset() {\r
- getFieldData().reset();\r
- }\r
-\r
- public void pos(int rec) {\r
- getFieldData().reset();\r
- getTokenData().pos(rec);\r
- }\r
-\r
- public String next() {\r
- return getFieldData().next();\r
- }\r
- \r
- public String at(int field) {\r
- return getFieldData().at(field);\r
- }\r
-\r
- public String atToEnd(int field) {\r
- return getFieldData().atToEnd(field);\r
- }\r
-\r
- public Field getFieldData() {\r
- return fieldData;\r
- }\r
-\r
- public Token getTokenData() {\r
- return tokenData;\r
- }\r
-\r
- }\r
- \r
- public Reuse reuse() {\r
- return new Reuse(maxLineSize,delim);\r
- }\r
-\r
- public Iter iterator() {\r
- return new Iter();\r
- }\r
- \r
- public class Iter implements Iterator<String> {\r
- private Reuse reuse;\r
- private org.onap.aaf.authz.local.TextIndex.Iter tii;\r
-\r
- public Iter() {\r
- reuse = reuse();\r
- tii = ti.new Iter();\r
- }\r
-\r
- @Override\r
- public boolean hasNext() {\r
- return tii.hasNext();\r
- }\r
-\r
- @Override\r
- public String next() {\r
- reuse.reset();\r
- int rec = tii.next();\r
- reuse.pos(rec);\r
- return reuse.at(0);\r
- }\r
-\r
- @Override\r
- public void remove() {\r
- // read only\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.local;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.io.RandomAccessFile;\r
-import java.nio.ByteBuffer;\r
-import java.nio.IntBuffer;\r
-import java.nio.MappedByteBuffer;\r
-import java.nio.channels.FileChannel;\r
-import java.nio.channels.FileChannel.MapMode;\r
-\r
-public class DataFile {\r
- private RandomAccessFile rafile;\r
- private FileChannel channel;\r
- public MappedByteBuffer mapBuff;\r
- private final File file;\r
- private final String access;\r
- \r
- public DataFile(File file, String access) {\r
- this.file = file;\r
- this.access = access;\r
- }\r
- public void open() throws IOException {\r
- if(!file.exists()) throw new FileNotFoundException();\r
- rafile = new RandomAccessFile(file,access);\r
- channel = rafile.getChannel();\r
- mapBuff = channel.map("r".equals(access)?MapMode.READ_ONLY:MapMode.READ_WRITE,0,channel.size());\r
- }\r
- public void close() throws IOException {\r
- if(channel!=null){channel.close();}\r
- if(rafile!=null) {rafile.close();}\r
- mapBuff = null;\r
- }\r
-\r
- public long size() throws IOException {\r
- return channel.size();\r
- }\r
-\r
- private synchronized int load(Token t) {\r
- int len = Math.min(mapBuff.limit()-t.next,t.buff.length);\r
- if(len>0) {\r
- mapBuff.position(t.next);\r
- mapBuff.get(t.buff,0,len);\r
- }\r
- return len<0?0:len;\r
- }\r
- \r
- public class Token {\r
- private byte[] buff;\r
- int pos, next, end;\r
- \r
- public Token(int size) {\r
- buff = new byte[size];\r
- pos = next = end = 0;\r
- }\r
- \r
- public boolean pos(int to) {\r
- pos = next = to;\r
- return (end=load(this))>0;\r
- }\r
- \r
- public boolean nextLine() {\r
- end = load(this);\r
- pos = next;\r
- for(int i=0;i<end;++i) {\r
- if(buff[i]=='\n') {\r
- end = i;\r
- next += i+1;\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- public IntBuffer getIntBuffer() {\r
- return ByteBuffer.wrap(buff).asIntBuffer();\r
- }\r
-\r
-\r
-\r
- public String toString() {\r
- return new String(buff,0,end);\r
- }\r
- public class Field {\r
- char delim;\r
- int idx;\r
- ByteBuffer bb;\r
-\r
- public Field(char delimiter) {\r
- delim = delimiter;\r
- idx = 0;\r
- bb = null;\r
- }\r
- \r
- public Field reset() {\r
- idx = 0;\r
- return this;\r
- }\r
- \r
- public String next() {\r
- if(idx>=end)return null;\r
- int start = idx;\r
- byte c=0;\r
- int endStr = -1;\r
- while(idx<end && idx<buff.length && (c=buff[idx])!=delim && c!='\n') { // for DOS\r
- if(c=='\r')endStr=idx;\r
- ++idx;\r
- }\r
- \r
- if(endStr<0) {\r
- endStr=idx-start;\r
- } else {\r
- endStr=endStr-start;\r
- }\r
- ++idx;\r
- return new String(buff,start,endStr);\r
- }\r
-\r
- public String at(int fieldOffset) {\r
- int start;\r
- byte c=0;\r
- for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) {\r
- if((c=buff[idx])==delim || c=='\n') {\r
- if(count++ == fieldOffset) {\r
- break;\r
- }\r
- start = idx+1;\r
- }\r
- }\r
- return new String(buff,start,(idx-start-(c=='\r'?1:0)));\r
- }\r
- \r
- public String atToEnd(int fieldOffset) {\r
- int start;\r
- byte c=0;\r
- for(int count = idx = start = 0; idx<end && idx<buff.length; ++idx) {\r
- if((c=buff[idx])==delim || c=='\n') {\r
- if(count++ == fieldOffset) {\r
- break;\r
- }\r
- start = idx+1;\r
- }\r
- }\r
- \r
- for(; idx<end && idx<buff.length && (c=buff[idx])!='\n'; ++idx) {\r
- ++idx;\r
- }\r
- return new String(buff,start,(idx-start-((c=='\r' || idx>=end)?1:0)));\r
- }\r
-\r
- }\r
-\r
- public int pos() {\r
- return pos;\r
- }\r
- }\r
-\r
- public File file() {\r
- return file;\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.local;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.RandomAccessFile;\r
-import java.nio.ByteBuffer;\r
-import java.nio.IntBuffer;\r
-import java.nio.channels.FileChannel;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.local.DataFile.Token;\r
-import org.onap.aaf.authz.local.DataFile.Token.Field;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public class TextIndex {\r
- private static final int REC_SIZE=8;\r
- \r
- private File file;\r
- private DataFile dataFile=null;\r
- \r
- public TextIndex(File theFile) {\r
- file = theFile;\r
- }\r
- \r
- public void open() throws IOException {\r
- dataFile = new DataFile(file,"r");\r
- dataFile.open();\r
- }\r
- \r
- public void close() throws IOException {\r
- if(dataFile!=null) {dataFile.close();}\r
- }\r
-\r
- public int find(Object key, AbsData.Reuse reuse, int offset) throws IOException {\r
- return find(key,reuse.getTokenData(),reuse.getFieldData(),offset);\r
- }\r
- \r
- public int find(Object key, DataFile.Token dtok, Field df, int offset) throws IOException {\r
- if(dataFile==null) {throw new IOException("File not opened");}\r
- long hash = hashToLong(key.hashCode());\r
- int min=0, max = (int)(dataFile.size()/REC_SIZE);\r
- Token ttok = dataFile.new Token(REC_SIZE);\r
- IntBuffer tib = ttok.getIntBuffer();\r
- long lhash;\r
- int curr;\r
- while((max-min)>100) {\r
- ttok.pos((curr=(min+(max-min)/2))*REC_SIZE);\r
- tib.rewind();\r
- lhash = hashToLong(tib.get());\r
- if(lhash<hash) {\r
- min=curr+1;\r
- } else if(lhash>hash) {\r
- max=curr-1;\r
- } else {\r
- min=curr-40;\r
- max=curr+40;\r
- break;\r
- }\r
- }\r
- \r
- List<Integer> entries = new ArrayList<Integer>();\r
- for(int i=min;i<=max;++i) {\r
- ttok.pos(i*REC_SIZE);\r
- tib.rewind();\r
- lhash = hashToLong(tib.get());\r
- if(lhash==hash) {\r
- entries.add(tib.get());\r
- } else if(lhash>hash) {\r
- break;\r
- }\r
- }\r
- \r
- for(Integer i : entries) {\r
- dtok.pos(i);\r
- if(df.at(offset).equals(key)) {\r
- return i;\r
- }\r
- }\r
- return -1;\r
- }\r
- \r
-\r
- /*\r
- * Have to change Bytes into a Long, to avoid the inevitable signs in the Hash\r
- */\r
- private static long hashToLong(int hash) {\r
- long rv;\r
- if(hash<0) {\r
- rv = 0xFFFFFFFFL & hash;\r
- } else {\r
- rv = hash;\r
- }\r
- return rv;\r
- }\r
- \r
- public void create(final Trans trans,final DataFile data, int maxLine, char delim, int fieldOffset, int skipLines) throws IOException {\r
- RandomAccessFile raf;\r
- FileChannel fos;\r
- \r
- List<Idx> list = new LinkedList<Idx>(); // Some hashcodes will double... DO NOT make a set\r
- TimeTaken tt2 = trans.start("Open Files", Env.SUB);\r
- try {\r
- raf = new RandomAccessFile(file,"rw");\r
- raf.setLength(0L);\r
- fos = raf.getChannel();\r
- } finally {\r
- tt2.done();\r
- }\r
- \r
- try {\r
- \r
- Token t = data.new Token(maxLine); \r
- Field f = t.new Field(delim);\r
- \r
- int count = 0;\r
- if(skipLines>0) {\r
- trans.info().log("Skipping",skipLines,"line"+(skipLines==1?" in":"s in"),data.file().getName());\r
- }\r
- for(int i=0;i<skipLines;++i) {\r
- t.nextLine();\r
- }\r
- tt2 = trans.start("Read", Env.SUB);\r
- try {\r
- while(t.nextLine()) {\r
- list.add(new Idx(f.at(fieldOffset),t.pos()));\r
- ++count;\r
- }\r
- } finally {\r
- tt2.done();\r
- }\r
- trans.checkpoint(" Read " + count + " records");\r
- tt2 = trans.start("Sort List", Env.SUB);\r
- Collections.sort(list);\r
- tt2.done();\r
- tt2 = trans.start("Write Idx", Env.SUB);\r
- try {\r
- ByteBuffer bb = ByteBuffer.allocate(8*1024);\r
- IntBuffer ib = bb.asIntBuffer();\r
- for(Idx idx : list) {\r
- if(!ib.hasRemaining()) {\r
- fos.write(bb);\r
- ib.clear();\r
- bb.rewind();\r
- }\r
- ib.put(idx.hash);\r
- ib.put(idx.pos);\r
- }\r
- bb.limit(4*ib.position());\r
- fos.write(bb);\r
- } finally {\r
- tt2.done();\r
- }\r
- } finally {\r
- fos.close();\r
- raf.close();\r
- }\r
- }\r
- \r
- public class Iter {\r
- private int idx;\r
- private Token t;\r
- private long end;\r
- private IntBuffer ib;\r
-\r
-\r
- public Iter() {\r
- try {\r
- idx = 0;\r
- end = dataFile.size();\r
- t = dataFile.new Token(REC_SIZE);\r
- ib = t.getIntBuffer();\r
-\r
- } catch (IOException e) {\r
- end = -1L;\r
- }\r
- }\r
- \r
- public int next() {\r
- t.pos(idx);\r
- ib.clear();\r
- ib.get();\r
- int rec = ib.get();\r
- idx += REC_SIZE;\r
- return rec;\r
- }\r
-\r
- public boolean hasNext() {\r
- return idx<end;\r
- }\r
- }\r
- \r
- private static class Idx implements Comparable<Idx> {\r
- public int hash, pos;\r
- public Idx(Object obj, int pos) {\r
- hash = obj.hashCode();\r
- this.pos = pos;\r
- }\r
- \r
- @Override\r
- public int compareTo(Idx ib) {\r
- long a = hashToLong(hash);\r
- long b = hashToLong(ib.hash);\r
- return a>b?1:a<b?-1:0;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.lang.Object#equals(java.lang.Object)\r
- */\r
- @Override\r
- public boolean equals(Object o) {\r
- if(o!=null && o instanceof Idx) {\r
- return hash == ((Idx)o).hash;\r
- }\r
- return false;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.lang.Object#hashCode()\r
- */\r
- @Override\r
- public int hashCode() {\r
- return hash;\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-public interface EmailWarnings\r
-{\r
- public long credExpirationWarning();\r
- public long roleExpirationWarning();\r
- public long credEmailInterval();\r
- public long roleEmailInterval();\r
- public long apprEmailInterval();\r
- public long emailUrgentWarning();\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-public interface Executor {\r
- // remove User from user/Role\r
- // remove user from Admins\r
- // if # of Owners > 1, remove User from Owner\r
- // if # of Owners = 1, changeOwner to X Remove Owner????\r
- boolean hasPermission(String user, String ns, String type, String instance, String action); \r
- boolean inRole(String name);\r
- \r
- public String namespace() throws Exception;\r
- public String id();\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-\r
-/**\r
- * Organization\r
- * \r
- * There is Organizational specific information required which we have extracted to a plugin\r
- * \r
- * It supports using Company Specific User Directory lookups, as well as supporting an\r
- * Approval/Validation Process to simplify control of Roles and Permissions for large organizations\r
- * in lieu of direct manipulation by a set of Admins. \r
- * \r
- *\r
- */\r
-public interface Organization {\r
- public static final String N_A = "n/a";\r
-\r
- public interface Identity {\r
- public String id();\r
- public String fullID(); // Fully Qualified ID (includes Domain of Organization)\r
- public String type(); // Must be one of "IdentityTypes", see below\r
- public String responsibleTo(); // Chain of Command, Comma Separated if required\r
- public List<String> delegate(); // Someone who has authority to act on behalf of Identity\r
- public String email();\r
- public String fullName();\r
- public boolean isResponsible(); // Is id passed belong to a person suitable to be Responsible for content Management\r
- public boolean isFound(); // Is Identity found in Identity stores\r
- public Identity owner() throws OrganizationException; // Identity is directly responsible for App ID\r
- public Organization org(); // Organization of Identity\r
- }\r
-\r
-\r
- /**\r
- * Name of Organization, suitable for Logging\r
- * @return\r
- */\r
- public String getName();\r
-\r
- /**\r
- * Realm, for use in distinguishing IDs from different systems/Companies\r
- * @return\r
- */\r
- public String getRealm();\r
-\r
- String getDomain();\r
-\r
- /**\r
- * Get Identity information based on userID\r
- * \r
- * @param id\r
- * @return\r
- */\r
- public Identity getIdentity(AuthzTrans trans, String id) throws OrganizationException;\r
- \r
-\r
- /**\r
- * Does the ID pass Organization Standards\r
- * \r
- * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of \r
- * reasons why it fails\r
- * \r
- * @param id\r
- * @return\r
- */\r
- public String isValidID(String id);\r
-\r
- /**\r
- * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of \r
- * reasons why it fails\r
- * \r
- * Identity is passed in to allow policies regarding passwords that are the same as user ID\r
- * \r
- * any entries for "prev" imply a reset\r
- * \r
- * @param id\r
- * @param password\r
- * @return\r
- */\r
- public String isValidPassword(String user, String password, String ... prev);\r
-\r
-\r
- /**\r
- * Does your Company distinguish essential permission structures by kind of Identity?\r
- * i.e. Employee, Contractor, Vendor \r
- * @return\r
- */\r
- public Set<String> getIdentityTypes();\r
-\r
- public enum Notify {\r
- Approval(1),\r
- PasswordExpiration(2),\r
- RoleExpiration(3);\r
-\r
- final int id;\r
- Notify(int id) {this.id = id;}\r
- public int getValue() {return id;}\r
- public static Notify from(int type) {\r
- for(Notify t : Notify.values()) {\r
- if(t.id==type) {\r
- return t;\r
- }\r
- }\r
- return null;\r
- }\r
- }\r
-\r
- public enum Response{\r
- OK,\r
- ERR_NotImplemented,\r
- ERR_UserNotExist,\r
- ERR_NotificationFailure,\r
- };\r
- \r
- public enum Expiration {\r
- Password,\r
- TempPassword, \r
- Future,\r
- UserInRole,\r
- UserDelegate, \r
- ExtendPassword\r
- }\r
- \r
- public enum Policy {\r
- CHANGE_JOB, \r
- LEFT_COMPANY, \r
- CREATE_MECHID, \r
- CREATE_MECHID_BY_PERM_ONLY,\r
- OWNS_MECHID,\r
- AS_EMPLOYEE, \r
- MAY_EXTEND_CRED_EXPIRES\r
- }\r
- \r
- /**\r
- * Notify a User of Action or Info\r
- * \r
- * @param type\r
- * @param url\r
- * @param users (separated by commas)\r
- * @param ccs (separated by commas)\r
- * @param summary\r
- */\r
-\r
- public Response notify(AuthzTrans trans, Notify type, String url, String ids[], String ccs[], String summary, Boolean urgent);\r
-\r
- /**\r
- * (more) generic way to send an email\r
- * \r
- * @param toList\r
- * @param ccList\r
- * @param subject\r
- * @param body\r
- * @param urgent\r
- */\r
-\r
- public int sendEmail(AuthzTrans trans, List<String> toList, List<String> ccList, String subject, String body, Boolean urgent) throws OrganizationException;\r
-\r
- /**\r
- * whenToValidate\r
- * \r
- * Authz support services will ask the Organization Object at startup when it should\r
- * kickoff Validation processes given particular types. \r
- * \r
- * This allows the Organization to express Policy\r
- * \r
- * Turn off Validation behavior by returning "null"\r
- * \r
- */\r
- public Date whenToValidate(Notify type, Date lastValidated);\r
-\r
- \r
- /**\r
- * Expiration\r
- * \r
- * Given a Calendar item of Start (or now), set the Expiration Date based on the Policy\r
- * based on type.\r
- * \r
- * For instance, "Passwords expire in 3 months"\r
- * \r
- * The Extra Parameter is used by certain Orgs.\r
- * \r
- * For Password, the extra is UserID, so it can check the Identity Type\r
- * \r
- * @param gc\r
- * @param exp\r
- * @return\r
- */\r
- public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String ... extra);\r
- \r
- /**\r
- * Get Email Warning timing policies\r
- * @return\r
- */\r
- public EmailWarnings emailWarningPolicy();\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param user\r
- * @return\r
- */\r
- public List<Identity> getApprovers(AuthzTrans trans, String user) throws OrganizationException ;\r
- \r
- /*\r
- * \r
- * @param user\r
- * @param type\r
- * @param users\r
- * @return\r
- public Response notifyRequest(AuthzTrans trans, String user, Approval type, List<User> approvers);\r
- */\r
- \r
- /**\r
- * \r
- * @return\r
- */\r
- public String getApproverType();\r
-\r
- /*\r
- * startOfDay - define for company what hour of day business starts (specifically for password and other expiration which\r
- * were set by Date only.)\r
- * \r
- * @return\r
- */\r
- public int startOfDay();\r
-\r
- /**\r
- * implement this method to support any IDs that can have multiple entries in the cred table\r
- * NOTE: the combination of ID/expiration date/(encryption type when implemented) must be unique.\r
- * Since expiration date is based on startOfDay for your company, you cannot create many\r
- * creds for the same ID in the same day.\r
- * @param id\r
- * @return\r
- */\r
- public boolean canHaveMultipleCreds(String id);\r
- \r
- /**\r
- * \r
- * @param id\r
- * @return\r
- */\r
- public boolean isValidCred(String id);\r
- \r
- /**\r
- * If response is Null, then it is valid. Otherwise, the Organization specific reason is returned.\r
- * \r
- * @param trans\r
- * @param policy\r
- * @param executor\r
- * @param vars\r
- * @return\r
- * @throws OrganizationException\r
- */\r
- public String validate(AuthzTrans trans, Policy policy, Executor executor, String ... vars) throws OrganizationException;\r
-\r
- boolean isTestEnv();\r
-\r
- public void setTestMode(boolean dryRun);\r
-\r
- public static final Organization NULL = new Organization() \r
- {\r
- private final GregorianCalendar gc = new GregorianCalendar(1900, 1, 1);\r
- private final List<Identity> nullList = new ArrayList<Identity>();\r
- private final Set<String> nullStringSet = new HashSet<String>();\r
- private final Identity nullIdentity = new Identity() {\r
- List<String> nullIdentity = new ArrayList<String>();\r
- @Override\r
- public String type() {\r
- return N_A;\r
- }\r
- @Override\r
- public String responsibleTo() {\r
- return N_A;\r
- }\r
- @Override\r
- public boolean isResponsible() {\r
- return false;\r
- }\r
- \r
- @Override\r
- public boolean isFound() {\r
- return false;\r
- }\r
- \r
- @Override\r
- public String id() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public String fullID() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public String email() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public List<String> delegate() {\r
- return nullIdentity;\r
- }\r
- @Override\r
- public String fullName() {\r
- return N_A;\r
- }\r
- @Override\r
- public Identity owner() {\r
- return null;\r
- }\r
- @Override\r
- public Organization org() {\r
- return NULL;\r
- }\r
- };\r
-\r
- @Override\r
- public String getName() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public String getRealm() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public String getDomain() {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public Identity getIdentity(AuthzTrans trans, String id) {\r
- return nullIdentity;\r
- }\r
- \r
- @Override\r
- public String isValidID(String id) {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public String isValidPassword(String user, String password,String... prev) {\r
- return N_A;\r
- }\r
- \r
- @Override\r
- public Set<String> getIdentityTypes() {\r
- return nullStringSet;\r
- }\r
- \r
- @Override\r
- public Response notify(AuthzTrans trans, Notify type, String url,\r
- String[] users, String[] ccs, String summary, Boolean urgent) {\r
- return Response.ERR_NotImplemented;\r
- }\r
- \r
- @Override\r
- public int sendEmail(AuthzTrans trans, List<String> toList, List<String> ccList,\r
- String subject, String body, Boolean urgent) throws OrganizationException {\r
- return 0;\r
- }\r
- \r
- @Override\r
- public Date whenToValidate(Notify type, Date lastValidated) {\r
- return gc.getTime();\r
- }\r
- \r
- @Override\r
- public GregorianCalendar expiration(GregorianCalendar gc,\r
- Expiration exp, String... extra) {\r
- return gc==null?new GregorianCalendar():gc;\r
- }\r
- \r
- @Override\r
- public List<Identity> getApprovers(AuthzTrans trans, String user)\r
- throws OrganizationException {\r
- return nullList;\r
- }\r
- \r
- @Override\r
- public String getApproverType() {\r
- return "";\r
- }\r
- \r
- @Override\r
- public int startOfDay() {\r
- return 0;\r
- }\r
- \r
- @Override\r
- public boolean canHaveMultipleCreds(String id) {\r
- return false;\r
- }\r
- \r
- @Override\r
- public boolean isValidCred(String id) {\r
- return false;\r
- }\r
- \r
- @Override\r
- public String validate(AuthzTrans trans, Policy policy, Executor executor, String ... vars)\r
- throws OrganizationException {\r
- return "Null Organization rejects all Policies";\r
- }\r
- \r
- @Override\r
- public boolean isTestEnv() {\r
- return false;\r
- }\r
- \r
- @Override\r
- public void setTestMode(boolean dryRun) {\r
- }\r
-\r
- @Override\r
- public EmailWarnings emailWarningPolicy() {\r
- return new EmailWarnings() {\r
-\r
- @Override\r
- public long credEmailInterval()\r
- {\r
- return 604800000L; // 7 days in millis 1000 * 86400 * 7\r
- }\r
- \r
- @Override\r
- public long roleEmailInterval()\r
- {\r
- return 604800000L; // 7 days in millis 1000 * 86400 * 7\r
- }\r
- \r
- @Override\r
- public long apprEmailInterval() {\r
- return 259200000L; // 3 days in millis 1000 * 86400 * 3\r
- }\r
- \r
- @Override\r
- public long credExpirationWarning()\r
- {\r
- return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds\r
- }\r
- \r
- @Override\r
- public long roleExpirationWarning()\r
- {\r
- return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds\r
- }\r
-\r
- @Override\r
- public long emailUrgentWarning()\r
- {\r
- return( 1209600000L ); // Two weeks, in milliseconds 1000 * 86400 * 14 in milliseconds\r
- }\r
-\r
- };\r
- }\r
- };\r
-}\r
-\r
-\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-public class OrganizationException extends Exception {\r
-\r
- /**\r
- * \r
- */\r
- private static final long serialVersionUID = 1L;\r
-\r
- public OrganizationException() {\r
- super();\r
- }\r
-\r
- public OrganizationException(String message) {\r
- super(message);\r
- }\r
-\r
- public OrganizationException(Throwable cause) {\r
- super(cause);\r
- }\r
-\r
- public OrganizationException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
- public OrganizationException(String message, Throwable cause, boolean enableSuppression,\r
- boolean writableStackTrace) {\r
- super(message, cause, enableSuppression, writableStackTrace);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-import java.lang.reflect.Constructor;\r
-import java.lang.reflect.InvocationTargetException;\r
-import java.util.Map;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-import org.onap.aaf.inno.env.Slot;\r
-\r
-/**\r
- * Organization Plugin Mechanism\r
- * \r
- * Define a NameSpace for the company (i.e. com.att), and put in Properties as \r
- * "Organization.[your NS" and assign the supporting Class. \r
- * \r
- * Example:\r
- * Organization.com.att=org.onap.aaf.authz.org.att.ATT\r
- *\r
- *\r
- */\r
-public class OrganizationFactory {\r
- public static final String ORG_SLOT = "ORG_SLOT";\r
- private static Organization defaultOrg = null;\r
- private static Map<String,Organization> orgs = new ConcurrentHashMap<String,Organization>();\r
- private static Slot orgSlot;\r
- \r
- public static void setDefaultOrg(AuthzEnv env, String orgClass) throws APIException {\r
- orgSlot = env.slot(ORG_SLOT);\r
- try {\r
- @SuppressWarnings("unchecked")\r
- Class<Organization> cls = (Class<Organization>) Class.forName(orgClass);\r
- Constructor<Organization> cnst = cls.getConstructor(AuthzEnv.class);\r
- defaultOrg = cnst.newInstance(env);\r
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | \r
- InstantiationException | IllegalAccessException | IllegalArgumentException | \r
- InvocationTargetException e) {\r
- throw new APIException(e);\r
- }\r
- }\r
- \r
- public static Organization obtain(AuthzEnv env,String orgNS) throws OrganizationException {\r
- int at = orgNS.indexOf('@');\r
- if(at<0) {\r
- if(!orgNS.startsWith("com.")) {\r
- int dot1;\r
- if((dot1 = orgNS.lastIndexOf('.'))>-1) {\r
- int dot2;\r
- StringBuilder sb = new StringBuilder();\r
- if((dot2 = orgNS.lastIndexOf('.',dot1-1))>-1) {\r
- sb.append(orgNS,dot1+1,orgNS.length());\r
- sb.append('.');\r
- sb.append(orgNS,dot2+1,dot1);\r
- } else {\r
- sb.append(orgNS,dot1+1,orgNS.length());\r
- sb.append('.');\r
- sb.append(orgNS,at+1,dot1);\r
- }\r
- orgNS=sb.toString();\r
- }\r
- }\r
- } else {\r
- // Only use two places (Enterprise) of domain\r
- int dot;\r
- if((dot= orgNS.lastIndexOf('.'))>-1) {\r
- StringBuilder sb = new StringBuilder();\r
- int dot2;\r
- if((dot2 = orgNS.lastIndexOf('.',dot-1))>-1) {\r
- sb.append(orgNS.substring(dot+1));\r
- sb.append(orgNS.subSequence(dot2, dot));\r
- orgNS = sb.toString();\r
- } else {\r
- sb.append(orgNS.substring(dot+1));\r
- sb.append('.');\r
- sb.append(orgNS.subSequence(at+1, dot));\r
- orgNS = sb.toString();\r
- }\r
- }\r
- }\r
- Organization org = orgs.get(orgNS);\r
- if(org == null) {\r
- String orgClass = env.getProperty("Organization."+orgNS);\r
- if(orgClass == null) {\r
- env.warn().log("There is no Organization." + orgNS + " property");\r
- } else {\r
- for(Organization o : orgs.values()) {\r
- if(orgClass.equals(o.getClass().getName())) {\r
- org = o;\r
- }\r
- }\r
- if(org==null) {\r
- try {\r
- @SuppressWarnings("unchecked")\r
- Class<Organization> cls = (Class<Organization>) Class.forName(orgClass);\r
- Constructor<Organization> cnst = cls.getConstructor(AuthzEnv.class);\r
- org = cnst.newInstance(env);\r
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | \r
- InstantiationException | IllegalAccessException | IllegalArgumentException | \r
- InvocationTargetException e) {\r
- throw new OrganizationException(e);\r
- }\r
- }\r
- orgs.put(orgNS, org);\r
- }\r
- if(org==null && defaultOrg!=null) {\r
- org=defaultOrg;\r
- orgs.put(orgNS, org);\r
- }\r
- }\r
- \r
- return org;\r
- }\r
-\r
- public static void set(AuthzTrans trans, String orgNS) throws OrganizationException {\r
- Organization org = obtain(trans.env(),orgNS);\r
- trans.put(orgSlot, org);\r
- }\r
- \r
- public static Organization get(AuthzTrans trans) {\r
- return trans.get(orgSlot,defaultOrg);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.server;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.lang.reflect.Constructor;\r
-import java.net.URL;\r
-import java.security.GeneralSecurityException;\r
-import java.security.Principal;\r
-import java.util.Properties;\r
-\r
-import javax.net.ssl.SSLContext;\r
-import javax.net.ssl.SSLSocketFactory;\r
-\r
-import org.onap.aaf.authz.common.Define;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.cssa.rserv.RServlet;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.LocatorException;\r
-//import org.onap.aaf.cadi.PropAccess;\r
-import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;\r
-import org.onap.aaf.cadi.client.Rcli;\r
-import org.onap.aaf.cadi.client.Retryable;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.cadi.http.HTransferSS;\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-public abstract class AbsServer extends RServlet<AuthzTrans> {\r
- private static final String AAF_API_VERSION = "2.0";\r
- public final String app;\r
- public final AuthzEnv env;\r
- public AAFConHttp aafCon;\r
-\r
- public AbsServer(final AuthzEnv env, final String app) throws CadiException, GeneralSecurityException, IOException {\r
- this.env = env;\r
- this.app = app;\r
- if(env.getProperty(Config.AAF_URL)!=null) {\r
- //aafCon = new AAFConHttp(env);\r
- }\r
- }\r
- \r
- // This is a method, so we can overload for AAFAPI\r
- public String aaf_url() {\r
- return env.getProperty(Config.AAF_URL);\r
- }\r
- \r
- public abstract void startDME2(Properties props) throws Exception;\r
- public static void setup(Class<?> abss, String propFile) {\r
-\r
- try {\r
- // Load Properties from authFramework.properties. Needed for DME2 and AuthzEnv\r
- Properties props = new Properties();\r
- URL rsrc = ClassLoader.getSystemResource(propFile);\r
- if(rsrc==null) {\r
- System.err.println("Folder containing " + propFile + " must be on Classpath");\r
- System.exit(1);\r
- }\r
-\r
- InputStream is = rsrc.openStream();\r
- try {\r
- props.load(is);\r
- } finally {\r
- is.close();\r
- is=null;\r
- }\r
-\r
- // Load Properties into AuthzEnv\r
- AuthzEnv env = new AuthzEnv(props);\r
- // Log where Config found\r
- env.init().log("Configuring from",rsrc.getPath());\r
- rsrc = null;\r
- \r
- // Print Cipher Suites Available\r
- if(env.debug().isLoggable()) {\r
- SSLContext context = SSLContext.getDefault();\r
- SSLSocketFactory sf = context.getSocketFactory();\r
- StringBuilder sb = new StringBuilder("Available Cipher Suites: ");\r
- boolean first = true;\r
- int count=0;\r
- for( String cs : sf.getSupportedCipherSuites()) {\r
- if(first)first = false;\r
- else sb.append(',');\r
- sb.append(cs);\r
- if(++count%4==0){sb.append('\n');}\r
- }\r
- env.debug().log(sb);\r
- }\r
-\r
- // Set ROOT NS, etc\r
- Define.set(env);\r
-\r
- // Convert CADI properties and Encrypted Passwords for these two properties (if exist) \r
- // to DME2 Readable. Further, Discovery Props are loaded to System if missing.\r
- // May be causing client errors\r
- //Config.cadiToDME2(env,props);\r
- env.init().log("DME2 ServiceName: " + env.getProperty("DMEServiceName","unknown"));\r
-\r
- // Construct with Env\r
- Constructor<?> cons = abss.getConstructor(new Class<?>[] {AuthzEnv.class});\r
- // Start DME2 (DME2 needs Properties form of props)\r
- AbsServer s = (AbsServer)cons.newInstance(env);\r
- \r
- // Schedule removal of Clear Text Passwords from System Props (DME2 Requirement) \r
-// new Timer("PassRemove").schedule(tt, 120000);\r
-// tt=null;\r
- \r
- s.startDME2(props);\r
- } catch (Exception e) {\r
- e.printStackTrace(System.err);\r
- System.exit(1);\r
- }\r
- }\r
- \r
- public Rcli<?> client() throws CadiException {\r
- return aafCon.client(AAF_API_VERSION);\r
- }\r
-\r
- public Rcli<?> clientAsUser(Principal p) throws CadiException {\r
- return aafCon.client(AAF_API_VERSION).forUser(\r
- new HTransferSS(p,app, aafCon.securityInfo()));\r
- }\r
-\r
- public<RET> RET clientAsUser(Principal p,Retryable<RET> retryable) throws APIException, LocatorException, CadiException {\r
- return aafCon.hman().best(new HTransferSS(p,app, aafCon.securityInfo()), retryable);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cache;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.Timer;\r
-import java.util.TimerTask;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-import java.util.logging.Level;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-/**\r
- * Create and maintain a Map of Maps used for Caching\r
- * \r
- *\r
- * @param <TRANS>\r
- * @param <DATA>\r
- */\r
-public class Cache<TRANS extends Trans, DATA> {\r
- private static Clean clean;\r
- private static Timer cleanseTimer;\r
-\r
- public static final String CACHE_HIGH_COUNT = "CACHE_HIGH_COUNT";\r
- public static final String CACHE_CLEAN_INTERVAL = "CACHE_CLEAN_INTERVAL";\r
-// public static final String CACHE_MIN_REFRESH_INTERVAL = "CACHE_MIN_REFRESH_INTERVAL";\r
-\r
- private static final Map<String,Map<String,Dated>> cacheMap;\r
-\r
- static {\r
- cacheMap = new HashMap<String,Map<String,Dated>>();\r
- }\r
-\r
- /**\r
- * Dated Class - store any Data with timestamp\r
- * \r
- *\r
- */\r
- public final static class Dated { \r
- public Date timestamp;\r
- public List<?> data;\r
- \r
- public Dated(List<?> data) {\r
- timestamp = new Date();\r
- this.data = data;\r
- }\r
-\r
- public <T> Dated(T t) {\r
- timestamp = new Date();\r
- ArrayList<T> al = new ArrayList<T>(1);\r
- al.add(t);\r
- data = al;\r
- }\r
-\r
- public void touch() {\r
- timestamp = new Date();\r
- }\r
- }\r
- \r
- public static Map<String,Dated> obtain(String key) {\r
- Map<String, Dated> m = cacheMap.get(key);\r
- if(m==null) {\r
- m = new ConcurrentHashMap<String, Dated>();\r
- synchronized(cacheMap) {\r
- cacheMap.put(key, m);\r
- }\r
- }\r
- return m;\r
- }\r
-\r
- /**\r
- * Clean will examine resources, and remove those that have expired.\r
- * \r
- * If "highs" have been exceeded, then we'll expire 10% more the next time. This will adjust after each run\r
- * without checking contents more than once, making a good average "high" in the minimum speed.\r
- * \r
- *\r
- */\r
- private final static class Clean extends TimerTask {\r
- private final Env env;\r
- private Set<String> set;\r
- \r
- // The idea here is to not be too restrictive on a high, but to Expire more items by \r
- // shortening the time to expire. This is done by judiciously incrementing "advance"\r
- // when the "highs" are exceeded. This effectively reduces numbers of cached items quickly.\r
- private final int high;\r
- private long advance;\r
- private final long timeInterval;\r
- \r
- public Clean(Env env, long cleanInterval, int highCount) {\r
- this.env = env;\r
- high = highCount;\r
- timeInterval = cleanInterval;\r
- advance = 0;\r
- set = new HashSet<String>();\r
- }\r
- \r
- public synchronized void add(String key) {\r
- set.add(key);\r
- }\r
-\r
- public void run() {\r
- int count = 0;\r
- int total = 0;\r
- // look at now. If we need to expire more by increasing "now" by "advance"\r
- Date now = new Date(System.currentTimeMillis() + advance);\r
- \r
- \r
- for(String name : set) {\r
- Map<String,Dated> map = cacheMap.get(name);\r
- if(map!=null) for(Map.Entry<String,Dated> me : map.entrySet()) {\r
- ++total;\r
- if(me.getValue().timestamp.before(now)) {\r
- map.remove(me.getKey());\r
- ++count;\r
- }\r
- }\r
-// if(count>0) {\r
-// env.info().log(Level.INFO, "Cache removed",count,"expired",name,"Elements");\r
-// }\r
- }\r
- \r
- if(count>0) {\r
- env.info().log(Level.INFO, "Cache removed",count,"expired Cached Elements out of", total);\r
- }\r
-\r
- // If High (total) is reached during this period, increase the number of expired services removed for next time.\r
- // There's no point doing it again here, as there should have been cleaned items.\r
- if(total>high) {\r
- // advance cleanup by 10%, without getting greater than timeInterval.\r
- advance = Math.min(timeInterval, advance+(timeInterval/10));\r
- } else {\r
- // reduce advance by 10%, without getting lower than 0.\r
- advance = Math.max(0, advance-(timeInterval/10));\r
- }\r
- }\r
- }\r
-\r
- public static synchronized void startCleansing(Env env, String ... keys) {\r
- if(cleanseTimer==null) {\r
- cleanseTimer = new Timer("Cache Cleanup Timer");\r
- int cleanInterval = Integer.parseInt(env.getProperty(CACHE_CLEAN_INTERVAL,"60000")); // 1 minute clean cycles \r
- int highCount = Integer.parseInt(env.getProperty(CACHE_HIGH_COUNT,"5000"));\r
- cleanseTimer.schedule(clean = new Clean(env, cleanInterval, highCount), cleanInterval, cleanInterval);\r
- }\r
- \r
- for(String key : keys) {\r
- clean.add(key);\r
- }\r
- }\r
-\r
- public static void stopTimer() {\r
- if(cleanseTimer!=null) {\r
- cleanseTimer.cancel();\r
- cleanseTimer = null;\r
- }\r
- }\r
-\r
- public static void addShutdownHook() {\r
- Runtime.getRuntime().addShutdownHook(new Thread() {\r
- @Override\r
- public void run() {\r
- Cache.stopTimer();\r
- }\r
- }); \r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-/**\r
- * Find Acceptable Paths and place them where TypeCode can evaluate.\r
- * \r
- * If there are more than one, TypeCode will choose based on "q" value\r
- *\r
- * @param <TRANS>\r
- */\r
-class Acceptor<TRANS extends Trans> {\r
- private List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types;\r
- List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> acceptable;\r
- \r
- public Acceptor(List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types) {\r
- this.types = types;\r
- acceptable = new ArrayList<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>>();\r
- }\r
- \r
- private boolean eval(HttpCode<TRANS,?> code, String str, List<String> props) {\r
-// int plus = str.indexOf('+');\r
-// if(plus<0) {\r
- boolean ok = false;\r
- boolean any = false;\r
- for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) {\r
- ok = true;\r
- if(type.x.equals(str)) {\r
- for(Iterator<String> iter = props.iterator();ok && iter.hasNext();) {\r
- ok = props(type,iter.next(),iter.next());\r
- }\r
- if(ok) {\r
- any = true;\r
- acceptable.add(type);\r
- }\r
- }\r
- }\r
-// } else { // Handle Accepts with "+" as in application/xaml+xml\r
-// int prev = str.indexOf('/')+1;\r
-// String first = str.substring(0,prev);\r
-// String nstr;\r
-// while(prev!=0) {\r
-// nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus));\r
-// \r
-// for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) {\r
-// if(type.x.equals(nstr)) {\r
-// acceptable.add(type);\r
-// return type;\r
-// }\r
-// }\r
-// prev = plus+1;\r
-// plus=str.indexOf('+', prev);\r
-// };\r
-// }\r
- return any;\r
- }\r
-\r
- /**\r
- * Evaluate Properties\r
- * @param type\r
- * @param tag\r
- * @param value\r
- * @return\r
- */\r
- private boolean props(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type, String tag, String value) {\r
- boolean rv = false;\r
- if(type.y!=null) {\r
- for(Pair<String,Object> prop : type.y.y){\r
- if(tag.equals(prop.x)) {\r
- if(tag.equals("charset")) {\r
- return prop.x==null?false:prop.y.equals(value.toLowerCase()); // return True if Matched\r
- } else if(tag.equals("version")) {\r
- return prop.y.equals(new Version(value)); // Note: Version Class knows Minor Version encoding\r
- } else if(tag.equals(Content.Q)) { // replace Q value\r
- try {\r
- type.y.y.get(0).y=Float.parseFloat(value);\r
- } catch (NumberFormatException e) {\r
- rv=false; // need to do something to make Sonar happy. But nothing to do.\r
- }\r
- return true;\r
- } else {\r
- return value.equals(prop.y);\r
- }\r
- }\r
- }\r
- }\r
- return rv;\r
- }\r
-\r
- /**\r
- * parse \r
- * \r
- * Note: I'm processing by index to avoid lots of memory creation, which speeds things\r
- * up for this time critical section of code. \r
- * @param code\r
- * @param cntnt\r
- * @return\r
- */\r
- protected boolean parse(HttpCode<TRANS, ?> code, String cntnt) {\r
- byte bytes[] = cntnt.getBytes();\r
- \r
- int cis,cie=-1,cend;\r
- int sis,sie,send;\r
- String name;\r
- ArrayList<String> props = new ArrayList<String>();\r
- do {\r
- // Clear these in case more than one Semi\r
- props.clear(); // on loop, do not want mixed properties\r
- name=null;\r
- \r
- cis = cie+1; // find comma start\r
- while(cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis;\r
- cie = cntnt.indexOf(',',cis); // find comma end\r
- cend = cie<0?bytes.length:cie; // If no comma, set comma end to full length, else cie\r
- while(cend>cis && Character.isSpaceChar(bytes[cend-1]))--cend;\r
- // Start SEMIS\r
- sie=cis-1; \r
- do {\r
- sis = sie+1; // semi start is one after previous end\r
- while(sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis; \r
- sie = cntnt.indexOf(';',sis);\r
- send = sie>cend || sie<0?cend:sie; // if the Semicolon is after the comma, or non-existent, use comma end, else keep\r
- while(send>sis && Character.isSpaceChar(bytes[send-1]))--send;\r
- if(name==null) { // first entry in Comma set is the name, not a property\r
- name = new String(bytes,sis,send-sis);\r
- } else { // We've looped past the first Semi, now process as properties\r
- // If there are additional elements (more entities within Semi Colons)\r
- // apply Properties\r
- int eq = cntnt.indexOf('=',sis);\r
- if(eq>sis && eq<send) {\r
- props.add(new String(bytes,sis,eq-sis));\r
- props.add(new String(bytes,eq+1,send-(eq+1)));\r
- }\r
- }\r
- // End Property\r
- } while(sie<=cend && sie>=cis); // End SEMI processing\r
- // Now evaluate Comma set and return if true\r
- if(eval(code,name,props))return true; // else loop again to check next comma\r
- } while(cie>=0); // loop to next comma\r
- return false; // didn't get even one match\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.FileReader;\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.io.Writer;\r
-import java.nio.ByteBuffer;\r
-import java.nio.channels.FileChannel;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-import java.util.NavigableMap;\r
-import java.util.Set;\r
-import java.util.Timer;\r
-import java.util.TimerTask;\r
-import java.util.TreeMap;\r
-import java.util.concurrent.ConcurrentSkipListMap;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.EnvJAXB;\r
-import org.onap.aaf.inno.env.LogTarget;\r
-import org.onap.aaf.inno.env.Store;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-/*\r
- * CachingFileAccess\r
- * \r
- * \r
- */\r
-public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void> {\r
- public static void setEnv(Store store, String[] args) {\r
- for(int i=0;i<args.length-1;i+=2) { // cover two parms required for each \r
- if(CFA_WEB_DIR.equals(args[i])) {\r
- store.put(store.staticSlot(CFA_WEB_DIR), args[i+1]); \r
- } else if(CFA_CACHE_CHECK_INTERVAL.equals(args[i])) {\r
- store.put(store.staticSlot(CFA_CACHE_CHECK_INTERVAL), Long.parseLong(args[i+1]));\r
- } else if(CFA_MAX_SIZE.equals(args[i])) {\r
- store.put(store.staticSlot(CFA_MAX_SIZE), Integer.parseInt(args[i+1]));\r
- }\r
- }\r
- }\r
- \r
- private static String MAX_AGE = "max-age=3600"; // 1 hour Caching\r
- private final Map<String,String> typeMap;\r
- private final NavigableMap<String,Content> content;\r
- private final Set<String> attachOnly;\r
- private final static String WEB_DIR_DEFAULT = "theme";\r
- public final static String CFA_WEB_DIR = "CFA_WebPath";\r
- // when to re-validate from file\r
- // Re validating means comparing the Timestamp on the disk, and seeing it has changed. Cache is not marked\r
- // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. \r
- // deployed GUI elements is unnecessary, and wastes time.\r
- // This parameter exists to cover the cases where data can be more volatile, so the user can choose how often the\r
- // File IO will be accessed, based on probability of change. "0", of course, means, check every time.\r
- private final static String CFA_CACHE_CHECK_INTERVAL = "CFA_CheckIntervalMS";\r
- private final static String CFA_MAX_SIZE = "CFA_MaxSize"; // Cache size limit\r
- private final static String CFA_CLEAR_COMMAND = "CFA_ClearCommand";\r
-\r
- // Note: can be null without a problem, but included\r
- // to tie in with existing Logging.\r
- public LogTarget logT = null;\r
- public long checkInterval; // = 600000L; // only check if not hit in 10 mins by default\r
- public int maxItemSize; // = 512000; // max file 500k\r
- private Timer timer;\r
- private String web_path;\r
- // A command key is set in the Properties, preferably changed on deployment.\r
- // it is compared at the beginning of the path, and if so, it is assumed to issue certain commands\r
- // It's purpose is to protect, to some degree the command, even though it is HTTP, allowing \r
- // local batch files to, for instance, clear caches on resetting of files.\r
- private String clear_command;\r
- \r
- public CachingFileAccess(EnvJAXB env, String ... args) {\r
- super(null,"Caching File Access");\r
- setEnv(env,args);\r
- content = new ConcurrentSkipListMap<String,Content>(); // multi-thread changes possible\r
-\r
- attachOnly = new HashSet<String>(); // short, unchanged\r
-\r
- typeMap = new TreeMap<String,String>(); // Structure unchanged after Construction\r
- typeMap.put("ico","image/icon");\r
- typeMap.put("html","text/html");\r
- typeMap.put("css","text/css");\r
- typeMap.put("js","text/javascript");\r
- typeMap.put("txt","text/plain");\r
- typeMap.put("xml","text/xml");\r
- typeMap.put("xsd","text/xml");\r
- attachOnly.add("xsd");\r
- typeMap.put("crl", "application/x-pkcs7-crl");\r
- typeMap.put("appcache","text/cache-manifest");\r
-\r
- typeMap.put("json","text/json");\r
- typeMap.put("ogg", "audio/ogg");\r
- typeMap.put("jpg","image/jpeg");\r
- typeMap.put("gif","image/gif");\r
- typeMap.put("png","image/png");\r
- typeMap.put("svg","image/svg+xml");\r
- typeMap.put("jar","application/x-java-applet");\r
- typeMap.put("jnlp", "application/x-java-jnlp-file");\r
- typeMap.put("class", "application/java");\r
- \r
- timer = new Timer("Caching Cleanup",true);\r
- timer.schedule(new Cleanup(content,500),60000,60000);\r
- \r
- // Property params\r
- web_path = env.getProperty(CFA_WEB_DIR,WEB_DIR_DEFAULT);\r
- Object obj;\r
- obj = env.get(env.staticSlot(CFA_CACHE_CHECK_INTERVAL),600000L); // Default is 10 mins\r
- if(obj instanceof Long) {checkInterval=(Long)obj;\r
- } else {checkInterval=Long.parseLong((String)obj);}\r
- \r
- obj = env.get(env.staticSlot(CFA_MAX_SIZE), 512000); // Default is max file 500k\r
- if(obj instanceof Integer) {maxItemSize=(Integer)obj;\r
- } else {maxItemSize =Integer.parseInt((String)obj);}\r
- \r
- clear_command = env.getProperty(CFA_CLEAR_COMMAND,null);\r
- }\r
-\r
- \r
-\r
- @Override\r
- public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException {\r
- String key = pathParam(req, ":key");\r
- if(key.equals(clear_command)) {\r
- String cmd = pathParam(req,":cmd");\r
- resp.setHeader("Content-type",typeMap.get("txt"));\r
- if("clear".equals(cmd)) {\r
- content.clear();\r
- resp.setStatus(HttpStatus.OK_200);\r
- } else {\r
- resp.setStatus(HttpStatus.BAD_REQUEST_400);\r
- }\r
- return;\r
- }\r
- Content c = load(logT , web_path,key, null, checkInterval);\r
- if(c.attachmentOnly) {\r
- resp.setHeader("Content-disposition", "attachment");\r
- }\r
- c.write(resp.getOutputStream());\r
- c.setHeader(resp);\r
- trans.checkpoint(req.getPathInfo());\r
- }\r
-\r
-\r
- public String webPath() {\r
- return web_path;\r
- }\r
- \r
- /**\r
- * Reset the Cleanup size and interval\r
- * \r
- * The size and interval when started are 500 items (memory size unknown) checked every minute in a background thread.\r
- * \r
- * @param size\r
- * @param interval\r
- */\r
- public void cleanupParams(int size, long interval) {\r
- timer.cancel();\r
- timer.schedule(new Cleanup(content,size), interval, interval);\r
- }\r
- \r
-\r
- \r
- /**\r
- * Load a file, first checking cache\r
- * \r
- * \r
- * @param logTarget - logTarget can be null (won't log)\r
- * @param dataRoot - data root storage directory\r
- * @param key - relative File Path\r
- * @param mediaType - what kind of file is it. If null, will check via file extension\r
- * @param timeCheck - "-1" will take system default - Otherwise, will compare "now" + timeCheck(Millis) before looking at File mod\r
- * @return\r
- * @throws IOException\r
- */\r
- public Content load(LogTarget logTarget, String dataRoot, String key, String mediaType, long _timeCheck) throws IOException {\r
- long timeCheck = _timeCheck;\r
- if(timeCheck<0) {\r
- timeCheck=checkInterval; // if time < 0, then use default\r
- }\r
- String fileName = dataRoot + '/' + key;\r
- Content c = content.get(key);\r
- long systime = System.currentTimeMillis(); \r
- File f=null;\r
- if(c!=null) {\r
- // Don't check every hit... only after certain time value\r
- if(c.date < systime + timeCheck) {\r
- f = new File(fileName);\r
- if(f.lastModified()>c.date) {\r
- c=null;\r
- }\r
- }\r
- }\r
- if(c==null) { \r
- if(logTarget!=null) {\r
- logTarget.log("File Read: ",key);\r
- }\r
- \r
- if(f==null){\r
- f = new File(fileName);\r
- }\r
-\r
- boolean cacheMe;\r
- if(f.exists()) {\r
- if(f.length() > maxItemSize) {\r
- c = new DirectFileContent(f);\r
- cacheMe = false;\r
- } else {\r
- c = new CachedContent(f);\r
- cacheMe = checkInterval>0;\r
- }\r
- \r
- if(mediaType==null) { // determine from file Ending\r
- int idx = key.lastIndexOf('.');\r
- String subkey = key.substring(++idx);\r
- if((c.contentType = idx<0?null:typeMap.get(subkey))==null) {\r
- // if nothing else, just set to default type...\r
- c.contentType = "application/octet-stream";\r
- }\r
- c.attachmentOnly = attachOnly.contains(subkey);\r
- } else {\r
- c.contentType=mediaType;\r
- c.attachmentOnly = false;\r
- }\r
- \r
- c.date = f.lastModified();\r
- \r
- if(cacheMe) {\r
- content.put(key, c);\r
- }\r
- } else {\r
- c=NULL;\r
- }\r
- } else {\r
- if(logTarget!=null)logTarget.log("Cache Read: ",key);\r
- }\r
-\r
- // refresh hit time\r
- c.access = systime;\r
- return c;\r
- }\r
- \r
- public Content loadOrDefault(Trans trans, String targetDir, String targetFileName, String sourcePath, String mediaType) throws IOException {\r
- try {\r
- return load(trans.info(),targetDir,targetFileName,mediaType,0);\r
- } catch(FileNotFoundException e) {\r
- String targetPath = targetDir + '/' + targetFileName;\r
- TimeTaken tt = trans.start("File doesn't exist; copy " + sourcePath + " to " + targetPath, Env.SUB);\r
- try {\r
- FileInputStream sourceFIS = new FileInputStream(sourcePath);\r
- FileChannel sourceFC = sourceFIS.getChannel();\r
- File targetFile = new File(targetPath);\r
- targetFile.getParentFile().mkdirs(); // ensure directory exists\r
- FileOutputStream targetFOS = new FileOutputStream(targetFile);\r
- try {\r
- ByteBuffer bb = ByteBuffer.allocate((int)sourceFC.size());\r
- sourceFC.read(bb);\r
- bb.flip(); // ready for reading\r
- targetFOS.getChannel().write(bb);\r
- } finally {\r
- sourceFIS.close();\r
- targetFOS.close();\r
- }\r
- } finally {\r
- tt.done();\r
- }\r
- return load(trans.info(),targetDir,targetFileName,mediaType,0);\r
- }\r
- }\r
-\r
- public void invalidate(String key) {\r
- content.remove(key);\r
- }\r
- \r
- private static final Content NULL=new Content() {\r
- \r
- @Override\r
- public void setHeader(HttpServletResponse resp) {\r
- resp.setStatus(HttpStatus.NOT_FOUND_404);\r
- resp.setHeader("Content-type","text/plain");\r
- }\r
-\r
- @Override\r
- public void write(Writer writer) throws IOException {\r
- }\r
-\r
- @Override\r
- public void write(OutputStream os) throws IOException {\r
- }\r
- \r
- };\r
-\r
- private static abstract class Content {\r
- private long date; // date of the actual artifact (i.e. File modified date)\r
- private long access; // last accessed\r
- \r
- protected String contentType;\r
- protected boolean attachmentOnly;\r
- \r
- public void setHeader(HttpServletResponse resp) {\r
- resp.setStatus(HttpStatus.OK_200);\r
- resp.setHeader("Content-type",contentType);\r
- resp.setHeader("Cache-Control", MAX_AGE);\r
- }\r
- \r
- public abstract void write(Writer writer) throws IOException;\r
- public abstract void write(OutputStream os) throws IOException;\r
-\r
- }\r
-\r
- private static class DirectFileContent extends Content {\r
- private File file; \r
- public DirectFileContent(File f) {\r
- file = f;\r
- }\r
- \r
- public String toString() {\r
- return file.getName();\r
- }\r
- \r
- public void write(Writer writer) throws IOException {\r
- FileReader fr = new FileReader(file);\r
- char[] buff = new char[1024];\r
- try {\r
- int read;\r
- while((read = fr.read(buff,0,1024))>=0) {\r
- writer.write(buff,0,read);\r
- }\r
- } finally {\r
- fr.close();\r
- }\r
- }\r
-\r
- public void write(OutputStream os) throws IOException {\r
- FileInputStream fis = new FileInputStream(file);\r
- byte[] buff = new byte[1024];\r
- try {\r
- int read;\r
- while((read = fis.read(buff,0,1024))>=0) {\r
- os.write(buff,0,read);\r
- }\r
- } finally {\r
- fis.close();\r
- }\r
- }\r
-\r
- }\r
- private static class CachedContent extends Content {\r
- private byte[] data;\r
- private int end;\r
- private char[] cdata; \r
- \r
- public CachedContent(File f) throws IOException {\r
- // Read and Cache\r
- ByteBuffer bb = ByteBuffer.allocate((int)f.length());\r
- FileInputStream fis = new FileInputStream(f);\r
- try {\r
- fis.getChannel().read(bb);\r
- } finally {\r
- fis.close();\r
- }\r
-\r
- data = bb.array();\r
- end = bb.position();\r
- cdata=null;\r
- }\r
- \r
- public String toString() {\r
- return data.toString();\r
- }\r
- \r
- public void write(Writer writer) throws IOException {\r
- synchronized(this) {\r
- // do the String Transformation once, and only if actually used\r
- if(cdata==null) {\r
- cdata = new char[end];\r
- new String(data).getChars(0, end, cdata, 0);\r
- }\r
- }\r
- writer.write(cdata,0,end);\r
- }\r
- public void write(OutputStream os) throws IOException {\r
- os.write(data,0,end);\r
- }\r
-\r
- }\r
-\r
- public void setEnv(LogTarget env) {\r
- logT = env;\r
- }\r
-\r
- /**\r
- * Cleanup thread to remove older items if max Cache is reached.\r
- *\r
- */\r
- private static class Cleanup extends TimerTask {\r
- private int maxSize;\r
- private NavigableMap<String, Content> content;\r
- \r
- public Cleanup(NavigableMap<String, Content> content, int size) {\r
- maxSize = size;\r
- this.content = content;\r
- }\r
- \r
- private class Comp implements Comparable<Comp> {\r
- public Map.Entry<String, Content> entry;\r
- \r
- public Comp(Map.Entry<String, Content> en) {\r
- entry = en;\r
- }\r
- \r
- @Override\r
- public int compareTo(Comp o) {\r
- return (int)(entry.getValue().access-o.entry.getValue().access);\r
- }\r
- \r
- }\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public void run() {\r
- int size = content.size();\r
- if(size>maxSize) {\r
- ArrayList<Comp> scont = new ArrayList<Comp>(size);\r
- Object[] entries = content.entrySet().toArray();\r
- for(int i=0;i<size;++i) {\r
- scont.add(i, new Comp((Map.Entry<String,Content>)entries[i]));\r
- }\r
- Collections.sort(scont);\r
- int end = size - ((maxSize/4)*3); // reduce to 3/4 of max size\r
- System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------");\r
- for(int i=0;i<end;++i) {\r
- Entry<String, Content> entry = scont.get(i).entry;\r
- content.remove(entry.getKey());\r
- System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());\r
- }\r
- for(int i=end;i<size;++i) {\r
- Entry<String, Content> entry = scont.get(i).entry;\r
- System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());\r
- }\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-// Package on purpose. only want between RServlet and Routes\r
-class CodeSetter<TRANS extends Trans> {\r
- private HttpCode<TRANS,?> code;\r
- private TRANS trans;\r
- private HttpServletRequest req;\r
- private HttpServletResponse resp;\r
- public CodeSetter(TRANS trans, HttpServletRequest req, HttpServletResponse resp) {\r
- this.trans = trans;\r
- this.req = req;\r
- this.resp = resp;\r
- \r
- }\r
- public boolean matches(Route<TRANS> route) throws IOException, ServletException {\r
- // Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists)\r
- return (code = route.getCode(trans, req, resp))!=null;\r
- }\r
- \r
- public HttpCode<TRANS,?> code() {\r
- return code;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.util.List;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-\r
-/**\r
- * A Class to hold Service "ContentTypes", and to match incoming "Accept" types from HTTP.\r
- * \r
- * This is a multi-use class built to use the same Parser for ContentTypes and Accept.\r
- * \r
- * Thus, you would create and use "Content.Type" within your service, and use it to match\r
- * Accept Strings. What is returned is an Integer (for faster processing), which can be\r
- * used in a switch statement to act on match different Actions. The server should\r
- * know which behaviors match.\r
- * \r
- * "bestMatch" returns an integer for the best match, or -1 if no matches.\r
- *\r
- *\r
- */\r
-public abstract class Content<TRANS extends Trans> {\r
- public static final String Q = "q";\r
- protected abstract Pair<String,Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>> types(HttpCode<TRANS,?> code, String str);\r
- protected abstract boolean props(Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>> type, String tag, String value);\r
-\r
- /**\r
- * Parse a Content-Type/Accept. As found, call "types" and "props", which do different\r
- * things depending on if it's a Content-Type or Accepts. \r
- * \r
- * For Content-Type, it builds a tree suitable for Comparison\r
- * For Accepts, it compares against the tree, and builds an acceptable type list\r
- * \r
- * Since this parse code is used for every incoming HTTP transaction, I have removed the implementation\r
- * that uses String.split, and replaced with integers evaluating the Byte array. This results\r
- * in only the necessary strings created, resulting in 1/3 better speed, and less \r
- * Garbage collection.\r
- * \r
- * @param trans\r
- * @param code\r
- * @param cntnt\r
- * @return\r
- */\r
- protected boolean parse(HttpCode<TRANS,?> code, String cntnt) {\r
- byte bytes[] = cntnt.getBytes();\r
- boolean contType=false,contProp=true;\r
- int cis,cie=-1,cend;\r
- int sis,sie,send;\r
- do {\r
- cis = cie+1;\r
- cie = cntnt.indexOf(',',cis);\r
- cend = cie<0?bytes.length:cie;\r
- // Start SEMIS\r
- sie=cis-1;\r
- Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> me = null;\r
- do {\r
- sis = sie+1;\r
- sie = cntnt.indexOf(';',sis);\r
- send = sie>cend || sie<0?cend:sie;\r
- if(me==null) {\r
- String semi = new String(bytes,sis,send-sis);\r
- // trans.checkpoint(semi);\r
- // Look at first entity within comma group\r
- // Is this an acceptable Type?\r
- me=types(code, semi);\r
- if(me==null) {\r
- sie=-1; // skip the rest of the processing... not a type\r
- } else {\r
- contType=true;\r
- }\r
- } else { // We've looped past the first Semi, now process as properties\r
- // If there are additional elements (more entities within Semi Colons)\r
- // apply Propertys\r
- int eq = cntnt.indexOf('=',sis);\r
- if(eq>sis && eq<send) {\r
- String tag = new String(bytes,sis,eq-sis);\r
- String value = new String(bytes,eq+1,send-(eq+1));\r
- // trans.checkpoint(" Prop " + tag + "=" + value);\r
- boolean bool = props(me,tag,value);\r
- if(!bool) {\r
- contProp=false;\r
- }\r
- }\r
- }\r
- // End Property\r
- } while(sie<=cend && sie>=cis);\r
- // End SEMIS\r
- } while(cie>=0);\r
- return contType && contProp; // for use in finds, True if a type found AND all props matched\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-/**\r
- * HTTP Code element, which responds to the essential "handle Method".\r
- * \r
- * Use Native HttpServletRe[quest|sponse] calls for questions like QueryParameters (getParameter, etc)\r
- * \r
- * Use local "pathParam" method to obtain in an optimized manner the path parameter, which must be interpreted by originating string\r
- * \r
- * i.e. my/path/:id/:other/*\r
- * \r
- *\r
- * @param <TRANS>\r
- * @param <T>\r
- */\r
-public abstract class HttpCode<TRANS extends Trans, CONTEXT> {\r
- protected CONTEXT context;\r
- private String desc;\r
- protected String [] roles;\r
- private boolean all;\r
- \r
- // Package by design... Set by Route when linked\r
- Match match;\r
- \r
- public HttpCode(CONTEXT context, String description, String ... roles) {\r
- this.context = context;\r
- desc = description;\r
- \r
- // Evaluate for "*" once...\r
- all = false;\r
- for(String srole : roles) {\r
- if("*".equals(srole)) {\r
- all = true;\r
- break;\r
- }\r
- }\r
- this.roles = all?null:roles;\r
- }\r
- \r
- public abstract void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws Exception;\r
- \r
- public String desc() {\r
- return desc;\r
- }\r
- \r
- /**\r
- * Get the variable element out of the Path Parameter, as set by initial Code\r
- * \r
- * @param req\r
- * @param key\r
- * @return\r
- */\r
- public String pathParam(HttpServletRequest req, String key) {\r
- return match.param(req.getPathInfo(), key);\r
- }\r
-\r
- // Note: get Query Params from Request\r
- \r
- /**\r
- * Check for Authorization when set.\r
- * \r
- * If no Roles set, then accepts all users\r
- * \r
- * @param req\r
- * @return\r
- */\r
- public boolean isAuthorized(HttpServletRequest req) {\r
- if(all)return true;\r
- if(roles!=null) {\r
- for(String srole : roles) {\r
- if(req.isUserInRole(srole)) return true;\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- public boolean no_cache() {\r
- return false;\r
- }\r
- \r
- public String toString() {\r
- return desc;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-public enum HttpMethods {\r
- POST,\r
- GET,\r
- PUT,\r
- DELETE\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-/**\r
- * This path matching algorithm avoids using split strings during the critical transactional run-time. By pre-analyzing the\r
- * content at "set Param" time, and storing data in an array-index model which presumably is done once and at the beginning, \r
- * we can match in much less time when it actually counts.\r
- * \r
- *\r
- */\r
-public class Match {\r
- private Map<String, Integer> params;\r
- private byte[] values[];\r
- private Integer vars[];\r
- private boolean wildcard;\r
-\r
- \r
- /*\r
- * These two methods are pairs of searching performance for variables Spark Style.\r
- * setParams evaluates the target path, and sets a HashMap that will return an Integer.\r
- * the Keys are both :key and key so that there will be no string operations during\r
- * a transaction\r
- * \r
- * For the Integer, if the High Order is 0, then it is just one value. If High Order >0, then it is \r
- * a multi-field option, i.e. ending with a wild-card.\r
- */\r
- public Match(String path) {\r
- // IF DEBUG: System.out.print("\n[" + path + "]");\r
- params = new HashMap<String,Integer>();\r
- if(path!=null) {\r
- String[] pa = path.split("/");\r
- values = new byte[pa.length][];\r
- vars = new Integer[pa.length];\r
- \r
- int val = 0;\r
- String key;\r
- for(int i=0;i<pa.length && !wildcard;++i) {\r
- if(pa[i].startsWith(":")) {\r
- if(pa[i].endsWith("*")) {\r
- val = i | pa.length<<16; // load end value in high order bits\r
- key = pa[i].substring(0, pa[i].length()-1);// remove *\r
- wildcard = true;\r
- } else {\r
- val = i;\r
- key = pa[i];\r
- }\r
- params.put(key,val); //put in :key \r
- params.put(key.substring(1,key.length()), val); // put in just key, better than adding a missing one, like Spark\r
- // values[i]=null; // null stands for Variable\r
- vars[i]=val;\r
- } else {\r
- values[i]=pa[i].getBytes();\r
- if(pa[i].endsWith("*")) {\r
- wildcard = true;\r
- if(pa[i].length()>1) {\r
- /* remove * from value */\r
- int newlength = values[i].length-1;\r
- byte[] real = new byte[newlength];\r
- System.arraycopy(values[i],0,real,0,newlength);\r
- values[i]=real;\r
- } else {\r
- vars[i]=0; // this is actually a variable, if it only contains a "*"\r
- }\r
- }\r
- // vars[i]=null;\r
- }\r
- }\r
- }\r
- }\r
-\r
- /*\r
- * This is the second of the param evaluation functions. First, we look up to see if there is\r
- * any reference by key in the params Map created by the above.\r
- * \r
- * The resulting Integer, if not null, is split high/low order into start and end.\r
- * We evaluate the string for '/', rather than splitting into String[] to avoid the time/mem needed\r
- * We traverse to the proper field number for slash, evaluate the end (whether wild card or no), \r
- * and return the substring. \r
- * \r
- * The result is something less than .003 milliseconds per evaluation\r
- * \r
- */\r
- public String param(String path,String key) {\r
- Integer val = params.get(key); // :key or key\r
- if(val!=null) {\r
- int start = val & 0xFFFF;\r
- int end = (val >> 16) & 0xFFFF;\r
- int idx = -1;\r
- int i;\r
- for(i=0;i<start;++i) {\r
- idx = path.indexOf('/',idx+1);\r
- if(idx<0)break;\r
- }\r
- if(i==start) { \r
- ++idx;\r
- if(end==0) {\r
- end = path.indexOf('/',idx);\r
- if(end<0)end=path.length();\r
- } else {\r
- end=path.length();\r
- }\r
- return path.substring(idx,end);\r
- } else if(i==start-1) { // if last spot was left blank, i.e. :key*\r
- return "";\r
- }\r
- }\r
- return null;\r
- }\r
- \r
- public boolean match(String path) {\r
- if(path==null|| path.length()==0 || "/".equals(path) ) {\r
- if(values==null)return true;\r
- switch(values.length) {\r
- case 0: return true;\r
- case 1: return values[0].length==0;\r
- default: return false;\r
- }\r
- } \r
- boolean rv = true;\r
- byte[] pabytes = path.getBytes();\r
- int field=0;\r
- int fieldIdx = 0;\r
-\r
- int lastField = values.length;\r
- int lastByte = pabytes.length;\r
- boolean fieldMatched = false; // = lastByte>0?(pabytes[0]=='/'):false;\r
- // IF DEBUG: System.out.println("\n -- " + path + " --");\r
- for(int i=0;rv && i<lastByte;++i) {\r
- if(field>=lastField) { // checking here allows there to be a non-functional ending /\r
- rv = false;\r
- break;\r
- }\r
- if(values[field]==null) { // it's a variable, just look for /s\r
- if(wildcard && field==lastField-1) return true;// we've made it this far. We accept all remaining characters\r
- Integer val = vars[field];\r
- int start = val & 0xFFFF;\r
- int end = (val >> 16) & 0xFFFF;\r
- if(end==0)end=start+1;\r
- int k = i;\r
- for(int j=start; j<end && k<lastByte; ++k) {\r
- // IF DEBUG: System.out.print((char)pabytes[k]);\r
- if(pabytes[k]=='/') {\r
- ++field;\r
- ++j;\r
- }\r
- }\r
- \r
- if(k==lastByte && pabytes[k-1]!='/')++field;\r
- if(k>i)i=k-1; // if we've incremented, have to accommodate the outer for loop incrementing as well\r
- fieldMatched = false; // reset\r
- fieldIdx = 0;\r
- } else {\r
- // IF DEBUG: System.out.print((char)pabytes[i]);\r
- if(pabytes[i]=='/') { // end of field, eval if Field is matched\r
- // if double slash, check if supposed to be empty\r
- if(fieldIdx==0 && values[field].length==0) {\r
- fieldMatched = true;\r
- }\r
- rv = fieldMatched && ++field<lastField;\r
- // reset\r
- fieldMatched = false; \r
- fieldIdx = 0;\r
- } else if(values[field].length==0) {\r
- // double slash in path, but content in field. We check specially here to avoid \r
- // Array out of bounds issues.\r
- rv = false;\r
- } else {\r
- if(fieldMatched) {\r
- rv =false; // field is already matched, now there's too many bytes\r
- } else {\r
- rv = pabytes[i]==values[field][fieldIdx++]; // compare expected (pabytes[i]) with value for particular field\r
- fieldMatched=values[field].length==fieldIdx; // are all the bytes match in the field?\r
- if(fieldMatched && (i==lastByte-1 || (wildcard && field==lastField-1)))\r
- return true; // last field info\r
- }\r
- }\r
- }\r
- }\r
- if(field!=lastField || pabytes.length!=lastByte) rv = false; // have we matched all the fields and all the bytes?\r
- return rv;\r
- }\r
- \r
- public Set<String> getParamNames() {\r
- return params.keySet();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-/**\r
- * A pair of generic Objects. \r
- *\r
- * @param <X>\r
- * @param <Y>\r
- */\r
-public class Pair<X,Y> {\r
- public X x;\r
- public Y y;\r
- \r
- public Pair(X x, Y y) {\r
- this.x = x;\r
- this.y = y;\r
- }\r
- \r
- public String toString() {\r
- return "X: " + x.toString() + "-->" + y.toString();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.util.List;\r
-\r
-import javax.servlet.Servlet;\r
-import javax.servlet.ServletConfig;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.ServletResponse;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public abstract class RServlet<TRANS extends Trans> implements Servlet {\r
- private Routes<TRANS> routes = new Routes<TRANS>();\r
-\r
- private ServletConfig config;\r
-\r
- @Override\r
- public void init(ServletConfig config) throws ServletException {\r
- this.config = config;\r
- }\r
-\r
- @Override\r
- public ServletConfig getServletConfig() {\r
- return config;\r
- }\r
-\r
- public void route(Env env, HttpMethods meth, String path, HttpCode<TRANS, ?> code, String ... moreTypes) {\r
- Route<TRANS> r = routes.findOrCreate(meth,path);\r
- r.add(code,moreTypes);\r
- env.init().log(r.report(code),code);\r
- }\r
- \r
- @Override\r
- public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {\r
- HttpServletRequest request = (HttpServletRequest)req;\r
- HttpServletResponse response = (HttpServletResponse)res;\r
- \r
- @SuppressWarnings("unchecked")\r
- TRANS trans = (TRANS)req.getAttribute(TransFilter.TRANS_TAG);\r
- if(trans==null) {\r
- response.setStatus(404); // Not Found, because it didn't go through TransFilter\r
- return;\r
- }\r
- \r
- Route<TRANS> route;\r
- HttpCode<TRANS,?> code=null;\r
- String ct = req.getContentType();\r
- TimeTaken tt = trans.start("Resolve to Code", Env.SUB);\r
- try {\r
- // routes have multiple code sets. This object picks the best code set\r
- // based on Accept or Content-Type\r
- CodeSetter<TRANS> codesetter = new CodeSetter<TRANS>(trans,request,response);\r
- // Find declared route\r
- route = routes.derive(request, codesetter);\r
- if(route==null) {\r
- String method = request.getMethod();\r
- trans.checkpoint("No Route matches "+ method + ' ' + request.getPathInfo());\r
- response.setStatus(404); // Not Found\r
- } else {\r
- // Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists)\r
- code = codesetter.code();// route.getCode(trans, request, response);\r
- }\r
- } finally {\r
- tt.done();\r
- }\r
- \r
- if(route!=null && code!=null) {\r
- StringBuilder sb = new StringBuilder(72);\r
- sb.append(route.auditText);\r
- sb.append(',');\r
- sb.append(code.desc());\r
- if(ct!=null) {\r
- sb.append(", ContentType: ");\r
- sb.append(ct);\r
- }\r
- tt = trans.start(sb.toString(),Env.SUB);\r
- try {\r
- /*obj = */\r
- code.handle(trans, request, response);\r
- response.flushBuffer();\r
- } catch (ServletException e) {\r
- trans.error().log(e);\r
- throw e;\r
- } catch (Exception e) {\r
- trans.error().log(e,request.getMethod(),request.getPathInfo());\r
- throw new ServletException(e);\r
- } finally {\r
- tt.done();\r
- }\r
- }\r
- }\r
- \r
- @Override\r
- public String getServletInfo() {\r
- return "RServlet for Jetty";\r
- }\r
-\r
- @Override\r
- public void destroy() {\r
- }\r
-\r
- public String applicationJSON(Class<?> cls, String version) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append("application/");\r
- sb.append(cls.getSimpleName());\r
- sb.append("+json");\r
- sb.append(";charset=utf-8");\r
- sb.append(";version=");\r
- sb.append(version);\r
- return sb.toString();\r
- }\r
-\r
- public String applicationXML(Class<?> cls, String version) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append("application/");\r
- sb.append(cls.getSimpleName());\r
- sb.append("+xml");\r
- sb.append(";charset=utf-8");\r
- sb.append(";version=");\r
- sb.append(version);\r
- return sb.toString();\r
- }\r
-\r
- public List<RouteReport> routeReport() {\r
- return routes.routeReport();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.util.List;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-public class Route<TRANS extends Trans> {\r
- public final String auditText;\r
- public final HttpMethods meth;\r
- public final String path;\r
- \r
- private Match match;\r
- // package on purpose\r
- private final TypedCode<TRANS> content;\r
- private final boolean isGet;\r
- \r
- public Route(HttpMethods meth, String path) {\r
- this.path = path;\r
- auditText = meth.name() + ' ' + path;\r
- this.meth = meth; // Note: Using Spark def for now.\r
- isGet = meth.compareTo(HttpMethods.GET) == 0;\r
- match = new Match(path);\r
- content = new TypedCode<TRANS>();\r
- }\r
- \r
- public void add(HttpCode<TRANS,?> code, String ... others) {\r
- code.match = match;\r
- content.add(code, others);\r
- }\r
- \r
-// public void add(HttpCode<TRANS,?> code, Class<?> cls, String version, String ... others) {\r
-// code.match = match;\r
-// content.add(code, cls, version, others);\r
-// }\r
-//\r
- public HttpCode<TRANS,?> getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {\r
- // Type is associated with Accept for GET (since it is what is being returned\r
- // We associate the rest with ContentType.\r
- // FYI, thought about this a long time before implementing this way.\r
- String compare;\r
-// String special[]; // todo, expose Charset (in special) to outside\r
- if(isGet) {\r
- compare = req.getHeader("Accept"); // Accept is used for read, as we want to agree on what caller is ready to handle\r
- } else {\r
- compare = req.getContentType(); // Content type used to declare what data is being created, updated or deleted (might be used for key)\r
- }\r
-\r
- Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> hl = content.prep(trans, compare);\r
- if(hl==null) {\r
- resp.setStatus(406); // NOT_ACCEPTABLE\r
- } else {\r
- if(isGet) { // Set Content Type to expected content\r
- if("*".equals(hl.x) || "*/*".equals(hl.x)) {// if wild-card, then choose first kind of type\r
- resp.setContentType(content.first());\r
- } else {\r
- resp.setContentType(hl.x);\r
- }\r
- }\r
- return hl.y.x;\r
- }\r
- return null;\r
- }\r
- \r
- public Route<TRANS> matches(String method, String path) {\r
- return meth.name().equalsIgnoreCase(method) && match.match(path)?this:null;\r
- }\r
- \r
- public TimeTaken start(Trans trans, String auditText, HttpCode<TRANS,?> code, String type) {\r
- StringBuilder sb = new StringBuilder(auditText);\r
- sb.append(", ");\r
- sb.append(code.desc());\r
- sb.append(", Content: ");\r
- sb.append(type);\r
- return trans.start(sb.toString(), Env.SUB);\r
- }\r
-\r
- // Package on purpose.. for "find/Create" routes only\r
- boolean resolvesTo(HttpMethods hm, String p) {\r
- return(path.equals(p) && hm.equals(meth));\r
- }\r
- \r
- public String toString() {\r
- return auditText + ' ' + content; \r
- }\r
-\r
- public String report(HttpCode<TRANS, ?> code) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append(auditText);\r
- sb.append(' ');\r
- content.relatedTo(code, sb);\r
- return sb.toString();\r
- }\r
-\r
- public RouteReport api() {\r
- RouteReport tr = new RouteReport();\r
- tr.meth = meth;\r
- tr.path = path;\r
- content.api(tr);\r
- return tr;\r
- }\r
-\r
-\r
- /**\r
- * contentRelatedTo (For reporting) list routes that will end up at a specific Code\r
- * @return\r
- */\r
- public String contentRelatedTo(HttpCode<TRANS, ?> code) {\r
- StringBuilder sb = new StringBuilder(path);\r
- sb.append(' ');\r
- content.relatedTo(code, sb);\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-public class RouteReport {\r
- public HttpMethods meth;\r
- public String path;\r
- public String desc;\r
- public final List<String> contextTypes = new ArrayList<String>();\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-public class Routes<TRANS extends Trans> {\r
- // Since this must be very, very fast, and only needs one creation, we'll use just an array.\r
- private Route<TRANS>[] routes;\r
- private int end;\r
- \r
-\r
- @SuppressWarnings("unchecked")\r
- public Routes() {\r
- routes = new Route[10];\r
- end = 0;\r
- }\r
- \r
- // This method for setup of Routes only...\r
- // Package on purpose\r
- synchronized Route<TRANS> findOrCreate(HttpMethods meth, String path) {\r
- Route<TRANS> rv = null;\r
- for(int i=0;i<end;++i) {\r
- if(routes[i].resolvesTo(meth,path))rv = routes[i];\r
- }\r
- \r
- if(rv==null) {\r
- if(end>=routes.length) {\r
- @SuppressWarnings("unchecked")\r
- Route<TRANS>[] temp = new Route[end+10];\r
- System.arraycopy(routes, 0, temp, 0, routes.length);\r
- routes = temp;\r
- }\r
- \r
- routes[end++]=rv=new Route<TRANS>(meth,path);\r
- }\r
- return rv;\r
- }\r
- \r
- public Route<TRANS> derive(HttpServletRequest req, CodeSetter<TRANS> codeSetter) throws IOException, ServletException {\r
- Route<TRANS> rv = null;\r
- String path = req.getPathInfo();\r
- String meth = req.getMethod();\r
- //TODO a TREE would be better\r
- for(int i=0;rv==null && i<end; ++i) {\r
- rv = routes[i].matches(meth,path);\r
- if(rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code \r
- rv = null; // not quite, keep going\r
- }\r
- }\r
- //TODO a Default?\r
- return rv;\r
- }\r
- \r
- public List<RouteReport> routeReport() {\r
- ArrayList<RouteReport> ltr = new ArrayList<RouteReport>();\r
- for(int i=0;i<end;++i) {\r
- ltr.add(routes[i].api());\r
- }\r
- return ltr;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.security.Principal;\r
-\r
-import javax.servlet.Filter;\r
-import javax.servlet.FilterChain;\r
-import javax.servlet.FilterConfig;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.ServletResponse;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.onap.aaf.cadi.Access;\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.CadiWrap;\r
-import org.onap.aaf.cadi.Connector;\r
-import org.onap.aaf.cadi.Lur;\r
-import org.onap.aaf.cadi.TrustChecker;\r
-import org.onap.aaf.cadi.filter.CadiHTTPManip;\r
-import org.onap.aaf.cadi.taf.TafResp;\r
-import org.onap.aaf.cadi.taf.TafResp.RESP;\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.TransStore;\r
-\r
-/**\r
- * Create a new Transaction Object for each and every incoming Transaction\r
- * \r
- * Attach to Request. User "FilterHolder" mechanism to retain single instance.\r
- * \r
- * TransFilter includes CADIFilter as part of the package, so that it can\r
- * set User Data, etc, as necessary.\r
- * \r
- *\r
- */\r
-public abstract class TransFilter<TRANS extends TransStore> implements Filter {\r
- public static final String TRANS_TAG = "__TRANS__";\r
- \r
- private CadiHTTPManip cadi;\r
- \r
- public TransFilter(Access access, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException {\r
- cadi = new CadiHTTPManip(access, con, tc, additionalTafLurs);\r
- }\r
-\r
- @Override\r
- public void init(FilterConfig filterConfig) throws ServletException {\r
- }\r
- \r
- protected Lur getLur() {\r
- return cadi.getLur();\r
- }\r
-\r
- protected abstract TRANS newTrans();\r
- protected abstract TimeTaken start(TRANS trans, ServletRequest request);\r
- protected abstract void authenticated(TRANS trans, Principal p);\r
- protected abstract void tallyHo(TRANS trans);\r
- \r
- @Override\r
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {\r
- TRANS trans = newTrans();\r
- \r
- TimeTaken overall = start(trans,request);\r
- try {\r
- request.setAttribute(TRANS_TAG, trans);\r
- \r
- HttpServletRequest req = (HttpServletRequest)request;\r
- HttpServletResponse res = (HttpServletResponse)response;\r
- \r
- TimeTaken security = trans.start("CADI Security", Env.SUB);\r
-// TimeTaken ttvalid;\r
- TafResp resp;\r
- RESP r;\r
- CadiWrap cw = null;\r
- try {\r
- resp = cadi.validate(req,res);\r
- switch(r=resp.isAuthenticated()) {\r
- case IS_AUTHENTICATED:\r
- cw = new CadiWrap(req,resp,cadi.getLur());\r
- authenticated(trans, cw.getUserPrincipal());\r
- break;\r
- default:\r
- break;\r
- }\r
- } finally {\r
- security.done();\r
- }\r
- \r
- if(r==RESP.IS_AUTHENTICATED) {\r
- trans.checkpoint(resp.desc());\r
- chain.doFilter(cw, response);\r
- } else {\r
- //TODO this is a good place to check if too many checks recently\r
- // Would need Cached Counter objects that are cleaned up on \r
- // use\r
- trans.checkpoint(resp.desc(),Env.ALWAYS);\r
- if(resp.isFailedAttempt())\r
- trans.audit().log(resp.desc());\r
- }\r
- } catch(Exception e) {\r
- trans.error().log(e);\r
- trans.checkpoint("Error: " + e.getClass().getSimpleName() + ": " + e.getMessage());\r
- throw new ServletException(e);\r
- } finally {\r
- overall.done();\r
- tallyHo(trans);\r
- }\r
- }\r
-\r
- @Override\r
- public void destroy() {\r
- };\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.security.Principal;\r
-\r
-import javax.servlet.Filter;\r
-import javax.servlet.FilterChain;\r
-import javax.servlet.FilterConfig;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.ServletResponse;\r
-\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.TransStore;\r
-\r
-/**\r
- * Create a new Transaction Object for each and every incoming Transaction\r
- * \r
- * Attach to Request. User "FilterHolder" mechanism to retain single instance.\r
- * \r
- * TransFilter includes CADIFilter as part of the package, so that it can\r
- * set User Data, etc, as necessary.\r
- * \r
- *\r
- */\r
-public abstract class TransOnlyFilter<TRANS extends TransStore> implements Filter {\r
- @Override\r
- public void init(FilterConfig filterConfig) throws ServletException {\r
- }\r
- \r
-\r
-\r
- protected abstract TRANS newTrans();\r
- protected abstract TimeTaken start(TRANS trans, ServletRequest request);\r
- protected abstract void authenticated(TRANS trans, Principal p);\r
- protected abstract void tallyHo(TRANS trans);\r
- \r
- @Override\r
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {\r
- TRANS trans = newTrans();\r
- \r
- TimeTaken overall = start(trans,request);\r
- try {\r
- request.setAttribute(TransFilter.TRANS_TAG, trans);\r
- chain.doFilter(request, response);\r
- } finally {\r
- overall.done();\r
- }\r
- tallyHo(trans);\r
- }\r
-\r
- @Override\r
- public void destroy() {\r
- };\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-\r
-import javax.servlet.ServletException;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-\r
-/**\r
- * TypedCode organizes implementation code based on the Type and Version of code it works with so that it can\r
- * be located quickly at runtime based on the "Accept" HTTP Header.\r
- *\r
- * FYI: For those in the future wondering why I would create a specialized set of "Pair" for the data content:\r
- * 1) TypeCode is used in Route, and this code is used for every transaction... it needs to be blazingly fast\r
- * 2) The actual number of objects accessed is quite small and built at startup. Arrays are best\r
- * 3) I needed a small, well defined tree where each level is a different Type. Using a "Pair" Generic definitions, \r
- * I created type-safety at each level, which you can't get from a TreeSet, etc.\r
- * 4) Chaining through the Network is simply object dereferencing, which is as fast as Java can go.\r
- * 5) The drawback is that in your code is that all the variables are named "x" and "y", which can be a bit hard to\r
- * read both in code, and in the debugger. However, TypeSafety allows your IDE (Eclipse) to help you make the \r
- * choices. Also, make sure you have a good "toString()" method on each object so you can see what's happening\r
- * in the IDE Debugger.\r
- * \r
- * Empirically, this method of obtaining routes proved to be much faster than the HashSet implementations available in otherwise\r
- * competent Open Source.\r
- *\r
- * @param <TRANS>\r
- */\r
-public class TypedCode<TRANS extends Trans> extends Content<TRANS> {\r
- private List<Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String, Object>>>>> types;\r
-\r
- public TypedCode() {\r
- types = new ArrayList<Pair<String,Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>>();\r
- }\r
- \r
- /**\r
- * Construct Typed Code based on ContentType parameters passed in\r
- * \r
- * @param code\r
- * @param others\r
- * @return\r
- */\r
- public TypedCode<TRANS> add(HttpCode<TRANS,?> code, String ... others) {\r
- StringBuilder sb = new StringBuilder();\r
- boolean first = true;\r
- for(String str : others) {\r
- if(first) {\r
- first = false; \r
- } else {\r
- sb.append(',');\r
- }\r
- sb.append(str);\r
- }\r
- parse(code, sb.toString());\r
- \r
- return this;\r
- }\r
- \r
- @Override\r
- protected Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> types(HttpCode<TRANS,?> code, String str) {\r
- Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String, Object>>>> type = null;\r
- ArrayList<Pair<String, Object>> props = new ArrayList<Pair<String,Object>>();\r
- // Want Q percentage is to be first in the array everytime. If not listed, 1.0 is default\r
- props.add(new Pair<String,Object>(Q,1f));\r
- Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>> cl = new Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>>(code, props);\r
-// // breakup "plus" stuff, i.e. application/xaml+xml\r
-// int plus = str.indexOf('+');\r
-// if(plus<0) {\r
- type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(str, cl);\r
- types.add(type);\r
- return type;\r
-// } else {\r
-// int prev = str.indexOf('/')+1;\r
-// String first = str.substring(0,prev);\r
-// String nstr;\r
-// while(prev!=0) {\r
-// nstr = first + (plus>-1?str.substring(prev,plus):str.substring(prev));\r
-// type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(nstr, cl);\r
-// types.add(type);\r
-// prev = plus+1;\r
-// plus = str.indexOf('+',prev);\r
-// }\r
-// return type;\r
-// }\r
- }\r
-\r
- @Override\r
- protected boolean props(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type, String tag, String value) {\r
- if(tag.equals(Q)) { // reset the Q value (first in array)\r
- boolean rv = true;\r
- try {\r
- type.y.y.get(0).y=Float.parseFloat(value);\r
- return rv;\r
- } catch (NumberFormatException e) {\r
- rv=false; // Note: this awkward syntax forced by Sonar, which doesn't like doing nothing with Exception\r
- // which is what should happen\r
- }\r
- }\r
- return type.y.y.add(new Pair<String,Object>(tag,"version".equals(tag)?new Version(value):value));\r
- }\r
- \r
- public Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> prep(TRANS trans, String compare) throws IOException, ServletException {\r
- Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> c,rv=null;\r
- if(types.size()==1 && "".equals((c=types.get(0)).x)) { // if there are no checks for type, skip\r
- rv = c;\r
- } else {\r
- if(compare==null || compare.length()==0) {\r
- rv = types.get(0); // first code is used\r
- } else {\r
- Acceptor<TRANS> acc = new Acceptor<TRANS>(types);\r
- boolean accepted;\r
- TimeTaken tt = trans.start(compare, Env.SUB);\r
- try {\r
- accepted = acc.parse(null, compare);\r
- } finally {\r
- tt.done();\r
- }\r
- if(accepted) {\r
- switch(acc.acceptable.size()) {\r
- case 0: \r
-// // TODO best Status Code?\r
-// resp.setStatus(HttpStatus.NOT_ACCEPTABLE_406);\r
- break;\r
- case 1: \r
- rv = acc.acceptable.get(0);\r
- break;\r
- default: // compare Q values to get Best Match\r
- float bestQ = -1.0f;\r
- Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> bestT = null;\r
- for(Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : acc.acceptable) {\r
- Float f = (Float)type.y.y.get(0).y; // first property is always Q\r
- if(f>bestQ) {\r
- bestQ=f;\r
- bestT = type;\r
- }\r
- }\r
- if(bestT!=null) {\r
- // When it is a GET, the matched type is what is returned, so set ContentType\r
-// if(isGet)resp.setContentType(bestT.x); // set ContentType of Code<TRANS,?>\r
-// rv = bestT.y.x;\r
- rv = bestT;\r
- }\r
- }\r
- } else {\r
- trans.checkpoint("No Match found for Accept");\r
- }\r
- }\r
- }\r
- return rv;\r
- }\r
- \r
- /**\r
- * Print on String Builder content related to specific Code\r
- * \r
- * This is for Reporting and Debugging purposes, so the content is not cached.\r
- * \r
- * If code is "null", then all content is matched\r
- * \r
- * @param code\r
- * @return\r
- */\r
- public StringBuilder relatedTo(HttpCode<TRANS, ?> code, StringBuilder sb) {\r
- boolean first = true;\r
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) {\r
- if(code==null || pair.y.x == code) {\r
- if(first) {\r
- first = false;\r
- } else {\r
- sb.append(',');\r
- }\r
- sb.append(pair.x);\r
- for(Pair<String,Object> prop : pair.y.y) {\r
- // Don't print "Q". it's there for internal use, but it is only meaningful for "Accepts"\r
- if(!prop.x.equals(Q) || !prop.y.equals(1f) ) {\r
- sb.append(';');\r
- sb.append(prop.x);\r
- sb.append('=');\r
- sb.append(prop.y);\r
- }\r
- }\r
- }\r
- }\r
- return sb;\r
- }\r
- \r
- public List<Pair<String, Object>> getContent(HttpCode<TRANS,?> code) {\r
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) {\r
- if(pair.y.x == code) {\r
- return pair.y.y;\r
- }\r
- }\r
- return null;\r
- }\r
- \r
- public String toString() {\r
- return relatedTo(null,new StringBuilder()).toString();\r
- }\r
- \r
- public void api(RouteReport tr) {\r
- // Need to build up a map, because Prop entries can be in several places.\r
- HashMap<HttpCode<?,?>,StringBuilder> psb = new HashMap<HttpCode<?,?>,StringBuilder>();\r
- StringBuilder temp;\r
- tr.desc = null;\r
- \r
- // Read through Code/TypeCode trees for all accepted Typecodes\r
- for(Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> tc : types) {\r
- // If new, then it's new Code set, create prefix content\r
- if((temp=psb.get(tc.y.x))==null) {\r
- psb.put(tc.y.x,temp=new StringBuilder());\r
- if(tr.desc==null) {\r
- tr.desc = tc.y.x.desc();\r
- }\r
- } else {\r
- temp.append(',');\r
- }\r
- temp.append(tc.x);\r
-\r
- // add all properties\r
- for(Pair<String, Object> props : tc.y.y) {\r
- temp.append(';');\r
- temp.append(props.x);\r
- temp.append('=');\r
- temp.append(props.y);\r
- }\r
- }\r
- // Gather all ContentType possibilities for the same code together\r
- \r
- for(StringBuilder sb : psb.values()) {\r
- tr.contextTypes.add(sb.toString());\r
- }\r
- }\r
-\r
- public String first() {\r
- if(types.size()>0) {\r
- return types.get(0).x;\r
- }\r
- return null;\r
- }\r
- \r
- }\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-\r
-/**\r
- * Analyze and hold Version information for Code\r
- * \r
- *\r
- */\r
-public class Version {\r
- private Object[] parts;\r
-\r
- public Version(String v) {\r
- String sparts[] = v.split("\\.");\r
- parts = new Object[sparts.length];\r
- System.arraycopy(sparts, 0, parts, 0, sparts.length);\r
- if(parts.length>1) { // has at least a minor\r
- try {\r
- parts[1]=Integer.decode(sparts[1]); // minor elements need to be converted to Integer for comparison\r
- } catch (NumberFormatException e) {\r
- // it's ok, leave it as a string\r
- parts[1]=sparts[1]; // This useless piece of code forced by Sonar which calls empty Exceptions "Blockers".\r
- }\r
- }\r
- }\r
-\r
- public boolean equals(Object obj) {\r
- if(obj instanceof Version) {\r
- Version ver = (Version)obj;\r
- int length = Math.min(parts.length, ver.parts.length);\r
- for(int i=0;i<length;++i) { // match on declared parts\r
- if(i==1) {\r
- if(parts[1] instanceof Integer && ver.parts[1] instanceof Integer) {\r
- // Match on Minor version if this Version is less than Version to be checked\r
- if(((Integer)parts[1])<((Integer)ver.parts[1])) {\r
- return false;\r
- }\r
- continue; // don't match next line\r
- }\r
- }\r
- if(!parts[i].equals(ver.parts[i])) {\r
- return false; // other spots exact match\r
- }\r
- }\r
- return true;\r
- }\r
- return false;\r
- }\r
- \r
- \r
- /* (non-Javadoc)\r
- * @see java.lang.Object#hashCode()\r
- */\r
- @Override\r
- public int hashCode() {\r
- return super.hashCode();\r
- }\r
-\r
- public String toString() {\r
- StringBuilder sb = new StringBuilder();\r
- boolean first = true;\r
- for(Object obj : parts) {\r
- if(first) {\r
- first = false;\r
- } else {\r
- sb.append('.');\r
- }\r
- sb.append(obj.toString());\r
- }\r
- return sb.toString();\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv.doc;\r
-\r
-import java.lang.annotation.ElementType;\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-import java.lang.annotation.Target;\r
-\r
-import org.onap.aaf.cssa.rserv.HttpMethods;\r
-@Retention(RetentionPolicy.RUNTIME)\r
-@Target({ElementType.METHOD})\r
-public @interface ApiDoc {\r
- HttpMethods method();\r
- String path();\r
- int expectedCode();\r
- int[] errorCodes();\r
- String[] text();\r
- /** Format with name|type|[true|false] */\r
- String[] params();\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.common;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.common.Define;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.config.Config;\r
-import org.onap.aaf.inno.env.Env;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_Define {\r
- Define define;\r
- public static String ROOT_NS="NS.Not.Set";\r
- public static String ROOT_COMPANY=ROOT_NS;\r
- \r
- @Mock \r
- Env envMock;\r
- \r
- \r
- @Before\r
- public void setUp(){\r
- define = new Define();\r
- }\r
-\r
- @Test\r
- public void testSet() throws CadiException {\r
- PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_NS)).thenReturn("aaf_root_ns");\r
- PowerMockito.when(envMock.getProperty(Config.AAF_ROOT_COMPANY)).thenReturn("aaf_root_company");\r
- //PowerMockito.when(envMock.init().log()).thenReturn(null);\r
- //PowerMockito.doNothing().doThrow(new CadiException()).when(envMock).init().log(Matchers.anyString());\r
- //define.set(envMock);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.cadi.Access.Level;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_AuthzEnv {\r
- private static final org.onap.aaf.cadi.Access.Level DEBUG = null;\r
- AuthzEnv authzEnv;\r
- enum Level {DEBUG, INFO, AUDIT, INIT, WARN, ERROR};\r
- \r
- @Before\r
- public void setUp(){\r
- authzEnv = new AuthzEnv();\r
- }\r
-\r
- @Test\r
- public void testTransRate() {\r
- Long Result = authzEnv.transRate();\r
- System.out.println("value of result " +Result); //Expected 300000\r
- assertNotNull(Result); \r
- }\r
- \r
- @Test(expected = IOException.class)\r
- public void testDecryptException() throws IOException{\r
- String encrypted = null;\r
- authzEnv.decrypt(encrypted, true);\r
- }\r
- \r
- @Test\r
- public void testDecrypt() throws IOException{\r
- String encrypted = "encrypted";\r
- String Result = authzEnv.decrypt(encrypted, true);\r
- System.out.println("value of res " +Result);\r
- assertEquals("encrypted",Result);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.env.AuthzTransFilter;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.Connector;\r
-import org.onap.aaf.cadi.TrustChecker;\r
-\r
-@RunWith(PowerMockRunner.class) \r
-public class JU_AuthzTransFilter {\r
-AuthzTransFilter authzTransFilter;\r
-@Mock\r
-AuthzEnv authzEnvMock;\r
-@Mock\r
-Connector connectorMock;\r
-@Mock\r
-TrustChecker trustCheckerMock;\r
-@Mock\r
-AuthzTrans authzTransMock;\r
-Object additionalTafLurs;\r
- \r
- @Before\r
- public void setUp(){\r
- try {\r
- authzTransFilter = new AuthzTransFilter(authzEnvMock, connectorMock, trustCheckerMock, additionalTafLurs);\r
- } catch (CadiException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
- \r
- @Test\r
- public void test()\r
- {\r
- //authzTransFilter.newTrans();\r
- assertTrue(true);\r
- }\r
- \r
- @Test\r
- public void testTallyHo(){\r
- PowerMockito.when(authzTransMock.info().isLoggable()).thenReturn(true);\r
- //if(trans.info().isLoggable())\r
- authzTransFilter.tallyHo(authzTransMock);\r
- \r
- }\r
- \r
- \r
-// AuthzTrans at = env.newTrans();\r
-// at.setLur(getLur());\r
-// return at\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTransImpl;\r
-import org.onap.aaf.authz.org.Organization;\r
-import org.onap.aaf.authz.org.OrganizationFactory;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.inno.env.LogTarget;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_AuthzTransImpl {\r
-\r
- AuthzTransImpl authzTransImpl;\r
- @Mock\r
- AuthzEnv authzEnvMock;\r
- \r
- private Organization org=null;\r
- \r
- @Before\r
- public void setUp(){\r
- authzTransImpl = new AuthzTransImpl(authzEnvMock);\r
- \r
- }\r
- \r
- @Test\r
- public void testOrg(){\r
- Organization result=null;\r
- result = authzTransImpl.org();\r
- System.out.println("value of Organization " + result);\r
- //assertTrue(true); \r
- }\r
- \r
- @Mock\r
- LogTarget logTargetMock;\r
- \r
- @Test\r
- public void testLogAuditTrail(){\r
- \r
- PowerMockito.when(logTargetMock.isLoggable()).thenReturn(false);\r
- authzTransImpl.logAuditTrail(logTargetMock);\r
- \r
- assertTrue(true);\r
- }\r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTransOnlyFilter;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_AuthzTransOnlyFilter {\r
- AuthzTransOnlyFilter authzTransOnlyFilter;\r
- @Mock\r
- AuthzEnv authzEnvMock;\r
- \r
- @Before\r
- public void setUp(){\r
- authzTransOnlyFilter = new AuthzTransOnlyFilter(authzEnvMock);\r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.env;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.env.NullTrans;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_NullTrans {\r
- NullTrans nullTrans;\r
- \r
- @Before\r
- public void setUp(){\r
- nullTrans = new NullTrans();\r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.layer;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.layer.Result;\r
-\r
-public class JU_Result {\r
- Result result;\r
-// @Mock\r
-// RV value;\r
- int status=0;\r
- String details = "details"; \r
- String[] variables;\r
- \r
- @SuppressWarnings({ "unchecked", "rawtypes" })\r
- @Before\r
- public void setUp(){\r
- result = new Result(result, status, details, variables);\r
- }\r
-\r
- @Test\r
- public void testPartialContent() {\r
- Result Res = result.partialContent(true);\r
- System.out.println("Res" +Res);\r
- assertEquals(details,Res.toString());\r
- \r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.local;\r
-\r
-import java.io.File;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.junit.AfterClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.authz.local.DataFile;\r
-import org.onap.aaf.authz.local.DataFile.Token;\r
-import org.onap.aaf.authz.local.DataFile.Token.Field;\r
-\r
-public class JU_DataFile {\r
-\r
- @AfterClass\r
- public static void tearDownAfterClass() throws Exception {\r
- }\r
-\r
- @Test\r
- public void test() throws Exception {\r
- File file = new File("../authz-batch/data/v1.dat");\r
- DataFile df = new DataFile(file,"r");\r
- int count = 0;\r
- List<String> list = new ArrayList<String>();\r
- try {\r
- df.open();\r
- Token tok = df.new Token(1024000);\r
- Field fld = tok.new Field('|');\r
- \r
- while(tok.nextLine()) {\r
- ++count;\r
- fld.reset();\r
- list.add(fld.at(0));\r
- }\r
-// Collections.sort(list);\r
- for(String s: list) {\r
- System.out.println(s);\r
-\r
- }\r
- } finally {\r
- System.out.printf("%15s:%12d\n","Total",count);\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.local;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.File;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.runners.MockitoJUnitRunner;\r
-import org.onap.aaf.authz.local.TextIndex;\r
-\r
-@RunWith(MockitoJUnitRunner.class)\r
-public class JU_TextIndex {\r
- TextIndex textIndex;\r
- @Mock\r
- File file;\r
- \r
- @Before\r
- public void setUp(){\r
- textIndex = new TextIndex(file);\r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_OrganizationException {\r
- \r
- OrganizationException organizationException;\r
- \r
- @Before\r
- public void setUp(){\r
- organizationException = new OrganizationException();\r
- }\r
- \r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.authz.org;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.authz.org.OrganizationFactory;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.inno.env.APIException;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_OrganizationFactory {\r
- private static final String ORG_SLOT = null;\r
- OrganizationFactory organizationFactory;\r
- @Mock\r
- AuthzEnv authzEnvMock;\r
- String orgClass="orgclass";\r
- String orgNS="orgns";\r
- @Before\r
- public void setUp(){\r
- organizationFactory = new OrganizationFactory(); \r
- }\r
-\r
- @SuppressWarnings("static-access")\r
- @Test(expected = APIException.class)\r
- public void testSetDefaultOrg() throws APIException {\r
- //PowerMockito.when(authzEnvMock.slot(ORG_SLOT)).thenReturn("ORG_SLOT");\r
- organizationFactory.setDefaultOrg(authzEnvMock, orgClass);\r
- }\r
- \r
- @SuppressWarnings("static-access")\r
- @Test(expected = OrganizationException.class)\r
- public void testObtain() throws OrganizationException{\r
- PowerMockito.when(authzEnvMock.getProperty("Organization."+orgNS)).thenReturn("notnull");\r
- organizationFactory.obtain(authzEnvMock, orgNS);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.onap.aaf.cssa.rserv.CachingFileAccess;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_CachingFileAccess {\r
- CachingFileAccess cachingFileAccess;\r
- \r
- \r
- @Before\r
- public void setUp(){\r
- cachingFileAccess = new CachingFileAccess(null, null);\r
- \r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.cssa.rserv.CodeSetter;\r
-import org.onap.aaf.cssa.rserv.Route;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_CodeSetter {\r
- CodeSetter codeSetter;\r
- @Mock\r
- Trans transMock;\r
- @Mock\r
- HttpServletRequest reqMock;\r
- @Mock\r
- HttpServletResponse respMock;\r
- \r
- @Before\r
- public void setUp(){\r
- codeSetter = new CodeSetter(transMock, reqMock, respMock);\r
- }\r
- \r
- @SuppressWarnings("rawtypes")\r
- @Mock\r
- Route routeMock;\r
- \r
- @Test\r
- public void testMatches() throws IOException, ServletException{\r
- boolean result = codeSetter.matches(routeMock);\r
- System.out.println("value of res " + codeSetter.matches(routeMock));\r
- assertFalse(result);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.onap.aaf.cssa.rserv.Pair;\r
-\r
-public class JU_Pair {\r
- Pair pair;\r
- Object x;\r
- Object y;\r
- \r
- @Before\r
- public void setUp(){\r
- pair = new Pair(x, y);\r
- }\r
-\r
- @Test\r
- public void test() {\r
- assertTrue(true);\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import java.io.IOException;\r
-import java.util.List;\r
-\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServletRequest;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.cssa.rserv.CodeSetter;\r
-import org.onap.aaf.cssa.rserv.Route;\r
-import org.onap.aaf.cssa.rserv.Routes;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_Routes {\r
- Routes routes;\r
- @Mock\r
- HttpServletRequest reqMock;\r
- CodeSetter<Trans> codeSetterMock;\r
- Route<Trans> routeObj;\r
- \r
- @Before\r
- public void setUp(){\r
- routes = new Routes();\r
- }\r
- \r
- @Test\r
- public void testRouteReport(){\r
- List listVal = routes.routeReport(); \r
- System.out.println("value of Listval " +listVal);\r
- assertNotNull(listVal);\r
- \r
- }\r
- \r
- @Test\r
- public void testDerive() throws IOException, ServletException{\r
- routeObj = routes.derive(reqMock, codeSetterMock);\r
- System.out.println("value of routeObj" +routeObj); \r
- }\r
- \r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.cssa.rserv.RouteReport;\r
-import org.onap.aaf.cssa.rserv.TypedCode;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_TypedCode {\r
- TypedCode typedCode;\r
- @Mock\r
- RouteReport routeReportMock;\r
- \r
- @Before\r
- public void setUp(){\r
- typedCode = new TypedCode();\r
- }\r
- \r
- @Test\r
- public void testFirst(){\r
- String returnVal = typedCode.first();\r
- assertNull(returnVal);\r
- }\r
- \r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.onap.aaf.cssa.rserv.Version;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_Version {\r
- Version version;\r
-\r
- \r
- @Before\r
- public void setUp(){\r
- version = new Version("String");\r
- }\r
-\r
- @Test\r
- public void testEquals(){\r
- boolean val = version.equals(version);\r
- System.out.println("value of val " +val);\r
- assertTrue(val);\r
- }\r
- \r
- @Test\r
- public void testToString(){\r
- String strVal = version.toString();\r
- System.out.println("value of strVal " +strVal);\r
- assertNotNull(strVal);\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv.test;\r
-\r
-import static junit.framework.Assert.assertEquals;\r
-import static junit.framework.Assert.assertFalse;\r
-import static junit.framework.Assert.assertTrue;\r
-\r
-import org.junit.Test;\r
-import org.onap.aaf.cssa.rserv.Match;\r
-\r
-import org.onap.aaf.inno.env.Env;\r
-import org.onap.aaf.inno.env.TimeTaken;\r
-import org.onap.aaf.inno.env.Trans;\r
-import org.onap.aaf.inno.env.impl.EnvFactory;\r
-\r
-\r
-public class JU_BetterMatch {\r
-\r
- @Test\r
- public void test() {\r
- Trans trans = EnvFactory.newTrans();\r
- // Bad Match\r
- Match bm = new Match("/req/1.0.0/:var");\r
-\r
- assertTrue(bm.match("/req/1.0.0/fred"));\r
- assertTrue(bm.match("/req/1.0.0/wilma"));\r
- assertTrue(bm.match("/req/1.0.0/wilma/"));\r
- assertFalse(bm.match("/req/1.0.0/wilma/bambam"));\r
- assertFalse(bm.match("/not/valid/234"));\r
- assertFalse(bm.match(""));\r
- \r
- TimeTaken tt = trans.start("A", Env.SUB);\r
- TimeTaken tt2;\r
- int i = 0;\r
- try {\r
- bm = new Match(null);\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match(""));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match(null));\r
- tt2.done();\r
- } finally {\r
- tt.done();\r
- }\r
- \r
- \r
- tt = trans.start("B", Env.SUB);\r
- i = 0;\r
- try {\r
- bm = new Match("/req/1.0.0/:urn/:ref");\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertFalse(bm.match("/req/1.0.0/urn"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/x"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx"));\r
- } finally {\r
- tt2.done();\r
- tt.done(); \r
- }\r
- \r
- tt = trans.start("C", Env.SUB);\r
- i = 0;\r
- try {\r
- String url = "/req/1.0.0/";\r
- bm = new Match(url+":urn*");\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- String value = "urn:fsdb,1.0,req,newreq/0x12345";\r
- \r
- assertTrue(bm.match(url+value));\r
- assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn"));\r
- } finally {\r
- tt2.done();\r
- tt.done(); \r
- }\r
-\r
- tt = trans.start("D", Env.SUB);\r
- i = 0;\r
- try {\r
- bm = new Match("/req/1.0.0/:urn/:ref*");\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/"));\r
- } finally {\r
- tt2.done();\r
- tt.done(); \r
- }\r
-\r
- tt = trans.start("E", Env.SUB);\r
- i = 0;\r
- try {\r
- bm = new Match("this*");\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("this"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("thisandthat"));\r
- tt2.done();\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/"));\r
- } finally {\r
- tt2.done();\r
- tt.done(); \r
- }\r
-\r
- tt = trans.start("F", Env.SUB);\r
- i = 0;\r
- try {\r
- bm = new Match("*");\r
- tt2 = trans.start(Integer.toString(++i), Env.SUB);\r
- assertTrue(bm.match("<pass>/this"));\r
- } finally {\r
- tt2.done();\r
- tt.done(); \r
- }\r
- \r
- StringBuilder sb = new StringBuilder();\r
- trans.auditTrail(0, sb);\r
- System.out.println(sb);\r
- \r
- }\r
- \r
- @Test\r
- public void specialTest() {\r
- Match match = new Match("/sample");\r
- assertTrue(match.match("/sample"));\r
- \r
- match = new Match("/lpeer//lpeer/:key/:item*");\r
- assertTrue(match.match("/lpeer//lpeer/x/y"));\r
- assertFalse(match.match("/lpeer/x/lpeer/x/y"));\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cssa.rserv.test;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertNull;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.junit.Test;\r
-import org.onap.aaf.cssa.rserv.HttpCode;\r
-import org.onap.aaf.cssa.rserv.TypedCode;\r
-\r
-import org.onap.aaf.inno.env.TransJAXB;\r
-import org.onap.aaf.inno.env.impl.EnvFactory;\r
-\r
-\r
-/**\r
- * Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values\r
- */\r
-public class JU_Content {\r
- \r
-\r
- @Test\r
- public void test() throws Exception {\r
- final String BOOL = "Boolean";\r
- final String XML = "XML";\r
- TransJAXB trans = EnvFactory.newTrans();\r
- try {\r
- HttpCode<TransJAXB, String> cBool = new HttpCode<TransJAXB,String>(BOOL,"Standard String") {\r
- @Override\r
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {\r
- try {\r
- resp.getOutputStream().write(context.getBytes());\r
- } catch (IOException e) {\r
- }\r
- }\r
- };\r
-\r
- HttpCode<TransJAXB,String> cXML = new HttpCode<TransJAXB,String>(XML, "Standard String") {\r
- @Override\r
- public void handle(TransJAXB trans, HttpServletRequest req, HttpServletResponse resp) {\r
- try {\r
- resp.getOutputStream().write(context.getBytes());\r
- } catch (IOException e) {\r
- }\r
- }\r
- };\r
-\r
- TypedCode<TransJAXB> ct = new TypedCode<TransJAXB>()\r
- .add(cBool,"application/" + Boolean.class.getName()+"+xml;charset=utf8;version=1.1")\r
- .add(cXML,"application/xml;q=.9");\r
- String expected = "application/java.lang.Boolean+xml;charset=utf8;version=1.1,application/xml;q=0.9";\r
- assertEquals(expected,ct.toString());\r
-\r
- //BogusReq req = new BogusReq();\r
- //expected = (expected);\r
- //HttpServletResponse resp = new BogusResp();\r
- \r
- assertNotNull("Same Content String and Accept String",ct.prep(trans,expected));\r
-\r
- //expects Null (not run)\r
- // A Boolean xml that must have charset utf8 and match version 1.2 or greater\r
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.2");\r
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));\r
-\r
- // Same with (too many) spaces\r
- expected = (" application/java.lang.Boolean+xml ; charset = utf8 ; version = 1.2 ");\r
- assertNull("Accept Minor Version greater than Content Minor Version",ct.prep(trans,expected));\r
-\r
- //expects Null (not run)\r
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=2.1");\r
- assertNull("Major Versions not the same",ct.prep(trans,expected));\r
-\r
- expected = ("application/java.lang.Boolean+xml;charset=utf8;version=1.0");\r
- assertNotNull("Content Minor Version is greater than Accept Minor Version",ct.prep(trans,expected));\r
-\r
- expected = "application/java.lang.Squid+xml;charset=utf8;version=1.0,application/xml;q=.9";\r
- assertNotNull("2nd one will have to do...",ct.prep(trans,expected));\r
-\r
- expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0";\r
- assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected));\r
-\r
- // expects no run \r
- expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0";\r
- assertNull("Unknown Minor Charset",ct.prep(trans,expected));\r
-\r
- expected="";\r
- assertNotNull("Blank Acceptance",ct.prep(trans,expected));\r
- \r
- expected=null;\r
- assertNotNull("Null Acceptance",ct.prep(trans,expected)); \r
-\r
- expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");\r
- assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected));\r
- \r
- // No SemiColon\r
- expected = ("i/am/bogus,application/xml");\r
- assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected));\r
-\r
- } finally { \r
- StringBuilder sb = new StringBuilder();\r
- trans.auditTrail(0, sb);\r
- System.out.println(sb);\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
- ============LICENSE_START====================================================\r
- * org.onap.aaf\r
- * ===========================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===========================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END====================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *\r
--->\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>parent</artifactId>\r
- <version>1.0.1-SNAPSHOT</version>\r
- <relativePath>../pom.xml</relativePath>\r
- </parent>\r
- \r
- <artifactId>authz-defOrg</artifactId>\r
- <name>Default Organization</name>\r
- <description>Example Organization Module</description>\r
- <packaging>jar</packaging>\r
- <url>https://github.com/att/AAF</url>\r
- \r
- <developers>\r
- <developer>\r
- <name>Jonathan Gathman</name>\r
- <email></email>\r
- <organization>ATT</organization>\r
- <organizationUrl></organizationUrl>\r
- </developer>\r
- </developers>\r
-\r
- <properties>\r
- <maven.test.failure.ignore>false</maven.test.failure.ignore>\r
- <project.swmVersion>0</project.swmVersion>\r
- <project.cadiVersion>1.0.0-SNAPSHOT</project.cadiVersion>\r
- <project.innoVersion>1.0.0-SNAPSHOT</project.innoVersion>\r
- <!-- SONAR -->\r
- <jacoco.version>0.7.7.201606060606</jacoco.version>\r
- <sonar.skip>true</sonar.skip>\r
- <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>\r
- <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>\r
- <!-- Default Sonar configuration -->\r
- <sonar.jacoco.reportPath>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>\r
- <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>\r
- <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->\r
- <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>\r
- <nexusproxy>https://nexus.onap.org</nexusproxy>\r
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>\r
- <sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>\r
-</properties>\r
-\r
- \r
- <dependencies>\r
- <dependency>\r
- <groupId>org.onap.aaf.cadi</groupId>\r
- <artifactId>cadi-core</artifactId>\r
- <version>${project.cadiVersion}</version>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>org.onap.aaf.authz</groupId>\r
- <artifactId>authz-core</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>javax.mail</groupId>\r
- <artifactId>mail</artifactId>\r
- </dependency> \r
- </dependencies>\r
-\r
- <build>\r
- <pluginManagement>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-javadoc-plugin</artifactId>\r
- <version>2.10.4</version>\r
- <configuration>\r
- <failOnError>false</failOnError>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>attach-javadocs</id>\r
- <goals>\r
- <goal>jar</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.sonatype.plugins</groupId>\r
- <artifactId>nexus-staging-maven-plugin</artifactId>\r
- <version>1.6.7</version>\r
- <extensions>true</extensions>\r
- <configuration>\r
- <nexusUrl>${nexusproxy}</nexusUrl>\r
- <stagingProfileId>176c31dfe190a</stagingProfileId>\r
- <serverId>ecomp-staging</serverId>\r
- </configuration>\r
- </plugin> \r
- <plugin>\r
- <groupId>org.jacoco</groupId>\r
- <artifactId>jacoco-maven-plugin</artifactId>\r
- <version>${jacoco.version}</version>\r
- <configuration>\r
- <excludes>\r
- <exclude>**/gen/**</exclude>\r
- <exclude>**/generated-sources/**</exclude>\r
- <exclude>**/yang-gen/**</exclude>\r
- <exclude>**/pax/**</exclude>\r
- </excludes>\r
- </configuration>\r
- <executions>\r
-\r
- <execution>\r
- <id>pre-unit-test</id>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</destFile>\r
- <propertyName>surefireArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
- \r
- \r
- <execution>\r
- <id>post-unit-test</id>\r
- <phase>test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>\r
- </configuration>\r
- </execution>\r
- <execution>\r
- <id>pre-integration-test</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>prepare-agent</goal>\r
- </goals>\r
- <configuration>\r
- <destFile>${project.build.directory}/code-coverage/jacoco-it.exec</destFile>\r
-\r
- <propertyName>failsafeArgLine</propertyName>\r
- </configuration>\r
- </execution>\r
-\r
- \r
- <execution>\r
- <id>post-integration-test</id>\r
- <phase>post-integration-test</phase>\r
- <goals>\r
- <goal>report</goal>\r
- </goals>\r
- <configuration>\r
- <dataFile>${project.build.directory}/code-coverage/jacoco-it.exec</dataFile>\r
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin> \r
-\r
- </plugins>\r
- </pluginManagement>\r
- </build>\r
- <distributionManagement>\r
- <repository>\r
- <id>ecomp-releases</id>\r
- <name>AAF Release Repository</name>\r
- <url>${nexusproxy}${releaseNexusPath}</url>\r
- </repository>\r
- <snapshotRepository>\r
- <id>ecomp-snapshots</id>\r
- <name>AAF Snapshot Repository</name>\r
- <url>${nexusproxy}${snapshotNexusPath}</url>\r
- </snapshotRepository>\r
- <site>\r
- <id>ecomp-site</id>\r
- <url>dav:${nexusproxy}${sitePath}</url>\r
- </site>\r
- </distributionManagement>\r
-\r
- \r
-</project>\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import javax.mail.Address;\r
-import javax.mail.Message;\r
-import javax.mail.MessagingException;\r
-import javax.mail.Session;\r
-import javax.mail.Transport;\r
-import javax.mail.internet.InternetAddress;\r
-import javax.mail.internet.MimeMessage;\r
-\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.org.EmailWarnings;\r
-import org.onap.aaf.authz.org.Executor;\r
-import org.onap.aaf.authz.org.Organization;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
-\r
-public class DefaultOrg implements Organization {\r
- private static final String PROPERTY_IS_REQUIRED = " property is Required";\r
- private static final String DOMAIN = "osaaf.com";\r
- private static final String REALM = "com.osaaf";\r
- private static final String NAME = "Default Organization";\r
- private static final String NO_PASS = NAME + " does not support Passwords. Use AAF";\r
- private final String mailHost,mailFromUserId,supportAddress;\r
- private String SUFFIX;\r
- // Possible ID Pattern\r
- private static final String ID_PATTERN = "a-z[a-z0-9]{5-8}@.*";\r
-\r
- public DefaultOrg(AuthzEnv env) throws OrganizationException {\r
- String s;\r
- mailHost = env.getProperty(s=(REALM + ".mailHost"), null);\r
- if(mailHost==null) {\r
- throw new OrganizationException(s + PROPERTY_IS_REQUIRED);\r
- }\r
- supportAddress = env.getProperty(s=(REALM + ".supportEmail"), null);\r
- if(supportAddress==null) {\r
- throw new OrganizationException(s + PROPERTY_IS_REQUIRED);\r
- }\r
- \r
- String temp = env.getProperty(s=(REALM + ".mailFromUserId"), null);\r
- mailFromUserId = temp==null?supportAddress:temp;\r
-\r
- System.getProperties().setProperty("mail.smtp.host",mailHost);\r
- System.getProperties().setProperty("mail.user", mailFromUserId);\r
- // Get the default Session object.\r
- session = Session.getDefaultInstance(System.getProperties());\r
-\r
- SUFFIX='.'+getDomain();\r
- \r
- try {\r
- String defFile;\r
- temp=env.getProperty(defFile = (getClass().getName()+".file"));\r
- File fIdentities=null;\r
- if(temp==null) {\r
- temp = env.getProperty("aaf_data_dir");\r
- if(temp!=null) {\r
- env.warn().log(defFile, "is not defined. Using default: ",temp+"/identities.dat");\r
- File dir = new File(temp);\r
- fIdentities=new File(dir,"identities.dat");\r
- if(!fIdentities.exists()) {\r
- env.warn().log("No",fIdentities.getCanonicalPath(),"exists. Creating.");\r
- if(!dir.exists()) {\r
- dir.mkdirs();\r
- }\r
- fIdentities.createNewFile();\r
- }\r
- }\r
- } else {\r
- fIdentities = new File(temp);\r
- if(!fIdentities.exists()) {\r
- String dataDir = env.getProperty("aaf_data_dir");\r
- if(dataDir!=null) {\r
- fIdentities = new File(dataDir,temp);\r
- }\r
- }\r
- }\r
- \r
- if(fIdentities!=null && fIdentities.exists()) {\r
- identities = new Identities(fIdentities);\r
- } else {\r
- throw new OrganizationException(fIdentities.getCanonicalPath() + " does not exist.");\r
- }\r
- } catch (IOException e) {\r
- throw new OrganizationException(e);\r
- }\r
- }\r
- \r
- // Implement your own Delegation System\r
- static final List<String> NULL_DELEGATES = new ArrayList<String>();\r
-\r
- public Identities identities;\r
- private boolean dryRun;\r
- private Session session;\r
- public enum Types {Employee, Contractor, Application, NotActive};\r
- private final static Set<String> typeSet;\r
- \r
- static {\r
- typeSet = new HashSet<String>();\r
- for(Types t : Types.values()) {\r
- typeSet.add(t.name());\r
- }\r
- }\r
- \r
- private static final EmailWarnings emailWarnings = new DefaultOrgWarnings();\r
-\r
- @Override\r
- public String getName() {\r
- return NAME;\r
- }\r
-\r
- @Override\r
- public String getRealm() {\r
- return REALM;\r
- }\r
-\r
- @Override\r
- public String getDomain() {\r
- return DOMAIN;\r
- }\r
-\r
- @Override\r
- public DefaultOrgIdentity getIdentity(AuthzTrans trans, String id) throws OrganizationException {\r
- return new DefaultOrgIdentity(trans,id,this);\r
- }\r
-\r
- // Note: Return a null if found; return a String Message explaining why not found. \r
- @Override\r
- public String isValidID(String id) {\r
- Data data;\r
- try {\r
- data = identities.find(id, identities.reuse());\r
- } catch (IOException e) {\r
- return getName() + " could not lookup " + id + ": " + e.getLocalizedMessage();\r
- }\r
- return data==null?id + "is not an Identity in " + getName():null;\r
- }\r
-\r
- @Override\r
- public String isValidPassword(String user, String password, String... prev) {\r
- // If you have an Organization user/Password scheme, use here, otherwise, just use AAF\r
- return NO_PASS;\r
- }\r
-\r
- @Override\r
- public Set<String> getIdentityTypes() {\r
- return typeSet;\r
- }\r
-\r
- @Override\r
- public Response notify(AuthzTrans trans, Notify type, String url, String[] identities, String[] ccs, String summary, Boolean urgent) {\r
- String system = trans.getProperty("CASS_ENV", "");\r
-\r
- ArrayList<String> toList = new ArrayList<String>();\r
- Identity identity;\r
- if (identities != null) {\r
- for (String user : identities) {\r
- try {\r
- identity = getIdentity(trans, user);\r
- if (identity == null) {\r
- trans.error().log(\r
- "Failure to obtain User " + user + " for "\r
- + getName());\r
- } else {\r
- toList.add(identity.email());\r
- }\r
- } catch (Exception e) {\r
- trans.error().log(\r
- e,\r
- "Failure to obtain User " + user + " for "\r
- + getName());\r
- }\r
- }\r
- }\r
-\r
- if (toList.isEmpty()) {\r
- trans.error().log("No Users listed to email");\r
- return Response.ERR_NotificationFailure;\r
- }\r
-\r
- ArrayList<String> ccList = new ArrayList<String>();\r
-\r
- // If we're sending an urgent email, CC the user's supervisor\r
- //\r
- if (urgent) {\r
- trans.info().log("urgent msg for: " + identities[0]);\r
- try {\r
- List<Identity> supervisors = getApprovers(trans, identities[0]);\r
- for (Identity us : supervisors) {\r
- trans.info().log("supervisor: " + us.email());\r
- ccList.add(us.email());\r
- }\r
- } catch (Exception e) {\r
- trans.error().log(e,\r
- "Failed to find supervisor for " + identities[0]);\r
- }\r
- }\r
-\r
- if (ccs != null) {\r
- for (String user : ccs) {\r
- try {\r
- identity = getIdentity(trans, user);\r
- ccList.add(identity.email());\r
- } catch (Exception e) {\r
- trans.error().log(\r
- e,\r
- "Failure to obtain User " + user + " for "\r
- + getName());\r
- }\r
- }\r
- }\r
-\r
- if (summary == null) {\r
- summary = "";\r
- }\r
-\r
- switch (type) {\r
- case Approval:\r
- try {\r
- sendEmail(trans, toList, ccList,\r
- "AAF Approval Notification "\r
- + (system.length() == 0 ? "" : "(ENV: "\r
- + system + ")"),\r
- "AAF is the "\r
- + NAME\r
- + "System for Fine-Grained Authorizations. You are being asked to Approve"\r
- + (system.length() == 0 ? "" : " in the "\r
- + system + " environment")\r
- + " before AAF Actions can be taken.\n\n"\r
- + "Please follow this link: \n\n\t" + url\r
- + "\n\n" + summary, urgent);\r
- } catch (Exception e) {\r
- trans.error().log(e, "Failure to send Email");\r
- return Response.ERR_NotificationFailure;\r
- }\r
- break;\r
- case PasswordExpiration:\r
- try {\r
- sendEmail(trans,\r
- toList,\r
- ccList,\r
- "AAF Password Expiration Warning "\r
- + (system.length() == 0 ? "" : "(ENV: "\r
- + system + ")"),\r
- "AAF is the "\r
- + NAME\r
- + " System for Authorizations.\n\nOne or more passwords will expire soon or have expired"\r
- + (system.length() == 0 ? "" : " in the "\r
- + system + " environment")\r
- + ".\n\nPasswords expired for more than 30 days without action are subject to deletion.\n\n"\r
- + "Please follow each link to add a New Password with Expiration Date. Either are valid until expiration. "\r
- + "Use this time to change the passwords on your system. If issues, reply to this email.\n\n"\r
- + summary, urgent);\r
- } catch (Exception e) {\r
- trans.error().log(e, "Failure to send Email");\r
- return Response.ERR_NotificationFailure;\r
- }\r
- break;\r
-\r
- case RoleExpiration:\r
- try {\r
- sendEmail(\r
- trans,\r
- toList,\r
- ccList,\r
- "AAF Role Expiration Warning "\r
- + (system.length() == 0 ? "" : "(ENV: "\r
- + system + ")"),\r
- "AAF is the "\r
- + NAME\r
- + " System for Authorizations. One or more roles will expire soon"\r
- + (system.length() == 0 ? "" : " in the "\r
- + system + " environment")\r
- + ".\n\nRoles expired for more than 30 days are subject to deletion."\r
- + "Please follow this link the GUI Command line, and either 'extend' or 'del' the user in the role.\n"\r
- + "If issues, reply to this email.\n\n\t" + url\r
- + "\n\n" + summary, urgent);\r
- } catch (Exception e) {\r
- trans.error().log(e, "Failure to send Email");\r
- return Response.ERR_NotificationFailure;\r
- }\r
- break;\r
- default:\r
- return Response.ERR_NotImplemented;\r
- }\r
- return Response.OK;\r
- }\r
-\r
- @Override\r
- public int sendEmail(AuthzTrans trans, List<String> toList, List<String> ccList, String subject, String body,\r
- Boolean urgent) throws OrganizationException {\r
- int status = 1;\r
- \r
- List<String> to = new ArrayList<String>();\r
- for(String em : toList) {\r
- if(em.indexOf('@')<0) {\r
- to.add(new DefaultOrgIdentity(trans, em, this).email());\r
- } else {\r
- to.add(em);\r
- }\r
- }\r
- \r
- List<String> cc = new ArrayList<String>();\r
- if(ccList!=null && !ccList.isEmpty()) {\r
- for(String em : ccList) {\r
- if(em.indexOf('@')<0) {\r
- cc.add(new DefaultOrgIdentity(trans, em, this).email());\r
- } else {\r
- cc.add(em);\r
- }\r
- }\r
- }\r
- \r
- \r
- // for now, I want all emails so we can see what goes out. Remove later\r
- if (!ccList.contains(supportAddress)) {\r
- ccList.add(supportAddress);\r
- }\r
-\r
- try {\r
- // Create a default MimeMessage object.\r
- MimeMessage message = new MimeMessage(session);\r
-\r
- // Set From: header field of the header.\r
- message.setFrom(new InternetAddress(mailFromUserId));\r
-\r
- if (!dryRun) {\r
- // Set To: header field of the header. This is a required field\r
- // and calling module should make sure that it is not null or\r
- // blank\r
- message.addRecipients(Message.RecipientType.TO,\r
- getAddresses(to));\r
-\r
- // Set CC: header field of the header.\r
- if ((ccList != null) && (ccList.size() > 0)) {\r
- message.addRecipients(Message.RecipientType.CC,\r
- getAddresses(cc));\r
- }\r
-\r
- // Set Subject: header field\r
- message.setSubject(subject);\r
-\r
- if (urgent) {\r
- message.addHeader("X-Priority", "1");\r
- }\r
-\r
- // Now set the actual message\r
- message.setText(body);\r
- } else {\r
- // override recipients\r
- message.addRecipients(Message.RecipientType.TO,\r
- InternetAddress.parse(supportAddress));\r
-\r
- // Set Subject: header field\r
- message.setSubject("[TESTMODE] " + subject);\r
-\r
- if (urgent) {\r
- message.addHeader("X-Priority", "1");\r
- }\r
-\r
- ArrayList<String> newBody = new ArrayList<String>();\r
-\r
- Address temp[] = getAddresses(to);\r
- String headerString = "TO:\t" + InternetAddress.toString(temp)\r
- + "\n";\r
-\r
- temp = getAddresses(cc);\r
- headerString += "CC:\t" + InternetAddress.toString(temp) + "\n";\r
-\r
- newBody.add(headerString);\r
-\r
- newBody.add("Text: \n");\r
-\r
- newBody.add(body);\r
- String outString = "";\r
- for (String s : newBody) {\r
- outString += s + "\n";\r
- }\r
-\r
- message.setText(outString);\r
- }\r
- // Send message\r
- Transport.send(message);\r
- status = 0;\r
-\r
- } catch (MessagingException mex) {\r
- throw new OrganizationException("Exception send email message "\r
- + mex.getMessage());\r
- }\r
-\r
- return status; \r
- }\r
-\r
- /**\r
- * Default Policy is to set to 6 Months for Notification Types.\r
- * add others/change as required\r
- */\r
- @Override\r
- public Date whenToValidate(Notify type, Date lastValidated) {\r
- switch(type) {\r
- case Approval:\r
- case PasswordExpiration:\r
- return null;\r
- default:\r
- GregorianCalendar gc = new GregorianCalendar();\r
- gc.setTime(lastValidated);\r
- gc.add(GregorianCalendar.MONTH, 6); // 6 month policy\r
- return gc.getTime();\r
- }\r
- }\r
-\r
- @Override\r
- public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String... extra) {\r
- GregorianCalendar rv = gc==null?new GregorianCalendar():(GregorianCalendar)gc.clone();\r
- switch (exp) {\r
- case ExtendPassword:\r
- // Extending Password give 5 extra days\r
- rv.add(GregorianCalendar.DATE, 5);\r
- break;\r
- case Future:\r
- // Future Requests last 15 days before subject to deletion.\r
- rv.add(GregorianCalendar.DATE, 15);\r
- break;\r
- case Password:\r
- // Passwords expire in 90 days\r
- rv.add(GregorianCalendar.DATE, 90);\r
- break;\r
- case TempPassword:\r
- // Temporary Passwords last for 12 hours.\r
- rv.add(GregorianCalendar.HOUR, 12);\r
- break;\r
- case UserDelegate:\r
- // Delegations expire max in 2 months\r
- rv.add(GregorianCalendar.MONTH, 2);\r
- break;\r
- case UserInRole:\r
- // Roles expire in 6 months\r
- rv.add(GregorianCalendar.MONTH, 6);\r
- break;\r
- default:\r
- // Unless other wise set, 6 months is default\r
- rv.add(GregorianCalendar.MONTH, 6);\r
- break;\r
- }\r
- return rv;\r
- }\r
-\r
- @Override\r
- public EmailWarnings emailWarningPolicy() {\r
- return emailWarnings;\r
- }\r
-\r
- /**\r
- * Assume the Supervisor is the Approver.\r
- */\r
- @Override\r
- public List<Identity> getApprovers(AuthzTrans trans, String user) throws OrganizationException {\r
- Identity orgIdentity = getIdentity(trans, user);\r
- List<Identity> orgIdentitys = new ArrayList<Identity>();\r
- if(orgIdentity!=null) {\r
- String supervisorID = orgIdentity.responsibleTo();\r
- if (supervisorID.indexOf('@') < 0) {\r
- supervisorID += getDomain();\r
- }\r
- Identity supervisor = getIdentity(trans, supervisorID);\r
- orgIdentitys.add(supervisor);\r
- }\r
- return orgIdentitys; \r
- }\r
-\r
- @Override\r
- public String getApproverType() {\r
- return "supervisor";\r
- }\r
-\r
- @Override\r
- public int startOfDay() {\r
- // TODO Auto-generated method stub\r
- return 0;\r
- }\r
-\r
- @Override\r
- public boolean canHaveMultipleCreds(String id) {\r
- // External entities are likely mono-password... if you change it, it is a global change.\r
- // This is great for people, but horrible for Applications. \r
- //\r
- // AAF's Password can have multiple Passwords, each with their own Expiration Date.\r
- // For Default Org, we'll assume true for all, but when you add your external\r
- // Identity stores, you need to return "false" if they cannot support multiple Passwords like AAF\r
- return true;\r
- }\r
-\r
- @Override\r
- public boolean isValidCred(String id) {\r
- if(id.endsWith(SUFFIX)) {\r
- return true;\r
- }\r
- return id.matches(ID_PATTERN);\r
- }\r
-\r
- @Override\r
- public String validate(AuthzTrans trans, Policy policy, Executor executor, String... vars) throws OrganizationException {\r
- switch(policy) {\r
- case OWNS_MECHID:\r
- case CREATE_MECHID:\r
- if(vars.length>0) {\r
- Identity requestor = getIdentity(trans, trans.user());\r
- if(requestor!=null) {\r
- Identity mechid = getIdentity(trans, vars[0]);\r
- if(requestor.equals(mechid.owner())) {\r
- return null;\r
- }\r
- }\r
- }\r
- return trans.user() + " is not the Sponsor of MechID " + vars[0];\r
- \r
- case CREATE_MECHID_BY_PERM_ONLY:\r
- return getName() + " only allows sponsors to create MechIDs";\r
- \r
- default:\r
- return policy.name() + " is unsupported at " + getName();\r
- } \r
- }\r
-\r
- @Override\r
- public boolean isTestEnv() {\r
- return false;\r
- }\r
-\r
- @Override\r
- public void setTestMode(boolean dryRun) {\r
- this.dryRun = dryRun;\r
- }\r
-\r
- /**\r
- * Convert the delimiter String into Internet addresses with the default\r
- * delimiter of ";"\r
- * @param strAddress\r
- * @return\r
- */\r
- private Address[] getAddresses(List<String> strAddress) throws OrganizationException {\r
- return this.getAddresses(strAddress,";");\r
- }\r
- /**\r
- * Convert the delimiter String into Internet addresses with the \r
- * delimiter of provided\r
- * @param strAddress\r
- * @param delimiter\r
- * @return\r
- */\r
- private Address[] getAddresses(List<String> strAddresses, String delimiter) throws OrganizationException {\r
- Address[] addressArray = new Address[strAddresses.size()];\r
- int count = 0;\r
- for (String addr : strAddresses)\r
- {\r
- try{\r
- addressArray[count] = new InternetAddress(addr);\r
- count++;\r
- }catch(Exception e){\r
- throw new OrganizationException("Failed to parse the email address "+ addr +": "+e.getMessage());\r
- }\r
- }\r
- return addressArray;\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import java.io.IOException;\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.local.AbsData.Reuse;\r
-import org.onap.aaf.authz.org.Organization;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.authz.org.Organization.Identity;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
-\r
-import org.onap.aaf.cadi.config.Config;\r
-\r
-/**\r
- * Org Users are essential representations of Identities within the Org. Since this is a highly individual \r
- * thing for most Orgs, i.e. some use LDAP, some need feed, some use something else, this object will allow\r
- * the Organization to connect to their own Identity systems...\r
- * \r
- *\r
- */\r
-public class DefaultOrgIdentity implements Identity {\r
- private final static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);\r
- \r
- private DefaultOrg org;\r
- private Data identity;\r
- private Identity owner;\r
-\r
- public DefaultOrgIdentity(AuthzTrans trans, String key, DefaultOrg dorg) throws OrganizationException {\r
- org = dorg;\r
- identity=null;\r
- try {\r
- org.identities.open(trans, TIMEOUT);\r
- try {\r
- Reuse r = org.identities.reuse();\r
- identity = org.identities.find(key, r);\r
- if(identity==null) {\r
- identity = Identities.NO_DATA;\r
- } else {\r
- if("a".equals(identity.status)) {\r
- owner = new DefaultOrgIdentity(trans,identity.responsibleTo,org);\r
- } else {\r
- owner = null;\r
- }\r
- }\r
- } finally {\r
- org.identities.close(trans);\r
- }\r
- } catch (IOException e) {\r
- throw new OrganizationException(e);\r
- }\r
- }\r
- \r
- @Override\r
- public boolean equals(Object b) {\r
- if(b instanceof DefaultOrgIdentity) {\r
- return identity.id.equals(((DefaultOrgIdentity)b).identity.id);\r
- }\r
- return false;\r
- }\r
-\r
- @Override\r
- public String id() {\r
- return identity.id;\r
- }\r
-\r
- @Override\r
- public String fullID() {\r
- return identity.id+'@'+org.getDomain();\r
- }\r
-\r
- @Override\r
- public String type() {\r
- switch(identity.status) {\r
- case "e": return DefaultOrg.Types.Employee.name();\r
- case "c": return DefaultOrg.Types.Contractor.name();\r
- case "a": return DefaultOrg.Types.Application.name();\r
- case "n": return DefaultOrg.Types.NotActive.name();\r
- default:\r
- return "Unknown";\r
- }\r
- }\r
-\r
- @Override\r
- public String responsibleTo() {\r
- return identity.responsibleTo;\r
- }\r
-\r
- @Override\r
- public List<String> delegate() {\r
- //NOTE: implement Delegate system, if desired\r
- return DefaultOrg.NULL_DELEGATES;\r
- }\r
-\r
- @Override\r
- public String email() {\r
- return identity.email;\r
- }\r
-\r
- @Override\r
- public String fullName() {\r
- return identity.name;\r
- }\r
-\r
- @Override\r
- public boolean isResponsible() {\r
- return "e".equals(identity.status); // Assume only Employees are responsible for Resources. \r
- }\r
-\r
- @Override\r
- public boolean isFound() {\r
- return identity!=null;\r
- }\r
-\r
- @Override\r
- public Identity owner() throws OrganizationException {\r
- return owner;\r
- }\r
-\r
- @Override\r
- public Organization org() {\r
- return org;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import org.onap.aaf.authz.org.EmailWarnings;\r
-\r
-public class DefaultOrgWarnings implements EmailWarnings {\r
-\r
- @Override\r
- public long credEmailInterval()\r
- {\r
- return 604800000L; // 7 days in millis 1000 * 86400 * 7\r
- }\r
- \r
- @Override\r
- public long roleEmailInterval()\r
- {\r
- return 604800000L; // 7 days in millis 1000 * 86400 * 7\r
- }\r
- \r
- @Override\r
- public long apprEmailInterval() {\r
- return 259200000L; // 3 days in millis 1000 * 86400 * 3\r
- }\r
- \r
- @Override\r
- public long credExpirationWarning()\r
- {\r
- return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds\r
- }\r
- \r
- @Override\r
- public long roleExpirationWarning()\r
- {\r
- return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds\r
- }\r
-\r
- @Override\r
- public long emailUrgentWarning()\r
- {\r
- return( 1209600000L ); // Two weeks, in milliseconds 1000 * 86400 * 14 in milliseconds\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-\r
-import org.onap.aaf.authz.local.AbsData;\r
-import org.onap.aaf.authz.local.DataFile.Token.Field;\r
-\r
-/*\r
- * Example User Data file, which can be modified for many different kinds of Data Feeds.\r
- * \r
- * Note: This has shown to be extremely effective in AT&T, an acknowledged very large organizations, \r
- * because there is no need to synchronize records. AAF simply receives a Data Feed in Organization\r
- * defined intervals. (You might want to check for validity, such as size, etc), then is copied into\r
- * Data Directory. You will want to do so first creating a "lock" file. Assuming the File name is "users.dat",\r
- * the Lock File is "users.lock". \r
- * \r
- * After the movement of the Datafile into place, it is best to remove the Index File, then remove the lock file.\r
- * \r
- * Note, Any AAF Programs needing this data WILL wait on the Lock file, so you should get fresh Data files\r
- * in a "stage" directory, from WEB, or wherever, and then, after it is correct, do the following as fast as feasible.\r
- * \r
- * a) lock\r
- * b) copy from stage\r
- * c) remove idx\r
- * d) unlock\r
- * \r
- * If the Index File is either non-existent or out of date from the Data File, it will be reindexed, which\r
- * has proven to be a very quick function, even with large numbers of entries.\r
- * \r
- * This Sample Feed is set for a file with delimiter of "|". 512 is maximum expected line length. The "0" is the\r
- * field offset for the "key" to the record, which, for user, should be the unique Organization Identity.\r
- * \r
- */\r
-public class Identities extends AbsData {\r
- public final static Data NO_DATA = new Data();\r
- \r
- public Identities(File users) {\r
- super(users,'|',512,0);\r
- }\r
-\r
- /*\r
- * Example Field Layout. note, in this example, Application IDs and People IDs are mixed. You may want to split\r
- * out AppIDs, choose your own status indicators, or whatever you use.\r
- * 0 - unique ID\r
- * 1 - full name\r
- * 2 - first name\r
- * 3 - last name\r
- * 4 - phone\r
- * 5 - official email\r
- * 6 - employment status e=employee, c=contractor, a=application, n=no longer with company\r
- * 7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID)\r
- */\r
- public static class Data {\r
- public final String id;\r
- public final String name;\r
- public final String fname;\r
- public final String lname;\r
- public final String phone;\r
- public final String email;\r
- public final String status;\r
- public final String responsibleTo;\r
- \r
- private Data(Field f) {\r
- f.reset();\r
- id=f.next();\r
- name=f.next();\r
- fname=f.next();\r
- lname=f.next();\r
- phone=f.next();\r
- email=f.next();\r
- status=f.next();\r
- responsibleTo =f.next();\r
- }\r
- \r
- private Data() {\r
- id = name = fname = lname =\r
- phone = email = status = responsibleTo \r
- = "";\r
- }\r
-\r
- public String toString() {\r
- return id + '|' +\r
- name + '|' +\r
- lname + '|' +\r
- fname + '|' +\r
- phone + '|' +\r
- email + '|' +\r
- status + '|' +\r
- responsibleTo;\r
- }\r
- \r
- // Here, make up your own Methods which help you easily determine your Organization's structure\r
- // in your Organization Object\r
- public boolean hasStatus(String possible) {\r
- return possible.contains(status);\r
- }\r
-\r
- public boolean isEmployee() {\r
- return "e".equals(status);\r
- }\r
- \r
- public boolean isContractor() {\r
- return "c".equals(status);\r
- }\r
- \r
- public boolean isApplication() {\r
- return "a".equals(status);\r
- }\r
- }\r
- \r
- public Data find(Object key,Reuse r) throws IOException {\r
- r.getFieldData().reset();\r
- // These are new, to allow for Thread Safety\r
- int rec = ti.find(key,r.getTokenData(),r.getFieldData(),0);\r
- if(rec<0) {\r
- return null;\r
- }\r
- r.getTokenData().pos(rec);\r
- return new Data(r.getFieldData());\r
- }\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-/**\r
- * \r
- */\r
-package org.onap.aaf.osaaf.defOrd.test;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-\r
-import org.junit.After;\r
-import org.junit.AfterClass;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.local.AbsData.Reuse;\r
-import org.onap.aaf.osaaf.defOrg.Identities;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
-\r
-/**\r
- *\r
- */\r
-public class JU_Identities {\r
-\r
- private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat";\r
- private static File fids;\r
- private static Identities ids;\r
- private static AuthzEnv env;\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @BeforeClass\r
- public static void setUpBeforeClass() throws Exception {\r
- env = new AuthzEnv();\r
- AuthzTrans trans = env.newTransNoAvg();\r
- // Note: utilize TimeTaken, from trans.start if you want to time.\r
- fids = new File(DATA_IDENTITIES);\r
- if(fids.exists()) {\r
- ids = new Identities(fids);\r
- ids.open(trans, 5000);\r
- } else {\r
- \r
- throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES \r
- + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")");\r
- }\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @AfterClass\r
- public static void tearDownAfterClass() throws Exception {\r
- AuthzTrans trans = env.newTransNoAvg();\r
- if(ids!=null) {\r
- ids.close(trans);\r
- }\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
- \r
- @Test\r
- public void test() throws IOException {\r
- Reuse reuse = ids.reuse(); // this object can be reused within the same thread.\r
- Data id = ids.find("osaaf",reuse);\r
- Assert.assertNotNull(id);\r
- System.out.println(id);\r
-\r
- id = ids.find("mmanager",reuse);\r
- Assert.assertNotNull(id);\r
- System.out.println(id);\r
-\r
- //TODO Fill out JUnit with Tests of all Methods in "Data id"\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.io.File;\r
-import java.util.Set;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Matchers;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_DefaultOrg {\r
-\r
-DefaultOrg defaultOrg;\r
-//private DefaultOrg defaultOrgMock;\r
-@Mock\r
-AuthzEnv authzEnvMock;\r
-\r
-private static final String PROPERTY_IS_REQUIRED = " property is Required";\r
-private static final String DOMAIN = "osaaf.com";\r
-private static final String REALM = "com.osaaf";\r
-private static final String NAME = "Default Organization";\r
-private static final String NO_PASS = NAME + " does not support Passwords. Use AAF";\r
-String mailHost,mailFromUserId,supportAddress;\r
-private String SUFFIX;\r
-String s;\r
-String defFile;\r
-@Mock\r
-File fIdentitiesMock;\r
-\r
-\r
-@Before\r
-public void setUp() throws OrganizationException{\r
- MockitoAnnotations.initMocks(this);\r
- PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".mailHost"), null)).thenReturn("hello");\r
- PowerMockito.when(authzEnvMock.getProperty(s=(REALM + ".supportEmail"), null)).thenReturn("notnull");\r
- PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn("src" + File.separator + "test" + File.separator + "resources" + File.separator + "test.txt");\r
- PowerMockito.when(fIdentitiesMock.exists()).thenReturn(true);\r
- //PowerMockito.when((fIdentitiesMock!=null && fIdentitiesMock.exists())).thenReturn(true);\r
- defaultOrg = new DefaultOrg(authzEnvMock);\r
-}\r
-\r
-@Test //(expected=OrganizationException.class)\r
-public void test() throws OrganizationException{\r
- //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");\r
- //defaultOrg = new DefaultOrg(authzEnvMock);\r
- assertTrue(defaultOrg != null);\r
-}\r
-\r
-\r
-@Test //(expected=OrganizationException.class)\r
-public void testMultipleCreds() throws OrganizationException{\r
- String id = "test";\r
- //PowerMockito.when(authzEnvMock.getProperty(Matchers.anyString())).thenReturn(" ");\r
- //defaultOrg = new DefaultOrg(authzEnvMock);\r
- boolean canHaveMultipleCreds;\r
- canHaveMultipleCreds = defaultOrg.canHaveMultipleCreds(id );\r
- System.out.println("value of canHaveMultipleCreds: " + canHaveMultipleCreds);\r
- assertTrue(canHaveMultipleCreds);\r
-}\r
-\r
-\r
-@Test \r
-public void testGetIdentityTypes() throws OrganizationException{\r
- Set<String> identityTypes = defaultOrg.getIdentityTypes();\r
- System.out.println("value of IdentityTypes: " + identityTypes);\r
- assertTrue(identityTypes.size() == 4);\r
-}\r
-\r
-\r
-@Test \r
-public void testGetRealm() throws OrganizationException{\r
- String realmTest = defaultOrg.getRealm();\r
- System.out.println("value of realm: " + realmTest);\r
- assertTrue(realmTest == REALM);\r
-}\r
-\r
-@Test \r
-public void testGetName() throws OrganizationException{\r
- String testName = defaultOrg.getName();\r
- System.out.println("value of name: " + testName);\r
- assertTrue(testName == NAME);\r
-}\r
-\r
-\r
-@Test \r
-public void testGetDomain() throws OrganizationException{\r
- String testDomain = defaultOrg.getDomain();\r
- System.out.println("value of domain: " + testDomain);\r
- assertTrue(testDomain == DOMAIN);\r
-}\r
-\r
-\r
-\r
-@Test\r
-public void testIsValidID(){ \r
- String Result = defaultOrg.isValidID(Matchers.anyString());\r
- System.out.println("value of res " +Result);\r
- assertNotNull(Result); \r
-}\r
-\r
-@Mock\r
-AuthzTrans authzTransMock;\r
-\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.org.OrganizationException;\r
-import org.onap.aaf.authz.org.Organization.Identity;\r
-import org.onap.aaf.osaaf.defOrg.DefaultOrg;\r
-import org.onap.aaf.osaaf.defOrg.DefaultOrgIdentity;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_DefaultOrgIdentity {\r
-\r
- private DefaultOrgIdentity defaultOrgIdentity;\r
- private DefaultOrgIdentity defaultOrgIdentityMock;\r
- \r
- @Mock\r
- AuthzTrans authzTransMock;\r
- \r
- String key="key";\r
- \r
- @Mock\r
- private DefaultOrg defaultOrgMock;\r
- @Mock\r
- private Data dataMock;\r
- @Mock\r
- private Identity identityMock;\r
- \r
- @Before\r
- public void setUp() throws OrganizationException{\r
- MockitoAnnotations.initMocks(this);\r
- defaultOrgIdentityMock = PowerMockito.mock(DefaultOrgIdentity.class);\r
- }\r
- \r
- @Test\r
- public void testEquals(){\r
- Object b = null;\r
- Boolean res = defaultOrgIdentityMock.equals(b);\r
- System.out.println("value of res " +res);\r
- }\r
- \r
- \r
- @Test\r
- public void testIsFound(){\r
- defaultOrgIdentityMock.isFound();\r
- System.out.println("value of found " +defaultOrgIdentityMock.isFound());\r
- assertFalse(defaultOrgIdentityMock.isFound());\r
- }\r
- \r
- @Test\r
- public void testIsResponsible(){\r
- defaultOrgIdentityMock.isResponsible();\r
- System.out.println("value of res " +defaultOrgIdentityMock.isResponsible());\r
- assertFalse(defaultOrgIdentityMock.isResponsible());\r
- }\r
- \r
- @Test\r
- public void testFullName(){\r
- String fullName = defaultOrgIdentityMock.fullName();\r
- System.out.println("value of fullname " +fullName);\r
- assertTrue(fullName == null);\r
- }\r
- \r
- \r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import static org.junit.Assert.*;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.junit.runner.RunWith;\r
-import org.mockito.MockitoAnnotations;\r
-import org.onap.aaf.osaaf.defOrg.DefaultOrgWarnings;\r
-import org.powermock.api.mockito.PowerMockito;\r
-import org.powermock.modules.junit4.PowerMockRunner;\r
-\r
-@RunWith(PowerMockRunner.class)\r
-public class JU_DefaultOrgWarnings {\r
- \r
- private DefaultOrgWarnings defaultOrgWarningsMock;\r
- private DefaultOrgWarnings defaultOrgWarnings;\r
- \r
- \r
- @Before\r
- public void setUp(){\r
- MockitoAnnotations.initMocks(this);\r
- \r
- defaultOrgWarningsMock = PowerMockito.mock(DefaultOrgWarnings.class);\r
- \r
- defaultOrgWarnings = new DefaultOrgWarnings();\r
- }\r
-\r
- \r
- @Test\r
- public void testApprEmailInterval() {\r
- \r
- assertEquals(259200000, defaultOrgWarnings.apprEmailInterval() );\r
- }\r
- \r
- @Test\r
- public void testCredEmailInterval() {\r
- assertEquals(604800000, defaultOrgWarnings.credEmailInterval());\r
- \r
- }\r
- \r
- @Test\r
- public void testCredExpirationWarning() {\r
- assertEquals(2592000000L, defaultOrgWarnings.credExpirationWarning());\r
- }\r
- \r
- @Test\r
- public void testEmailUrgentWarning() {\r
- assertEquals(1209600000L, defaultOrgWarnings.emailUrgentWarning());\r
- }\r
- \r
- @Test\r
- public void testRoleEmailInterval() {\r
- assertEquals(604800000L, defaultOrgWarnings.roleEmailInterval());\r
- }\r
- \r
- @Test\r
- public void testRoleExpirationWarning() {\r
- assertEquals(2592000000L, defaultOrgWarnings.roleExpirationWarning());\r
- }\r
-\r
-}\r
+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-/**\r
- * \r
- */\r
-package org.onap.aaf.osaaf.defOrg;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-\r
-import org.junit.After;\r
-import org.junit.AfterClass;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.BeforeClass;\r
-import org.junit.Test;\r
-import org.onap.aaf.authz.env.AuthzEnv;\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.local.AbsData.Reuse;\r
-import org.onap.aaf.osaaf.defOrg.Identities;\r
-import org.onap.aaf.osaaf.defOrg.Identities.Data;\r
-\r
-/**\r
- *\r
- */\r
-public class JU_Identities {\r
-\r
- private static final String DATA_IDENTITIES = "../opt/app/aaf/data/identities.dat";\r
- private static File fids;\r
- private static Identities ids;\r
- private static AuthzEnv env;\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @BeforeClass\r
- public static void setUpBeforeClass() throws Exception {\r
- env = new AuthzEnv();\r
- AuthzTrans trans = env.newTransNoAvg();\r
- // Note: utilize TimeTaken, from trans.start if you want to time.\r
- fids = new File(DATA_IDENTITIES);\r
- if(fids.exists()) {\r
- ids = new Identities(fids);\r
- ids.open(trans, 5000);\r
- } else {\r
- \r
- throw new Exception("Data File for Tests, \"" + DATA_IDENTITIES \r
- + "\" must exist before test can run. (Current dir is " + System.getProperty("user.dir") + ")");\r
- }\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @AfterClass\r
- public static void tearDownAfterClass() throws Exception {\r
- AuthzTrans trans = env.newTransNoAvg();\r
- if(ids!=null) {\r
- ids.close(trans);\r
- }\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @Before\r
- public void setUp() throws Exception {\r
- }\r
-\r
- /**\r
- * @throws java.lang.Exception\r
- */\r
- @After\r
- public void tearDown() throws Exception {\r
- }\r
- \r
- @Test\r
- public void test() throws IOException {\r
- Reuse reuse = ids.reuse(); // this object can be reused within the same thread.\r
- Data id = ids.find("osaaf",reuse);\r
- Assert.assertNotNull(id);\r
- System.out.println(id);\r
-\r
- id = ids.find("mmanager",reuse);\r
- Assert.assertNotNull(id);\r
- System.out.println(id);\r
-\r
- //TODO Fill out JUnit with Tests of all Methods in "Data id"\r
- }\r
-\r
-}\r
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
+++ /dev/null
-/*******************************************************************************
- * ============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====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.lur.aaf.test;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.AsyncContext;
-import javax.servlet.DispatcherType;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.Part;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.Lur;
-import org.onap.aaf.cadi.Permission;
-import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.Symm;
-import org.onap.aaf.cadi.Taf.LifeForm;
-import org.onap.aaf.cadi.aaf.AAFPermission;
-import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
-import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;
-import org.onap.aaf.cadi.aaf.v2_0.AAFTaf;
-import org.onap.aaf.cadi.locator.DNSLocator;
-import org.onap.aaf.cadi.lur.ConfigPrincipal;
-import org.onap.aaf.cadi.lur.LocalPermission;
-import org.onap.aaf.cadi.taf.TafResp;
-
-public class JU_Lur2_0Call {
- private static AAFConHttp aaf;
- private static PropAccess access;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- access = new PropAccess();
- aaf = new AAFConHttp(access,new DNSLocator(access,"https","localhost","8100"));
- aaf.basicAuth("testid", "whatever");
- }
-
- @Test
- public void test() throws Exception {
-
- AAFLurPerm aafLur = aaf.newLur();
-
- Principal pri = new ConfigPrincipal("testid@aaf.att.com","whatever");
- for (int i = 0; i < 10; ++i) {
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|write"),false);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|read"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|read"),true);
-
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","write"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","write"),false);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","read"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","read"),true);
-
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum.*|read"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true);
-
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum.*","read"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true);
-
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum[Qq]uat|read"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true);
-
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum[Qq]uat","read"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true);
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true);
-
-
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my.nstance|!wr*"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false);
-
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false);
-
- //Maitrayee, aren't we going to have issues if we do RegExp with "."?
- //Is it too expensive to only do Reg Ex in presence of special characters, []{}*, etc? Not sure this helps for GRID.
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kum.quat|read"),true);
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum..uat|read"),true);
-
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true); // ok if Stored Action is "*"
-
- // Key Evaluations
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:!my.*|write"),true); // ok if Stored Action is "*"
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*|write"),false); // not ok if key lengths don't match "*"
- print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:myCF|write"),true); // ok if Stored Action is "*"
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:!my.*","write"),true); // ok if Stored Action is "*"
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:myCF","write"),true); // ok if Stored Action is "*"
- print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*","write"),false); // not ok if key lengths don't match
-
- }
-
- print(aafLur, pri, new LocalPermission("bogus"),false);
-
-// try {
-// Thread.sleep(7000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
- for (int i = 0; i < 10; ++i)
- print(aafLur, pri, new LocalPermission("supergroup"),false);
-
- System.out.println("All Done");
- }
- @Test
- public void testTaf() throws Exception {
- AAFTaf<?> aaft = new AAFTaf<HttpURLConnection>(aaf,true);
-
- TafResp resp;
- // No Header
- resp = aaft.validate(LifeForm.CBLF, new Req(), null);
- assertEquals(TafResp.RESP.TRY_AUTHENTICATING, resp.isAuthenticated());
-
- String auth = "Basic " + Symm.base64.encode("testid:whatever");
- resp = aaft.validate(LifeForm.CBLF, new Req("Authorization",auth), null);
- assertEquals(TafResp.RESP.IS_AUTHENTICATED, resp.isAuthenticated());
-
- }
-// @Test
-// public void testRole() throws CadiException {
-// TestAccess ta = new TestAccess();
-// AAFLurRole1_0 aafLur = new AAFLurRole1_0(
-// ta,
-//// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=UAT/routeOffer=BAU_SE",
-// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=DEV/routeOffer=D1",
-// "m12345", "m12345pass", 50000, // dme Time
-// // 5*60000); // 5 minutes User Expiration
-// 50000, // 5 seconds after Expiration
-// 200); // High Count of items.. These do not take much memory
-//
-// Principal pri = new ConfigPrincipal("xy1234","whatever");
-// for (int i = 0; i < 10; ++i) {
-//// print(aafLur, pri, new LocalPermission("*|*|*|com.att.authz"));
-// print(aafLur, pri, new LocalPermission("service|myInstance|write"),false);
-// print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),false);
-// print(aafLur, pri, new LocalPermission("org.osaaf.cadi"),true);
-// print(aafLur, pri, new LocalPermission("global"),true);
-// print(aafLur, pri, new LocalPermission("kumquat"),false);
-// }
-//
-// print(aafLur, pri, new LocalPermission("bogus"),false);
-//
-// for (int i = 0; i < 10; ++i)
-// print(aafLur, pri, new LocalPermission("supergroup"),false);
-//
-// System.out.println("All Done");
-// }
-
-
- private void print(Lur aafLur, Principal pri, Permission perm, boolean shouldBe)
- throws CadiException {
- long start = System.nanoTime();
-
- // The Call
- boolean ok = aafLur.fish(pri, perm);
-
- assertEquals(shouldBe,ok);
- float ms = (System.nanoTime() - start) / 1000000f;
- if (ok) {
- System.out.println("Yes, part of " + perm.getKey() + " (" + ms
- + "ms)");
- } else {
- System.out.println("No, not part of " + perm.getKey() + " (" + ms
- + "ms)");
- }
- }
-
- @SuppressWarnings("rawtypes")
- public class Req implements HttpServletRequest {
- private String[] headers;
-
- public Req(String ... headers) {
- this.headers = headers;
- }
-
- public Object getAttribute(String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getAttributeNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getCharacterEncoding() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setCharacterEncoding(String env)
- throws UnsupportedEncodingException {
- // TODO Auto-generated method stub
-
- }
-
- public int getContentLength() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getContentType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ServletInputStream getInputStream() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getParameter(String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getParameterNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getParameterValues(String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Map getParameterMap() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getProtocol() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getScheme() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getServerName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getServerPort() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public BufferedReader getReader() throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRemoteAddr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRemoteHost() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setAttribute(String name, Object o) {
- // TODO Auto-generated method stub
-
- }
-
- public void removeAttribute(String name) {
- // TODO Auto-generated method stub
-
- }
-
- public Locale getLocale() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getLocales() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isSecure() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public RequestDispatcher getRequestDispatcher(String path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRealPath(String path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getRemotePort() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getLocalName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getLocalAddr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getLocalPort() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getAuthType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Cookie[] getCookies() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public long getDateHeader(String name) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getHeader(String name) {
- for(int i=1;i<headers.length;i=i+2) {
- if(headers[i-1].equals(name)) return headers[i];
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getHeaders(String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration getHeaderNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getIntHeader(String name) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public String getMethod() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getPathInfo() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getPathTranslated() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getContextPath() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getQueryString() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRemoteUser() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isUserInRole(String role) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Principal getUserPrincipal() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRequestedSessionId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRequestURI() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public StringBuffer getRequestURL() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public HttpSession getSession(boolean create) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public HttpSession getSession() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean isRequestedSessionIdValid() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromCookie() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromURL() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isRequestedSessionIdFromUrl() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public ServletContext getServletContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public AsyncContext startAsync() throws IllegalStateException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public AsyncContext startAsync(ServletRequest servletRequest,
- ServletResponse servletResponse) throws IllegalStateException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isAsyncStarted() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isAsyncSupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public AsyncContext getAsyncContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public DispatcherType getDispatcherType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean authenticate(HttpServletResponse response)
- throws IOException, ServletException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void login(String username, String password)
- throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void logout() throws ServletException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Collection<Part> getParts() throws IOException, ServletException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Part getPart(String name) throws IOException, ServletException {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-}
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
<dependency>
<!--
- ============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.
- *
+ * ============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.authz</groupId>
+ <groupId>osaaf</groupId>
<artifactId>parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <name>aaf-authz</name>
+ <version>2.1.0-SNAPSHOT</version>
+ <name>AAF Overall Parent</name>
<packaging>pom</packaging>
- <url>https://github.com/att/AAF</url>
-
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>1.1.0</version>
- </parent>
-
-
- <developers>
- <developer>
- <name>Jonathan Gathman</name>
- <email></email>
- <organization>ATT</organization>
- <organizationUrl></organizationUrl>
- </developer>
- </developers>
- <description>This module is used to organize all of the common SWM (Software Manager)
- artifacts and capabilities that are inherited by all modules that are SWM
- packaged. This prevents duplication of these common artifacts, plugins, and
- other settings and provides a single place to support this configuration.
- </description>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <skipTests>false</skipTests>
- <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.dme2Version>3.1.200</project.dme2Version>
- <!-- SONAR -->
- <jacoco.version>0.7.7.201606060606</jacoco.version>
- <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>
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <skipTests>${skipTests}</skipTests>
- <includes>
- <include>**/JU*.java</include>
- </includes>
- <excludes>
-
- <exclude>**/JU_DataFile.java</exclude>
- <exclude>**/JU_ArtiDAO.java</exclude>
- <exclude>**/JU_CertDAO.java</exclude>
- <exclude>**/JU_FastCalling.java</exclude>
- <exclude>**/JU_NsDAO.java</exclude>
- <!-- <exclude>**/authz-cass/**</exclude> -->
- <!-- <exclude>**/JU_UseCase1.java</exclude> -->
- <exclude>**/JU_RoleDAO.java</exclude>
- <exclude>**/JU_PermDAO.java</exclude>
- <exclude>**/JU_Question.java</exclude>
- <!-- <exclude>**/JU_NS.java</exclude> -->
- <exclude>**/JU_HistoryDAO.java</exclude>
- <exclude>**/JU_DelegateDAO.java</exclude>
- <exclude>**/JU_CredDAO.java</exclude>
- <exclude>**/JU_CacheInfoDAO.java</exclude>
- <exclude>**/JU_ApprovalDAO.java</exclude>
- <!-- <exclude>**/JU_Define.java</exclude> -->
- <exclude>**/JU_Identities.java</exclude>
- <exclude>**/JU_AuthzTransFilter.java</exclude>
- <exclude>**/JU_CachingFileAccess.java</exclude>
- <!-- <exclude>**/AbsServiceTest.java</exclude> -->
- <!-- <exclude>**/JU_DefaultOrg.java</exclude> -->
- <exclude>**/JU_FileServer.java</exclude>
- <exclude>**/JU_DirectAAFLur.java</exclude>
- <exclude>**/JU_AuthAPI.java</exclude>
- <exclude>**/JU_GwAPI.java</exclude>
- <exclude>**/JU_NsDAO.java</exclude>
- <exclude>**/JU_Delete.java</exclude>
- <exclude>**/JU_Create.java</exclude>
- <exclude>**/JU_Admin.java</exclude>
- <exclude>**/JU_Attrib.java</exclude>
- <exclude>**/JU_Describe.java</exclude>
- <exclude>**/JU_ListUsersInRole.java</exclude>
- <exclude>**/JU_ListUsersWithPerm.java</exclude>
- <exclude>**/JU_Responsible.java</exclude>
-
-
-
-
- <!-- <exclude>**/JU_Perm_2_0*.java</exclude> -->
- <!-- <exclude>**/JU_Role_2_0*.java</exclude> -->
-
- </excludes>
-
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId>
- <version>1.3</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>xjc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <schemaDirectory>src/main/xsd</schemaDirectory>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jarsigner-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>sign</id>
- <goals>
- <goal>sign</goal>
- </goals>
- <configuration>
- <!-- skip>${skipSigning}</skip -->
- <archive>target/${project.artifactId}-${project.version}.jar</archive>
- </configuration>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- <configuration>
- <archive>target/${project.artifactId}-${project.version}.jar</archive>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <skip>true</skip>
- <alias>aaf</alias>
- <keystore>/Volumes/Data/src/cadi/keys/aaf_cadi.jks</keystore>
- <storepass>Surprise!</storepass>
- <keypass>Surprise!</keypass>
- <verbose>true</verbose>
- <certs>true</certs>
- </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.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.7</version>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
<configuration>
- <formats>
- <format>html</format>
- <format>xml</format>
- </formats>
+ <skip>true</skip>
</configuration>
</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>
- </pluginManagement>
+ </plugins>
</build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
-
-
- </dependencies>
-
<modules>
+ <module>auth/auth-client</module>
+ <module>misc</module>
+ <module>cadi</module>
+ <module>auth</module>
</modules>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>env</artifactId>
- <version>${project.innoVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.inno</groupId>
- <artifactId>log4j</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.inno</groupId>
- <artifactId>xgen</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-client</artifactId>
- <version>${project.cadiVersion}</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.onap.aaf.cadi</groupId>
- <artifactId>cadi-aaf</artifactId>
- <version>${project.cadiVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-client</artifactId>
- <version>${project.interfaceVersion}</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-cass</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-batch</artifactId>
- <version>${project.interfaceVersion}</version>
- </dependency>
-
-
-
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-cmd</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>authz-gw</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.att.aft</groupId>
- <artifactId>dme2</artifactId>
- <version>${project.dme2Version}</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>9.0.3.v20130506</version>
- </dependency>
-
- <dependency>
- <groupId>com.datastax.cassandra</groupId>
- <artifactId>cassandra-all</artifactId>
- <version>2.1.10</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.datastax.cassandra</groupId>
- <artifactId>cassandra-driver-core</artifactId>
- <!-- version>1.0.3</version -->
- <!-- version>1.0.5</version -->
- <version>2.1.10</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.5</version>
- </dependency>
-
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.5</version>
- </dependency>
-
-
- </dependencies>
- </dependencyManagement>
+
+
<distributionManagement>
<repository>
- <id>ecomp-releases</id>
- <name>AAF Release Repository</name>
- <url>${nexusproxy}${releaseNexusPath}</url>
+ <id>nexus</id>
+ <name>attarch-releases</name>
+ <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases</url>
</repository>
<snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>AAF Snapshot Repository</name>
- <url>${nexusproxy}${snapshotNexusPath}</url>
+ <id>nexus</id>
+ <name>attarch-snapshots</name>
+ <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots</url>
</snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
</distributionManagement>
-
+
</project>