Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encrypted passwords with the cipher tool are not being decrypted #331

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<exclude>**/CertValidationErrors.class</exclude>
<exclude>**/JDBCRetentionDataPersistenceManager.class</exclude>
<exclude>**/*Type*/**</exclude>
<exclude>**/*OpenBankingConfigurationService*/**</exclude>
</excludes>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023 - 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -30,6 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.wso2.securevault.SecretResolver;
import org.wso2.securevault.SecretResolverFactory;
import org.wso2.securevault.commons.MiscellaneousUtil;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -484,9 +485,8 @@ private void readChildElements(OMElement serverConfig, Stack<String> nameStack)
String key = getKey(nameStack);
Object currentObject = configuration.get(key);
String value = replaceSystemProperty(element.getText());
if (secretResolver != null && secretResolver.isInitialized() &&
secretResolver.isTokenProtected(key)) {
value = secretResolver.resolve(key);
if (secretResolver != null && secretResolver.isInitialized()) {
value = MiscellaneousUtil.resolve(element, secretResolver);
}
if (currentObject == null) {
configuration.put(key, value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023 - 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -18,6 +18,7 @@

package com.wso2.openbanking.accelerator.common.config;

import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand All @@ -44,4 +45,7 @@ public interface OpenBankingConfigurationService {

public Map<String, String> getAuthenticationWorkers();

default List<String> getServiceActivatorSubscribers() {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2023 - 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -83,5 +83,9 @@ public Map<String, String> getAuthenticationWorkers() {
return openBankingConfigParser.getAuthWorkerConfig();
}

@Override
public List<String> getServiceActivatorSubscribers() {
return openBankingConfigParser.getServiceActivatorSubscribers();
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
*
* Copyright (c) 2023 - 2025, WSO2 LLC. (https://www.wso2.com).
* <p>
* WSO2 LLC. licenses this file to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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
Expand All @@ -18,32 +18,36 @@

package com.wso2.openbanking.accelerator.service.activator.internal;

import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser;
import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigurationService;
import com.wso2.openbanking.accelerator.service.activator.OBServiceObserver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

import java.util.Objects;

/**
* ServiceRegisterComponent.
*
* <p>
* OSGI Component class to register and activate subscriber (observer) classes
*/
@Component
public class ServiceRegisterComponent {

private static final Log LOG = LogFactory.getLog(ServiceRegisterComponent.class);
private OpenBankingConfigurationService openBankingConfigurationService;

@Activate
protected void activate(ComponentContext context) {
ServiceObservable serviceObservable = ServiceObservable.getInstance();

OpenBankingConfigParser.getInstance().getServiceActivatorSubscribers()
this.openBankingConfigurationService.getServiceActivatorSubscribers()
.stream()
.map(this::getInstanceFromFQN)
.filter(Objects::nonNull)
Expand All @@ -55,7 +59,7 @@ protected void activate(ComponentContext context) {

@Deactivate
protected void deactivate(ComponentContext context) {
LOG.debug("Metadata Updater bundle is deactivated");
LOG.debug("Service register component is deactivated");
}

private OBServiceObserver getInstanceFromFQN(String fqn) {
Expand All @@ -68,4 +72,20 @@ private OBServiceObserver getInstanceFromFQN(String fqn) {
}
return null;
}

@Reference(
service = OpenBankingConfigurationService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetOpenBankingConfigurationService"
)
public void setOpenBankingConfigurationService(OpenBankingConfigurationService openBankingConfigurationService) {

this.openBankingConfigurationService = openBankingConfigurationService;
}

public void unsetOpenBankingConfigurationService(OpenBankingConfigurationService openBankingConfigurationService) {

this.openBankingConfigurationService = null;
}
}
Loading