use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SessionSharingTest method setUp.
@Before
public void setUp() throws Exception {
schedulerRest = new SchedulerStateRest();
rmRest = new RMRest();
studioRest = new StudioRest();
SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
rmMock = mock(RMProxyUserInterface.class);
when(schedulerFactory.connectToRM(Matchers.<CredData>any())).thenReturn(rmMock);
schedulerMock = mock(SchedulerProxyUserInterface.class);
when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(schedulerMock);
SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SchedulerRMProxyFactory method connectToScheduler.
public SchedulerProxyUserInterface connectToScheduler(CredData credData) throws ActiveObjectCreationException, NodeException, LoginException, SchedulerException {
SchedulerProxyUserInterface scheduler = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[] {});
scheduler.init(PortalConfiguration.SCHEDULER_URL.getValueAsString(), credData);
return scheduler;
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class SchedulerRMProxyFactory method connectToRM.
public RMProxyUserInterface connectToRM(CredData credData) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
RMProxyUserInterface rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
rm.init(PortalConfiguration.RM_URL.getValueAsString(), credData);
return rm;
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class RMStateCaching method init_.
private static void init_() {
while (rm == null) {
String url = PortalConfiguration.RM_URL.getValueAsString();
String cred_path = PortalConfiguration.RM_CACHE_CREDENTIALS.getValueAsStringOrNull();
try {
if (rm == null) {
rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
if (cred_path != null && !(new File(cred_path)).exists()) {
logger.error("Credentials path set in " + PortalConfiguration.RM_CACHE_CREDENTIALS.getKey() + " but file " + cred_path + " does not exist");
}
if (cred_path != null && new File(cred_path).exists()) {
Credentials cred = Credentials.getCredentials(cred_path);
rm.init(url, cred);
} else {
String login = PortalConfiguration.RM_CACHE_LOGIN.getValueAsString();
String password = PortalConfiguration.RM_CACHE_PASSWORD.getValueAsString();
rm.init(url, new CredData(login, password));
}
}
} catch (Exception e) {
logger.warn("Could not connect to resource manager at " + url + " retrying in 8 seconds", e);
if (rm != null) {
PAActiveObject.terminateActiveObject(rm, true);
rm = null;
}
new Sleeper(8 * 1000, logger).sleep();
continue;
}
}
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class JMXAuthenticatorImpl method authenticate.
/**
* This method is automatically called when a JMX client tries to connect to the MBean Server referred
* by the connector.
* <p>
* The only allowed credentials structure provided by the client is Object[] that contains
* username/password (String/String) or username/{@link org.ow2.proactive.authentication.crypto.Credentials}
*
* @return a subject with the username as JMXPrincipal and the role as pubCredentials {@link javax.security.auth.Subject}
* @param rawCredentials the credentials provided by the client
*/
public Subject authenticate(final Object rawCredentials) {
// If not an array of object do not give any clues just throw exception
if (rawCredentials == null || !(rawCredentials instanceof Object[])) {
throw new SecurityException("Invalid credentials");
}
final Object[] arr = (Object[]) rawCredentials;
if (arr[0] == null || arr[1] == null) {
throw new SecurityException("Invalid credentials");
}
final String username = arr[0].toString();
Credentials internalCredentials = null;
// If username/Credentials
if (arr[1] instanceof Credentials) {
internalCredentials = (Credentials) arr[1];
// If username/password (ex: JConsole)
} else if (arr[1] instanceof String) {
try {
internalCredentials = Credentials.createCredentials(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), (String) arr[1]), authentication.getPublicKey());
} catch (Exception e) {
throw new SecurityException("Invalid credentials", e);
}
} else {
throw new SecurityException("Invalid credentials");
}
try {
Subject s = this.authentication.authenticate(internalCredentials);
if (permissionChecker != null) {
boolean allowed = permissionChecker.checkPermission(internalCredentials);
if (!allowed) {
throw new SecurityException("Permission denied");
}
}
return s;
} catch (LoginException e) {
throw new SecurityException("Unable to authenticate " + username);
}
}
Aggregations