org.ligoj.app.iam.ContainerOrg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin-api Show documentation
Show all versions of plugin-api Show documentation
Plugin API definition and compatibility following semver
The newest version!
/*
* Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
*/
package org.ligoj.app.iam;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.Length;
import org.ligoj.app.api.Normalizer;
import org.ligoj.bootstrap.core.IDescribableBean;
import org.ligoj.bootstrap.core.NamedBean;
import lombok.Getter;
import lombok.Setter;
/**
* A basic organizational container.
* "id" corresponds to the normalized name.
* "name" corresponds to the real name, not normalized.
* "description" corresponds to the normalized "Distinguished Name".
*/
@Getter
@Setter
public class ContainerOrg extends NamedBean implements ResourceOrg, IDescribableBean {
/**
* SID
*/
private static final long serialVersionUID = 1L;
/**
* Name pattern validation, includes LDAP injection protection.
*/
public static final String NAME_PATTERN = "[a-zA-Z0-9]([\\-: ]?[a-zA-Z0-9])+";
/**
* Name pattern validation with string limits, includes LDAP injection protection.
*/
public static final String NAME_PATTERN_WRAPPER = "^" + NAME_PATTERN + "$";
/**
* Flag indicating this container cannot be deleted or updated.
*/
private boolean locked;
@Length(max = 512)
private String description;
/**
* Parent group/company this container is member of. Identifier (normalized CN) is used.
*/
@JsonIgnore
private String parent;
/**
* All arguments constructor.
*
* @param dn Corresponds to the "Distinguished Name". Will be saved in "description".
* @param name "name" corresponds to the display name. Will be saved in "name", and in "id" in is normalized form.
*/
public ContainerOrg(final String dn, final String name) {
setId(Normalizer.normalize(name));
setName(name);
setDescription(dn);
}
@Override
public String getDn() {
return getDescription();
}
}