Java Code Examples for org.apache.commons.vfs2.UserAuthenticationData#Type

The following examples show how to use org.apache.commons.vfs2.UserAuthenticationData#Type . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaticUserAuthenticator.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
@Override
public UserAuthenticationData requestAuthentication(final UserAuthenticationData.Type[] types) {
    final UserAuthenticationData data = new UserAuthenticationData();
    for (final UserAuthenticationData.Type type : types) {
        if (type == UserAuthenticationData.DOMAIN) {
            data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain));
        } else if (type == UserAuthenticationData.USERNAME) {
            data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(username));
        } else if (type == UserAuthenticationData.PASSWORD) {
            data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(password));
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug(StaticUserAuthenticator.class.getSimpleName()
                        + " does not support authentication data type '" + type
                        + "'; authentication request for this type ignored.");
            }
        }
    }
    return data;
}
 
Example 2
Source File: SmbUserAuthenticator.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Override
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) {
  LOGGER.debug("Requested for authentication");
  for (UserAuthenticationData.Type type : types) {
    LOGGER.debug("Requested for authentication: %s",type);
  }
  if (data == null) {
    return super.requestAuthentication(types);
  } else {
    return data;
  }
}
 
Example 3
Source File: UseCentralsFromSessionUserAuthenticator.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Override
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) {
  UserAuthenticationData userAuthenticationData = getStaticWorkingUserAuthForSmb(sessionAuthStore, getUrl());
  if (userAuthenticationData ==null){
    userAuthenticationData = otrosUserAuthenticator.requestAuthentication(types);
  }
  return userAuthenticationData;
}
 
Example 4
Source File: UserAuthenticatorUtils.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Gets data of given type from the UserAuthenticationData or null if there is no data or data of this type
 * available.
 *
 * @param data The UserAuthenticationData.
 * @param type The type of the element to retrieve.
 * @param overriddenValue The default value.
 * @return The data of the given type as a character array or null if the data is not available.
 */
public static char[] getData(final UserAuthenticationData data, final UserAuthenticationData.Type type,
        final char[] overriddenValue) {
    if (overriddenValue != null) {
        return overriddenValue;
    }

    if (data == null) {
        return null;
    }

    return data.getData(type);
}
 
Example 5
Source File: UserAuthenticatorUtils.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Authenticates if there is an authenticator, else returns null.
 *
 * @param auth The UserAuthenticator.
 * @param authenticatorTypes An array of types describing the data to be retrieved.
 * @return A UserAuthenticationData object containing the data requested.
 */
public static UserAuthenticationData authenticate(final UserAuthenticator auth,
        final UserAuthenticationData.Type[] authenticatorTypes) {
    if (auth == null) {
        return null;
    }

    return auth.requestAuthentication(authenticatorTypes);
}
 
Example 6
Source File: UserAuthenticatorUtils.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Authenticates if there is an authenticator, else returns null.
 *
 * @param opts The FileSystemOptions.
 * @param authenticatorTypes An array of types describing the data to be retrieved.
 * @return A UserAuthenticationData object containing the data requested.
 */
public static UserAuthenticationData authenticate(final FileSystemOptions opts,
        final UserAuthenticationData.Type[] authenticatorTypes) {
    final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts);
    return authenticate(auth, authenticatorTypes);
}