[midPoint] Generate string according to valuePolicy in groovy

Arnošt Starosta - AMI Praha a.s. arnost.starosta at ami.cz
Tue Nov 12 09:46:02 CET 2019


Hi Lubomir,

using the ValuePolicyProcessor from the spring context works for me

def policyProcessor =
SpringApplicationContextHolder.getBean(ValuePolicyProcessor.class)
def valuePolicy = midpoint.getObject(ValuePolicyType.class,
'pwd-policy-oid')

policyProcessor.generate(null, valuePolicy, length, false, null, 'password
generation', midpoint.getCurrentTask(), midpoint.getCurrentResult())

arnost

po 11. 11. 2019 v 21:47 odesílatel Lubomir Odlevak <
odlevak.lubomir at gmail.com> napsal:

> How it is possible to generate random string according to valuePolicy in
> groovy with GenerateExpressionEvaluatorType ? I would like to achieve
> something like this, but GenerateExpressionEvaluatorType does not have any
> generate method ( generateNewValue()  in my ecample):
>              <code>
>                     import
> com.evolveum.midpoint.xml.ns._public.common.common_3.*
>                     import com.evolveum.midpoint.schema.constants.*
>
>                     generator = new GenerateExpressionEvaluatorType()
>                     ortype= new ObjectReferenceType()
>
>                     ortype.setOid(valuePolicyOID);
>                     ortype.setType(ValuePolicyType.COMPLEX_TYPE);
>                     ortype.setRelation(SchemaConstants.ORG_DEFAULT);
>                     generator.setValuePolicyRef(ortype)
>
>                     while(1){
>                         newValue=generator.generateNewValue()
>                         if(myCondition == True){
>                             return newValue
>                         }
>                      }
>               </code>
>
> I know there is similar xml-way to generate password according to
> valuePolicy:
>         <expression>
>             <generate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="c:GenerateExpressionEvaluatorType">
>                 <valuePolicyRef
> oid="12340000-0000-0000-0000-123400332211"/>
>             </generate>
>         </expression>
> ,but my valuePolicy contains <checkExpression> part and it seems that
> generate function ignore that.
>
> Thanks
> Lubomir Odlevak
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>


-- 

*Arnošt Starosta*
solution architect

gsm: [+420] 603 794 932
e‑mail: arnost.starosta at ami.cz

*AMI Praha a.s.*
Pláničkova 11, 162 00 Praha 6

tel.: [+420] 274 783 239 | web: www.ami.cz

[image: AMI Praha a.s.]

Textem tohoto e‑mailu podepisující neslibuje uzavřít ani neuzavírá
za společnost AMI Praha a.s.
jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena, musí mít výhradně
písemnou formu.

Tento e‑mail je určen výhradně pro potřeby jeho adresáta/ů a může obsahovat
důvěrné nebo osobní
informace. Nejste‑li zamýšleným příjemcem, je zakázáno jakékoliv
zveřejňování, zprostředkování
nebo jiné použití těchto informací. Pokud jste obdrželi e‑mail neoprávněně,
informujte o tom prosím
odesílatele a vymažte neprodleně všechny kopie tohoto e‑mailu včetně
všech jeho příloh. Nakládáním
s neoprávněně získanými informacemi se vystavujete riziku právního postihu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20191112/21da3760/attachment.htm>


More information about the midPoint mailing list