diff options
author | Ravindra Bakkamanthala <rb7147@att.com> | 2017-05-31 15:54:24 -0400 |
---|---|---|
committer | Ravindra Bakkamanthala <rb7147@att.com> | 2017-05-31 15:57:02 -0400 |
commit | d9007d680d19734d5dc106479784c420236cca4b (patch) | |
tree | b3356847c3d6e1543098b447c1df7d49e7118652 /PolicyEngineUtils | |
parent | 6a5e800771311208c66ad79ce1bdf76affd144b2 (diff) |
[Policy-17] Removed the sql scripts from sdk app
Change-Id: I5b017aad569014c7f12eab35e1dbd1c215f90ebe
Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'PolicyEngineUtils')
3 files changed, 64 insertions, 28 deletions
diff --git a/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFEnvironment.java b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFEnvironment.java new file mode 100644 index 000000000..dd599cb85 --- /dev/null +++ b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFEnvironment.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * 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========================================================= + */ +package org.openecomp.policy.utils; + +public enum AAFEnvironment { + /* + * Enumeration for the Resource Node Naming. Add here if required. + */ + DEVL, + TEST, + PROD +} diff --git a/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClient.java b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClient.java index 0c8de2702..3955e944a 100644 --- a/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClient.java +++ b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClient.java @@ -1,28 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * 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========================================================= + */ package org.openecomp.policy.utils; import java.lang.reflect.Method; import java.util.Properties; public interface AAFPolicyClient { - /* - * Enumeration for the Resource Node Naming. Add here if required. - */ - String AAF_DEFAULT_CLASS = "org.openecomp.policy.utils.AAFPolicyClientImpl"; - public enum Environment{ - DEVL, - TEST, - PROD - } + public boolean checkAuth(String userName, String pass); public void updateProperties(Properties properties) throws AAFPolicyException; public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action); public boolean checkPerm(String userName, String pass, String type, String instance, String action); public static AAFPolicyClient getInstance(Properties properties) throws AAFPolicyException{ try { - Class<?> aafPolicyClient = Class.forName(properties.getProperty("aafClient.impl.className", AAF_DEFAULT_CLASS)); + Class<?> aafPolicyClient = Class.forName(properties.getProperty("aafClient.impl.className", AAFPolicyClientImpl.class.getName())); Method method = aafPolicyClient.getMethod("getInstance", Properties.class); - AAFPolicyClient instance = (AAFPolicyClient) method.invoke(null, properties); - return instance; + return (AAFPolicyClient) method.invoke(null, properties); } catch (Exception e) { throw new AAFPolicyException(e); } diff --git a/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClientImpl.java b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClientImpl.java index bd640261f..a1c489922 100644 --- a/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClientImpl.java +++ b/PolicyEngineUtils/src/main/java/org/openecomp/policy/utils/AAFPolicyClientImpl.java @@ -41,7 +41,7 @@ import com.att.cadi.config.Config; * */ public class AAFPolicyClientImpl implements AAFPolicyClient{ - private static Logger LOGGER = Logger.getLogger(AAFPolicyClientImpl.class.getName()); + private static Logger logger = Logger.getLogger(AAFPolicyClientImpl.class.getName()); private static final String ENVIRONMENT = "ENVIRONMENT"; @@ -80,14 +80,14 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ */ public static synchronized AAFPolicyClientImpl getInstance(Properties properties) throws AAFPolicyException{ if(instance == null) { - LOGGER.info("Creating AAFClient Instance "); + logger.info("Creating AAFClient Instance "); instance = new AAFPolicyClientImpl(properties); } return instance; } // To set Property values && Connections. - private void setup(Properties properties) throws AAFPolicyException { + private static void setup(Properties properties) throws AAFPolicyException { if(properties!=null && !properties.isEmpty()){ props = System.getProperties(); props.setProperty("AFT_LATITUDE", properties.getProperty("AFT_LATITUDE", DEFAULT_AFT_LATITUDE)); @@ -101,9 +101,9 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ props.setProperty(Config.AAF_URL, properties.getProperty(Config.AAF_URL)); }else{ // Set Default values. - if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(Environment.TEST.toString())){ + if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.TEST.toString())){ props.setProperty(Config.AAF_URL, TEST_AAF_URL); - }else if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(Environment.PROD.toString())){ + }else if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.PROD.toString())){ props.setProperty(Config.AAF_URL, PROD_AAF_URL); aftEnv = PROD_AFT_ENVIRONMENT; }else{ @@ -114,7 +114,7 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ props.setProperty(Config.AAF_USER_EXPIRES, properties.getProperty(Config.AAF_USER_EXPIRES, DEFAULT_AAF_USER_EXPIRES)); props.setProperty(Config.AAF_HIGH_COUNT, properties.getProperty(Config.AAF_HIGH_COUNT, DEFAULT_AAF_HIGH_COUNT)); }else{ - LOGGER.error("Required Property value is missing : " + ENVIRONMENT); + logger.error("Required Property value is missing : " + ENVIRONMENT); throw new AAFPolicyException("Required Property value is missing : " + ENVIRONMENT); } access = new PolicyAccess(props, Level.valueOf(properties.getProperty("AAF_LOG_LEVEL", Level.ERROR.toString()))); @@ -142,10 +142,7 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ * @return */ public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action){ - if(checkAuth(mechID, pass) && checkPerm(mechID, pass, type, instance, action)){ - return true; - } - return false; + return checkAuth(mechID, pass) && checkPerm(mechID, pass, type, instance, action); } /** @@ -166,10 +163,10 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ i++; }while(i<2); } catch (Exception e) { - LOGGER.error(e.getMessage()); + logger.error(e.getMessage() + e); } } - LOGGER.info("Authentication failed for : " + userName + " in " + props.getProperty(Config.AAF_URL)); + logger.info("Authentication failed for : " + userName + " in " + props.getProperty(Config.AAF_URL)); return false; } @@ -193,24 +190,24 @@ public class AAFPolicyClientImpl implements AAFPolicyClient{ AAFPermission perm = new AAFPermission(type, instance, action); result = aafLurPerm.fish(userName, perm); } catch (CadiException e) { - LOGGER.error(e.getMessage()); + logger.error(e.getMessage() + e); aafLurPerm.destroy(); } } - LOGGER.info("Permissions for : " + userName + " in " + props.getProperty(Config.AAF_URL) + " for " + type + "," + instance + "," + action + "\n Result is: " + result); + logger.info("Permissions for : " + userName + " in " + props.getProperty(Config.AAF_URL) + " for " + type + "," + instance + "," + action + "\n Result is: " + result); i++; }while(i<2 && !result); // Try once more to check if this can be passed. AAF has some issues. return result; } - private boolean setUpAAF(){ + private static boolean setUpAAF(){ try { aafCon = new AAFConDME2(access); aafLurPerm = aafCon.newLur();//new AAFLurPerm(aafCon); aafAuthn = aafCon.newAuthn(aafLurPerm);//new AAFAuthn(aafCon, aafLurPerm); return true; } catch (Exception e) { - LOGGER.error("Error while setting up AAF Connection " + e.getMessage()); + logger.error("Error while setting up AAF Connection " + e.getMessage() + e); return false; } } |