use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class AuthenticationTest method loginIncorrectAdminPassword.
private void loginIncorrectAdminPassword(RMAuthentication auth) throws KeyException {
// negative
log("Test 3");
log("Trying to authorized with incorrect user name and password");
try {
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.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.CredData in project scheduling by ow2-proactive.
the class AuthenticationTest method loginAsUser.
private void loginAsUser(RMAuthentication auth) throws LoginException, KeyException {
log("Test 2");
log("Trying to authorized with correct user name and password");
Credentials cred = Credentials.createCredentials(new CredData(TestUsers.USER.username, TestUsers.USER.password), auth.getPublicKey());
ResourceManager user = auth.login(cred);
user.disconnect().getBooleanValue();
log("Passed: successful authentication");
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class RMProxyUserInterfaceTest method createRMCachingProxyUserInterface.
private RMListenerProxy createRMCachingProxyUserInterface() throws Exception {
RMListenerProxy proxyUserInterface = PAActiveObject.newActive(RMListenerProxy.class, new Object[] {});
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
proxyUserInterface.init(RMTHelper.getLocalUrl(), adminCreds);
return proxyUserInterface;
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class ResourceManagerJMXTest method action.
@Test
public void action() throws Exception {
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
final JMXServiceURL jmxRmiServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI));
final JMXServiceURL jmxRoServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RO));
final ObjectName allAccountsMBeanName = new ObjectName(RMJMXBeans.ALLACCOUNTS_MBEAN_NAME);
final ObjectName myAccountMBeanName = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
final ObjectName runtimeDataMBeanName = new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME);
final ObjectName managementMBeanName = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
final String suffix = "/" + PAResourceManagerProperties.RM_JMX_CONNECTOR_NAME.getValueAsString();
jmxURLsAreWellFormed(jmxRmiServiceURL, jmxRoServiceURL, suffix);
jmxAuthInvalidCreds(jmxRmiServiceURL);
jmxAuthNullLoginPassword(jmxRmiServiceURL);
jmxAuthInvalidLoginPassword(jmxRmiServiceURL);
jmxRMIAsUser(jmxRmiServiceURL, allAccountsMBeanName, myAccountMBeanName, runtimeDataMBeanName);
jmxRemoteObjectAsAdmin(adminCreds, jmxRoServiceURL, allAccountsMBeanName, managementMBeanName);
simultaneousRMIAndROConnections(adminCreds, jmxRmiServiceURL, jmxRoServiceURL);
jmxClientHelper(auth, adminCreds);
}
use of org.ow2.proactive.authentication.crypto.CredData in project scheduling by ow2-proactive.
the class AddGetDownRemoveTest method action.
@Test
public void action() throws Exception {
// The username and thr password must be the same a used to connect to the RM
final ResourceManager rm = rmHelper.getResourceManager();
// All accounting values are checked through JMX
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
final JMXServiceURL jmxRmiServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI));
final HashMap<String, Object> env = new HashMap<>(1);
env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.TEST.username, adminCreds });
// Connect to the JMX RMI Connector Server
final ObjectName myAccountMBeanName = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
final ObjectName managementMBeanName = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
final JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxRmiServiceURL, env);
final MBeanServerConnection conn = jmxConnector.getMBeanServerConnection();
long usedNodeTime = (Long) conn.getAttribute(myAccountMBeanName, "UsedNodeTime");
// ADD, GET, DOWN, REMOVE
// 1) ADD
final String name = "AddGetDownRemoveTest";
testNode = rmHelper.createNode(name);
Node node = testNode.getNode();
final String nodeURL = node.getNodeInformation().getURL();
rm.addNode(nodeURL).getBooleanValue();
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, NodeSource.DEFAULT);
rm.setNodeSourcePingFrequency(5000, NodeSource.DEFAULT);
// wait for node from configuring to free
rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeURL);
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeURL);
// 2) GET the same node
final long beforeGetTime = System.currentTimeMillis();
node = rm.getNodes(new Criteria(1)).get(0);
// Sleep a certain amount of time that will be the minimum amount of the GET->RELEASE duration
Thread.sleep(GR_DURATION);
// 3) Kill the node to ensure that the RM considers it as being DOWN
try {
node.getProActiveRuntime().killNode(node.getNodeInformation().getName());
} catch (Exception e) {
}
while (rm.nodeIsAvailable(nodeURL).getBooleanValue()) {
RMTHelper.log("Node is available " + nodeURL);
Thread.sleep(100);
}
final long getDownMaxDuration = System.currentTimeMillis() - beforeGetTime;
// 4) REMOVE
rm.removeNode(nodeURL, true).getBooleanValue();
// Refresh the account manager
conn.invoke(managementMBeanName, "clearAccoutingCache", null, null);
// Check account values validity
usedNodeTime = (Long) conn.getAttribute(myAccountMBeanName, "UsedNodeTime") - usedNodeTime;
Assert.assertTrue("Invalid value of the usedNodeTime attribute : " + usedNodeTime + " while expected is " + GR_DURATION, (usedNodeTime >= GR_DURATION) && (usedNodeTime <= getDownMaxDuration));
}
Aggregations