}
catch(SSOException ssoex)
{
System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
ssoex.printStackTrace();
throw new Exception(ssoex.getMessage());
}
}
else
{
System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL);
}
// Add another remote principal for the same user
if ( ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
{
System.out.println("No SSO Credential for user:" + TEST_USER+ " site: " + TEST_URL2);
// Add credential
try
{
ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2,REMOTE_PWD_1);
System.out.println("SSO Credential added for user:" + TEST_USER+ " site: " + TEST_URL2);
}
catch(SSOException ssoex)
{
System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL2);
ssoex.printStackTrace();
throw new Exception(ssoex.getMessage());
}
}
else
{
System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL2);
}
// Add the credentail again -- should get an error
try
{
ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2,REMOTE_PWD_1);
throw new Exception("Added same credentail twice -- API should prevent users from doing that.");
}
catch(SSOException ssoex)
{
System.out.println("Adding same SSO Credentialtwice failed (as expected) Message :" + ssoex.getMessage());
}
catch( Exception e)
{
throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
}
// Test if the credential where persisted
// Test credential update
SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential()+ " for site: " + TEST_URL);
SSOContext ssocontext2 = ssoBroker.getCredentials(subject, TEST_URL2);
System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);
try
{
// Update Remote credential
System.out.println("SSO Credential Update" );
ssoBroker.updateCredentialsForSite(subject, REMOTE_USER , TEST_URL, REMOTE_PWD_2);
ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential());
}
catch(SSOException ssoex)
{
System.out.println("SSO Credential update FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
throw new Exception(ssoex.getMessage());
}
/*
* For hypersonic the cascading deletes are not generated by Torque and the remove credentials
* fails with a constraint error.