001/* 002 * Copyright 2012-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2018 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.extensions; 022 023 024 025import java.io.Serializable; 026import java.util.Date; 027 028import com.unboundid.util.NotMutable; 029import com.unboundid.util.StaticUtils; 030import com.unboundid.util.ThreadSafety; 031import com.unboundid.util.ThreadSafetyLevel; 032 033 034 035/** 036 * This class defines a data structure with information about a subtree with 037 * restricted access, as may be included in a 038 * {@link GetSubtreeAccessibilityExtendedResult}. 039 * <BR> 040 * <BLOCKQUOTE> 041 * <B>NOTE:</B> This class, and other classes within the 042 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 043 * supported for use against Ping Identity, UnboundID, and 044 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 045 * for proprietary functionality or for external specifications that are not 046 * considered stable or mature enough to be guaranteed to work in an 047 * interoperable way with other types of LDAP servers. 048 * </BLOCKQUOTE> 049 */ 050@NotMutable() 051@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 052public final class SubtreeAccessibilityRestriction 053 implements Serializable 054{ 055 /** 056 * The serial version UID for this serializable class. 057 */ 058 private static final long serialVersionUID = -1893365464740536092L; 059 060 061 062 // The time the subtree accessibility restriction was created. 063 private final Date effectiveTime; 064 065 // The DN of a user allowed to bypass any associated restrictions. 066 private final String bypassUserDN; 067 068 // The base DN of the affected subtree. 069 private final String subtreeBaseDN; 070 071 // The accessibility state of the affected subtree. 072 private final SubtreeAccessibilityState accessibilityState; 073 074 075 076 /** 077 * Creates a new subtree accessibility restriction object with the provided 078 * information. 079 * 080 * @param subtreeBaseDN The base DN of the affected subtree. 081 * @param accessibilityState The accessibility state of the affected 082 * subtree. 083 * @param bypassUserDN The DN of a user allowed to bypass any 084 * associated restrictions, if defined. 085 * @param effectiveTime The time this restriction was put into place. 086 */ 087 public SubtreeAccessibilityRestriction(final String subtreeBaseDN, 088 final SubtreeAccessibilityState accessibilityState, 089 final String bypassUserDN, final Date effectiveTime) 090 { 091 this.subtreeBaseDN = subtreeBaseDN; 092 this.accessibilityState = accessibilityState; 093 this.bypassUserDN = bypassUserDN; 094 this.effectiveTime = effectiveTime; 095 } 096 097 098 099 /** 100 * Retrieves the base DN for the affected subtree. 101 * 102 * @return The base DN for the affected subtree. 103 */ 104 public String getSubtreeBaseDN() 105 { 106 return subtreeBaseDN; 107 } 108 109 110 111 /** 112 * Retrieves the accessibility state for the affected subtree. 113 * 114 * @return The accessibility state for the affected subtree. 115 */ 116 public SubtreeAccessibilityState getAccessibilityState() 117 { 118 return accessibilityState; 119 } 120 121 122 123 /** 124 * Retrieves the DN of a user that will be allowed to bypass any restrictions 125 * on the affected subtree. 126 * 127 * @return The DN of a user that will be allowed to bypass any restrictions 128 * on the affected subtree, or {@code null} if no bypass user is 129 * defined. 130 */ 131 public String getBypassUserDN() 132 { 133 return bypassUserDN; 134 } 135 136 137 138 /** 139 * Retrieves the time the accessibility restriction was put into place. 140 * 141 * @return The time the accessibility restriction was put into place. 142 */ 143 public Date getEffectiveTime() 144 { 145 return effectiveTime; 146 } 147 148 149 150 /** 151 * Retrieves a string representation of this accessibility restriction. 152 * 153 * @return A string representation of this accessibility restriction. 154 */ 155 @Override() 156 public String toString() 157 { 158 final StringBuilder buffer = new StringBuilder(); 159 toString(buffer); 160 return buffer.toString(); 161 } 162 163 164 165 /** 166 * Appends a string representation of this accessibility restriction to the 167 * provided buffer. 168 * 169 * @param buffer The buffer to which the information should be appended. 170 */ 171 public void toString(final StringBuilder buffer) 172 { 173 buffer.append("SubtreeAccessibilityRestriction(base='"); 174 buffer.append(subtreeBaseDN.replace("\\\"", "\\22")); 175 buffer.append("', state='"); 176 buffer.append(accessibilityState.getStateName()); 177 buffer.append('\''); 178 179 if (bypassUserDN != null) 180 { 181 buffer.append(", bypassUser='"); 182 buffer.append(bypassUserDN.replace("\\\"", "\\22")); 183 buffer.append('\''); 184 } 185 186 buffer.append(", effectiveTime='"); 187 buffer.append(StaticUtils.encodeGeneralizedTime(effectiveTime)); 188 buffer.append("')"); 189 } 190}