Added security authority implementations for the icq slick

cusax-fix
Emil Ivov 20 years ago
parent 17a22a4a41
commit 828b9cbaaa

@ -141,7 +141,7 @@ public void testRegisterWrongUsername()
provider.addRegistrationStateChangeListener(regFailedEvtCollector);
provider.register(null);
provider.register(new SecurityAuthorityImpl(passwd.toCharArray()));
//give it enough time to register. We won't really have to wait all this
//time since the registration event collector would notify us the moment
@ -261,7 +261,7 @@ public void testRegisterWrongPassword()
provider.addRegistrationStateChangeListener(regFailedEvtCollector);
provider.register(null);
provider.register(new SecurityAuthorityImpl(passwd.toCharArray()));
//give it enough time to register. We won't really have to wait all this
//time since the registration event collector would notify us the moment
@ -455,4 +455,45 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
}
}
}
/**
* A very simple straight forward implementation of a security authority
* that would always return the same password (the one specified upon
* construction) when asked for credentials.
*/
public class SecurityAuthorityImpl implements SecurityAuthority
{
/**
* The password to return when asked for credentials
*/
private char[] passwd = null;
/**
* Creates an instance of this class that would always return "passwd"
* when asked for credentials.
*
* @param passwd the password that this class should return when
* asked for credentials.
*/
public SecurityAuthorityImpl(char[] passwd)
{
this.passwd = passwd;
}
/**
* Returns a Credentials object associated with the specified realm.
* <p>
* @param realm The realm that the credentials are needed for.
* @param defaultValues the values to propose the user by default
* @return The credentials associated with the specified realm or null if
* none could be obtained.
*/
public UserCredentials obtainCredentials(String realm,
UserCredentials defaultValues)
{
defaultValues.setPassword(passwd);
return defaultValues;
}
}
}

@ -274,4 +274,40 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
}
}
/**
* A very simple straightforward implementation of a security authority
* that would authentify our tested implementation if necessary, by
* retrieving its password through the system properties.
*/
public class SecurityAuthorityImpl implements SecurityAuthority
{
/**
* Creates an instance of this class that would would authentify our
* tested implementation if necessary, by retrieving its password
* through the system properties.
*/
public SecurityAuthorityImpl()
{}
/**
* Returns a Credentials object containing the password for our
* tested implementation.
* <p>
* @param realm The realm that the credentials are needed for.
* @param defaultValues the values to propose the user by default
* @return The credentials associated with the specified realm or null if
* none could be obtained.
*/
public UserCredentials obtainCredentials(String realm,
UserCredentials defaultValues)
{
String passwd = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_PWD_PROP_NAME, null );
defaultValues.setPassword(passwd.toCharArray());
return defaultValues;
}
}
}

Loading…
Cancel
Save