<div dir="ltr">Hello Marco,<div><br></div><div>I suggest iteration over modifications.</div><div><br></div><div>In one hook I check whether email is changed this way:</div><div><br></div><div><div>Collection deltas = new ArrayList&lt;&gt;();</div><div>if (modelContext.getFocusContext() != null) {</div><div><span style="white-space:pre">    </span>addIgnoreNull(deltas, modelContext.getFocusContext().getPrimaryDelta());</div><div><span style="white-space:pre">      </span>addIgnoreNull(deltas, modelContext.getFocusContext().getSecondaryDelta());</div><div>}</div><div><br></div><div>for(delta in deltas) {</div><div><span style="white-space:pre">      </span>modifications = delta.getModifications();</div><div><span style="white-space:pre">     </span>for(modification in modifications){</div><div><span style="white-space:pre">           </span>//<a href="http://log.info">log.info</a>("modification " + modification);</div><div><span style="white-space:pre">             </span>//<a href="http://log.info">log.info</a>("modification.getAnyValue() " + modification.getAnyValue());</div><div><span style="white-space:pre">         </span>isEmailChange = modification.getElementName().getLocalPart() == "emailAddress";</div><div><span style="white-space:pre">             </span>if(isEmailChange){</div><div><span style="white-space:pre">                    </span>//do something</div><div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">     </span>}</div><div>}</div></div><div><br></div><div>hint: if you want to compare old and new value I suggest fetching old user from database via midpoint.getUserByOid()</div><div><br></div><div>Best regards</div><div>Oskar Butovič</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-27 17:18 GMT+01:00 Marco Benucci <span dir="ltr"><<a href="mailto:m.benucci@nsr.it" target="_blank">m.benucci@nsr.it</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <p><font face="Roboto">Hi,</font></p>
    <p><font face="Roboto">I'm running midPoint 3.6 and I'm playing with
        hooks.</font></p>
    <p><font face="Roboto">I'd like to detect when an user has changed
        his/her password using hooks and I have tried this without luck:<br>
      </font></p>
    <p><font face="Roboto">delta =
        ObjectDelta.summarize(<wbr>modelContext.<wbr>getPrimaryChanges());<br>
        QName pwdName = new
        QName(<a class="m_2059009159504493465moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" target="_blank">"http://midpoint.<wbr>evolveum.com/xml/ns/public/<wbr>common/common-3"</a>,
        "credentials/password/value"); <br>
        ItemPath pwdPath = new ItemPath(pwdName);<br>
        if(delta.hasItemDelta(pwdPath)<wbr>){<br>
            println("user has changed the password");<br>
        }<br>
      </font></p>
    <p><font face="Roboto"><br>
      </font></p>
    <p><font face="Roboto">Is there a better way to do this..?<br>
        <br>
        Thank you.</font></p>
    <p><font face="Roboto"><br>
      </font></p>
  </div>

<br>______________________________<wbr>_________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/<wbr>mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><table style="font-family:Verdana,Arial,Helvetica,sans-serif;border-collapse:collapse;padding:0px;margin:0px;border-width:0px!important;border-style:solid!important;width:482px!important"><tbody><tr style="padding:0px;margin:0px;border:0px solid gray!important"><td style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:11px;width:160px;vertical-align:bottom;padding:0px;border:0px solid gray!important"><p><span style="font-size:14px;font-weight:bold">Oskar Butovič</span><br>solution architect<br><br>gsm: [+420] 774 480 101<br>e-mail: <a href="mailto:oskar.butovic@ami.cz" target="_blank">oskar.butovic@ami.cz</a></p></td><td style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;border-right-width:1px;border-right-style:solid;border-right-color:rgb(204,204,204);padding:0px;border-top-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;border-top-style:solid!important;border-bottom-style:solid!important;border-left-style:solid!important;border-top-color:gray!important;border-bottom-color:gray!important;border-left-color:gray!important">   </td><td style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;padding:0px;border:0px solid gray!important">   </td><td style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:11px;vertical-align:bottom;padding:0px;width:123px;border:0px solid gray!important"><p>AMI Praha a.s.<br>Pláničkova 11<br>162 00 Praha 6<br>tel.: [+420] 274 783 239<br>web: <a href="http://www.ami.cz/" target="_blank">www.ami.cz</a></p></td><td style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;border-right-width:1px;border-right-style:solid;border-right-color:rgb(204,204,204);padding:0px;border-top-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;border-top-style:solid!important;border-bottom-style:solid!important;border-left-style:solid!important;border-top-color:gray!important;border-bottom-color:gray!important;border-left-color:gray!important">   </td><td style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;padding:0px;border:0px solid gray!important">   </td><td style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:11px;margin:8px;border:0px solid gray!important;width:116px"><p><img src="http://www.ami.cz/images/podpis/ami_logo.gif" alt="AMI Praha a.s." style="border:0px"></p></td></tr><tr style="padding:0px;margin:0px;border:0px solid gray!important"><td colspan="7" style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10px;padding:0px;width:480px;border:0px solid gray!important"><br><a href="http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management" target="_blank"><img src="http://www.ami.cz/images/podpis/AMI-podpis-IdM_1.png" alt="AMI Praha a.s." style="border:0px;width:480px!important;height:82px!important"></a></td></tr><tr style="padding:0px;margin:0px;border:0px solid gray!important"><td colspan="7" style="color:rgb(128,128,128);font-family:Arial,sans-serif;font-size:11px;padding:0px;border:0px solid gray!important"><br>Textem tohoto e-mailu podepisující neslibuje uzavřít ani neuzavírá za společnost AMI Praha a.s.<br>jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena, musí mít výhradně písemnou formu.<br><br></td></tr></tbody></table></div></div></div></div></div></div></div>
</div>