
alpine.model.LdapUser Maven / Gradle / Ivy
/*
* This file is part of Alpine.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) Steve Springett. All Rights Reserved.
*/
package alpine.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import javax.jdo.annotations.Column;
import javax.jdo.annotations.Element;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Join;
import javax.jdo.annotations.Order;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import java.io.Serializable;
import java.security.Principal;
import java.util.List;
/**
* Persistable object representing an LdapUser.
*
* @author Steve Springett
* @since 1.0.0
*/
@PersistenceCapable
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LdapUser implements Serializable, Principal, UserPrincipal {
private static final long serialVersionUID = 261924579887470488L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE)
@JsonIgnore
private long id;
@Persistent
@Unique(name = "LDAPUSER_USERNAME_IDX")
@Column(name = "USERNAME")
@NotBlank
@Size(min = 1, max = 255)
@Pattern(regexp = "[\\P{Cc}]+", message = "The username must not contain control characters")
private String username;
@Persistent
@Column(name = "DN", allowsNull = "false")
@NotBlank
@Size(min = 1, max = 255)
@Pattern(regexp = "[\\P{Cc}]+", message = "The distinguished name must not contain control characters")
private String dn;
@Persistent(table = "LDAPUSERS_TEAMS", defaultFetchGroup = "true")
@Join(column = "LDAPUSER_ID")
@Element(column = "TEAM_ID")
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "name ASC"))
private List teams;
@Persistent
@Column(name = "EMAIL", allowsNull = "true")
@Size(max = 255)
@Pattern(regexp = "[\\P{Cc}]+", message = "The email address must not contain control characters")
private String email;
@Persistent(table = "LDAPUSERS_PERMISSIONS", defaultFetchGroup = "true")
@Join(column = "LDAPUSER_ID")
@Element(column = "PERMISSION_ID")
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "name ASC"))
private List permissions;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDN() {
return dn;
}
public void setDN(String dn) {
this.dn = dn;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public List getTeams() {
return teams;
}
public void setTeams(List teams) {
this.teams = teams;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public List getPermissions() {
return permissions;
}
public void setPermissions(List permissions) {
this.permissions = permissions;
}
/**
* Do not use - only here to satisfy Principal implementation requirement.
* @deprecated use {@link LdapUser#getUsername()}
* @return the value of {@link #getUsername()}
*/
@Deprecated
@JsonIgnore
public String getName() {
return getUsername();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy