[CRV-19] Working propagation to mock Federation Server

parent 4b4c3b9f
......@@ -135,21 +135,23 @@ public class FederationServerConnector implements Connector,
endUser.getGroups().add(value.toString());
});
}
} else if (attr.getName().contains("#")) {
} else if (attr.getName().endsWith(" " + FederationServerConstants.SERVICE_USERNAME)
|| attr.getName().endsWith(" " + FederationServerConstants.SERVICE_PASSWORD)) {
if (attr.getValue() != null) {
String[] parts = attr.getName().split("#");
if (parts != null && parts.length == 2) {
Map.Entry<String, String> credentials = serviceCredentials.get(parts[0]);
if (credentials == null) {
credentials = new Pair<>();
serviceCredentials.put(parts[0], credentials);
}
if (attr.getValue() != null && !attr.getValue().isEmpty()) {
if (parts[1].equals(FederationServerConstants.SERVICE_USERNAME_SUFFIX)) {
((Pair<String, String>) credentials).first = attr.getValue().get(0).toString();
} else if (parts[1].equals(FederationServerConstants.SERVICE_PASSWORD_SUFFIX)) {
((Pair<String, String>) credentials).second = attr.getValue().get(0).toString();
}
String serviceName = attr.getName().substring(0, attr.getName().lastIndexOf(' '));
String credential = attr.getName().substring(attr.getName().lastIndexOf(' ') + 1);
Map.Entry<String, String> credentials = serviceCredentials.get(serviceName);
if (credentials == null) {
credentials = new Pair<>();
serviceCredentials.put(serviceName, credentials);
}
if (attr.getValue() != null && !attr.getValue().isEmpty()) {
if (credential.equals(FederationServerConstants.SERVICE_USERNAME)) {
((Pair<String, String>) credentials).first = attr.getValue().get(0).toString();
} else if (credential.equals(FederationServerConstants.SERVICE_PASSWORD)) {
((Pair<String, String>) credentials).second = attr.getValue().get(0).toString();
}
}
}
......@@ -269,10 +271,10 @@ public class FederationServerConnector implements Connector,
endUser.getServiceCredentials().entrySet().stream().forEach((entry) -> {
attrs.add(AttributeBuilder.build(
entry.getKey() + "#" + FederationServerConstants.SERVICE_USERNAME_SUFFIX,
entry.getKey() + " " + FederationServerConstants.SERVICE_USERNAME,
entry.getValue().getKey()));
attrs.add(AttributeBuilder.build(
entry.getKey() + "#" + FederationServerConstants.SERVICE_PASSWORD_SUFFIX,
entry.getKey() + " " + FederationServerConstants.SERVICE_PASSWORD,
entry.getValue().getValue()));
});
......
......@@ -21,9 +21,9 @@ public final class FederationServerConstants {
public static final String CHOREOGRAPHIES_NAME = "__CHOREOGRAPHIES__";
public static final String SERVICE_USERNAME_SUFFIX = "Username";
public static final String SERVICE_USERNAME = "Username";
public static final String SERVICE_PASSWORD_SUFFIX = "Password";
public static final String SERVICE_PASSWORD = "Password";
private FederationServerConstants() {
// private constructor for static utility class
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment