Skip to content

Commit

Permalink
Merge pull request #27304 from c00crane/298327
Browse files Browse the repository at this point in the history
Modifications to work around a Java 8/Shibboleth/LDAP issue
  • Loading branch information
c00crane authored Jan 22, 2024
2 parents ace0341 + 9b4a6f4 commit 13f830b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2023 IBM Corporation and others.
* Copyright (c) 2013, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -21,14 +21,17 @@
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import org.junit.rules.ExternalResource;

import com.ibm.websphere.simplicity.LocalFile;
import com.ibm.websphere.simplicity.RemoteFile;
import com.ibm.websphere.simplicity.log.Log;
import com.ibm.ws.security.fat.common.ValidationData.validationData;
Expand Down Expand Up @@ -754,11 +757,42 @@ public void stopServer() throws Exception {
// ignore ssl message - runtime retries and can proceed (sometimes) when it can't tests will fail when they don't get the correct response
server.addIgnoredErrors(Arrays.asList(MessageConstants.CWWKO0801E_UNABLE_TO_INIT_SSL));

shibbolehtBackup(server);

server.stopServer(ignoredServerExceptions);
}
unInstallCallbackHandler(callback, callbackFeature);
}

/**
* backup shibboleth config
*/
private void shibbolehtBackup(LibertyServer server) throws Exception {
final String method = "shibbolehtBackup";
Log.entering(thisClass, method, server.getServerName());

if (server.getServerName().contains("shibboleth")) {
Log.info(thisClass, method, "Need to back up shibboleth-idp directory");
} else {
Log.info(thisClass, method, "There is no shibboleth-idp directory to backup");
return;
}

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss");
Date d = new Date(System.currentTimeMillis());

String logDirectoryName = "";
logDirectoryName = server.getPathToAutoFVTOutputServersFolder() + "/" + server.getServerNameWithRepeatAction().replace("shibboleth", "shibboleth-idp") + "-" + sdf.format(d);
LocalFile logFolder = new LocalFile(logDirectoryName);
String shibbolethDir = new File(".").getAbsoluteFile().getCanonicalPath().replace("\\", "/") + "/shibboleth-idp";
RemoteFile serverFolder = new RemoteFile(server.getMachine(), shibbolethDir);

// Copy the log files: try to move them instead if we can
server.recursivelyCopyDirectory(serverFolder, logFolder, false, false, true);

Log.exiting(thisClass, method);
}

/**
* Restores the original server config and sets the mark to the end of the logs.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corporation and others.
* Copyright (c) 2021, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -95,6 +95,7 @@ task copyShibbolethIdpConfig (dependsOn: [':com.ibm.ws.security.fat.common:assem
from project(':com.ibm.ws.security.saml.sso_fat.common').buildDir
into autoFvtDir
include 'shibboleth-idp/**'
exclude 'shibboleth-idp/4.0.1'
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
<md:SingleLogoutService
Location="https://localhost:xxx_SpSecurePort_xxx/ibm/saml20/spOP/slo"
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" />
<md:AssertionConsumerService
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://localhost:xxx_SpSecurePort_xxx/ibm/saml20/spOP/acs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3493,6 +3493,10 @@ private void _postStopServerArchive(boolean skipArchives) throws Exception {
Log.exiting(c, method);
}

public String getPathToAutoFVTOutputServersFolder() {
return pathToAutoFVTOutputServersFolder;
}

protected void runJextract(RemoteFile serverFolder) throws Exception {
RemoteFile[] files = serverFolder.list(false);
if (files != null) {
Expand Down Expand Up @@ -3553,9 +3557,9 @@ private boolean isLog(String localPath, String remoteName, String dumpName) {
}
}

protected void recursivelyCopyDirectory(RemoteFile remoteSrcDir,
LocalFile localDstDir,
boolean ignoreFailures, boolean skipArchives, boolean moveFile) throws Exception {
public void recursivelyCopyDirectory(RemoteFile remoteSrcDir,
LocalFile localDstDir,
boolean ignoreFailures, boolean skipArchives, boolean moveFile) throws Exception {

String method = "recursivelyCopyDirectory";

Expand Down

0 comments on commit 13f830b

Please sign in to comment.