* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (Files.notExists(this.repository)) {
Files.createDirectory(repository);
}
- if (Files.isDirectory(this.repository) == false) {
+ if (!Files.isDirectory(this.repository)) {
throw new PAPException ("Repository is NOT a directory: " + this.repository.toAbsolutePath());
}
- if (Files.isWritable(this.repository) == false) {
+ if (!Files.isWritable(this.repository)) {
throw new PAPException ("Repository is NOT writable: " + this.repository.toAbsolutePath());
}
//
this.doSave();
} else {
PolicyLogger.error("Failed to add to new group, putting back into original group.");
- if (((StdPDPGroup) currentGroup).removePDP(pdp) == false) {
+ if (!((StdPDPGroup) currentGroup).removePDP(pdp)) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "Failed to put PDP back into original group.");
}
}
// the only things that the user can change are name and description
currentPDP.setDescription(pdp.getDescription());
currentPDP.setName(pdp.getName());
- if (currentPDP instanceof OnapPDP && pdp instanceof OnapPDP) {
- ((OnapPDP)currentPDP).setJmxPort(((OnapPDP)pdp).getJmxPort());
+ if (currentPDP instanceof OnapPDP) {
+ ((OnapPDP)currentPDP).setJmxPort(pdp.getJmxPort());
}
this.doSave();
}
// Save the configuration
//
this.saveConfiguration();
- } catch (IOException e) {
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdEngine", "Failed to save configuration");
- } catch (PAPException e) {
+ } catch (IOException|PAPException e) {
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdEngine", "Failed to save configuration");
}
}
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Override
public PAPPolicyEngine newEngine() throws FactoryException, PAPException {
try {
- return (PAPPolicyEngine) new StdEngine();
+ return new StdEngine();
} catch (IOException e) {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "StdEngineFactory", "Failed to create engine");
return null;
public PAPPolicyEngine newEngine(Properties properties) throws FactoryException,
PAPException {
try {
- return (PAPPolicyEngine) new StdEngine(properties);
+ return new StdEngine(properties);
} catch (IOException e) {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "StdEngineFactory", "Failed to create engine");
return null;
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (o == null) {
return -1;
}
- if ( ! (o instanceof StdPDP)) {
- return -1;
- }
if (o.name == null) {
return -1;
}
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@JsonIgnore
private Integer jmxport;
+ public StdPDPGroup() {
+ //
+ // Methods needed for JSON deserialization
+ //
+ }
+
+ public StdPDPGroup(OnapPDPGroup group) {
+ this.id = group.getId();
+ this.name = group.getName();
+ this.description = group.getDescription();
+ this.isDefault = group.isDefaultGroup();
+ this.pdps = group.getOnapPdps();
+ this.policies = group.getPolicies();
+ this.pipConfigs = group.getPipConfigs();
+ }
public StdPDPGroup(String id, Path directory) {
this.id = id;
// to occur: 1) old default=false (don't want to fire) and
// then 2) new default=true (yes fire - but we'll have to do that
// elsewhere.
- //this.firePDPGroupChanged(this);
}
@Override
logger.info("Copied " + num + " bytes for policy " + name);
StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, isRoot, name, tempFile.toUri());
- if (tempRootPolicy.isValid() == false) {
+ if (!tempRootPolicy.isValid()) {
try {
Files.delete(tempFile);
} catch(Exception ee) {
// policy is new to this group
StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, true, name, policyFile.toUri());
- if (tempRootPolicy.isValid() == false) {
+ if (!tempRootPolicy.isValid()) {
try {
Files.delete(policyFile);
} catch(Exception ee) {
// policy is new to this group
StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, true, name, policyFile.toUri());
- if (tempRootPolicy.isValid() == false) {
+ if (!tempRootPolicy.isValid()) {
try {
Files.delete(policyFile);
} catch(Exception ee) {
this.changed();
}
-
- public StdPDPGroup() {
- //
- // Methods needed for JSON deserialization
- //
- }
-
- public StdPDPGroup(OnapPDPGroup group) {
- this.id = group.getId();
- this.name = group.getName();
- this.description = group.getDescription();
- this.isDefault = group.isDefaultGroup();
- this.pdps = group.getOnapPdps();
- this.policies = group.getPolicies();
- this.pipConfigs = group.getPipConfigs();
- }
-
public boolean isDefault() {
return isDefault;
}
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public StdPDPGroupStatus(PDPGroupStatus stat) {
this.status = stat.getStatus();
- this.failedPDPs.clear(); this.failedPDPs.addAll(stat.getFailedPDPs());
- this.failedPIPConfigs.clear(); this.failedPIPConfigs.addAll(stat.getFailedPipConfigs());
- this.failedPolicies.clear(); this.failedPolicies.addAll(stat.getFailedPolicies());
- this.inSynchPDPs.clear(); this.inSynchPDPs.addAll(stat.getInSynchPDPs());
- this.lastUpdateFailedPDPs.clear(); this.lastUpdateFailedPDPs.addAll(stat.getLastUpdateFailedPDPs());
- this.loadedPIPConfigs.clear(); this.loadedPIPConfigs.addAll(stat.getLoadedPipConfigs());
- this.loadedPolicies.clear(); this.loadedPolicies.addAll(stat.getLoadedPolicies());
- this.loadErrors.clear(); this.loadErrors.addAll(stat.getLoadErrors());
- this.loadWarnings.clear(); this.loadWarnings.addAll(stat.getLoadWarnings());
- this.outOfSynchPDPs.clear(); this.outOfSynchPDPs.addAll(stat.getOutOfSynchPDPs());
- this.unknownPDPs.clear(); this.unknownPDPs.addAll(stat.getUpdatingPDPs());
- this.updatingPDPs.clear(); this.updatingPDPs.addAll(stat.getUpdatingPDPs());
+ this.failedPDPs.clear();
+ this.failedPDPs.addAll(stat.getFailedPDPs());
+ this.failedPIPConfigs.clear();
+ this.failedPIPConfigs.addAll(stat.getFailedPipConfigs());
+ this.failedPolicies.clear();
+ this.failedPolicies.addAll(stat.getFailedPolicies());
+ this.inSynchPDPs.clear();
+ this.inSynchPDPs.addAll(stat.getInSynchPDPs());
+ this.lastUpdateFailedPDPs.clear();
+ this.lastUpdateFailedPDPs.addAll(stat.getLastUpdateFailedPDPs());
+ this.loadedPIPConfigs.clear();
+ this.loadedPIPConfigs.addAll(stat.getLoadedPipConfigs());
+ this.loadedPolicies.clear();
+ this.loadedPolicies.addAll(stat.getLoadedPolicies());
+ this.loadErrors.clear();
+ this.loadErrors.addAll(stat.getLoadErrors());
+ this.loadWarnings.clear();
+ this.loadWarnings.addAll(stat.getLoadWarnings());
+ this.outOfSynchPDPs.clear();
+ this.outOfSynchPDPs.addAll(stat.getOutOfSynchPDPs());
+ this.unknownPDPs.clear();
+ this.unknownPDPs.addAll(stat.getUpdatingPDPs());
+ this.updatingPDPs.clear();
+ this.updatingPDPs.addAll(stat.getUpdatingPDPs());
}
public Set<PDPPIPConfig> getLoadedPIPConfigs() {
@Override
@JsonIgnore
public boolean isGroupOk() {
- if (this.policiesOK() == false) {
+ if (!this.policiesOK()) {
return false;
}
- if (this.pipConfigOK() == false) {
+ if (!this.pipConfigOK()) {
return false;
}
- if (this.pdpsOK() == false) {
+ if (!this.pdpsOK()) {
return false;
}
- if (this.loadErrors.isEmpty() == false) {
+ if (!this.loadErrors.isEmpty()) {
return false;
}
return this.status == Status.OK;
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private URI location = null;
-
+ public StdPDPPolicy() {
+ //
+ // Methods needed for JSON Deserialization
+ //
+ }
+
public StdPDPPolicy(String id, boolean isRoot) {
this.id = id;
this.isRoot = isRoot;
}
if (this.policyId != null) {
ArrayList<String> foo = Lists.newArrayList(Splitter.on(':').split(this.policyId));
- if (foo.isEmpty() == false) {
+ if (!foo.isEmpty()) {
return foo.get(foo.size() - 1);
}
}
return versionString;
}
-
-
- public StdPDPPolicy() {
- //
- // Methods needed for JSON Deserialization
- //
- }
-
public void setPolicyId(String policyId) {
this.policyId = policyId;
}
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
new IdentifierImpl("target"),
XACML.ID_DATATYPE_STRING);
+
+ public OperationHistoryEngine() {
+ super();
+ }
private void addIntegerAttribute(StdMutablePIPResponse stdPIPResponse, Identifier category, Identifier attributeId, int value, PIPRequest pipRequest) {
AttributeValue<BigInteger> attributeValue = null;
}
}
- public OperationHistoryEngine() {
- super();
- }
-
@Override
public Collection<PIPRequest> attributesRequired() {
return new ArrayList<>();
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class MetricsUtil {
+ private MetricsUtil() {
+ //
+ // private constructor to hide the implicit public one for utility class
+ //
+ }
+
public static class AvgLatency {
private long cumLatency = 0;
private long count = 0;
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.IdReferenceType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
if (this.policyObject == null) {
return null;
}
- if (this.callback != null) {
- if (this.callback.onBeginScan(this.policyObject) == CallbackResult.STOP) {
- return this.policyObject;
- }
+ if (this.callback != null && this.callback.onBeginScan(this.policyObject) == CallbackResult.STOP) {
+ return this.policyObject;
}
if (this.policyObject instanceof PolicyType) {
this.scanPolicy(null, (PolicyType) this.policyObject);
if (logger.isTraceEnabled()) {
logger.trace("scanning policy set: " + policySet.getPolicySetId() + " " + policySet.getDescription());
}
- if (this.callback != null) {
- if (this.callback.onPreVisitPolicySet(parent, policySet) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPreVisitPolicySet(parent, policySet) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
//
// Scan its info
//
List<JAXBElement<?>> list = policySet.getPolicySetOrPolicyOrPolicySetIdReference();
for (JAXBElement<?> element: list) {
- if ("PolicySet".equals(element.getName().getLocalPart())) {
- if (this.scanPolicySet(policySet, (PolicySetType)element.getValue()) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
- } else if ("Policy".equals(element.getName().getLocalPart())) {
- if (this.scanPolicy(policySet, (PolicyType)element.getValue()) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
- } else if (element.getValue() instanceof IdReferenceType) {
- if ("PolicySetIdReference".equals(element.getName().getLocalPart())) {
-
- } else if ("PolicyIdReference".equals(element.getName().getLocalPart())) {
-
- }
+ if ("PolicySet".equals(element.getName().getLocalPart()) &&
+ this.scanPolicySet(policySet, (PolicySetType)element.getValue()) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
+ } else if ("Policy".equals(element.getName().getLocalPart()) &&
+ this.scanPolicy(policySet, (PolicyType)element.getValue()) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
} else {
logger.warn("generating policy sets found unsupported element: " + element.getName().getNamespaceURI());
}
}
- if (this.callback != null) {
- if (this.callback.onPostVisitPolicySet(parent, policySet) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPostVisitPolicySet(parent, policySet) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
return CallbackResult.CONTINUE;
}
if (logger.isTraceEnabled()) {
logger.trace("scanning policy: " + policy.getPolicyId() + " " + policy.getDescription());
}
- if (this.callback != null) {
- if (this.callback.onPreVisitPolicy(parent, policy) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPreVisitPolicy(parent, policy) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
//
// Scan its info
if (logger.isTraceEnabled()) {
logger.trace("scanning rule: " + rule.getRuleId() + " " + rule.getDescription());
}
- if (this.callback != null) {
- if (this.callback.onPreVisitRule(policy, rule) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPreVisitRule(policy, rule) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
if (this.scanTarget(rule, rule.getTarget()) == CallbackResult.STOP) {
return CallbackResult.STOP;
if (this.scanAdvice(rule, rule.getAdviceExpressions()) == CallbackResult.STOP) {
return CallbackResult.STOP;
}
- if (this.callback != null) {
- if (this.callback.onPostVisitRule(policy, rule) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPostVisitRule(policy, rule) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
} else if (o instanceof VariableDefinitionType) {
- if (this.callback != null) {
- if (this.callback.onVariable(policy, (VariableDefinitionType) o) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onVariable(policy, (VariableDefinitionType) o) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
} else {
if (logger.isDebugEnabled()) {
}
}
}
- if (this.callback != null) {
- if (this.callback.onPostVisitPolicy(parent, policy) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onPostVisitPolicy(parent, policy) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
return CallbackResult.CONTINUE;
}
} else {
logger.warn("NULL designator/selector or value for match.");
}
- if (attribute != null && this.callback != null) {
- if (this.callback.onAttribute(parent, target, attribute) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (attribute != null && this.callback != null && this.callback.onAttribute(parent, target, attribute) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
}
}
ob.addAttributeAssignment(attribute);
}
}
- if (this.callback != null) {
- if (this.callback.onObligation(parent, expression, ob) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onObligation(parent, expression, ob) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
}
return CallbackResult.CONTINUE;
ob.addAttributeAssignment(attribute);
}
}
- if (this.callback != null) {
- if (this.callback.onAdvice(parent, expression, ob) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
+ if (this.callback != null && this.callback.onAdvice(parent, expression, ob) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
}
return CallbackResult.CONTINUE;
return CallbackResult.CONTINUE;
}
for (Object o : list) {
- if (o instanceof VariableDefinitionType) {
- if (this.callback != null) {
- if (this.callback.onVariable(policy, (VariableDefinitionType) o) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
- }
+ if (o instanceof VariableDefinitionType && this.callback != null && this.callback.onVariable(policy, (VariableDefinitionType) o) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
}
* @return
*/
protected CallbackResult scanConditions(RuleType rule, ConditionType condition) {
- if (condition != null) {
- if (this.callback != null) {
- if (this.callback.onCondition(rule, condition) == CallbackResult.STOP) {
- return CallbackResult.STOP;
- }
- }
+ if (condition != null && this.callback != null && this.callback.onCondition(rule, condition) == CallbackResult.STOP) {
+ return CallbackResult.STOP;
}
return CallbackResult.CONTINUE;
}
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(policyElement, byteArrayOutputStream);
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
- return byteArrayInputStream;
-
+ return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
} catch (JAXBException e) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
return null;
* ============LICENSE_START=======================================================
* ONAP-XACML
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.xacml.test.util;
public class AAFEngineTest {
-
+ //
+ // Some tests to be added
+ //
}