use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class RMNodeStarter method getDefaultCredentials.
private Credentials getDefaultCredentials() {
try {
return Credentials.getCredentials();
} catch (KeyException fromDiskKeyException) {
try {
Credentials credentialsFromRMHome = Credentials.getCredentials(new File(PAResourceManagerProperties.RM_HOME.getValueAsStringOrNull(), "config/authentication/rm.cred").getAbsolutePath());
logger.info("Using default credentials from ProActive home, authenticating as user rm");
return credentialsFromRMHome;
} catch (KeyException fromRMHomeKeyException) {
try {
Credentials credentialsFromJar = Credentials.getCredentials(RMNodeStarter.class.getResourceAsStream("/config/authentication/rm.cred"));
logger.info("Using default credentials from ProActive jars, authenticating as user rm");
return credentialsFromJar;
} catch (Exception fromJarKeyException) {
logger.error("Failed to read credentials, from location obtained using system property, RM home or ProActive jars", fromJarKeyException);
System.exit(ExitStatus.CRED_UNREADABLE.exitCode);
}
}
}
return null;
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class RMNodeStarter method registerInRM.
/**
* Tries to join to the Resource Manager with a specified timeout
* at the given URL, logs with provided credentials and adds the local node to
* the Resource Manager. Handles all errors/exceptions.
*/
protected ResourceManager registerInRM(final Credentials credentials, final String rmURL, final String nodeName, final Collection<Node> nodes) {
RMAuthentication auth = joinResourceManager(rmURL);
final ResourceManager rm = loginToResourceManager(credentials, auth);
SigarExposer sigarExposer = null;
if (!disabledMonitoring) {
// initializing JMX server with Sigar beans
sigarExposer = new SigarExposer(nodeName);
final RMAuthentication rmAuth = auth;
sigarExposer.boot(auth, false, new PermissionChecker() {
@Override
public boolean checkPermission(Credentials cred) {
ResourceManager rm = null;
try {
rm = rmAuth.login(cred);
if (NB_OF_ADD_NODE_ATTEMPTS == 0)
return true;
boolean isAdmin = rm.isNodeAdmin(nodes.iterator().next().getNodeInformation().getURL()).getBooleanValue();
if (!isAdmin) {
throw new SecurityException("Permission denied");
}
return true;
} catch (LoginException e) {
throw new SecurityException(e);
} finally {
if (rm != null) {
rm.disconnect();
}
}
}
});
} else {
logger.info("JMX monitoring is disabled.");
}
for (final Node node : nodes) {
nodeSetJmxUrl(sigarExposer, node);
addNodeToResourceManager(rmURL, node, rm);
}
return rm;
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class SSHInfrastructure method configure.
/**
* Configures the Infrastructure
*
* @param parameters
* parameters[4] : ssh Options, see {@link SSHClient}
* parameters[5] : java path on the remote machines parameters[6]
* : Scheduling path on remote machines parameters[7] : target
* OS' type (Linux, Windows or Cygwin) parameters[8] : extra java
* options parameters[9] : rm cred
* @throws IllegalArgumentException
* configuration failed
*/
@Override
public void configure(Object... parameters) {
super.configure(parameters);
int index = 4;
if (parameters != null && parameters.length >= 10) {
this.sshOptions = parameters[index++].toString();
this.javaPath = parameters[index++].toString();
if (this.javaPath == null || this.javaPath.equals("")) {
throw new IllegalArgumentException("A valid Java path must be supplied.");
}
this.schedulingPath = parameters[index++].toString();
// target OS
if (parameters[index] != null) {
OperatingSystem configuredTargetOs = OperatingSystem.getOperatingSystem(parameters[index++].toString());
if (configuredTargetOs == null) {
throw new IllegalArgumentException("Only 'Linux', 'Windows' and 'Cygwin' are valid values for Target OS Property.");
}
persistedInfraVariables.put(TARGET_OS_OBJ_KEY, configuredTargetOs);
} else {
throw new IllegalArgumentException("Target OS parameter cannot be null");
}
this.javaOptions = parameters[index++].toString();
// credentials
if (parameters[index] == null) {
throw new IllegalArgumentException("Credentials must be specified");
}
try {
persistedInfraVariables.put(CREDENTIALS_KEY, Credentials.getCredentialsBase64((byte[]) parameters[index++]));
} catch (KeyException e) {
throw new IllegalArgumentException("Could not retrieve base64 credentials", e);
}
} else {
throw new IllegalArgumentException("Invalid parameters for infrastructure creation");
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class AuthenticationTest method loginIncorrectUserPassword.
private void loginIncorrectUserPassword(RMAuthentication auth) throws KeyException {
log("Test 4");
log("Trying to authorized with incorrect user name and password");
try {
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.username, "b"), auth.getPublicKey());
auth.login(cred);
fail("Error: successful authentication");
} catch (LoginException e) {
log("Passed: expected error " + e.getMessage());
}
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class AuthenticationTest method loginAsAdmin.
private void loginAsAdmin(RMAuthentication auth) throws LoginException, KeyException {
log("Test 1");
log("Trying to authorized with correct admin name and password");
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), auth.getPublicKey());
ResourceManager admin = auth.login(cred);
admin.disconnect().getBooleanValue();
log("Passed: successful authentication");
}
Aggregations