by dmm » Thu Aug 29, 2013 5:32 pm
Sure.
The checkPassword function is called with checkpassword("guest","guest").
I made a modification to this file:
service-ome.api.IAdmin.xml
<bean id="centrifyPasswordProvider" class="ome.security.auth.CentrifyPasswordProvider">
<constructor-arg ref="passwordUtil"/>
</bean>
and added this file to the directory under components/server/src/ome/security/auth:
package ome.security.auth;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class CentrifyPasswordProvider extends ConfigurablePasswordProvider {
public CentrifyPasswordProvider(PasswordUtil util) {
super(util);
}
public CentrifyPasswordProvider(PasswordUtil util, boolean ignoreUnknown) {
super(util, ignoreUnknown);
}
@Override
public boolean hasPassword(String user) {
Long id = util.userId(user);
return id != null;
}
@Override
public Boolean checkPassword(String user, String password, boolean readOnly) {
Long id = util.userId(user);
if (id == null || password == null || password.equals("")) {
return false;
}
String line;
String command = "sh authCentrify.sh " + user + " " + password;
log.info(String.format(
"CENTRIFY: command = %s",
command));
log.error(command);
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
pr.waitFor();
BufferedReader is = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String item = is.readLine();
log.info(String.format(
"CENTRIFY: item = %s",
item));
if (item != null) {
log.error("centrify");
log.error(item);
if (item.equals("OK")) {
loginAttempt(user, true);
return true;
}
}
} catch (InterruptedException ex) {
String errorMessage = "The command [" + command + "] did not complete due to an unexpected interruption.";
log.error(errorMessage, ex);
throw new RuntimeException(errorMessage, ex);
} catch (IOException ex) {
String errorMessage = "The command [" + command + "] did not complete due to an IO error.";
log.error(errorMessage, ex);
throw new RuntimeException(errorMessage, ex);
}
return super.checkPassword(user, password, readOnly);
}
}