/** {@inheritDoc} */
  @Override
  public ByteString encodePasswordWithScheme(ByteSequence plaintext) throws DirectoryException {
    StringBuilder buffer = new StringBuilder();
    buffer.append('{');
    buffer.append(STORAGE_SCHEME_NAME_SHA_1);
    buffer.append('}');

    // TODO: Can we avoid this copy?
    byte[] plaintextBytes = null;
    byte[] digestBytes;

    synchronized (digestLock) {
      try {
        plaintextBytes = plaintext.toByteArray();
        digestBytes = messageDigest.digest(plaintextBytes);
      } catch (Exception e) {
        logger.traceException(e);

        LocalizableMessage message =
            ERR_PWSCHEME_CANNOT_ENCODE_PASSWORD.get(CLASS_NAME, getExceptionMessage(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
      } finally {
        if (plaintextBytes != null) {
          Arrays.fill(plaintextBytes, (byte) 0);
        }
      }
    }

    buffer.append(Base64.encode(digestBytes));

    return ByteString.valueOfUtf8(buffer);
  }
 /** {@inheritDoc} */
 @Override
 public void toString(StringBuilder buffer) {
   buffer.append("VirtualStaticGroup(dn=");
   buffer.append(groupEntryDN);
   buffer.append(",targetGroupDN=");
   buffer.append(targetGroupDN);
   buffer.append(")");
 }
Exemplo n.º 3
0
  /** {@inheritDoc} */
  @Override()
  public void toString(StringBuilder buffer) {
    buffer.append("DynamicGroup(dn=");
    buffer.append(groupEntryDN);
    buffer.append(",urls={");

    if (!memberURLs.isEmpty()) {
      Iterator<LDAPURL> iterator = memberURLs.iterator();
      buffer.append("\"");
      iterator.next().toString(buffer, false);

      while (iterator.hasNext()) {
        buffer.append("\", ");
        iterator.next().toString(buffer, false);
      }

      buffer.append("\"");
    }

    buffer.append("})");
  }