001package org.apache.archiva.redback.common.ldap.role; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 021import java.util.ArrayList; 022import java.util.Collection; 023import java.util.Collections; 024import java.util.List; 025 026/** 027 * Representation of a LDAP group 028 * @author Martin Stockhammer <martin_s@apache.org> 029 * @since 3.0 030 */ 031public class LdapGroup 032{ 033 String dn = ""; 034 String name = ""; 035 String description = ""; 036 List<String> memberList; 037 038 public LdapGroup( ) 039 { 040 } 041 042 public LdapGroup( String dn ) 043 { 044 this.dn = dn; 045 } 046 047 public LdapGroup( String dn, String name, String displayName, String description ) 048 { 049 this.dn = dn; 050 this.name = name; 051 this.description = description; 052 } 053 054 public String getDn( ) 055 { 056 return dn; 057 } 058 059 public void setDn( String dn ) 060 { 061 this.dn = dn; 062 } 063 064 public String getName( ) 065 { 066 return name; 067 } 068 069 public void setName( String name ) 070 { 071 this.name = name; 072 } 073 074 public String getDescription( ) 075 { 076 return description; 077 } 078 079 public void setDescription( String description ) 080 { 081 this.description = description; 082 } 083 084 public void addMember(String member) { 085 if (this.memberList==null) { 086 this.memberList = new ArrayList<>( ); 087 } 088 this.memberList.add( member ); 089 } 090 091 public void setMemberList( Collection<String> memberList) { 092 this.memberList = new ArrayList<>( memberList ); 093 } 094 095 public List<String> getMemberList() { 096 if (memberList==null) { 097 return Collections.EMPTY_LIST; 098 } 099 return memberList; 100 } 101 102 @Override 103 public boolean equals( Object o ) 104 { 105 if ( this == o ) return true; 106 if ( o == null || getClass( ) != o.getClass( ) ) return false; 107 108 LdapGroup ldapGroup = (LdapGroup) o; 109 110 return dn.equals( ldapGroup.dn ); 111 } 112 113 @Override 114 public int hashCode( ) 115 { 116 return dn.hashCode( ); 117 } 118 119 @Override 120 public String toString( ) 121 { 122 final StringBuilder sb = new StringBuilder( "LdapGroup{" ); 123 sb.append( "dn='" ).append( dn ).append( '\'' ); 124 sb.append( ", name='" ).append( name ).append( '\'' ); 125 sb.append( '}' ); 126 return sb.toString( ); 127 } 128}