private ClampProperties refProp;
private SecurityContext securityContext = SecurityContextHolder.getContext();
- private final static String permPrefix = "security.permission.type.";
- private final static String permInstance = "security.permission.instance";
+ private static final String permPrefix = "security.permission.type.";
+ private static final String permInstance = "security.permission.instance";
public AuthorizationController() {
}
+
/**
- * Insert event using process variables.
+ * Insert authorize the api based on the permission
*
* @param camelExchange
* The Camel Exchange object containing the properties
- * @param actionState
- * The action state that is used instead of the one in exchange property
+ * @param typeVar
+ * The type of the permissions
+ * @param instanceVar
+ * The instance of the permissions. e.g. dev
+ * @param action
+ * The action of the permissions. e.g. read
*/
-
public void authorize (Exchange camelExchange, String typeVar, String instanceVar, String action) {
String type = refProp.getStringValue(permPrefix + typeVar);
String instance = refProp.getStringValue(permInstance);
-
+
if (null == type || type.isEmpty()) {
//authorization is turned off, since the permission is not defined
return;
}
if (null != instanceVar && !instanceVar.isEmpty()) {
- instance = instanceVar;
+ instance = instanceVar;
}
String principalName = PrincipalUtils.getPrincipalName();
SecureServicePermission perm = SecureServicePermission.create(type, instance, action);
// check if the user has the permission key or the permission key with a
// combination of all instance and/or all action.
if (hasRole(inPermission.getKey())) {
- auditLogger.info("{} authorized because user has permission with * for instance: {}", principalName, inPermission.getKey());
+ auditLogger.info("{} authorized because user has permission with * for instance: {}",
+ principalName, inPermission.getKey());
authorized = true;
// the rest of these don't seem to be required - isUserInRole method
// appears to take * as a wildcard
} else if (hasRole(inPermission.getKeyAllInstance())) {
- auditLogger.info("{} authorized because user has permission with * for instance: {}", principalName, inPermission.getKey());
+ auditLogger.info("{} authorized because user has permission with * for instance: {}",
+ principalName, inPermission.getKey());
authorized = true;
} else if (hasRole(inPermission.getKeyAllInstanceAction())) {
- auditLogger.info("{} authorized because user has permission with * for instance and * for action: {}", principalName, inPermission.getKey());
+ auditLogger.info("{} authorized because user has permission with * for instance and * for action: {}",
+ principalName, inPermission.getKey());
authorized = true;
} else if (hasRole(inPermission.getKeyAllAction())) {
- auditLogger.info("{} authorized because user has permission with * for action: {}", principalName, inPermission.getKey());
+ auditLogger.info("{} authorized because user has permission with * for action: {}",
+ principalName, inPermission.getKey());
authorized = true;
} else {
throw new NotAuthorizedException("");
return authorized;
}
+ /**
+ * Verify whether the user has the permission
+ *
+ * @param inPermission
+ * The permissions to verify
+ */
public boolean isUserPermittedNoException(SecureServicePermission inPermission) {
try {
- return isUserPermitted (inPermission);
+ return isUserPermitted(inPermission);
} catch (NotAuthorizedException e) {
return false;
}
return false;
}
for (GrantedAuthority auth : authentication.getAuthorities()) {
- if (role.equals(auth.getAuthority()))
+ if (role.equals(auth.getAuthority())) {
return true;
+ }
}
return false;
}
* This method is used to declare the camel servlet.
*
* @return A servlet bean
- * @throws IOException
+ * @throws IOException IO Exception
*/
@Bean
public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
public class ClampServlet extends CamelHttpTransportServlet {
/**
- *
+ * The serial version ID.
*/
private static final long serialVersionUID = -4198841134910211542L;
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- Principal p = request.getUserPrincipal();
- if (loadDynamicAuthenticationClass().isInstance(p)) {
+ Principal principal = request.getUserPrincipal();
+ if (loadDynamicAuthenticationClass().isInstance(principal)) {
// When AAF is enabled, there is a need to provision the permissions to Spring
// system
List<GrantedAuthority> grantedAuths = new ArrayList<>();
grantedAuths.add(new SimpleGrantedAuthority(permString));
}
}
- Authentication auth = new UsernamePasswordAuthenticationToken(new User(p.getName(), "", grantedAuths), "",
+ Authentication auth = new UsernamePasswordAuthenticationToken(new User(principal.getName(), "", grantedAuths), "",
grantedAuths);
SecurityContextHolder.getContext().setAuthentication(auth);
}
* This class is a factory that redirects by default all HTTP to HTTPS
* connector. It is used by the Application.java class and defined in a Spring
* Bean.
- *
* In order to do this, the method postProcessContext has been overridden to
* provide another behavior.
- *
*/
public class TomcatEmbeddedServletContainerFactoryRedirection extends TomcatServletWebServerFactory {
this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
}\r
\r
+ /**\r
+ * Get the Operation Status from a specified URL with retry.\r
+ * @param operationStatusUrl\r
+ * The URL of the DCAE\r
+ * @return The status\r
+ * @throws InterruptedException Exception during the retry\r
+ */\r
public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {\r
String operationStatus = "";\r
for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {\r
\r
/**\r
* Get the Operation Status from a specified URL.\r
- *\r
* @param statusUrl\r
* The URL provided by a previous DCAE Query\r
* @return The status\r
\r
/**\r
* Returns status URL for createNewDeployment operation.\r
- *\r
* @param deploymentId\r
* The deployment ID\r
* @param serviceTypeId\r
\r
/***\r
* Returns status URL for deleteExistingDeployment operation.\r
- *\r
* @param deploymentId\r
* The deployment ID\r
* @param serviceTypeId\r
import org.springframework.stereotype.Component;
/**
- *
* This class manages the HTTP and HTTPS connections to DCAE.
- *
*/
@Component
public class DcaeHttpConnectionManager {
private final CldsDao cldsDao;\r
private final DcaeHttpConnectionManager dcaeHttpConnectionManager;\r
\r
+ /**\r
+ * Constructor.\r
+ */\r
@Autowired\r
public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao,\r
DcaeHttpConnectionManager dcaeHttpConnectionManager) {\r
*/\r
public DcaeInventoryResponse getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid)\r
throws IOException, ParseException, InterruptedException {\r
- Date startTime = new Date();\r
LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");\r
String queryString = "?asdcResourceId=" + resourceUuid + "&asdcServiceId=" + serviceUuid + "&typeName="\r
+ artifactName;\r
logger.info("Dcae Inventory Service full url - " + fullUrl);\r
DcaeInventoryResponse response = queryDcaeInventory(fullUrl);\r
LoggingUtils.setResponseContext("0", "Get Dcae Information success", this.getClass().getName());\r
+ Date startTime = new Date();\r
LoggingUtils.setTimeContext(startTime, new Date());\r
return response;\r
}\r
Policy policy = prop.getType(Policy.class);
if (policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for(PolicyItem policyItem:GuardPolicyAttributesConstructor.getAllPolicyGuardsFromPolicyChain(policyChain)) {
+ for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+ .getAllPolicyGuardsFromPolicyChain(policyChain)) {
prop.setCurrentModelElementId(policy.getId());
prop.setPolicyUniqueId(policyChain.getPolicyId());
prop.setGuardUniqueId(policyItem.getId());
String eventAction = (String) camelExchange.getProperty("eventAction");
if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- for(PolicyItem policyItem:GuardPolicyAttributesConstructor.getAllPolicyGuardsFromPolicyChain(policyChain)) {
+ for (PolicyItem policyItem:GuardPolicyAttributesConstructor
+ .getAllPolicyGuardsFromPolicyChain(policyChain)) {
prop.setCurrentModelElementId(policy.getId());
prop.setPolicyUniqueId(policyChain.getPolicyId());
prop.setGuardUniqueId(policyItem.getId());
Policy policy = prop.getType(Policy.class);
if (policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor.formatAttributes(refProp,
- prop, prop.getType(Policy.class).getId(), policyChain);
+ Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor
+ .formatAttributes(refProp,prop, prop.getType(Policy.class).getId(), policyChain);
responseMessage = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
}
if (responseMessage != null) {
return createAttributesMap(matchingAttributes);
}
+ /**
+ * Get all the Guard policies from the policy chain.
+ * @param policyChain The policy chain
+ * @return The list of guard policies
+ */
public static List<PolicyItem> getAllPolicyGuardsFromPolicyChain(PolicyChain policyChain) {
List<PolicyItem> listItem = new ArrayList<>();
for (PolicyItem policyItem : policyChain.getPolicyItems()) {
private OperationalPolicyAttributesConstructor() {
}
+ /**
+ * Format the attributes.
+ * @param refProp The Clamp properties
+ * @param modelProperties The model properties
+ * @param modelElementId The model element ID
+ * @param policyChain The policy chain
+ * @return The attributes map
+ * @throws BuilderException Exception while building up the attributes map
+ * @throws UnsupportedEncodingException Unsupported encoding exception
+ */
public static Map<AttributeType, Map<String, String>> formatAttributes(ClampProperties refProp,
ModelProperties modelProperties,
String modelElementId, PolicyChain policyChain)
return createAttributesMap(matchingAttributes, ruleAttributes);
}
- private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties, ModelProperties modelProperties,
+ private static Map<String, String> prepareRuleAttributes(ClampProperties clampProperties,
+ ModelProperties modelProperties,
String modelElementId, PolicyChain policyChain, String globalService)
throws BuilderException, UnsupportedEncodingException {
logger.info("Preparing rule attributes...");
return attributes;
}
- private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp, ModelProperties modelProperties,
+ private static ImmutableMap<String, String> createRuleAttributesFromPolicy(ClampProperties refProp,
+ ModelProperties modelProperties,
String modelElementId, PolicyChain policyChain,
String globalService, String operationTopic)
throws BuilderException, UnsupportedEncodingException {
}
}
- private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem, String recipeTopic) {
+ private static ImmutableMap<String, String> createRuleAttributesFromPolicyItem(PolicyItem policyItem,
+ String recipeTopic) {
logger.info("recipeTopic=" + recipeTopic);
return ImmutableMap.<String, String>builder()
.put(RECIPE_TOPIC, recipeTopic)
* ===================================================================
*
*/
+
package org.onap.clamp.clds.client.req.policy;
import com.att.eelf.configuration.EELFLogger;
/**
* Format Operational OpenLoop Policy yaml.
*
- * @param prop
- * @param modelElementId
- * @param policyChain
- * @return
- * @throws BuilderException
- * @throws UnsupportedEncodingException
+ * @param prop The model properties
+ * @param modelElementId The model element ID
+ * @param policyChain The policy chain
+ * @return The operational openloop policy in yaml format
+ * @throws BuilderException The builder exception
+ * @throws UnsupportedEncodingException The unsupported encoding exception
*/
public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
throws BuilderException, UnsupportedEncodingException {
return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
+ /**
+ * Format Operational Policy yaml.
+ * @param prop The model properties
+ * @param modelElementId The model element ID
+ * @param policyChain The policy chain
+ * @return The operational policy properties in yaml format
+ * @throws BuilderException The builder exception
+ * @throws UnsupportedEncodingException The unsupported encoding exception
+ */
public static String formatYaml(ModelProperties prop, String modelElementId, PolicyChain policyChain)
throws BuilderException, UnsupportedEncodingException {
// get property objects
}
/**
- * Method to return correct policy name with prefix
+ * Method to return correct policy name with prefix.
*
* @param prop
* The ModelProperties
* Policy Prefix
* @param policyNameWithPrefix
* Policy Name With Prefix
- * @return
+ * @return The policy name with the prefix
*/
protected String selectRightPolicyNameWithPrefix(ModelProperties prop, String policyPrefix,
String policyNameWithPrefix) {
deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group"));
deletePolicyParameters.setPolicyType(policyType);
// send delete request
- StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
logger.info("Deleting policy from PAP...");
+ StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop));
deletePolicyParameters.setPolicyComponent("PAP");
deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
// send delete request
}
/**
- * Create a temp Tosca model file and perform import model to Policy Engine
+ * Create a temp Tosca model file and perform import model to Policy Engine.
*
* @param cldsToscaModel
* Policy model details
}
/**
+ * Import the model.
* @param importParameters
* The ImportParameters
* @return The response message from policy
}
/**
+ * Build file path for tosca file.
* @param clampToscaPath
* Temp directory path for writing tosca files
* @param toscaModelName
/**
* ll get the latest version of the artifact (version can be specified to DCAE
- * call)
+ * call).
*
* @return The DcaeInventoryResponse object containing the dcae values
*/
public class Loop implements Serializable {
/**
- *
+ * The serial version id.
*/
private static final long serialVersionUID = -286522707701388642L;
@Expose
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
+ @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"),
+ inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
@Expose
public Loop() {
}
+ /**
+ * Constructor.
+ */
public Loop(String name, String blueprint, String svgRepresentation) {
this.name = name;
this.svgRepresentation = svgRepresentation;
this.modelPropertiesJson = modelPropertiesJson;
}
+ /**
+ * Generate the loop name.
+ * @param serviceName The service name
+ * @param serviceVersion The service version
+ * @param resourceName The resource name
+ * @param blueprintFileName The blueprint file name
+ * @return The generated loop name
+ */
public static String generateLoopName(String serviceName, String serviceVersion, String resourceName,
String blueprintFilename) {
StringBuilder buffer = new StringBuilder("LOOP_").append(serviceName).append("_v").append(serviceVersion)
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Loop other = (Loop) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
return true;
}
private final LoopService loopService;
private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken<List<OperationalPolicy>>() {
- }.getType();
+ }.getType();
private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken<List<MicroServicePolicy>>() {
- }.getType();
+ }.getType();
@Autowired
public LoopController(LoopService loopService) {
return loopService.getLoop(loopName);
}
+ /**
+ * Update the Operational Policy properties.
+ * @param loopName The loop name
+ * @param operationalPoliciesJson The new Operational Policy properties
+ * @return The updated loop
+ */
public Loop updateOperationalPolicies(String loopName, JsonArray operationalPoliciesJson) {
List<OperationalPolicy> operationalPolicies = JsonUtils.GSON
.fromJson(operationalPoliciesJson, OPERATIONAL_POLICY_TYPE);
return loopService.updateAndSaveOperationalPolicies(loopName, operationalPolicies);
}
+ /**
+ * Update the whole array of MicroService policies properties
+ * @param loopName The loop name
+ * @param microServicePoliciesJson The array of all MicroService policies properties
+ * @return The updated loop
+ */
public Loop updateMicroservicePolicies(String loopName, JsonArray microServicePoliciesJson) {
List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON
.fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
return loopService.updateAndSaveMicroservicePolicies(loopName, microservicePolicies);
}
- public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties){
+ /**
+ * Update the global properties
+ * @param loopName The loop name
+ * @param globalProperties The updated global properties
+ * @return The updated loop
+ */
+ public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties) {
return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
}
+ /**
+ * Update one MicroService policy properties
+ * @param loopName The loop name
+ * @param newMicroservicePolicy The new MicroService policy properties
+ * @return The updated MicroService policy
+ */
public MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
return loopService.updateMicroservicePolicy(loopName, newMicroservicePolicy);
}
+ /**
+ * Get the SVG representation of the loop
+ * @param loopName The loop name
+ * @return The SVG representation
+ */
public String getSVGRepresentation(String loopName) {
return loopService.getClosedLoopModelSVG(loopName);
import java.util.List;
import java.util.Set;
-import javax.persistence.EntityNotFoundException;
import com.google.gson.JsonObject;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
-import org.onap.clamp.policy.operational.OperationalPolicyService;
+
+import javax.persistence.EntityNotFoundException;
+
import org.onap.clamp.policy.microservice.MicroServicePolicy;
+import org.onap.clamp.policy.microservice.MicroservicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.onap.clamp.policy.operational.OperationalPolicyService;
import org.springframework.stereotype.Service;
@Service
private final MicroservicePolicyService microservicePolicyService;
private final OperationalPolicyService operationalPolicyService;
+ /**
+ * Constructor.
+ */
public LoopService(LoopsRepository loopsRepository,
MicroservicePolicyService microservicePolicyService,
OperationalPolicyService operationalPolicyService) {
return loopsRepository.getAllLoopNames();
}
- Loop getLoop(String loopName){
+ Loop getLoop(String loopName) {
return loopsRepository
.findById(loopName)
.orElse(null);
}
MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
- Loop loop = findClosedLoopByName(loopName);
+ Loop loop = findClosedLoopByName(loopName);
MicroServicePolicy newPolicies = microservicePolicyService
.getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
return newPolicies;
import org.onap.clamp.loop.Loop;
/**
- *
* This class holds the logs created by the Clamp Backend. The Instant is always
* rounded to the nearest second as the nano seconds can't be stored in the
* database. The logs can be therefore exposed to the UI or the client doing
@Table(name = "loop_logs")
public class LoopLog implements Serializable {
/**
- *
+ * The serial version ID.
*/
private static final long serialVersionUID = 1988276670074437631L;
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
LoopLog other = (LoopLog) obj;
if (id == null) {
- if (other.id != null)
+ if (other.id != null) {
return false;
- } else if (!id.equals(other.id))
+ }
+ } else if (!id.equals(other.id)) {
return false;
+ }
return true;
}
JsonObject getJsonRepresentation();
+ /**
+ * Generate the policy name.
+ * @param policyType The policy type
+ * @param serviceName The service name
+ * @param serviceVersion The service version
+ * @param resourceName The resource name
+ * @param blueprintFilename The blueprint file name
+ * @return The generated policy name
+ */
static String generatePolicyName(String policyType, String serviceName, String serviceVersion, String resourceName,
String blueprintFilename) {
StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
public class MicroServicePolicy implements Serializable, Policy {
/**
- *
+ * The serial version ID.
*/
private static final long serialVersionUID = 6271238288583332616L;
// serialization
}
+ /**
+ * The constructor.
+ * @param name The name of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is shared
+ * @param usedByLoops The list of loops that uses this MicroService
+ */
public MicroServicePolicy(String name, String policyTosca, Boolean shared, Set<Loop> usedByLoops) {
this.name = name;
this.policyTosca = policyTosca;
this.usedByLoops = usedByLoops;
}
+ /**
+ * The constructor.
+ * @param name The name of the MicroService
+ * @param policyTosca The policy Tosca of the MicroService
+ * @param shared The flag indicate whether the MicroService is shared
+ * @param jsonRepresentation The UI representation in json format
+ * @param usedByLoops The list of loops that uses this MicroService
+ */
public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
Set<Loop> usedByLoops) {
this.name = name;
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
MicroServicePolicy other = (MicroServicePolicy) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
return true;
}
return repository.existsById(policyName);
}
+ /**
+ * Get and update the MicroService policy properties.
+ * @param loop The loop
+ * @param policy The new MicroService policy
+ * @return The updated MicroService policy
+ */
@Transactional
public MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
return repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.policy.Policy;
-import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
@Entity
@Table(name = "operational_policies")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
public class OperationalPolicy implements Serializable, Policy {
/**
- *
+ * The serial version ID.
*/
private static final long serialVersionUID = 6117076450841538255L;
//Serialization
}
+ /**
+ * The constructor.
+ * @param name The name of the operational policy
+ * @param loop The loop that uses this operational policy
+ * @param configurationsJson The operational policy property in the format of json
+ */
public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson) {
this.name = name;
this.loop = loop;
this.loop = loopName;
}
- public Loop getLoop(){
+ public Loop getLoop() {
return loop;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
OperationalPolicy other = (OperationalPolicy) obj;
if (name == null) {
- if (other.name != null)
+ if (other.name != null) {
return false;
- } else if (!name.equals(other.name))
+ }
+ } else if (!name.equals(other.name)) {
return false;
+ }
return true;
}
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onap.clamp.policy.PolicyService;
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.policy.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Get the Full name.
*
- * @return
+ * @return The user name
*/
public static String getUserName() {
String name = userNameHandler.retrieveUserName(securityContext);
/**
* Get the userId from AAF/CSP.
*
- * @return
+ * @return The user ID
*/
public static String getUserId() {
return getUserName();
/**
* Get the principal name.
*
- * @return
+ * @return The principal name
*/
public static String getPrincipalName() {
String principal = ((UserDetails)securityContext.getAuthentication().getPrincipal()).getUsername();
}
return name;
}
+
public static void setSecurityContext(SecurityContext securityContext) {
PrincipalUtils.securityContext = securityContext;
}