use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class SAML2ITCase method validateIdpInitiatedLoginResponseFailure.
// Make sure that the IdP initiated case is only supported when "supportUnsolicited" is true for that IdP
@Test
public void validateIdpInitiatedLoginResponseFailure() throws Exception {
assumeTrue(SAML2SPDetector.isSAML2SPAvailable());
SAML2SPService saml2Service = anonymous.getService(SAML2SPService.class);
// Create a SAML Response using WSS4J
SAML2ReceivedResponseTO response = new SAML2ReceivedResponseTO();
response.setSpEntityID("http://recipient.apache.org/");
response.setUrlContext("saml2sp");
org.opensaml.saml.saml2.core.Response samlResponse = createResponse(null, true, SAML2Constants.CONF_BEARER, "urn:org:apache:cxf:fediz:idp:realm-A");
Document doc = DOMUtils.newDocument();
Element responseElement = OpenSAMLUtil.toDom(samlResponse, doc);
String responseStr = DOM2Writer.nodeToString(responseElement);
// Validate the SAML Response
response.setSamlResponse(Base64.getEncoder().encodeToString(responseStr.getBytes()));
response.setRelayState("idpInitiated");
try {
saml2Service.validateLoginResponse(response);
fail("Failure expected on an unsolicited login");
} catch (SyncopeClientException e) {
assertNotNull(e);
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class UserITCase method customPolicyRules.
@Test
public void customPolicyRules() {
// Using custom policy rules with application/xml requires to overwrite
// org.apache.syncope.common.lib.policy.AbstractAccountRuleConf's and / or
// org.apache.syncope.common.lib.policy.AbstractPasswordRuleConf's
// @XmlSeeAlso - the power of JAXB :-/
assumeTrue(MediaType.APPLICATION_JSON_TYPE.equals(clientFactory.getContentType().getMediaType()));
ImplementationTO implementationTO = new ImplementationTO();
implementationTO.setKey("TestAccountRuleConf" + UUID.randomUUID().toString());
implementationTO.setEngine(ImplementationEngine.JAVA);
implementationTO.setType(ImplementationType.ACCOUNT_RULE);
implementationTO.setBody(POJOHelper.serialize(new TestAccountRuleConf()));
Response response = implementationService.create(implementationTO);
implementationTO.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
AccountPolicyTO accountPolicy = new AccountPolicyTO();
accountPolicy.setDescription("Account Policy with custom rules");
accountPolicy.getRules().add(implementationTO.getKey());
accountPolicy = createPolicy(PolicyType.ACCOUNT, accountPolicy);
assertNotNull(accountPolicy);
implementationTO = new ImplementationTO();
implementationTO.setKey("TestPasswordRuleConf" + UUID.randomUUID().toString());
implementationTO.setEngine(ImplementationEngine.JAVA);
implementationTO.setType(ImplementationType.PASSWORD_RULE);
implementationTO.setBody(POJOHelper.serialize(new TestPasswordRuleConf()));
response = implementationService.create(implementationTO);
implementationTO.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
PasswordPolicyTO passwordPolicy = new PasswordPolicyTO();
passwordPolicy.setDescription("Password Policy with custom rules");
passwordPolicy.getRules().add(implementationTO.getKey());
passwordPolicy = createPolicy(PolicyType.PASSWORD, passwordPolicy);
assertNotNull(passwordPolicy);
RealmTO realm = realmService.list("/even/two").get(0);
String oldAccountPolicy = realm.getAccountPolicy();
realm.setAccountPolicy(accountPolicy.getKey());
String oldPasswordPolicy = realm.getPasswordPolicy();
realm.setPasswordPolicy(passwordPolicy.getKey());
realmService.update(realm);
try {
UserTO user = getUniqueSampleTO("custompolicyrules@syncope.apache.org");
user.setRealm(realm.getFullPath());
try {
createUser(user);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidUser, e.getType());
assertTrue(e.getElements().iterator().next().startsWith("InvalidPassword"));
}
user.setPassword(user.getPassword() + "XXX");
try {
createUser(user);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidUser, e.getType());
assertTrue(e.getElements().iterator().next().startsWith("InvalidUsername"));
}
user.setUsername("YYY" + user.getUsername());
user = createUser(user).getEntity();
assertNotNull(user);
} finally {
realm.setAccountPolicy(oldAccountPolicy);
realm.setPasswordPolicy(oldPasswordPolicy);
realmService.update(realm);
policyService.delete(PolicyType.PASSWORD, passwordPolicy.getKey());
policyService.delete(PolicyType.ACCOUNT, accountPolicy.getKey());
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class NotificationITCase method issueSYNCOPE974.
@Test
public void issueSYNCOPE974() {
NotificationTO notificationTO = new NotificationTO();
notificationTO.setRecipientAttrName("email");
notificationTO.setSelfAsRecipient(false);
notificationTO.setSender("sender@ukr.net");
notificationTO.setSubject("subject 21");
notificationTO.setTemplate("requestPasswordReset");
notificationTO.setTraceLevel(TraceLevel.ALL);
notificationTO.setActive(true);
try {
notificationService.create(notificationTO);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
assertTrue(e.getMessage().contains("events"));
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class NotificationITCase method issueSYNCOPE83.
@Test
public void issueSYNCOPE83() {
NotificationTO notificationTO = buildNotificationTO();
notificationTO.setSelfAsRecipient(true);
NotificationTO actual = null;
try {
Response response = notificationService.create(notificationTO);
actual = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
} catch (SyncopeClientException e) {
assertNotNull(e);
}
assertNotNull(actual);
assertNotNull(actual.getKey());
notificationTO.setKey(actual.getKey());
assertEquals(actual, notificationTO);
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class NotificationITCase method issueSYNCOPE445.
@Test
public void issueSYNCOPE445() {
NotificationTO notificationTO = buildNotificationTO();
notificationTO.getStaticRecipients().add("syncope445@syncope.apache.org");
NotificationTO actual = null;
try {
Response response = notificationService.create(notificationTO);
actual = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
} catch (SyncopeClientException e) {
assertNotNull(e);
}
assertNotNull(actual);
assertNotNull(actual.getKey());
notificationTO.setKey(actual.getKey());
assertEquals(actual, notificationTO);
}
Aggregations