- cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
- @Override
- public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
- String incomingID= trans.get(sID, "");
- boolean skipCurrent = false;
- if(incomingID.length()>0) {
- try {
- Organization org = OrganizationFactory.obtain(trans.env(), incomingID);
- if(org==null) {
- hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: There is no supported company for ").text(incomingID).end();
- } else {
- Identity user = org.getIdentity(trans, incomingID);
- if(user==null) {
- int at = incomingID.indexOf('@');
- hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: You are not the sponsor of '").text(at<0?incomingID:incomingID.substring(0,at))
- .text("' defined at ").text(org.getName()).end();
- incomingID = "";
- } else {
- // Owners/or the IDs themselves are allowed to reset password without previous one
- skipCurrent=skipCurrent(trans, user);
-
- if(!skipCurrent) {
- final String id = incomingID;
- try {
- skipCurrent=gui.clientAsUser(trans.getUserPrincipal(), new Retryable<Boolean>() {
- @Override
- public Boolean code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- Future<Users> fc = client.read("/authn/creds/id/"+id,gui.getDF(Users.class));
- if(fc.get(AAFcli.timeout())) {
- GregorianCalendar now = new GregorianCalendar();
- for(aaf.v2_0.Users.User u : fc.value.getUser()) {
- if(u.getType()<10 && u.getType()>=1 && u.getExpires().toGregorianCalendar().after(now)) {
- return false; // an existing, non expired, password type exists
- }
- }
- return true; // no existing, no expired password
- } else {
- if(fc.code()==404) { // not found...
- return true;
- } else {
- trans.error().log(gui.aafCon.readableErrMsg(fc));
- }
- }
- return false;
- }
- });
- } catch (LocatorException | CadiException e) {
- trans.error().log(e);
- }
- }
- }
- }
- } catch (OrganizationException e) {
- hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: ")
- .text(e.getMessage()).end();
- }
- }
-
- hgen.input(fields[0],"ID*",true,"value="+incomingID,(incomingID.length()==0?"":"readonly"));
- if(!skipCurrent) {
- hgen.input(fields[1],"Current Password*",true,"type=password");
- }
- if(skipCurrent) {
- hgen.input(fields[1],"",false,"type=hidden", "value=").end();
- }
+ cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
+ @Override
+ public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
+ String incomingID= trans.get(sID, "");
+ boolean skipCurrent = false;
+ if(incomingID.length()>0) {
+ try {
+ Organization org = OrganizationFactory.obtain(trans.env(), incomingID);
+ if(org==null) {
+ hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: There is no supported company for ").text(incomingID).end();
+ } else {
+ Identity user = org.getIdentity(trans, incomingID);
+ if(user==null) {
+ int at = incomingID.indexOf('@');
+ hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: You are not the sponsor of '").text(at<0?incomingID:incomingID.substring(0,at))
+ .text("' defined at ").text(org.getName()).end();
+ incomingID = "";
+ } else {
+ // Owners/or the IDs themselves are allowed to reset password without previous one
+ skipCurrent=skipCurrent(trans, user);
+
+ if(!skipCurrent) {
+ final String id = incomingID;
+ try {
+ skipCurrent=gui.clientAsUser(trans.getUserPrincipal(), new Retryable<Boolean>() {
+ @Override
+ public Boolean code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ Future<Users> fc = client.read("/authn/creds/id/"+id,gui.getDF(Users.class));
+ if(fc.get(AAFcli.timeout())) {
+ GregorianCalendar now = new GregorianCalendar();
+ for(aaf.v2_0.Users.User u : fc.value.getUser()) {
+ if(u.getType()<10 && u.getType()>=1 && u.getExpires().toGregorianCalendar().after(now)) {
+ return false; // an existing, non expired, password type exists
+ }
+ }
+ return true; // no existing, no expired password
+ } else {
+ if(fc.code()==404) { // not found...
+ return true;
+ } else {
+ trans.error().log(gui.aafCon.readableErrMsg(fc));
+ }
+ }
+ return false;
+ }
+ });
+ } catch (LocatorException | CadiException e) {
+ trans.error().log(e);
+ }
+ }
+ }
+ }
+ } catch (OrganizationException e) {
+ hgen.incr(HTMLGen.H4,"style=color:red;").text("Error: ")
+ .text(e.getMessage()).end();
+ }
+ }
+
+ hgen.input(fields[0],"ID*",true,"value="+incomingID,(incomingID.length()==0?"":"readonly"));
+ if(!skipCurrent) {
+ hgen.input(fields[1],"Current Password*",true,"type=password");
+ }
+ if(skipCurrent) {
+ hgen.input(fields[1],"",false,"type=hidden", "value=").end();
+ }