Skip to content

Instantly share code, notes, and snippets.

@aldaris
Created July 25, 2018 12:28
Show Gist options
  • Save aldaris/76f8eb9800b60e9fad911b41ad07b04c to your computer and use it in GitHub Desktop.
Save aldaris/76f8eb9800b60e9fad911b41ad07b04c to your computer and use it in GitHub Desktop.
Export all service schemas
<%@ page language="java" import="java.security.AccessController,
java.io.FileWriter,
com.sun.identity.security.AdminTokenAction,
com.iplanet.sso.SSOToken,
com.sun.identity.sm.ServiceManager,
com.sun.identity.sm.ServiceSchemaManager,
org.apache.commons.io.IOUtils"
%>
<html>
<head>
<title>OpenAM</title>
</head>
<body>
<%
// Get valid SSOToken
SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
for (String serviceName : new ServiceManager(token).getServiceNames()) {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
try (FileWriter fw = new FileWriter("/Users/aldaris/openam/config/xml/" + serviceName + ".xml")) {
IOUtils.copy(ssm.getSchema(), fw);
}
}
} catch (Exception ex) {
out.println(ex);
}
%>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment