From 5e4b48acc875f88e2958b4469cb889222ca2f11c Mon Sep 17 00:00:00 2001 From: sstoykov Date: Mon, 26 Nov 2018 15:45:47 -0500 Subject: Removed edit attribute code Removed obsolete code related to the edit attributes feature from sparky-be. Issue-ID: AAI-1956 Change-Id: I25754ec5440ce199ca5678b2074a1f090dde46ab Signed-off-by: sstoykov --- .../editattributes/AttributeEditProcessor.java | 178 ---------- .../sparky/editattributes/AttributeUpdater.java | 360 --------------------- .../editattributes/UserAuthorizationReader.java | 75 ----- .../aai/sparky/editattributes/UserValidator.java | 63 ---- .../sparky/editattributes/entity/EditRequest.java | 65 ---- .../exception/AttributeUpdateException.java | 58 ---- .../org/onap/aai/sparky/logging/AaiUiMsgs.java | 14 - .../aai/sparky/security/filter/LoginFilter.java | 15 +- .../main/resources/logging/AAIUIMsgs.properties | 28 -- 9 files changed, 4 insertions(+), 852 deletions(-) delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java (limited to 'sparkybe-onap-service/src/main') diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java deleted file mode 100644 index fbdbb94..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes; - -import java.io.UnsupportedEncodingException; -import java.util.Map; - -import org.apache.camel.Exchange; -import org.apache.camel.component.restlet.RestletConstants; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; -import org.onap.aai.cl.mdc.MdcContext; -import org.onap.aai.restclient.client.OperationResult; -import org.onap.aai.sparky.editattributes.entity.EditRequest; -import org.onap.aai.sparky.logging.AaiUiMsgs; -import org.onap.aai.sparky.util.NodeUtils; -import org.restlet.Request; -import org.restlet.Response; -import org.restlet.data.ClientInfo; -import org.restlet.data.Cookie; -import org.restlet.data.MediaType; -import org.restlet.data.Status; -import org.restlet.util.Series; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * The Class AttributeEditProcessor. - */ -public class AttributeEditProcessor { - - private static final Logger LOG = - LoggerFactory.getInstance().getLogger(AttributeEditProcessor.class); - - private ObjectMapper mapper; - private AttributeUpdater attrUpdater; - - public AttributeEditProcessor(AttributeUpdater attributeUpdater) { - this.attrUpdater = attributeUpdater; - - this.mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_EMPTY); - } - - public void editAttribute(Exchange exchange) { - - Object xTransactionId = exchange.getIn().getHeader("X-TransactionId"); - - if (xTransactionId == null) { - xTransactionId = NodeUtils.getRandomTxnId(); - } - - Object partnerName = exchange.getIn().getHeader("X-FromAppId"); - if (partnerName == null) { - partnerName = "Browser"; - } - - Request request = exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class); - - /* - * Disables automatic Apache Camel Restlet component logging which prints out an undesirable log - * entry which includes client (e.g. browser) information - */ - request.setLoggable(false); - - ClientInfo clientInfo = request.getClientInfo(); - MdcContext.initialize((String) xTransactionId, "AAI-UI", "", (String) partnerName, - clientInfo.getAddress() + ":" + clientInfo.getPort()); - - String payload = exchange.getIn().getBody(String.class); - EditRequest editRequest = null; - OperationResult operationResult = new OperationResult(); - - Response response = exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class); - response.setStatus(Status.SUCCESS_OK); // 200 is assumed unless an actual exception occurs (a failure is still a valid response) - - boolean wasErrorDuringProcessing = false; - String errorMessage = null; - - - try { - - if (payload != null && !payload.isEmpty()) { - editRequest = mapper.readValue(payload, EditRequest.class); - - if (editRequest != null) { - - String attUid = getAttUid(request.getCookies()); - String objectUri = editRequest.getEntityUri(); - Map attributeValues = editRequest.getAttributes(); - - if (attUid != null && !attUid.isEmpty() && objectUri != null && !objectUri.isEmpty() - && attributeValues != null && !attributeValues.isEmpty()) { - - LOG.info(AaiUiMsgs.ATTRIBUTES_HANDLING_EDIT, objectUri, editRequest.toString()); - - operationResult = attrUpdater.updateObjectAttribute(objectUri, attributeValues, attUid); - - boolean wasSuccess = (operationResult.getResultCode() == 200); - String message = String.format("Edit Attributes completed with Result Code : %s (%s).", - operationResult.getResultCode(), wasSuccess ? "success" : "failed"); - - LOG.info(AaiUiMsgs.INFO_GENERIC, message); - } - } - } else { - wasErrorDuringProcessing = true; - errorMessage = "Empty payload provided, need details to complete request"; - } - } catch (Exception exc) { - LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage()); - operationResult.setResult(500, "Error encountered while trying to update attributes."); - response.setStatus(Status.SERVER_ERROR_INTERNAL); - } - - if(wasErrorDuringProcessing) { - LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_MESSAGE, errorMessage); - } - - response.setEntity(operationResult.getResult(), MediaType.APPLICATION_JSON); - exchange.getOut().setBody(response); - } - - /** - * Gets the att uid. - * - * @param request the request - * @return the att uid - * @throws UnsupportedEncodingException the unsupported encoding exception - */ - public String getAttUid(Series cookies) throws UnsupportedEncodingException { - String attId = ""; - if (cookies == null) { - LOG.error(AaiUiMsgs.COOKIE_NOT_FOUND); - return attId; - } - for (Cookie cookie : cookies) { - if (cookie.getName().equals("attESHr")) { - // This cookie is of the form : - // "FIRSTNAME|LASTNAME|emailname@domain.com|||ab1234||fl6789,RBFMSKQ," - // + "Z9V2298,9762186|YNNNNNNNNNNNNNYNNYYNNNNN|FIRSTNAME|EY6SC9000|" - // we are to extract fl6789 from this which would be the attuid for the user. - String value = cookie.getValue(); - value = java.net.URLDecoder.decode(value, "UTF-8"); - LOG.info(AaiUiMsgs.COOKIE_FOUND, value); - String[] values = value.split("\\|"); - if (values.length > 7) { - attId = (values[7].split(","))[0]; - - String initials = (values[0].substring(0, 1) + values[1].substring(0, 1)).toLowerCase(); - if (attId.startsWith(initials)) { - return attId; - } - } - } - } - return attId; - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java deleted file mode 100644 index 23928a5..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java +++ /dev/null @@ -1,360 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.ws.rs.core.UriBuilder; - -import org.eclipse.persistence.dynamic.DynamicType; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; -import org.onap.aai.restclient.client.OperationResult; -import org.onap.aai.sparky.config.oxm.OxmEntityLookup; -import org.onap.aai.sparky.config.oxm.OxmModelLoader; -import org.onap.aai.sparky.dal.ActiveInventoryAdapter; -import org.onap.aai.sparky.editattributes.exception.AttributeUpdateException; -import org.onap.aai.sparky.logging.AaiUiMsgs; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; - -/** - * Class to process attribute updates on AAI objects. - * - * - */ -public class AttributeUpdater { - - /** - * The Class AaiEditObject. - */ - public class AaiEditObject { - String objectType; - String rootElement; - String keyName; - String keyValue; - String schemaVersion; - - /** - * Instantiates a new aai edit object. - */ - public AaiEditObject() { - - } - - /** - * Instantiates a new aai edit object. - * - * @param objectType the object type - * @param idName the id name - * @param schemaVersion the schema version - */ - public AaiEditObject(String objectType, String idName, String schemaVersion) { - super(); - this.objectType = objectType; - this.keyName = idName; - this.schemaVersion = schemaVersion; - } - - public String getObjectType() { - return objectType; - } - - public void setObjectType(String objectType) { - this.objectType = objectType; - } - - public String getKeyName() { - return keyName; - } - - public void setKeyName(String idName) { - this.keyName = idName; - } - - public String getSchemaVersion() { - return schemaVersion; - } - - public void setSchemaVersion(String schemaVersion) { - this.schemaVersion = schemaVersion; - } - - public void setKeyValue(String keyValue) { - this.keyValue = keyValue; - } - - public String getKeyValue() { - return keyValue; - } - - public String getRootElement() { - return rootElement; - } - - public void setRootElement(String rootElement) { - this.rootElement = rootElement; - } - - } - - private static final Logger LOG = LoggerFactory.getInstance().getLogger(AttributeUpdater.class); - private static final String MESSAGE_VERSION_EXTRACTION_REGEX = "\\/(v[0-9]+)"; - private static final String ATTRIBUTES_UPDATED_SUCCESSFULLY = "Attributes updated successfully"; - private static final String ATTRIBUTES_NOT_UPDATED = "Attributes not updated. "; - - private ActiveInventoryAdapter aaiAdapter; - private UserValidator validator; - private OxmModelLoader oxmModelLoader; - private OxmEntityLookup oxmEntityLookup; - private String domain; - - /** - * Instantiates a new attribute updater. - * @throws AttributeUpdateException - */ - public AttributeUpdater(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup, ActiveInventoryAdapter activeInventoryAdapter,String domain) throws AttributeUpdateException { - super(); - this.oxmModelLoader = oxmModelLoader; - this.oxmEntityLookup = oxmEntityLookup; - this.aaiAdapter = activeInventoryAdapter; - this.domain = domain; - - try { - this.validator = new UserValidator(); - } catch (Exception exc) { - LOG.error(AaiUiMsgs.ATTRIBUTES_ERROR_GETTING_AAI_CONFIG_OR_ADAPTER, exc.getLocalizedMessage()); - throw new AttributeUpdateException(exc); - } - } - - protected String getResourceBasePath() { - - String versionStr = null; - if (oxmModelLoader != null) { - versionStr = String.valueOf(oxmModelLoader.getOxmApiVersion()); - } - - return "/" + domain + "/v" + versionStr; - - } - - protected URI getBaseUri() { - return UriBuilder - .fromUri("https://" + aaiAdapter.getEndpointConfig().getEndpointIpAddress() + ":" - + aaiAdapter.getEndpointConfig().getEndpointServerPort() + getResourceBasePath()) - .build(); - } - - /** - * Update object attribute. - * - * @param objectUri - Valid URI of the object as per OXM model. - * @param attributeValues - Map of (attribute-name & attribute-value) for - * any attributes to be updated to the value. - * @param attUid - ATTUID of the user requesting the update. - * @return - OperationResult with success or failure reason. - */ - public OperationResult updateObjectAttribute(String objectUri, Map attributeValues, String attUid) { - OperationResult result = new OperationResult(); - LOG.info(AaiUiMsgs.ATTRIBUTES_UPDATE_METHOD_CALLED, objectUri, attUid, String.valueOf(attributeValues)); - if (!validator.isAuthorizedUser(attUid)) { - result.setResultCode(403); - result.setResult(String.format("User %s is not authorized for Attributes update ", attUid)); - LOG.error(AaiUiMsgs.ATTRIBUTES_USER_NOT_AUTHORIZED_TO_UPDATE, attUid); - return result; - } - - AaiEditObject object = null; - - try { - object = getEditObjectFromUri(objectUri); - } catch (AttributeUpdateException exc) { - result.setResultCode(400); - result.setResult(ATTRIBUTES_NOT_UPDATED); - LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage()); - return result; - } - try { - String jsonPayload = convertEditRequestToJson(object, attributeValues); - String patchUri = getBaseUri().toString() + getRelativeUri(objectUri); - - - /* - * FIX ME: Dave Adams, 8-Nov-2017 - */ - - //result = aaiAdapter.doPatch(patchUri, jsonPayload, MediaType.APPLICATION_JSON); - - result = new OperationResult(); - result.setResultCode(404); - - if (result.getResultCode() == 200) { - result.setResult(ATTRIBUTES_UPDATED_SUCCESSFULLY); - String message = result.getResult() + " for " + objectUri; - LOG.info(AaiUiMsgs.INFO_GENERIC, message); - } else { - String message = ATTRIBUTES_NOT_UPDATED + " For: " + objectUri + ". AAI PATCH Status Code : " - + result.getResultCode() + ". Error : " + result.getResult(); - LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_MESSAGE, message); - } - } catch (AttributeUpdateException exc) { - result.setResultCode(500); - result.setResult(ATTRIBUTES_NOT_UPDATED + exc.getLocalizedMessage()); - LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage()); - } - return result; - - } - - /** - * Gets the relative uri. - * - * @param objectUri the object uri - * @return the relative uri - */ - public String getRelativeUri(String objectUri) { - String tempUri = objectUri; - final Pattern pattern = Pattern.compile(MESSAGE_VERSION_EXTRACTION_REGEX, Pattern.DOTALL); - Matcher matcher = pattern.matcher(objectUri); - while (matcher.find()) { - tempUri = objectUri.substring(matcher.end()); - } - if (!tempUri.startsWith("/")) { - tempUri = "/" + tempUri; - } - return tempUri; - } - - /** - * Gets the edits the object from uri. - * - * @param objectUri the object uri - * @return the edits the object from uri - * @throws AttributeUpdateException the attribute update exception - */ - public AaiEditObject getEditObjectFromUri(String objectUri) throws AttributeUpdateException { - - AaiEditObject object = new AaiEditObject(); - String version = getVersionFromUri(objectUri); - - if ( null == version ) { - version = "v" + String.valueOf(oxmModelLoader.getOxmApiVersion()); - } - object.setSchemaVersion(version); - - String[] values = objectUri.split("/"); - if (values.length < 2) { - throw new AttributeUpdateException("Invalid or malformed object URI : " + objectUri); - } - String keyValue = values[values.length - 1]; - String rootElement = values[values.length - 2]; - - object.setKeyValue(keyValue); - object.setRootElement(rootElement); - - String objectJavaType = null; - Map entityTypeLookup = oxmEntityLookup.getEntityTypeLookup(); - DynamicType entity = entityTypeLookup.get(rootElement); - if ( null != entity ) { - objectJavaType = entity.getName(); - String message = "Descriptor: Alias: " + objectJavaType + " : DefaultRootElement: " - + rootElement; - LOG.debug(AaiUiMsgs.DEBUG_GENERIC, message); - } - - - if (objectJavaType == null) { - throw new AttributeUpdateException( - "Object type could not be determined from the URI : " + objectUri); - } - object.setObjectType(objectJavaType); - - // Set key attribute name - final List primaryKeys = entity.getDescriptor().getPrimaryKeyFieldNames(); - - if (primaryKeys.isEmpty()) { - throw new AttributeUpdateException("Object primary key not found in OXM version " + version); - } - - for (int i = 0; i < primaryKeys.size(); i++) { - final String primaryKey = primaryKeys.get(i); - if (primaryKey.indexOf("/text()") != -1) { - primaryKeys.set(i, primaryKey.replace("/text()", "")); - } - } - object.setKeyName(primaryKeys.iterator().next()); - - return object; - } - - /** - * Gets the version from uri. - * - * @param objectUri the object uri - * @return the version from uri - * @throws AttributeUpdateException the attribute update exception - */ - private String getVersionFromUri(String objectUri) throws AttributeUpdateException { - final Pattern pattern = Pattern.compile(MESSAGE_VERSION_EXTRACTION_REGEX, Pattern.DOTALL); - Matcher matcher = pattern.matcher(objectUri); - String messageSchemaVersion = null; - while (matcher.find()) { - messageSchemaVersion = matcher.group(1); - break; - } - return messageSchemaVersion; - } - - /** - * Convert edit request to json. - * - * @param object the object - * @param attributeValues the attribute values - * @return the string - * @throws AttributeUpdateException the attribute update exception - */ - private static String convertEditRequestToJson(AaiEditObject object, - Map attributeValues) throws AttributeUpdateException { - - ObjectMapper mapper = new ObjectMapper(); - mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy()); - ObjectWriter ow = mapper.writer(); - - Map patchAttributes = new HashMap<>(); - patchAttributes.put(object.getKeyName(), object.getKeyValue()); - patchAttributes.putAll(attributeValues); - - try { - return ow.writeValueAsString(patchAttributes); - } catch (JsonProcessingException exc) { - throw new AttributeUpdateException("Caught a JPE while creating PATCH request body = ", exc); - } - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java deleted file mode 100644 index 170ed5f..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Reads user IDs from a file. Each line in the user authorization file should contain a single user - * ID. For example, - * - *
- * user1
- * user2
- * 
- */ -public class UserAuthorizationReader { - - private File userAuthorizationFile; - - /** - * Set the user authorization file. - * - * @param file a user authorization file - */ - public UserAuthorizationReader(File file) { - this.userAuthorizationFile = file; - } - - /** - * Gets user IDs from a file. - * - * @return a list of user IDs - * @throws IOException if there is a problem reading the user configuration file - */ - public List getUsers() throws IOException { - List userList = new ArrayList<>(); - try (Stream stream = Files.lines(getUserAuthorizationFile().toPath())) { - userList.addAll(stream.map(String::trim).collect(Collectors.toList())); - } - return userList; - } - - // Getters and setters - public File getUserAuthorizationFile() { - return userAuthorizationFile; - } - - public void setUserAuthorizationFile(File file) { - this.userAuthorizationFile = file; - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java deleted file mode 100644 index 83b3932..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; -import org.onap.aai.sparky.logging.AaiUiMsgs; -import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; - -/** - * Validates users against a user authorization file. - */ -public class UserValidator { - - private static final Logger LOG = LoggerFactory.getInstance().getLogger(UserValidator.class); - private static final String USER_AUTH_FILE = - SparkyConstants.AUTHORIZED_USERS_FILE_LOCATION; - - private UserAuthorizationReader userAuthorizationReader = - new UserAuthorizationReader(new File(USER_AUTH_FILE)); - - /** - * Returns true if the user is authorized. - * - * @param userId a user identifier - * @return true if the user ID is present in the user authorization file - */ - public boolean isAuthorizedUser(String userId) { - if (userId != null && !userId.isEmpty()) { - try { - List users = userAuthorizationReader.getUsers(); - return users.contains(userId); - } catch (IOException exc) { - LOG.error(AaiUiMsgs.USER_AUTHORIZATION_FILE_UNAVAILABLE, userId); - return false; - } - } else { - return false; - } - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java deleted file mode 100644 index eb34eab..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes.entity; - -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The Class EditRequest. - */ -public class EditRequest { - - @JsonProperty("entity-uri") - private String entityUri; - - @JsonProperty("entity-type") - private String entityType; - - @JsonProperty("attributes") - private Map attributes = new HashMap<>(); - - public String getEntityUri() { - return entityUri; - } - - public void setEntityUri(String entityUri) { - this.entityUri = entityUri; - } - - public String getEntityType() { - return entityType; - } - - public void setEntityType(String entityType) { - this.entityType = entityType; - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java deleted file mode 100644 index 8ce56bd..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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.aai.sparky.editattributes.exception; - -/** - * The Class AttributeUpdateException. - */ -public class AttributeUpdateException extends Exception { - - private static final long serialVersionUID = 1L; - - /** - * Attribute Edit specific Exception Class. - * - * @param exc the exc - */ - - public AttributeUpdateException(Exception exc) { - super(exc); - } - - /** - * Instantiates a new attribute update exception. - * - * @param message the message - */ - public AttributeUpdateException(String message) { - super(message); - } - - /** - * Instantiates a new attribute update exception. - * - * @param message the message - * @param exc the exc - */ - public AttributeUpdateException(String message, Exception exc) { - super(message, exc); - } -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java index c86f5b1..90a1bd2 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java @@ -310,20 +310,6 @@ public enum AaiUiMsgs implements LogMessageEnum { AAI_RETRIEVAL_FAILED_GENERIC, /** Arguments: {0} = Self Link */ AAI_RETRIEVAL_FAILED_FOR_SELF_LINK, - /** Arguments: {0} = Exception */ - ATTRIBUTES_NOT_UPDATED_EXCEPTION, - /** Arguments: {0} = Message */ - ATTRIBUTES_NOT_UPDATED_MESSAGE, - /** Arguments: {0} = Exception */ - ATTRIBUTES_ERROR_GETTING_AAI_CONFIG_OR_ADAPTER, - /** Arguments: {0} = Schema File URI */ - ATTRIBUTES_ERROR_LOADING_MODEL_VERSION, - /** Arguments: {0} = Request URI {1} = Edit Request Body */ - ATTRIBUTES_HANDLING_EDIT, - /** Arguments: {0} = Object URI {1} = Attribute ID {2} Attribute Values */ - ATTRIBUTES_UPDATE_METHOD_CALLED, - /** Arguments: {0} = Attribute ID */ - ATTRIBUTES_USER_NOT_AUTHORIZED_TO_UPDATE, /** Arguments: {0} = Cookie */ COOKIE_FOUND, /** No argument */ diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/filter/LoginFilter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/filter/LoginFilter.java index c566e14..bcb7ba2 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/filter/LoginFilter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/filter/LoginFilter.java @@ -123,17 +123,10 @@ public class LoginFilter implements Filter { // All other requests require ECOMP Portal authentication if (EcompSso.validateEcompSso(request) == null) { String redirectURL, logMessage; - if (request.getRequestURI().contains("/editAttributes")) { - // If request is for Edit Attributes UI, redirect straight to the application. - String appPath = request.getRequestURI().substring(request.getContextPath().length() + 1) - + (request.getQueryString() != null ? ("?" + request.getQueryString()) : ""); - redirectURL = SSOUtil.getECOMPSSORedirectURL(request, response, appPath); - logMessage = "Unauthenticated Edit Attributes UI login attempt."; - } else { - // Redirect to Portal UI - redirectURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); - logMessage = "Unauthorized login attempt."; - } + + // Redirect to Portal UI + redirectURL = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); + logMessage = "Unauthorized login attempt."; LOG.debug(AaiUiMsgs.LOGIN_FILTER_DEBUG, logMessage + diff --git a/sparkybe-onap-service/src/main/resources/logging/AAIUIMsgs.properties b/sparkybe-onap-service/src/main/resources/logging/AAIUIMsgs.properties index 94196e2..e9c61c9 100644 --- a/sparkybe-onap-service/src/main/resources/logging/AAIUIMsgs.properties +++ b/sparkybe-onap-service/src/main/resources/logging/AAIUIMsgs.properties @@ -122,14 +122,6 @@ DATA_CACHE_SUCCESS=\ AAIUI00025D|\ InMemoryEntityCache cached data with key = {0} -ATTRIBUTES_UPDATE_METHOD_CALLED=\ - AAIUI00026I|\ - updateObjectAttribute called for : {0} ATTUID : {1} Attributes : {2} - -ATTRIBUTES_HANDLING_EDIT=\ - AAIUI00027I|\ - Handling Edit Attributes: requestUri = {0} Body : {1} - RESTFULL_OP_COMPLETE=\ AAIUI00028I|\ doRestfulOperation() operation for {0} execution time = {1} ms for link = {2}, ResultCode = {3} @@ -329,14 +321,6 @@ EXECUTOR_SERV_EXCEPTION=\ AAIUI3003E|\ Thread: {0}. The following exception has occurred: {1} -ATTRIBUTES_NOT_UPDATED_EXCEPTION=\ - AAIUI3004E|\ - Attributes not updated. {0} - -ATTRIBUTES_NOT_UPDATED_MESSAGE=\ - AAIUI3005E|\ - {0} - SYNC_NOT_VALID_STATE_DURING_REQUEST=\ AAIUI3006E|\ Sync requested while synchronizer not in valid state. Current internal state: {0} @@ -493,10 +477,6 @@ PEGGING_ERROR=\ AAIUI30044E|\ Pegging UNKNOWN_EXCEPTION due to unexpected exception = {0} -ATTRIBUTES_ERROR_LOADING_MODEL_VERSION=\ - AAIUI30045E|\ - Model Version Error. {0} Not Found or not loaded successfully. - INVALID_REQUEST=\ AAIUI30046E|\ {0} @@ -589,10 +569,6 @@ RESTFULL_OP_ERROR_VERBOSE=\ AAIUI30069E|\ Error retrieving link: {0} from restful endpoint due to error: {1} -ATTRIBUTES_ERROR_GETTING_AAI_CONFIG_OR_ADAPTER=\ - AAIUI30070E|\ - Error in getting AAI configuration or Adaptor: {0} - USER_AUTHORIZATION_FILE_UNAVAILABLE=\ AAIUI30071E|\ User authorization file unavailable. User {0} cannot be authorized. @@ -609,10 +585,6 @@ FILE_NOT_FOUND=\ AAIUI30074E|\ Failed to find file: {0} -ATTRIBUTES_USER_NOT_AUTHORIZED_TO_UPDATE=\ - AAIUI30075E|\ - User {0} is not authorized for Attributes update - SELF_LINK_NULL_EMPTY_RESPONSE=\ AAIUI30076E|\ AIN - Failed to process null or empty pathed self link response -- cgit 1.2.3-korg