| | |
| | | Main.connection = connection; |
| | | |
| | | final BindRequest request = Requests.newSimpleBindRequest(userName, |
| | | password); |
| | | password.toCharArray()); |
| | | connection.bind(request, new BindResultHandlerImpl()); |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.bind(userName, password); |
| | | connection.bind(userName, password.toCharArray()); |
| | | |
| | | // Write the changes. |
| | | final ConnectionChangeRecordWriter writer = new ConnectionChangeRecordWriter( |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.bind(userName, password); |
| | | connection.bind(userName, password.toCharArray()); |
| | | |
| | | // Read the entries and output them as LDIF. |
| | | final ConnectionEntryReader reader = connection.search(baseDN, scope, |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2009 Parametric Technology Corporation (PTC) |
| | | */ |
| | | |
| | |
| | | import javax.net.ssl.TrustManagerFactory; |
| | | import javax.net.ssl.X509KeyManager; |
| | | |
| | | import com.sun.opends.sdk.util.Platform; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | // Handle IBM specific cases if the user did not specify a algorithm |
| | | // and/or provider. |
| | | if (userSpecifiedAlgo == null && Platform.isVendor("IBM")) |
| | | final String vendor = System.getProperty("java.vendor"); |
| | | if (vendor.startsWith("IBM")) |
| | | { |
| | | userSpecifiedAlgo = "IbmX509"; |
| | | } |
| | | if (userSpecifiedProvider == null && Platform.isVendor("IBM")) |
| | | { |
| | | userSpecifiedProvider = "IBMJSSE2"; |
| | | if (userSpecifiedAlgo == null) |
| | | { |
| | | userSpecifiedAlgo = "IbmX509"; |
| | | } |
| | | if (userSpecifiedProvider == null) |
| | | { |
| | | userSpecifiedProvider = "IBMJSSE2"; |
| | | } |
| | | } |
| | | |
| | | // Have some fallbacks to choose the provider and algorith of the |
| | |
| | | if(successRecentCount.get() * ((float)invalidCredPercent/100) > |
| | | invalidCredRecentCount.get()) |
| | | { |
| | | sbr.setPassword("invalid-password"); |
| | | sbr.setPassword("invalid-password".toCharArray()); |
| | | } |
| | | else |
| | | { |
| | |
| | | if(successRecentCount.get() * ((float)invalidCredPercent/100) > |
| | | invalidCredRecentCount.get()) |
| | | { |
| | | sbr.setPassword("invalid-password"); |
| | | sbr.setPassword("invalid-password".toCharArray()); |
| | | } |
| | | else |
| | | { |
| | |
| | | if(successRecentCount.get() * ((float)invalidCredPercent/100) > |
| | | invalidCredRecentCount.get()) |
| | | { |
| | | sbr.setPassword("invalid-password"); |
| | | sbr.setPassword("invalid-password".toCharArray()); |
| | | } |
| | | else |
| | | { |
| | |
| | | if(successRecentCount.get() * ((float)invalidCredPercent/100) > |
| | | invalidCredRecentCount.get()) |
| | | { |
| | | sbr.setPassword("invalid-password"); |
| | | sbr.setPassword("invalid-password".toCharArray()); |
| | | } |
| | | else |
| | | { |
| | |
| | | if(successRecentCount.get() * ((float)invalidCredPercent/100) > |
| | | invalidCredRecentCount.get()) |
| | | { |
| | | sbr.setPassword("invalid-password"); |
| | | sbr.setPassword("invalid-password".toCharArray()); |
| | | } |
| | | else |
| | | { |
| | |
| | | * method will always throw {@code UnsupportedOperationException}. |
| | | */ |
| | | @Override |
| | | public BindResult bind(final String name, final String password) |
| | | public BindResult bind(final String name, final char[] password) |
| | | throws UnsupportedOperationException |
| | | { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | if (bindNameArg.isPresent() || bindPasswordFileArg.isPresent() |
| | | || bindPasswordArg.isPresent()) |
| | | { |
| | | bindRequest = |
| | | Requests.newSimpleBindRequest(getBindName(), getPassword()); |
| | | bindRequest = Requests.newSimpleBindRequest(getBindName(), |
| | | getPassword().toCharArray()); |
| | | } |
| | | } |
| | | else if (mech.equals(DigestMD5SASLBindRequest.SASL_MECHANISM_NAME)) |
| | |
| | | { |
| | | tm = TrustManagers.checkValidityDates(TrustManagers.checkHostName( |
| | | hostNameArg.getValue(), TrustManagers.checkUsingTrustStore( |
| | | trustStorePathArg.getValue(), getTrustStorePIN(), null))); |
| | | trustStorePathArg.getValue(), getTrustStorePIN().toCharArray(), |
| | | null))); |
| | | } |
| | | else if (getTrustStore() != null) |
| | | { |
| | | tm = TrustManagers.checkValidityDates(TrustManagers.checkHostName( |
| | | hostNameArg.getValue(), TrustManagers.checkUsingTrustStore( |
| | | getTrustStore(), getTrustStorePIN(), null))); |
| | | getTrustStore(), getTrustStorePIN().toCharArray(), null))); |
| | | } |
| | | |
| | | if (app != null && !app.isQuiet()) |
| | |
| | | if (result.getGeneratedPassword() != null) |
| | | { |
| | | message = INFO_LDAPPWMOD_GENERATED_PASSWORD.get(result |
| | | .getGeneratedPasswordAsString()); |
| | | .getGeneratedPassword().toString()); |
| | | println(message); |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | */ |
| | | package com.sun.opends.sdk.util; |
| | | |
| | |
| | | |
| | | import static com.sun.opends.sdk.util.Validator.ensureNotNull; |
| | | |
| | | import java.text.Normalizer; |
| | | import java.text.Normalizer.Form; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | |
| | |
| | | // Map the attribute value. |
| | | map(buffer, sequence.subSequence(i, length), trim, foldCase); |
| | | // Normalize the attribute value. |
| | | normalize(buffer); |
| | | String normalizedForm = Normalizer.normalize(buffer, Form.NFKD); |
| | | buffer.setLength(0); |
| | | buffer.append(normalizedForm); |
| | | break; |
| | | } |
| | | int buffLen = buffer.length(); |
| | |
| | | |
| | | |
| | | |
| | | // Normalizes the input string with NFKC Form. |
| | | private static void normalize(final StringBuilder buffer) |
| | | { |
| | | Platform.normalize(buffer); |
| | | } |
| | | |
| | | |
| | | |
| | | // Prevent instantiation. |
| | | private StringPrepProfile() |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public BindResult bind(final String name, final String password) |
| | | public BindResult bind(final String name, final char[] password) |
| | | throws ErrorResultException, InterruptedException, |
| | | LocalizedIllegalArgumentException, UnsupportedOperationException, |
| | | IllegalStateException, NullPointerException |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.sdk; |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.CharBuffer; |
| | | import java.nio.charset.Charset; |
| | | import java.util.logging.Level; |
| | | |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns a byte string containing the UTF-8 encoded bytes of the provided |
| | | * char array. |
| | | * |
| | | * @param chars |
| | | * The char array to use. |
| | | * @return A byte string containing the UTF-8 encoded bytes of the provided |
| | | * char array. |
| | | */ |
| | | public static ByteString valueOf(final char[] chars) |
| | | { |
| | | Charset utf8 = Charset.forName("UTF-8"); |
| | | ByteBuffer buffer = utf8.encode(CharBuffer.wrap(chars)); |
| | | byte[] bytes = new byte[buffer.remaining()]; |
| | | buffer.get(bytes); |
| | | return wrap(bytes); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a byte string that wraps the provided byte array. |
| | | * <p> |
| | | * <b>NOTE:</b> this method takes ownership of the provided byte array and, |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the UTF-8 decoded char array representation of this byte sequence. |
| | | * |
| | | * @return The UTF-8 decoded char array representation of this byte sequence. |
| | | */ |
| | | public char[] toCharArray() |
| | | { |
| | | Charset utf8 = Charset.forName("UTF-8"); |
| | | CharBuffer charBuffer = utf8 |
| | | .decode(ByteBuffer.wrap(buffer, offset, length)); |
| | | char[] chars = new char[charBuffer.remaining()]; |
| | | charBuffer.get(chars); |
| | | return chars; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the integer value represented by the first four bytes of this byte |
| | | * string in big-endian order. |
| | | * |
| | |
| | | * @throws NullPointerException |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | BindResult bind(String name, String password) throws ErrorResultException, |
| | | BindResult bind(String name, char[] password) throws ErrorResultException, |
| | | InterruptedException, LocalizedIllegalArgumentException, |
| | | UnsupportedOperationException, IllegalStateException, |
| | | NullPointerException; |
| | |
| | | * If {@code file} was {@code null}. |
| | | */ |
| | | public static X509KeyManager useKeyStoreFile(final String file, |
| | | final String password, final String format) |
| | | final char[] password, final String format) |
| | | throws GeneralSecurityException, IOException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(file); |
| | | |
| | | final File keyStoreFile = new File(file); |
| | | final char[] keyStorePassword = password != null ? password.toCharArray() |
| | | : null; |
| | | final String keyStoreFormat = format != null ? format : KeyStore |
| | | .getDefaultType(); |
| | | |
| | |
| | | try |
| | | { |
| | | fos = new FileInputStream(keyStoreFile); |
| | | keyStore.load(fos, keyStorePassword); |
| | | keyStore.load(fos, password); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | final KeyManagerFactory kmf = KeyManagerFactory |
| | | .getInstance(KeyManagerFactory.getDefaultAlgorithm()); |
| | | kmf.init(keyStore, keyStorePassword); |
| | | kmf.init(keyStore, password); |
| | | |
| | | X509KeyManager x509km = null; |
| | | for (final KeyManager km : kmf.getKeyManagers()) |
| | |
| | | * @throws IOException |
| | | * If the PKCS#11 token could not be found or could not be read. |
| | | */ |
| | | public static X509KeyManager usePKCS11Token(final String password) |
| | | public static X509KeyManager usePKCS11Token(final char[] password) |
| | | throws GeneralSecurityException, IOException |
| | | { |
| | | final char[] keyStorePassword = password != null ? password.toCharArray() |
| | | : null; |
| | | final KeyStore keyStore = KeyStore.getInstance("PKCS11"); |
| | | keyStore.load(null, keyStorePassword); |
| | | keyStore.load(null, password); |
| | | final KeyManagerFactory kmf = KeyManagerFactory |
| | | .getInstance(KeyManagerFactory.getDefaultAlgorithm()); |
| | | kmf.init(keyStore, keyStorePassword); |
| | | kmf.init(keyStore, password); |
| | | |
| | | X509KeyManager x509km = null; |
| | | for (final KeyManager km : kmf.getKeyManagers()) |
| | |
| | | * If {@code file} was {@code null}. |
| | | */ |
| | | public static X509TrustManager checkUsingTrustStore(final String file, |
| | | final String password, final String format) |
| | | final char[] password, final String format) |
| | | throws GeneralSecurityException, IOException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(file); |
| | | |
| | | final File trustStoreFile = new File(file); |
| | | final char[] trustStorePassword = password != null ? password.toCharArray() |
| | | : null; |
| | | final String trustStoreFormat = format != null ? format : KeyStore |
| | | .getDefaultType(); |
| | | |
| | |
| | | try |
| | | { |
| | | fos = new FileInputStream(trustStoreFile); |
| | | keyStore.load(fos, trustStorePassword); |
| | | keyStore.load(fos, password); |
| | | } |
| | | finally |
| | | { |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | CRAMMD5SASLBindRequest setPassword(String password) |
| | | CRAMMD5SASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public CRAMMD5SASLBindRequest setPassword(final String password) |
| | | public CRAMMD5SASLBindRequest setPassword(final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | DigestMD5SASLBindRequest setPassword(String password) |
| | | DigestMD5SASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(final String password) |
| | | public DigestMD5SASLBindRequest setPassword(final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | GSSAPISASLBindRequest setPassword(String password) |
| | | GSSAPISASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(final String password) |
| | | public GSSAPISASLBindRequest setPassword(final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the desired password for the user decoded as a UTF-8 string, or |
| | | * {@code null} if a new password should be generated. |
| | | * |
| | | * @return The desired password for the user decoded as a UTF-8 string, or |
| | | * {@code null} if a new password should be generated. |
| | | */ |
| | | String getNewPasswordAsString(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | String getOID(); |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the current password for the user, if known, decoded as a UTF-8 |
| | | * string. |
| | | * |
| | | * @return The current password for the user decoded as a UTF-8 string, or |
| | | * {@code null} if the password is not known. |
| | | */ |
| | | String getOldPasswordAsString(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | ExtendedResultDecoder<PasswordModifyExtendedResult> getResultDecoder(); |
| | |
| | | * If this password modify extended request does not permit the new |
| | | * password to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setNewPassword(String newPassword) |
| | | PasswordModifyExtendedRequest setNewPassword(char[] newPassword) |
| | | throws UnsupportedOperationException; |
| | | |
| | | |
| | |
| | | * If this password modify extended request does not permit the old |
| | | * password to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setOldPassword(String oldPassword) |
| | | PasswordModifyExtendedRequest setOldPassword(char[] oldPassword) |
| | | throws UnsupportedOperationException; |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getNewPasswordAsString() |
| | | { |
| | | return newPassword != null ? newPassword.toString() : null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getOldPasswordAsString() |
| | | { |
| | | return oldPassword != null ? oldPassword.toString() : null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ExtendedResultDecoder<PasswordModifyExtendedResult> getResultDecoder() |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setNewPassword(final String newPassword) |
| | | public PasswordModifyExtendedRequest setNewPassword(final char[] newPassword) |
| | | { |
| | | this.newPassword = (newPassword != null) ? ByteString.valueOf(newPassword) |
| | | : null; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setOldPassword(final String oldPassword) |
| | | public PasswordModifyExtendedRequest setOldPassword(final char[] oldPassword) |
| | | { |
| | | this.oldPassword = (oldPassword != null) ? ByteString.valueOf(oldPassword) |
| | | : null; |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | PlainSASLBindRequest setPassword(String password) |
| | | PlainSASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PlainSASLBindRequest setPassword(final String password) |
| | | public PlainSASLBindRequest setPassword(final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest(final String name, |
| | | final String password) throws NullPointerException |
| | | final char[] password) throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(name, password); |
| | | return new SimpleBindRequestImpl(name, ByteString.valueOf(password)); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.sdk.requests; |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the password of the Directory object that the client wishes to bind |
| | | * as decoded as a UTF-8 string. The password may be empty (but never {@code |
| | | * null}) when used for of anonymous or unauthenticated binds. |
| | | * |
| | | * @return The password of the Directory object that the client wishes to bind |
| | | * as decoded as a UTF-8 string. |
| | | */ |
| | | String getPasswordAsString(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the name of the Directory object that the client wishes to bind as. |
| | | * The name may be empty (but never {@code null} when used for of anonymous |
| | | * binds, or when using SASL authentication. The server shall not dereference |
| | |
| | | * Sets the password of the Directory object that the client wishes to bind |
| | | * as. The password will be converted to a UTF-8 octet string. The password |
| | | * may be empty (but never {@code null}) when used for of anonymous or |
| | | * unauthenticated binds. |
| | | * unauthenticated binds. Subsequent modifications to the {@code password} |
| | | * array will not alter this bind request. |
| | | * |
| | | * @param password |
| | | * The password of the Directory object that the client wishes to |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | SimpleBindRequest setPassword(String password) |
| | | SimpleBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getPasswordAsString() |
| | | { |
| | | return password.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public SimpleBindRequest setName(final String name) |
| | | throws UnsupportedOperationException, NullPointerException |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public SimpleBindRequest setPassword(final String password) |
| | | public SimpleBindRequest setPassword(final char[] password) |
| | | throws UnsupportedOperationException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | builder.append(getName()); |
| | | builder.append(", authentication=simple"); |
| | | builder.append(", password="); |
| | | builder.append(getPasswordAsString()); |
| | | builder.append(getPassword()); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CRAMMD5SASLBindRequest setPassword(String password) |
| | | public CRAMMD5SASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(String password) |
| | | public DigestMD5SASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(String password) |
| | | public GSSAPISASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | return impl.getNewPassword(); |
| | | } |
| | | |
| | | public String getNewPasswordAsString() { |
| | | return impl.getNewPasswordAsString(); |
| | | } |
| | | |
| | | public ByteString getOldPassword() { |
| | | return impl.getOldPassword(); |
| | | } |
| | | |
| | | public String getOldPasswordAsString() { |
| | | return impl.getOldPasswordAsString(); |
| | | } |
| | | |
| | | public ByteString getUserIdentity() { |
| | | return impl.getUserIdentity(); |
| | | } |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setNewPassword(String newPassword) { |
| | | public PasswordModifyExtendedRequest setNewPassword(char[] newPassword) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setOldPassword(String oldPassword) { |
| | | public PasswordModifyExtendedRequest setOldPassword(char[] oldPassword) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PlainSASLBindRequest setPassword(String password) |
| | | public PlainSASLBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | return impl.getPassword(); |
| | | } |
| | | |
| | | public String getPasswordAsString() { |
| | | return impl.getPasswordAsString(); |
| | | } |
| | | |
| | | public SimpleBindRequest setName(String name) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public SimpleBindRequest setPassword(String password) |
| | | public SimpleBindRequest setPassword(char[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the newly generated password decoded as a UTF-8 string, but only if |
| | | * the password modify request succeeded and a generated password was |
| | | * requested. |
| | | * |
| | | * @return The newly generated password decoded as a UTF-8 string, or {@code |
| | | * null} if the password modify request failed or a generated password |
| | | * was not requested. |
| | | */ |
| | | String getGeneratedPasswordAsString(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | String getMatchedDN(); |
| | |
| | | * If this password modify extended result does not permit the |
| | | * generated password to be set. |
| | | */ |
| | | PasswordModifyExtendedResult setGeneratedPassword(String password) |
| | | PasswordModifyExtendedResult setGeneratedPassword(char[] password) |
| | | throws UnsupportedOperationException; |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public String getGeneratedPasswordAsString() |
| | | { |
| | | return password != null ? password.toString() : null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedResult setGeneratedPassword( |
| | | final String password) throws UnsupportedOperationException |
| | | final char[] password) throws UnsupportedOperationException |
| | | { |
| | | this.password = (password != null) ? ByteString.valueOf(password) : null; |
| | | return this; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getGeneratedPasswordAsString() { |
| | | return impl.getGeneratedPasswordAsString(); |
| | | } |
| | | |
| | | @Override |
| | | public PasswordModifyExtendedResult setGeneratedPassword(ByteString password) |
| | | throws UnsupportedOperationException |
| | | { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PasswordModifyExtendedResult setGeneratedPassword(String password) |
| | | public PasswordModifyExtendedResult setGeneratedPassword(char[] password) |
| | | throws UnsupportedOperationException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | |
| | | |
| | | @DataProvider(name = "byteStringIntegerProvier") |
| | | @DataProvider(name = "byteStringIntegerProvider") |
| | | public Object[][] byteStringIntegerProvider() |
| | | { |
| | | return new Object[][] { { ByteString.valueOf(0), 0 }, |
| | |
| | | |
| | | |
| | | |
| | | @DataProvider(name = "byteStringLongProvier") |
| | | @DataProvider(name = "byteStringLongProvider") |
| | | public Object[][] byteStringLongProvider() |
| | | { |
| | | return new Object[][] { { ByteString.valueOf(0L), 0L }, |
| | |
| | | |
| | | |
| | | |
| | | @DataProvider(name = "byteStringCharArrayProvider") |
| | | public Object[][] byteStringCharArrayProvider() |
| | | { |
| | | return new Object[][] { { "" }, { "1" }, { "1234567890" } }; |
| | | } |
| | | |
| | | |
| | | |
| | | @Test(expectedExceptions = IndexOutOfBoundsException.class) |
| | | public void testInvalidWrapLength() |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Test(dataProvider = "byteStringCharArrayProvider") |
| | | public void testToCharArray(final String s) |
| | | { |
| | | ByteString bs = ByteString.valueOf(s); |
| | | Assert.assertTrue(Arrays.equals(bs.toCharArray(), s.toCharArray())); |
| | | } |
| | | |
| | | |
| | | |
| | | @Test(dataProvider = "byteStringCharArrayProvider") |
| | | public void testValueOfCharArray(final String s) |
| | | { |
| | | ByteString bs = ByteString.valueOf(s.toCharArray()); |
| | | Assert.assertEquals(bs.toString(), s); |
| | | } |
| | | |
| | | |
| | | |
| | | @Test(expectedExceptions = IndexOutOfBoundsException.class) |
| | | public void testUndersizedToInteger() |
| | | { |
| | |
| | | // AuthenticatedConnectionFactory |
| | | factories[2][0] = new AuthenticatedConnectionFactory( |
| | | new LDAPConnectionFactory("localhost", TestCaseUtils.getLdapPort()), |
| | | Requests.newSimpleBindRequest("", "")); |
| | | Requests.newSimpleBindRequest("", new char[0])); |
| | | |
| | | // AuthenticatedConnectionFactory with multi-stage SASL |
| | | factories[3][0] = new AuthenticatedConnectionFactory( |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import com.sun.opends.sdk.util.Platform; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | proxyListener.getSocketAddress()).getConnection(); |
| | | try |
| | | { |
| | | connection.bind("cn=test", "password"); |
| | | connection.bind("cn=test", "password".toCharArray()); |
| | | |
| | | Assert.assertTrue(proxyServerConnection.isConnected.await(10, |
| | | TimeUnit.SECONDS)); |
| | |
| | | proxyListener.getSocketAddress()).getConnection(); |
| | | try |
| | | { |
| | | connection.bind("cn=test", "password"); |
| | | connection.bind("cn=test", "password".toCharArray()); |
| | | |
| | | Assert.assertTrue(proxyServerConnection.isConnected.await(10, |
| | | TimeUnit.SECONDS)); |
| | |
| | | onlineServerListener.getSocketAddress()).getConnection(); |
| | | try |
| | | { |
| | | connection.bind("cn=test", "password"); |
| | | connection.bind("cn=test", "password".toCharArray()); |
| | | } |
| | | catch (final ErrorResultException e) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | connection.bind("cn=test", "password"); |
| | | connection.bind("cn=test", "password".toCharArray()); |
| | | Assert.fail("Bind attempt on closed connection succeeded unexpectedly"); |
| | | } |
| | | catch (final ErrorResultException e) |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import com.sun.opends.sdk.util.Platform; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | public Object[][] getSimpleBindRequests() throws Exception |
| | | { |
| | | final SimpleBindRequest[] requests = { Requests.newSimpleBindRequest(),// anonymous; |
| | | Requests.newSimpleBindRequest("username", "password") }; |
| | | Requests.newSimpleBindRequest("username", "password".toCharArray()) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | |
| | | package org.opends.sdk.schema; |
| | | |
| | | import java.text.Normalizer; |
| | | import java.text.Normalizer.Form; |
| | | |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.DataProvider; |
| | | import static org.testng.Assert.assertEquals; |
| | | import org.opends.sdk.ConditionResult; |
| | | import org.opends.sdk.ByteString; |
| | | import static org.opends.sdk.schema.SchemaConstants.EMR_DN_OID; |
| | | import com.sun.opends.sdk.util.Platform; |
| | | |
| | | /** |
| | | * Test the DistinguishedNameEqualityMatchingRule |
| | |
| | | |
| | | final ByteString normalizedValue1 = rule.normalizeAttributeValue(ByteString |
| | | .valueOf(value1)); |
| | | StringBuilder buffer = new StringBuilder(value2); |
| | | Platform.normalize(buffer); |
| | | final ByteString expectedValue = ByteString.valueOf(buffer); |
| | | final ByteString expectedValue = ByteString.valueOf(Normalizer.normalize( |
| | | value2, Form.NFKD)); |
| | | assertEquals(normalizedValue1, expectedValue); |
| | | } |
| | | } |