Hi All,
I need to store User Custom variables like firstName, MiddleName, and Last Name
and using following code:
SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().
setAddress("http://localhost:8080/syncope/rest").
setDomain("Master").
setContentType(SyncopeClientFactoryBean.ContentType.XML).
setUseCompression(true);
SyncopeClient client = clientFactory.create("admin", "password");
UserService userService = client.getService(UserService.class);
UserTO userTo = new UserTO();
userTo.setUsername(username);
userTo.setPassword(password);
userTo.setCreationDate(new Date());
userTo.setCreator("admin");
userTo.setRealm("/");
userTo.getPlainAttrs().add(new
AttrTO.Builder().schema("email").value(email).build());
userTo.getPlainAttrs().add(new
AttrTO.Builder().schema("firstName").value(firstName).build());
userTo.getPlainAttrs().add(new
AttrTO.Builder().schema("middleName").value(middleName).build());
userTo.getPlainAttrs().add(new
AttrTO.Builder().schema("lastName").value(lastName).build());
Response userResponse = userService.create(userTo,true);
System.out.println(userResponse.getStatus());
After Successful creation of user, authenticated using email, with following
code:
client = clientFactory.
setDomain("Master").create(email, password);
Pair<Map<String, Set<String>>, UserTO> self = client.self();
Object auth = self.getKey();
UserTO selfUserTO = (UserTO)self.getValue();
System.out.println(selfUserTO);
First Question: selfUserTO is not retrieving firstName, middleName, and
LastName from Plain Attributes. What are changes needed to be done for storing
these plain attributes values?
Second Question: I am able to save email address and also able to retrieve
(authenticate) using the email address. If I have created two users with the
same email address, the system is not able to log in using this email address.
Because the email address is not unique across all users. How to make email
address unique across all users.
plainAttrs=[org.apache.syncope.common.lib.to.AttrTO@6f8f9349[
schemaInfo=org.apache.syncope.common.lib.to.PlainSchemaTO@75c9e76b[
type=String
mandatoryCondition=false
multivalue=false
uniqueConstraint=false
readonly=false
conversionPattern=<null>
validatorClass=org.apache.syncope.core.persistence.jpa.attrvalue.validation.EmailAddressValidator
enumerationValues=<null>
enumerationKeys=<null>
secretKey=<null>
cipherAlgorithm=<null>
mimeType=<null>
key=email
anyTypeClass=BaseUser
]
schema=email
values=[[email protected]]
]]
Your help in this regard greatly appreciated.
Thanks
Ravi
<http://www.ooftish.com>