public static void addPasswordMetadata(PasswordType p, XMLGregorianCalendar now, PrismObject<UserType> owner) { MetadataType metadata = p.getMetadata(); if (metadata != null) { return; } // Supply some metadata if they are not present. However the // normal thing is that those metadata are provided by model metadata = new MetadataType(); metadata.setCreateTimestamp(now); if (owner != null) { metadata.creatorRef(owner.getOid(), null); } p.setMetadata(metadata); }
protected void assertShadowPasswordMetadata(PrismObject<ShadowType> shadow, boolean passwordCreated, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal, String actorOid, String channel) { CredentialsType creds = shadow.asObjectable().getCredentials(); assertNotNull("No credentials in shadow "+shadow, creds); PasswordType password = creds.getPassword(); assertNotNull("No password in shadow "+shadow, password); MetadataType metadata = password.getMetadata(); assertNotNull("No metadata in shadow "+shadow, metadata); assertMetadata("Password metadata in "+shadow, metadata, passwordCreated, false, startCal, endCal, actorOid, channel); }
private void transplantPasswordMetadata(ShadowType repoShadowType, ShadowType resultAccountShadow) { CredentialsType repoCreds = repoShadowType.getCredentials(); if (repoCreds == null) { return; } PasswordType repoPassword = repoCreds.getPassword(); if (repoPassword == null) { return; } MetadataType repoMetadata = repoPassword.getMetadata(); if (repoMetadata == null) { return; } CredentialsType resultCreds = resultAccountShadow.getCredentials(); if (resultCreds == null) { resultCreds = new CredentialsType(); resultAccountShadow.setCredentials(resultCreds); } PasswordType resultPassword = resultCreds.getPassword(); if (resultPassword == null) { resultPassword = new PasswordType(); resultCreds.setPassword(resultPassword); } MetadataType resultMetadata = resultPassword.getMetadata(); if (resultMetadata == null) { resultMetadata = repoMetadata.clone(); resultPassword.setMetadata(resultMetadata); } }
private void assertPasswordCreateMetadata(PrismObject<UserType> user) { CredentialsType credentials = user.asObjectable().getCredentials(); assertNotNull("No credentials", credentials); PasswordType password = credentials.getPassword(); assertNotNull("No credentials/password", password); MetadataType metadata = password.getMetadata(); assertNotNull("No credentials/password/metadata", metadata); assertNotNull("No credentials/password/metadata/createTimestamp", metadata.getCreateTimestamp()); assertNotNull("No credentials/password/metadata/creatorRef", metadata.getCreatorRef()); assertEquals("Wrong createChannel", SchemaConstants.CHANNEL_GUI_USER_URI, metadata.getCreateChannel()); }
private void assertPasswordModifyMetadata(PrismObject<UserType> user) { CredentialsType credentials = user.asObjectable().getCredentials(); assertNotNull("No credentials", credentials); PasswordType password = credentials.getPassword(); assertNotNull("No credentials/password", password); MetadataType metadata = password.getMetadata(); assertNotNull("No credentials/password/metadata", metadata); assertNotNull("No credentials/password/metadata/modifyTimestamp", metadata.getModifyTimestamp()); assertNotNull("No credentials/password/metadata/modifierRef", metadata.getModifierRef()); assertEquals("Wrong modifyChannel", SchemaConstants.CHANNEL_GUI_USER_URI, metadata.getModifyChannel()); } }
checkPasswordValidityAndAge(connEnv, principal, passwordType.getValue(), passwordType.getMetadata(), passwordCredentialsPolicy);
display("user after password change", user); PasswordType passwordType = assertUserPassword(user, "nbusr123"); MetadataType metadata = passwordType.getMetadata(); assertNotNull("No password metadata", metadata); assertMetadata("password metadata", metadata, true, false, startTs, endTs, USER_JACK_OID, SchemaConstants.CHANNEL_GUI_USER_URI);