935 HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
937 inum = request.getParameter(
"inum");
941 ByteArrayOutputStream bos =
new ByteArrayOutputStream(16384);
942 ZipOutputStream zos = ResponseHelper.createZipStream(bos,
"Shibboleth v3 configuration files");
944 zos.setMethod(ZipOutputStream.DEFLATED);
945 zos.setLevel(Deflater.DEFAULT_COMPRESSION);
949 if (!ResponseHelper.addFileToZip(idpMetadataFilePath, zos,
950 Shibboleth3ConfService.SHIB3_IDP_IDP_METADATA_FILE)) {
951 log.error(
"Failed to add " + idpMetadataFilePath +
" to zip");
952 return OxTrustConstants.RESULT_FAILURE;
955 if (trustRelationship.getSpMetaDataFN() == null) {
956 log.error(
"SpMetaDataFN is not set.");
957 return OxTrustConstants.RESULT_FAILURE;
961 if (!ResponseHelper.addFileToZip(spMetadataFilePath, zos,
962 Shibboleth3ConfService.SHIB3_IDP_SP_METADATA_FILE)) {
963 log.error(
"Failed to add " + spMetadataFilePath +
" to zip");
964 return OxTrustConstants.RESULT_FAILURE;
966 String sslDirFN =
appConfiguration.getShibboleth3IdpRootDir() + File.separator
967 + TrustService.GENERATED_SSL_ARTIFACTS_DIR + File.separator;
969 .replaceFirst(
"\\.xml$",
".key");
970 if (!ResponseHelper.addFileToZip(spKeyFilePath, zos, Shibboleth3ConfService.SHIB3_IDP_SP_KEY_FILE)) {
971 log.error(
"Failed to add " + spKeyFilePath +
" to zip");
975 .replaceFirst(
"\\.xml$",
".crt");
976 if (!ResponseHelper.addFileToZip(spCertFilePath, zos, Shibboleth3ConfService.SHIB3_IDP_SP_CERT_FILE)) {
977 log.error(
"Failed to add " + spCertFilePath +
" to zip");
982 if (spAttributeMap == null) {
983 log.error(
"spAttributeMap is not set.");
984 return OxTrustConstants.RESULT_FAILURE;
986 if (!ResponseHelper.addFileContentToZip(spAttributeMap, zos,
987 Shibboleth3ConfService.SHIB3_SP_ATTRIBUTE_MAP_FILE)) {
988 log.error(
"Failed to add " + spAttributeMap +
" to zip");
989 return OxTrustConstants.RESULT_FAILURE;
992 VelocityContext context =
new VelocityContext();
994 context.put(
"spUrl", (trustRelationship.getUrl() != null ? trustRelationship.getUrl() :
""));
995 String gluuSPEntityId = trustRelationship.getEntityId();
996 context.put(
"gluuSPEntityId", gluuSPEntityId);
997 String spHost = (trustRelationship.getUrl() != null
998 ? trustRelationship.getUrl().replaceAll(
":[0-9]*$",
"").replaceAll(
"^.*?//",
"")
1000 context.put(
"spHost", spHost);
1002 context.put(
"idpUrl", idpUrl);
1003 String idpHost = idpUrl.replaceAll(
":[0-9]*$",
"").replaceAll(
"^.*?//",
"");
1004 context.put(
"idpHost", idpHost);
1011 if (!ResponseHelper.addFileContentToZip(shibConfig, zos,
1012 Shibboleth3ConfService.SHIB3_SP_SHIBBOLETH2_FILE)) {
1013 log.error(
"Failed to add " + spShibboleth3FilePath +
" to zip");
1014 return OxTrustConstants.RESULT_FAILURE;
1018 String fileName = (
new File(spReadMeResourceName)).getName();
1022 InputStream is = FacesContext.getCurrentInstance().getExternalContext()
1023 .getResourceAsStream(spReadMeResourceName);
1027 if (!ResponseHelper.addResourceToZip(is, fileName, zos)) {
1028 log.error(
"Failed to add " + spReadMeResourceName +
" to zip");
1029 return OxTrustConstants.RESULT_FAILURE;
1033 fileName = (
new File(spReadMeWindowsResourceName)).getName();
1036 is = FacesContext.getCurrentInstance().getExternalContext()
1037 .getResourceAsStream(spReadMeWindowsResourceName);
1039 if (!ResponseHelper.addResourceToZip(is, fileName, zos)) {
1040 log.error(
"Failed to add " + spReadMeWindowsResourceName +
" to zip");
1041 return OxTrustConstants.RESULT_FAILURE;
1045 IOUtils.closeQuietly(zos);
1046 IOUtils.closeQuietly(bos);
1049 boolean result = ResponseHelper.downloadFile(
"shibboleth3-configuration.zip",
1050 OxTrustConstants.CONTENT_TYPE_APPLICATION_ZIP, bos.toByteArray(), FacesContext.getCurrentInstance());
1052 return result ? OxTrustConstants.RESULT_SUCCESS : OxTrustConstants.RESULT_FAILURE;
GluuSAMLTrustRelationship trustRelationship
Definition: UpdateTrustRelationshipAction.java:115
String getOrganizationInum()
Definition: OrganizationService.java:202
GluuSAMLTrustRelationship getRelationshipByInum(String inum)
Definition: TrustService.java:163
String getSpShibboleth3FilePath()
Definition: Shibboleth3ConfService.java:881
AppConfiguration appConfiguration
Definition: UpdateTrustRelationshipAction.java:108
OrganizationService organizationService
Definition: UpdateTrustRelationshipAction.java:118
String getIdpMetadataFilePath()
Definition: Shibboleth3ConfService.java:614
TrustService trustService
Definition: UpdateTrustRelationshipAction.java:130
String getSpMetadataFilePath(String spMetaDataFN)
Definition: Shibboleth3ConfService.java:692
String generateSpAttributeMapFile(GluuSAMLTrustRelationship trustRelationship)
Definition: Shibboleth3ConfService.java:797
TemplateService templateService
Definition: UpdateTrustRelationshipAction.java:139
String getSpReadMeWindowsResourceName()
Definition: Shibboleth3ConfService.java:891
Shibboleth3ConfService shibboleth3ConfService
Definition: UpdateTrustRelationshipAction.java:145
String getSpNewMetadataFileName(GluuSAMLTrustRelationship trustRel)
Definition: Shibboleth3ConfService.java:703
Logger log
Definition: UpdateTrustRelationshipAction.java:105
String inum
Definition: UpdateTrustRelationshipAction.java:112
String generateConfFile(String template, VelocityContext context)
Definition: TemplateService.java:51
String getSpReadMeResourceName()
Definition: Shibboleth3ConfService.java:887