use of org.objectweb.proactive.extensions.dataspaces.api.UserCredentials in project scheduling by ow2-proactive.
the class TaskProActiveDataspaces method initDataSpaces.
private void initDataSpaces() throws Exception {
long startTime = System.currentTimeMillis();
// configure node for application
String appId = taskId.toString();
// prepare scratch, input, output
Node node = PAActiveObject.getNode();
logger.info("Configuring dataspaces for app " + appId + " on " + node.getNodeInformation().getName());
DataSpacesNodes.configureApplication(node, appId, namingService);
SCRATCH = PADataSpaces.resolveScratchForAO();
logger.info("SCRATCH space is " + SCRATCH.getRealURI());
// Set the scratch folder writable for everyone
if (!SCRATCH.setWritable(true, false)) {
logger.warn("Missing permission to change write permissions to " + getScratchFolder());
}
InputOutputSpaceConfiguration cacheConfiguration = DataSpaceNodeConfigurationAgent.getCacheSpaceConfiguration();
if (cacheConfiguration != null) {
final String cacheName = cacheConfiguration.getName();
cacheSpaceInstanceInfo = new SpaceInstanceInfo(appId, cacheConfiguration);
try {
namingService.register(cacheSpaceInstanceInfo);
} catch (SpaceAlreadyRegisteredException e) {
// this is a rare case where the cache space has already been registered for the same task and there was a node failure.
namingService.unregister(cacheSpaceInstanceInfo.getMountingPoint());
namingService.register(cacheSpaceInstanceInfo);
}
CACHE = initDataSpace(new Callable<DataSpacesFileObject>() {
@Override
public DataSpacesFileObject call() throws Exception {
return PADataSpaces.resolveOutput(cacheName);
}
}, "CACHE", false);
} else {
logger.error("No Cache space configuration found, cache space is disabled.");
}
UserCredentials userCredentials;
if (decrypter != null) {
CredData credData = decrypter.decrypt();
userCredentials = new UserCredentials(credData.getLogin(), credData.getPassword(), credData.getDomain(), credData.getKey());
} else {
logger.warn("No decryter found");
userCredentials = new UserCredentials();
}
INPUT = initDataSpace(new Callable<DataSpacesFileObject>() {
@Override
public DataSpacesFileObject call() throws Exception {
return PADataSpaces.resolveDefaultInput();
}
}, "INPUT", true);
OUTPUT = initDataSpace(new Callable<DataSpacesFileObject>() {
@Override
public DataSpacesFileObject call() throws Exception {
return PADataSpaces.resolveDefaultOutput();
}
}, "OUTPUT", false);
GLOBAL = initDataSpace(new Callable<DataSpacesFileObject>() {
@Override
public DataSpacesFileObject call() throws Exception {
return PADataSpaces.resolveOutput(SchedulerConstants.GLOBALSPACE_NAME);
}
}, "GLOBAL", false);
USER = initDataSpace(new Callable<DataSpacesFileObject>() {
@Override
public DataSpacesFileObject call() throws Exception {
return PADataSpaces.resolveOutput(SchedulerConstants.USERSPACE_NAME, userCredentials);
}
}, "USER", false);
logger.info("Time needed to mount data spaces: " + (System.currentTimeMillis() - startTime) + " ms");
}
use of org.objectweb.proactive.extensions.dataspaces.api.UserCredentials in project scheduling by ow2-proactive.
the class SchedulerSpacesSupport method registerUserSpace.
/**
* This method creates a dedicated USER space for the user which successfully connected
* This USER space is a subspace of the scheduler default USER space,
* A sub-folder named with the username is created to contain the USER space
*
* @param username the username of an identified user
* @param credentials credentials of the user
*/
public void registerUserSpace(String username, Credentials credentials) {
if (this.userGlobalSpaces.get(username) == null && shouldRegisterUserSpace(username)) {
synchronized (this) {
DataSpacesFileObject userSpace;
String userSpaceName = SchedulerConstants.USERSPACE_NAME + "_" + username;
if (!PASchedulerProperties.DATASPACE_DEFAULTUSER_URL.isSet()) {
logger.warn("URL of the root USER space is not set, cannot create a USER space for " + username);
return;
}
String localpath = PASchedulerProperties.DATASPACE_DEFAULTUSER_LOCALPATH.getValueAsStringOrNull();
String hostname = PASchedulerProperties.DATASPACE_DEFAULTUSER_HOSTNAME.getValueAsStringOrNull();
try {
UserCredentials userCredentials = getUserCredentials(username, credentials);
DataSpaceServiceStarter.getDataSpaceServiceStarter().createSpaceWithUserNameSubfolder(username, userCredentials, SchedulerConstants.SCHEDULER_DATASPACE_APPLICATION_ID, userSpaceName, PASchedulerProperties.DATASPACE_DEFAULTUSER_URL.getValueAsString(), localpath, hostname, false, true);
// immediately retrieve the User Space
userSpace = PADataSpaces.resolveOutput(userSpaceName, userCredentials);
logger.info("USER space for user " + username + " is at " + userSpace.getAllRealURIs());
// register the user GlobalSpace to the frontend state
this.userGlobalSpaces.put(username, userSpace);
} catch (Exception e) {
logger.error("", e);
return;
}
}
}
}
use of org.objectweb.proactive.extensions.dataspaces.api.UserCredentials in project scheduling by ow2-proactive.
the class SchedulerSpacesSupport method getUserCredentials.
private UserCredentials getUserCredentials(String username, Credentials credentials) {
UserCredentials userCredentials = new UserCredentials();
if (!PASchedulerProperties.DATASPACE_DEFAULTUSER_IMPERSONATION.getValueAsBoolean() || isInternalUser(username)) {
return userCredentials;
}
try {
CredData decryptedUserCredentials = credentials.decrypt(corePrivateKey);
if (PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.isSet() && decryptedUserCredentials.getDomain() == null) {
decryptedUserCredentials.setDomain(PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.getValueAsString());
}
userCredentials = new UserCredentials(decryptedUserCredentials.getLogin(), decryptedUserCredentials.getPassword(), decryptedUserCredentials.getDomain(), decryptedUserCredentials.getKey());
} catch (Exception e) {
logger.error("Could not decrypt user credentials", e);
}
return userCredentials;
}
use of org.objectweb.proactive.extensions.dataspaces.api.UserCredentials in project scheduling by ow2-proactive.
the class InternalJob method getUserCredentials.
private UserCredentials getUserCredentials() {
UserCredentials userCredentials = null;
try {
CredData decryptedUserCredentials = credentials.decrypt(corePrivateKey);
if (PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.isSet() && decryptedUserCredentials.getDomain() == null) {
decryptedUserCredentials.setDomain(PASchedulerProperties.SCHEDULER_AUTH_GLOBAL_DOMAIN.getValueAsString());
}
userCredentials = new UserCredentials(decryptedUserCredentials.getLogin(), decryptedUserCredentials.getPassword(), decryptedUserCredentials.getDomain(), decryptedUserCredentials.getKey());
} catch (Exception e) {
LOGGER.error("Could not decrypt user credentials", e);
}
return userCredentials;
}
use of org.objectweb.proactive.extensions.dataspaces.api.UserCredentials in project scheduling by ow2-proactive.
the class InternalJob method startDataSpaceApplication.
/**
* Start dataspace configuration and application
*/
public void startDataSpaceApplication(NamingService namingService, List<InternalTask> tasks) {
if (taskDataSpaceApplications == null) {
taskDataSpaceApplications = new HashMap<>();
}
UserCredentials userCredentials = getUserCredentials();
for (InternalTask internalTask : tasks) {
long taskId = internalTask.getId().longValue();
// if a task restart due to a failure for instance
if (!taskDataSpaceApplications.containsKey(taskId)) {
String appId = internalTask.getId().toString();
TaskDataSpaceApplication taskDataSpaceApplication = new TaskDataSpaceApplication(appId, namingService);
taskDataSpaceApplications.put(taskId, taskDataSpaceApplication);
taskDataSpaceApplication.startDataSpaceApplication(getInputSpace(), getOutputSpace(), getGlobalSpace(), getUserSpace(), getOwner(), userCredentials, getId());
}
}
}
Aggregations