Hello,

I'm using Syncope 2.1.4 and I'm trying to set a custom plain attribute named
/tempPassword/ to an user using *Flowable* without success. This custom
attribute was added before to the schemas and added to the base user object.
It is writable and contains plain text.
I have a groovy /Script task/ like the follow:

/*** BEGIN SCRIPT ***/
import org.apache.syncope.common.lib.patch.AttrPatch;
import org.apache.syncope.common.lib.types.PatchOperation;
import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.flowable.impl.FlowableRuntimeUtils;
import org.apache.syncope.common.lib.patch.UserPatch;

User user = execution.getVariable(FlowableRuntimeUtils.USER, User.class);

String alphabet =
(('A'..'N')+('P'..'Z')+('a'..'k')+('m'..'z')+('2'..'9')).join() ;
int n = 12;
def password = new Random().with { (1..n).collect { alphabet[ nextInt(
alphabet.length() ) ] }.join(); }

user.setPassword(password, CipherAlgorithm.SSHA256);
user.setMustChangePassword(true);

user.getPlainAttrs().add(new
AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(createAttrTO("tempPassword",
password)));

execution.setVariable(FlowableRuntimeUtils.USER, user);

def AttrTO createAttrTO(String key, String value) {
        return new AttrTO.Builder().schema(key).value(value).build();
}
/*** END SCRIPT ***/

The /password/ and the /mustChangePassword/ attributes are correctly
assigned to the user but I don't find a way to set any plain attributes.



-----
Michele
--
Sent from: http://syncope-user.1051894.n5.nabble.com/

Reply via email to