Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.
Open
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
25 changes: 25 additions & 0 deletions conf/Language-ext.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
com.dotcms.repackage.javax.portlet.title.saml=SAML Configuration
add-idp=Add New SAML Configuration
disabled-sites=Disabled SAML Authentication
disable-site=Disable SAML per Site
download-sp-metadata=Download SP Metadata
idp-name=IdP Name
sp-metadata-file=SP Metadata File
idp-config-name-label=Configuration Name
idp-id=Configuration Id
idp-status-label=Enabled?
sp-issuer-url-label=SP Issuer URL
sp-endpoint-hostname-label=SP Endponint Hostname
private-key-label=Private Key
public-certificate-label=Public Cert
idp-metadata-label=IdP Metadata File
idp-validation-label=Validation Type
optional-properties-label=Override Properties
add-site=Sites
add-site-to-config=Add Site
site=Site
remove=Remove
add-edit-dialog-title=Add/Edit SAML Configuration
disabled-sites-dialog-title=Add/Remove Disabled SAML Sites
delete-dialog-title=Delete SAML Configuration Confirmation
delete-dialog-text=Are you sure you want to delete this SAML Configuration? (This operation cannot be undone)
12 changes: 12 additions & 0 deletions conf/portlet-ext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<portlet>
<portlet-name>saml</portlet-name>
<display-name>SAML Configuration</display-name>
<portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/plugins/plugin-com.dotcms.dotsaml/saml/view_saml_configuration.jsp</value>
</init-param>
<security-role-ref>
<role-name>CMS Administrator</role-name>
</security-role-ref>
</portlet>
1 change: 1 addition & 0 deletions conf/web-ext.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<filter>
<filter-name>SamlAccessFilter</filter-name>
<filter-class>com.dotcms.plugin.saml.v3.filter.SamlAccessFilter</filter-class>
<async-supported>true</async-supported>
</filter>

<filter-mapping>
Expand Down
346 changes: 346 additions & 0 deletions src/com/dotcms/plugin/saml/v3/rest/api/v1/DotSamlResource.java

Large diffs are not rendered by default.

203 changes: 203 additions & 0 deletions src/com/dotcms/plugin/saml/v3/rest/api/v1/IdpConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
package com.dotcms.plugin.saml.v3.rest.api.v1;

import java.io.File;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;

public class IdpConfig {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why it is not a immutable bean


private String id;
private String idpName;
private boolean enabled;
private String sPIssuerURL;
private String sPEndponintHostname;
private File privateKey;
private File publicCert;
private File idPMetadataFile;
private String signatureValidationType;
private Properties optionalProperties;
private Map<String, String> sites;

private IdpConfig() {
}

public static class Builder {
private IdpConfig idpConfigToBuild;

Builder() {
idpConfigToBuild = new IdpConfig();
}

IdpConfig build() {
IdpConfig builtIdpConfig = idpConfigToBuild;
idpConfigToBuild = new IdpConfig();

return builtIdpConfig;
}

public Builder id(String id) {
this.idpConfigToBuild.id = id;
return this;
}

public Builder idpName(String idpName) {
this.idpConfigToBuild.idpName = idpName;
return this;
}

public Builder enabled(boolean enabled) {
this.idpConfigToBuild.enabled = enabled;
return this;
}

public Builder sPIssuerURL(String sPIssuerURL) {
this.idpConfigToBuild.sPIssuerURL = sPIssuerURL;
return this;
}

public Builder sPEndponintHostname(String sPEndponintHostname) {
this.idpConfigToBuild.sPEndponintHostname = sPEndponintHostname;
return this;
}

public Builder privateKey(File privateKey) {
this.idpConfigToBuild.privateKey = privateKey;
return this;
}

public Builder publicCert(File publicCert) {
this.idpConfigToBuild.publicCert = publicCert;
return this;
}

public Builder idPMetadataFile(File idPMetadataFile) {
this.idpConfigToBuild.idPMetadataFile = idPMetadataFile;
return this;
}

public Builder signatureValidationType(String signatureValidationType) {
this.idpConfigToBuild.signatureValidationType = signatureValidationType;
return this;
}

public Builder optionalProperties(Properties optionalProperties) {
this.idpConfigToBuild.optionalProperties = optionalProperties;
return this;
}

public Builder sites(Map<String, String> sites) {
this.idpConfigToBuild.sites = sites;
return this;
}
}

public static IdpConfig.Builder convertIdpConfigToBuilder(IdpConfig idpConfig){
IdpConfig.Builder builder = new IdpConfig.Builder();

builder.id(idpConfig.getId())
.idpName(idpConfig.getIdpName())
.enabled(idpConfig.isEnabled())
.sPIssuerURL(idpConfig.getsPIssuerURL())
.sPEndponintHostname(idpConfig.getsPEndponintHostname())
.privateKey(idpConfig.getPrivateKey())
.publicCert(idpConfig.getPublicCert())
.idPMetadataFile(idpConfig.getIdPMetadataFile())
.signatureValidationType(idpConfig.getSignatureValidationType())
.optionalProperties(idpConfig.getOptionalProperties())
.sites(idpConfig.getSites());

return builder;
}

public String getId() {
return id;
}

public String getIdpName() {
return idpName;
}

public boolean isEnabled() {
return enabled;
}

public String getsPIssuerURL() {
return sPIssuerURL;
}

public String getsPEndponintHostname() {
return sPEndponintHostname;
}

public File getPrivateKey() {
return privateKey;
}

public File getPublicCert() {
return publicCert;
}

public File getIdPMetadataFile() {
return idPMetadataFile;
}

public String getSignatureValidationType() {
return signatureValidationType;
}

public Properties getOptionalProperties() {
return optionalProperties;
}

public Map<String, String> getSites() {
return sites;
}

private String getSearchable() {
StringBuilder sb = new StringBuilder();

//config name.
sb.append(this.idpName);
sb.append(" ");
//SP Issuer URL.
sb.append(this.sPIssuerURL);
sb.append(" ");
//SP Endpoint Hostname.
sb.append(this.sPEndponintHostname);
sb.append(" ");
//sites related to the IdP.
for (Map.Entry<String, String> entry : this.sites.entrySet()) {
sb.append(entry.getKey());
sb.append(" ");
sb.append(entry.getValue());
sb.append(" ");
}
//any override parameter.
sb.append(this.optionalProperties);

return sb.toString();
}

public boolean contains(String string) {
return getSearchable().toLowerCase().contains(string.trim().toLowerCase());
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IdpConfig idpConfig = (IdpConfig) o;
return Objects.equals(id, idpConfig.id);
}

@Override
public int hashCode() {

return Objects.hash(id);
}
}
11 changes: 11 additions & 0 deletions src/com/dotcms/plugin/saml/v3/rest/api/v1/IdpConfigComparator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.dotcms.plugin.saml.v3.rest.api.v1;

import java.util.Comparator;

public class IdpConfigComparator implements Comparator<IdpConfig>{

@Override
public int compare(IdpConfig idpConfig1, IdpConfig idpConfig2) {
return idpConfig1.getIdpName().compareToIgnoreCase(idpConfig2.getIdpName());
}
}
Loading