/** Activates the RMI Connectors. It starts the secure connectors. */ public void initialize() { try { // // start the common registry startCommonRegistry(); // // start the RMI connector (SSL + server authentication) startConnectorNoClientCertificate(); // // start the RMI connector (SSL + server authentication + // client authentication + identity given part SASL/PLAIN) // TODO startConnectorClientCertificate(clientConnection); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw new RuntimeException("Error while starting the RMI module : " + e.getMessage()); } if (debugEnabled()) { TRACER.debugVerbose("RMI module started"); } }
/** * A utility method which may be used by implementations in order to obtain the value of the * specified attribute from the provided entry as a boolean. * * @param entry The entry whose attribute is to be parsed as a boolean. * @param attributeType The attribute type whose value should be parsed as a boolean. * @return The attribute's value represented as a ConditionResult value, or * ConditionResult.UNDEFINED if the specified attribute does not exist in the entry. * @throws DirectoryException If the value cannot be decoded as a boolean. */ protected static final ConditionResult getBoolean( final Entry entry, final AttributeType attributeType) throws DirectoryException { final List<Attribute> attrList = entry.getAttribute(attributeType); if (attrList != null) { for (final Attribute a : attrList) { if (a.isEmpty()) { continue; } final String valueString = toLowerCase(a.iterator().next().getValue().toString()); if (valueString.equals("true") || valueString.equals("yes") || valueString.equals("on") || valueString.equals("1")) { if (debugEnabled()) { TRACER.debugInfo( "Attribute %s resolves to true for user entry " + "%s", attributeType.getNameOrOID(), entry.getDN().toString()); } return ConditionResult.TRUE; } if (valueString.equals("false") || valueString.equals("no") || valueString.equals("off") || valueString.equals("0")) { if (debugEnabled()) { TRACER.debugInfo( "Attribute %s resolves to false for user " + "entry %s", attributeType.getNameOrOID(), entry.getDN().toString()); } return ConditionResult.FALSE; } if (debugEnabled()) { TRACER.debugError( "Unable to resolve value %s for attribute %s " + "in user entry %s as a Boolean.", valueString, attributeType.getNameOrOID(), entry.getDN().toString()); } final Message message = ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN.get( valueString, attributeType.getNameOrOID(), entry.getDN().toString()); throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); } } if (debugEnabled()) { TRACER.debugInfo( "Returning %s because attribute %s does not exist " + "in user entry %s", ConditionResult.UNDEFINED.toString(), attributeType.getNameOrOID(), entry.getDN().toString()); } return ConditionResult.UNDEFINED; }
/** {@inheritDoc} */ public ConfigChangeResult applyConfigurationAdd(LogRotationPolicyCfg config) { // Default result code. ResultCode resultCode = ResultCode.SUCCESS; boolean adminActionRequired = false; ArrayList<Message> messages = new ArrayList<Message>(); try { RotationPolicy rotationPolicy = getRotationPolicy(config); DirectoryServer.registerRotationPolicy(config.dn(), rotationPolicy); } catch (ConfigException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } messages.add(e.getMessageObject()); resultCode = DirectoryServer.getServerErrorResultCode(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } messages.add( ERR_CONFIG_ROTATION_POLICY_CANNOT_CREATE_POLICY.get( String.valueOf(config.dn().toString()), stackTraceToSingleLineString(e))); resultCode = DirectoryServer.getServerErrorResultCode(); } return new ConfigChangeResult(resultCode, adminActionRequired, messages); }
/** * Generates an entry for a backup directory based on the provided DN. The DN must contain an RDN * component that specifies the path to the backup directory, and that directory must exist and be * a valid backup directory. * * @param entryDN The DN of the backup directory entry to retrieve. * @return The requested backup directory entry. * @throws DirectoryException If the specified directory does not exist or is not a valid backup * directory, or if the DN does not specify any backup directory. */ private Entry getBackupDirectoryEntry(DN entryDN) throws DirectoryException { // Make sure that the DN specifies a backup directory. AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); AttributeValue v = entryDN.getRDN().getAttributeValue(t); if (v == null) { Message message = ERR_BACKUP_DN_DOES_NOT_SPECIFY_DIRECTORY.get(String.valueOf(entryDN)); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, backupBaseDN, null); } // Get a handle to the backup directory and the information that it // contains. BackupDirectory backupDirectory; try { backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.getValue().toString()); } catch (ConfigException ce) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, ce); } Message message = ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(String.valueOf(entryDN), ce.getMessage()); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } Message message = ERR_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY.get(getExceptionMessage(e)); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } // Construct the backup directory entry to return. LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<ObjectClass, String>(2); ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); ObjectClass backupDirOC = DirectoryServer.getObjectClass(OC_BACKUP_DIRECTORY, true); ocMap.put(backupDirOC, OC_BACKUP_DIRECTORY); LinkedHashMap<AttributeType, List<Attribute>> opAttrs = new LinkedHashMap<AttributeType, List<Attribute>>(0); LinkedHashMap<AttributeType, List<Attribute>> userAttrs = new LinkedHashMap<AttributeType, List<Attribute>>(3); ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); attrList.add(Attributes.create(t, v)); userAttrs.put(t, attrList); t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true); attrList = new ArrayList<Attribute>(1); attrList.add( Attributes.create( t, AttributeValues.create(t, backupDirectory.getConfigEntryDN().toString()))); userAttrs.put(t, attrList); Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); e.processVirtualAttributes(); return e; }
/** * Closes this connection handler so that it will no longer accept new client connections. It may * or may not disconnect existing client connections based on the provided flag. * * @param stopRegistry Indicates if the RMI registry should be stopped */ public void finalizeConnectionHandler(boolean stopRegistry) { try { if (jmxRmiConnectorNoClientCertificate != null) { jmxRmiConnectorNoClientCertificate.stop(); } if (jmxRmiConnectorClientCertificate != null) { jmxRmiConnectorClientCertificate.stop(); } } catch (Exception e) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } jmxRmiConnectorNoClientCertificate = null; jmxRmiConnectorClientCertificate = null; // // Unregister connectors and stop them. try { ObjectName name = new ObjectName(jmxRmiConnectorNoClientCertificateName); if (mbs.isRegistered(name)) { mbs.unregisterMBean(name); } if (jmxRmiConnectorNoClientCertificate != null) { jmxRmiConnectorNoClientCertificate.stop(); } // TODO: unregister the connector with SSL client authen // name = new ObjectName(jmxRmiConnectorClientCertificateName); // if (mbs.isRegistered(name)) // { // mbs.unregisterMBean(name); // } // jmxRmiConnectorClientCertificate.stop() ; } catch (Exception e) { // TODO Log an error message if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } if (stopRegistry) { // // Close the socket try { if (rmiSsf != null) rmiSsf.close(); } catch (IOException e) { // TODO Log an error message if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } registry = null; } }
/** * Starts the common RMI registry. In order to provide RMI stub for remote client, the JMX RMI * connector should be register into an RMI registry. Each server will maintain its own private * one. * * @throws Exception if the registry cannot be started */ private void startCommonRegistry() throws Exception { int registryPort = jmxConnectionHandler.getListenPort(); // // create our local RMI registry if it does not exist already if (debugEnabled()) { TRACER.debugVerbose("start or reach an RMI registry on port %d", registryPort); } try { // // TODO Not yet implemented: If the host has several interfaces if (registry == null) { rmiSsf = new OpendsRmiServerSocketFactory(); registry = LocateRegistry.createRegistry(registryPort, null, rmiSsf); } } catch (RemoteException re) { // // is the registry already created ? if (debugEnabled()) { TRACER.debugWarning("cannot create the RMI registry -> already done ?"); } try { // // get a 'remote' reference on the registry Registry reg = LocateRegistry.getRegistry(registryPort); // // 'ping' the registry reg.list(); registry = reg; } catch (Exception e) { if (debugEnabled()) { // // no 'valid' registry found on the specified port TRACER.debugError("exception thrown while pinging the RMI registry"); // // throw the original exception TRACER.debugCaught(DebugLogLevel.ERROR, re); } throw re; } // // here the registry is ok even though // it was not created by this call if (debugEnabled()) { TRACER.debugWarning("RMI was registry already started"); } } }
/** {@inheritDoc} */ @Override() public void finalizeBackend() { // Deregister as a change listener. cfg.removeLocalDBChangeListener(this); // Deregister our base DNs. for (DN dn : rootContainer.getBaseDNs()) { try { DirectoryServer.deregisterBaseDN(dn); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } DirectoryServer.deregisterMonitorProvider(rootContainerMonitor); DirectoryServer.deregisterMonitorProvider(diskMonitor); // We presume the server will prevent more operations coming into this // backend, but there may be existing operations already in the // backend. We need to wait for them to finish. waitUntilQuiescent(); // Close the database. try { rootContainer.close(); rootContainer = null; } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } Message message = ERR_JEB_DATABASE_EXCEPTION.get(e.getMessage()); logError(message); } // Checksum this db environment and register its offline state id/checksum. DirectoryServer.registerOfflineBackendStateID(this.getBackendID(), checksumDbEnv()); // Deregister the alert generator. DirectoryServer.deregisterAlertGenerator(this); // Make sure the thread counts are zero for next initialization. threadTotalCount.set(0); threadWriteCount.set(0); // Log an informational message. Message message = NOTE_BACKEND_OFFLINE.get(cfg.getBackendId()); logError(message); }
/** * A utility method which may be used by implementations in order to obtain the value of the * specified attribute from the provided entry as a time in generalized time format. * * @param entry The entry whose attribute is to be parsed as a boolean. * @param attributeType The attribute type whose value should be parsed as a generalized time * value. * @return The requested time, or -1 if it could not be determined. * @throws DirectoryException If a problem occurs while attempting to decode the value as a * generalized time. */ protected static final long getGeneralizedTime( final Entry entry, final AttributeType attributeType) throws DirectoryException { long timeValue = -1; final List<Attribute> attrList = entry.getAttribute(attributeType); if (attrList != null) { for (final Attribute a : attrList) { if (a.isEmpty()) { continue; } final AttributeValue v = a.iterator().next(); try { timeValue = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(v.getNormalizedValue()); } catch (final Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); TRACER.debugWarning( "Unable to decode value %s for attribute %s " + "in user entry %s: %s", v.getValue().toString(), attributeType.getNameOrOID(), entry.getDN().toString(), stackTraceToSingleLineString(e)); } final Message message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.get( v.getValue().toString(), attributeType.getNameOrOID(), entry.getDN().toString(), String.valueOf(e)); throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); } break; } } if (timeValue == -1) { if (debugEnabled()) { TRACER.debugInfo( "Returning -1 because attribute %s does not " + "exist in user entry %s", attributeType.getNameOrOID(), entry.getDN().toString()); } } // FIXME: else to be consistent... return timeValue; }
/** * Verify the integrity of the backend instance. * * @param verifyConfig The verify configuration. * @param statEntry Optional entry to save stats into. * @return The error count. * @throws ConfigException If an unrecoverable problem arises during initialization. * @throws InitializationException If a problem occurs during initialization that is not related * to the server configuration. * @throws DirectoryException If a Directory Server error occurs. */ public long verifyBackend(VerifyConfig verifyConfig, Entry statEntry) throws InitializationException, ConfigException, DirectoryException { // If the backend already has the root container open, we must use the same // underlying root container boolean openRootContainer = rootContainer == null; long errorCount = 0; try { if (openRootContainer) { EnvironmentConfig envConfig = ConfigurableEnvironment.parseConfigEntry(cfg); envConfig.setReadOnly(true); envConfig.setAllowCreate(false); envConfig.setTransactional(false); envConfig.setConfigParam("je.env.isLocking", "true"); envConfig.setConfigParam("je.env.runCheckpointer", "true"); rootContainer = initializeRootContainer(envConfig); } VerifyJob verifyJob = new VerifyJob(verifyConfig); errorCount = verifyJob.verifyBackend(rootContainer, statEntry); } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw createDirectoryException(e); } catch (JebException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw new DirectoryException( DirectoryServer.getServerErrorResultCode(), e.getMessageObject()); } finally { // If a root container was opened in this method as read only, close it // to leave the backend in the same state. if (openRootContainer && rootContainer != null) { try { rootContainer.close(); rootContainer = null; } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } } return errorCount; }
/** {@inheritDoc} */ @Override() public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException { readerBegin(); EntryContainer ec; if (rootContainer != null) { ec = rootContainer.getEntryContainer(searchOperation.getBaseDN()); } else { Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID()); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } ec.sharedLock.lock(); try { ec.search(searchOperation); } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw createDirectoryException(e); } finally { ec.sharedLock.unlock(); readerEnd(); } }
/** {@inheritDoc} */ @Override() public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation) throws DirectoryException, CanceledOperationException { checkDiskSpace(modifyOperation); writerBegin(); DN entryDN = newEntry.getDN(); EntryContainer ec; if (rootContainer != null) { ec = rootContainer.getEntryContainer(entryDN); } else { Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID()); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } ec.sharedLock.lock(); try { ec.replaceEntry(oldEntry, newEntry, modifyOperation); } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw createDirectoryException(e); } finally { ec.sharedLock.unlock(); writerEnd(); } }
/** {@inheritDoc} */ @Override() public long numSubordinates(DN entryDN, boolean subtree) throws DirectoryException { EntryContainer ec; if (rootContainer != null) { ec = rootContainer.getEntryContainer(entryDN); } else { Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID()); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } if (ec == null) { return -1; } readerBegin(); ec.sharedLock.lock(); try { long count = ec.getNumSubordinates(entryDN, subtree); if (count == Long.MAX_VALUE) { // The index entry limit has exceeded and there is no count maintained. return -1; } return count; } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw createDirectoryException(e); } finally { ec.sharedLock.unlock(); readerEnd(); } }
/** * Reads an LDAP message from the associated input stream. * * @return The LDAP message read from the associated input stream, or <CODE>null</CODE> if the end * of the stream has been reached. * @throws IOException If a problem occurs while attempting to read from the input stream. * @throws ASN1Exception If a problem occurs while attempting to decode the data read as an ASN.1 * sequence. * @throws LDAPException If a problem occurs while attempting to decode the LDAP message. */ public LDAPMessage readMessage() throws IOException, ASN1Exception, LDAPException { debugInputStream.setRecordingEnabled(debugEnabled()); if (!asn1Reader.hasNextElement()) { // EOF was reached... return null; } LDAPMessage message = org.opends.server.protocols.ldap.LDAPReader.readMessage(asn1Reader); if (debugInputStream.isRecordingEnabled()) { ByteString bytesRead = debugInputStream.getRecordedBytes(); debugInputStream.clearRecordedBytes(); StringBuilder builder = new StringBuilder(); builder.append("bytes read from wire(len="); builder.append(bytesRead.length()); builder.append("):"); builder.append(ServerConstants.EOL); bytesRead.toHexPlusAscii(builder, 4); TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, builder.toString()); TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, message.toString()); } return message; }
/** {@inheritDoc} */ @Override() public DynamicGroup newInstance(Entry groupEntry) throws DirectoryException { ensureNotNull(groupEntry); // Get the memberURL attribute from the entry, if there is one, and parse // out the LDAP URLs that it contains. LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<LDAPURL>(); AttributeType memberURLType = DirectoryConfig.getAttributeType(ATTR_MEMBER_URL_LC, true); List<Attribute> attrList = groupEntry.getAttribute(memberURLType); if (attrList != null) { for (Attribute a : attrList) { for (AttributeValue v : a) { try { memberURLs.add(LDAPURL.decode(v.getValue().toString(), true)); } catch (DirectoryException de) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, de); } Message message = ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL.get( v.getValue().toString(), String.valueOf(groupEntry.getDN()), de.getMessageObject()); ErrorLogger.logError(message); } } } } return new DynamicGroup(groupEntry.getDN(), memberURLs); }
/** {@inheritDoc} */ @Override() public Entry getEntry(DN entryDN) throws DirectoryException { readerBegin(); EntryContainer ec; if (rootContainer != null) { ec = rootContainer.getEntryContainer(entryDN); } else { Message message = ERR_ROOT_CONTAINER_NOT_INITIALIZED.get(getBackendID()); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } ec.sharedLock.lock(); Entry entry; try { entry = ec.getEntry(entryDN); } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } throw createDirectoryException(e); } finally { ec.sharedLock.unlock(); readerEnd(); } return entry; }
/** * Getter for the serviceID field. * * @return The service ID. */ public String getServiceID() { try { return this.draftCNDbCursor.currentServiceID(); } catch (Exception e) { TRACER.debugCaught(DebugLogLevel.ERROR, e); return null; } }
/** * This method will attempt to checksum the current JE db environment by computing the Adler-32 * checksum on the latest JE log file available. * * @return The checksum of JE db environment or zero if checksum failed. */ private long checksumDbEnv() { File parentDirectory = getFileForPath(cfg.getDBDirectory()); File backendDirectory = new File(parentDirectory, cfg.getBackendId()); List<File> jdbFiles = new ArrayList<File>(); if (backendDirectory.isDirectory()) { jdbFiles = Arrays.asList( backendDirectory.listFiles( new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jdb"); } })); } if (!jdbFiles.isEmpty()) { Collections.sort(jdbFiles, Collections.reverseOrder()); FileInputStream fis = null; try { fis = new FileInputStream(jdbFiles.get(0).toString()); CheckedInputStream cis = new CheckedInputStream(fis, new Adler32()); byte[] tempBuf = new byte[8192]; while (cis.read(tempBuf) >= 0) {} return cis.getChecksum().getValue(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } finally { if (fis != null) { try { fis.close(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } } } return 0; }
/** * Getter for the replication change number field. * * @return The replication change number field. */ public ChangeNumber getChangeNumber() { try { ChangeNumber cn = this.draftCNDbCursor.currentChangeNumber(); return cn; } catch (Exception e) { TRACER.debugCaught(DebugLogLevel.ERROR, e); return null; } }
/** * Process all ACIs under the "cn=config" naming context and adds them to the ACI list cache. It * also logs messages about the number of ACIs added to the cache. This method is called once at * startup. It will put the server in lockdown mode if needed. * * @throws InitializationException If there is an error searching for the ACIs in the naming * context. */ private void processConfigAcis() throws InitializationException { LinkedHashSet<String> requestAttrs = new LinkedHashSet<String>(1); requestAttrs.add("aci"); LinkedList<Message> failedACIMsgs = new LinkedList<Message>(); InternalClientConnection conn = InternalClientConnection.getRootConnection(); ConfigHandler configBackend = DirectoryServer.getConfigHandler(); for (DN baseDN : configBackend.getBaseDNs()) { try { if (!configBackend.entryExists(baseDN)) { continue; } } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } // FIXME -- Is there anything that we need to do here? continue; } try { InternalSearchOperation internalSearch = new InternalSearchOperation( conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), null, baseDN, SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, SearchFilter.createFilterFromString("aci=*"), requestAttrs, null); LocalBackendSearchOperation localSearch = new LocalBackendSearchOperation(internalSearch); configBackend.search(localSearch); if (!internalSearch.getSearchEntries().isEmpty()) { int validAcis = aciList.addAci(internalSearch.getSearchEntries(), failedACIMsgs); if (!failedACIMsgs.isEmpty()) { aciListenerMgr.logMsgsSetLockDownMode(failedACIMsgs); } Message message = INFO_ACI_ADD_LIST_ACIS.get(Integer.toString(validAcis), String.valueOf(baseDN)); logError(message); } } catch (Exception e) { Message message = INFO_ACI_HANDLER_FAIL_PROCESS_ACI.get(); throw new InitializationException(message, e); } } }
/** Closes this LDAP reader and the underlying socket. */ public void close() { try { asn1Reader.close(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } if (socket != null) { try { socket.close(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } }
/** * Wait until there are no more threads accessing the database. It is assumed that new threads * have been prevented from entering the database at the time this method is called. */ private void waitUntilQuiescent() { while (threadTotalCount.get() > 0) { // Still have threads in the database so sleep a little try { Thread.sleep(500); } catch (InterruptedException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } }
/** * Returns {@code true} if this authentication policy state is associated with a user whose * account has been administratively disabled. * * <p>The default implementation is use the value of the "ds-pwp-account-disable" attribute in the * user's entry. * * @return {@code true} if this authentication policy state is associated with a user whose * account has been administratively disabled. */ public boolean isDisabled() { final AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_ACCOUNT_DISABLED, true); try { isDisabled = getBoolean(userEntry, type); } catch (final Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } isDisabled = ConditionResult.TRUE; if (debugEnabled()) { TRACER.debugWarning( "User %s is considered administratively " + "disabled because an error occurred while " + "attempting to make the determination: %s.", userEntry.getDN().toString(), stackTraceToSingleLineString(e)); } return true; } if (isDisabled == ConditionResult.UNDEFINED) { isDisabled = ConditionResult.FALSE; if (debugEnabled()) { TRACER.debugInfo( "User %s is not administratively disabled since " + "the attribute \"%s\" is not present in the entry.", userEntry.getDN().toString(), OP_ATTR_ACCOUNT_DISABLED); } return false; } if (debugEnabled()) { TRACER.debugInfo( "User %s %s administratively disabled.", userEntry.getDN().toString(), ((isDisabled == ConditionResult.TRUE) ? " is" : " is not")); } return isDisabled == ConditionResult.TRUE; }
/** {@inheritDoc} */ @Override public void finalizeBackend() { super.finalizeBackend(); currentConfig.removeBackupChangeListener(this); try { DirectoryServer.deregisterBaseDN(backupBaseDN); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } }
/** {@inheritDoc} */ @Override() public long getEntryCount() { if (rootContainer != null) { try { return rootContainer.getEntryCount(); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } } } return -1; }
private RootContainer initializeRootContainer(EnvironmentConfig envConfig) throws ConfigException, InitializationException { // Open the database environment try { RootContainer rc = new RootContainer(this, cfg); rc.open(envConfig); return rc; } catch (DatabaseException e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } Message message = ERR_JEB_OPEN_ENV_FAIL.get(e.getMessage()); throw new InitializationException(message, e); } }
/** {@inheritDoc} */ @Override() public boolean hasValue(Entry entry, VirtualAttributeRule rule) { Backend backend = DirectoryServer.getBackend(entry.getDN()); try { ConditionResult ret = backend.hasSubordinates(entry.getDN()); return ret != null && ret != ConditionResult.UNDEFINED; } catch (DirectoryException de) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, de); } return false; } }
/** * Indicates whether the provided value is acceptable for use in an attribute with this syntax. If * it is not, then the reason may be appended to the provided buffer. * * @param value The value for which to make the determination. * @param invalidReason The buffer to which the invalid reason should be appended. * @return <CODE>true</CODE> if the provided value is acceptable for use with this syntax, or * <CODE>false</CODE> if not. */ @Override public boolean valueIsAcceptable(ByteSequence value, MessageBuilder invalidReason) { // We'll use the decodeAttributeType method to determine if the value is // acceptable. try { decodeLDAPSyntax(value, DirectoryServer.getSchema(), true); return true; } catch (DirectoryException de) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, de); } invalidReason.append(de.getMessageObject()); return false; } }
/** * Process all global ACI attribute types found in the configuration entry and adds them to that * ACI list cache. It also logs messages about the number of ACI attribute types added to the * cache. This method is called once at startup. It also will put the server into lockdown mode if * needed. * * @param configuration The config handler containing the ACI configuration information. * @throws InitializationException If there is an error reading the global ACIs from the * configuration entry. */ private void processGlobalAcis(DseeCompatAccessControlHandlerCfg configuration) throws InitializationException { SortedSet<Aci> globalAcis = configuration.getGlobalACI(); try { if (globalAcis != null) { aciList.addAci(DN.nullDN(), globalAcis); Message message = INFO_ACI_ADD_LIST_GLOBAL_ACIS.get(Integer.toString(globalAcis.size())); logError(message); } } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } Message message = INFO_ACI_HANDLER_FAIL_PROCESS_GLOBAL_ACI.get(String.valueOf(configuration.dn())); throw new InitializationException(message, e); } }
/** {@inheritDoc} */ @Override() public Set<AttributeValue> getValues(Entry entry, VirtualAttributeRule rule) { Backend backend = DirectoryServer.getBackend(entry.getDN()); try { ConditionResult ret = backend.hasSubordinates(entry.getDN()); if (ret != null && ret != ConditionResult.UNDEFINED) { AttributeValue value = AttributeValues.create( ByteString.valueOf(ret.toString()), ByteString.valueOf(ret.toString())); return Collections.singleton(value); } } catch (DirectoryException de) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, de); } } return Collections.emptySet(); }
/** {@inheritDoc} */ @Override() public boolean isIndexed(AttributeType attributeType, IndexType indexType) { try { EntryContainer ec = rootContainer.getEntryContainer(baseDNs[0]); AttributeIndex ai = ec.getAttributeIndex(attributeType); if (ai == null) { return false; } Set<LocalDBIndexCfgDefn.IndexType> indexTypes = ai.getConfiguration().getIndexType(); switch (indexType) { case PRESENCE: return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.PRESENCE); case EQUALITY: return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.EQUALITY); case SUBSTRING: case SUBINITIAL: case SUBANY: case SUBFINAL: return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.SUBSTRING); case GREATER_OR_EQUAL: case LESS_OR_EQUAL: return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.ORDERING); case APPROXIMATE: return indexTypes.contains(LocalDBIndexCfgDefn.IndexType.APPROXIMATE); default: return false; } } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } return false; } }