use of com.adeptj.modules.jaxrs.core.auth.JaxRSAuthenticationInfo in project adeptj-modules by AdeptJ.
the class DefaultJaxRSAuthenticationRealm method updated.
/**
* {@inheritDoc}
*/
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
String username = Objects.requireNonNull((String) properties.get(KEY_USERNAME), USERNAME_NULL_MSG);
String password = Objects.requireNonNull((String) properties.get(KEY_PWD), PWD_NULL_MSG);
LOGGER.info("Creating JaxRSAuthenticationInfo for User: [{}]", username);
if (this.pidVsUserMappings.containsKey(pid)) {
// This is an update
this.pidVsUserMappings.put(pid, username);
this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
} else if (!this.pidVsUserMappings.containsKey(pid) && this.pidVsUserMappings.containsValue(username)) {
LOGGER.warn("User: [{}] already present, ignoring this config!!");
throw new ConfigurationException(KEY_USERNAME, "User already present!!");
} else if (!this.pidVsUserMappings.containsKey(pid) && !this.pidVsUserMappings.containsValue(username)) {
this.pidVsUserMappings.put(pid, username);
this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
}
}
Aggregations