public void auditLoginSuccess(@NotNull NodeType node, @NotNull ConnectionEnvironment connEnv) { auditLogin(node.getName().getOrig(), null, connEnv, OperationResultStatus.SUCCESS, null); }
private List<PrismObject<NodeType>> getMatchingNodes(List<PrismObject<NodeType>> knownNodes, String remoteName, String remoteAddress, String operation) { List<PrismObject<NodeType>> matchingNodes = new ArrayList<>(); for (PrismObject<NodeType> node : knownNodes) { NodeType actualNode = node.asObjectable(); if (remoteName != null && remoteName.equalsIgnoreCase(actualNode.getHostname())) { LOGGER.trace("The node {} was recognized as a known node (remote host name {} matched). Attempting to execute the requested operation: {} ", actualNode.getName(), actualNode.getHostname(), operation); matchingNodes.add(node); continue; } if (actualNode.getIpAddress().contains(remoteAddress)) { LOGGER.trace("The node {} was recognized as a known node (remote host address {} matched). Attempting to execute the requested operation: {} ", actualNode.getName(), remoteAddress, operation); matchingNodes.add(node); continue; } } return matchingNodes; }
public static void copyFromJAXB(NodeType jaxb, RNode repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException { copyObjectInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult); repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName())); repo.setNodeIdentifier(jaxb.getNodeIdentifier()); } }
public boolean authenticate(String remoteName, String remoteAddress, String operation) { LOGGER.debug("Checking if {} ({}) is a known node", remoteName, remoteAddress); OperationResult result = new OperationResult(OPERATION_SEARCH_NODE); ConnectionEnvironment connEnv = ConnectionEnvironment.create(SchemaConstants.CHANNEL_REST_URI); try { List<PrismObject<NodeType>> allNodes = repositoryService.searchObjects(NodeType.class, null, null, result); List<PrismObject<NodeType>> matchingNodes = getMatchingNodes(allNodes, remoteName, remoteAddress, operation); if (matchingNodes.size() == 1 || matchingNodes.size() >= 1 && taskManager.isLocalNodeClusteringEnabled()) { PrismObject<NodeType> actualNode = allNodes.iterator().next(); LOGGER.trace( "Matching result: The node {} was recognized as a known node (remote host name {} or IP address {} matched). Attempting to execute the requested operation: {}", actualNode.asObjectable().getName(), actualNode.asObjectable().getHostname(), remoteAddress, operation); NodeAuthenticationToken authNtoken = new NodeAuthenticationToken(actualNode, remoteAddress, Collections.emptyList()); SecurityContextHolder.getContext().setAuthentication(authNtoken); securityHelper.auditLoginSuccess(actualNode.asObjectable(), connEnv); return true; } } catch (RuntimeException | SchemaException e) { LOGGER.error("Unhandled exception when listing nodes"); LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", e); } securityHelper.auditLoginFailure(remoteName != null ? remoteName : remoteAddress, null, connEnv, "Failed to authenticate node."); return false; }
LOGGER.error("Internal node identifier has been overwritten in the repository. " + "Probably somebody has overwritten it in the meantime, i.e. another node with the name of '" + cachedLocalNodeObject.asObjectable().getName() + "' is running. Stopping the scheduler."); registerNodeError(NodeErrorStatusType.DUPLICATE_NODE_ID_OR_NAME); return null;
nodesInRepo = findNodesWithGivenName(result, PolyString.getOrig(nodeToBe.getName())); } catch (SchemaException e) { throw new TaskManagerInitializationException("Node registration failed because of schema exception", e); LOGGER.warn("More than one node with the name of {}: removing all of them.", nodeToBe.getName());