From 13494d99a913817342da23ffc58029bdc4203814 Mon Sep 17 00:00:00 2001 From: "mark.j.leonard" Date: Mon, 11 Mar 2019 17:50:07 +0000 Subject: Refactor auth classes and add tests Add new tests to give better coverage of the authorization classes. Refactor the core class for readability. Change-Id: I2be467d8f4492249a0c29be8b108bb2bce2818dd Issue-ID: AAI-2229 Signed-off-by: mark.j.leonard --- .../org/onap/aai/auth/AAIMicroServiceAuthCore.java | 100 +++++++++++---------- .../org/onap/aai/babel/config/BabelAuthConfig.java | 5 +- 2 files changed, 57 insertions(+), 48 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java index ddbc002..0eec7e1 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2019 European Software Marketing Ltd. + * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2017-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +27,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; @@ -44,15 +46,15 @@ public class AAIMicroServiceAuthCore { private static LogHelper applicationLogger = LogHelper.INSTANCE; - private static final String CONFIG_HOME = System.getProperty("CONFIG_HOME"); - - public static final String FILESEP = - (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - public static final String APPCONFIG_DIR = - (CONFIG_HOME == null) ? System.getProperty("APP_HOME") + FILESEP + "appconfig" : CONFIG_HOME; - - private static String appConfigAuthDir = APPCONFIG_DIR + FILESEP + "auth"; - private static String defaultAuthFileName = appConfigAuthDir + FILESEP + "auth_policy.json"; + /** + * The default policy file is expected to be located in either one of + *