001/*
002 *  Copyright 2017 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.core.impl.user;
017
018import org.ametys.core.user.UserIdentity;
019import org.ametys.plugins.core.impl.user.directory.LdapUserDirectory;
020
021/**
022 * {@link UserIdentity} of a user in a {@link LdapUserDirectory}. It contains the DN of the user
023 */
024public class LdapUserIdentity extends UserIdentity
025{
026    /** The DN of the user */
027    protected String _dn;
028
029    /**
030     * Constructs a LDAP user identity, containing the DN of the user
031     * @param login The login of the user
032     * @param populationId The id of the user population the user belongs to
033     * @param dn The DN of the user in the LDAP
034     */
035    public LdapUserIdentity(String login, String populationId, String dn)
036    {
037        super(login, populationId);
038        _dn = dn;
039    }
040    
041    /**
042     * Gets the DN of the user in the {@link LdapUserDirectory}
043     * @return the DN of the user
044     */
045    public String getDn()
046    {
047        return _dn;
048    }
049    
050    @Override
051    public String toString()
052    {
053        return "LdapUserIdentity [login=" + getLogin() + ", population=" + getPopulationId() + ", DN='" + _dn + "']";
054    }
055}