public static PasswordCapabilityType getEffectivePasswordCapability(ResourceType resource, ResourceObjectTypeDefinitionType def) { CredentialsCapabilityType cct = getEffectiveCapability(resource, def, CredentialsCapabilityType.class); if (cct == null || cct.getPassword() == null || Boolean.FALSE.equals(cct.getPassword().isEnabled())) { return null; } else { return cct.getPassword(); } }
/** * Creates a new {@code CredentialsCapabilityType} instance by deeply copying a given {@code CredentialsCapabilityType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public CredentialsCapabilityType(final CredentialsCapabilityType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(o); if (o == null) { throw new NullPointerException("Cannot create a copy of 'CredentialsCapabilityType' from 'null'."); } // CClassInfo: com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType this.password = ((o.password == null)?null:((o.getPassword() == null)?null:o.getPassword().clone())); }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public CredentialsCapabilityType clone() { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final CredentialsCapabilityType clone = ((CredentialsCapabilityType) super.clone()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType clone.password = ((this.password == null)?null:((this.getPassword() == null)?null:this.getPassword().clone())); return clone; } }
public static boolean isPasswordReturnedByDefault(CredentialsCapabilityType capability) { if (capability == null) { return false; } PasswordCapabilityType password = capability.getPassword(); if (password == null) { return false; } if (password.isReturnedByDefault() == null) { return true; } return password.isReturnedByDefault(); }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof CredentialsCapabilityType)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final CredentialsCapabilityType that = ((CredentialsCapabilityType) object); { PasswordCapabilityType lhsPassword; lhsPassword = this.getPassword(); PasswordCapabilityType rhsPassword; rhsPassword = that.getPassword(); if (!strategy.equals(LocatorUtils.property(thisLocator, "password", lhsPassword), LocatorUtils.property(thatLocator, "password", rhsPassword), lhsPassword, rhsPassword)) { return false; } } return true; }
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = super.hashCode(locator, strategy); { PasswordCapabilityType thePassword; thePassword = this.getPassword(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "password", thePassword), currentHashCode, thePassword); } return currentHashCode; }
private boolean getEvaluateWeak(LensProjectionContext projCtx) { CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(projCtx.getResource(), CredentialsCapabilityType.class); if (credentialsCapabilityType != null) { PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword(); if (passwordCapabilityType != null) { if (passwordCapabilityType.isEnabled() != Boolean.FALSE) { Boolean readable = passwordCapabilityType.isReadable(); if (readable != null && readable) { // If we have readable password then we can evaluate the weak mappings // normally (even if the reads return incomplete values). return true; } } } } // Password not readable. Therefore evaluate weak mappings only during add operaitons. // We do not know whether there is a password already set on the resource. And we do not // want to overwrite it every time. return projCtx.isAdd(); }
protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) { PasswordCapabilityType passwordCapabilityType = capCred.getPassword(); assertNotNull("password native capability not present", passwordCapabilityType); Boolean readable = passwordCapabilityType.isReadable(); if (readable != null) { assertFalse("Unexpected 'readable' in password capability", readable); } }
@Override protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) { PasswordCapabilityType passwordCapabilityType = capCred.getPassword(); assertNotNull("password native capability not present", passwordCapabilityType); Boolean readable = passwordCapabilityType.isReadable(); assertNotNull("No 'readable' inducation in password capability", readable); assertTrue("Password not 'readable' in password capability", readable); }
@Override protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) { PasswordCapabilityType passwordCapabilityType = capCred.getPassword(); assertNotNull("password native capability not present", passwordCapabilityType); Boolean readable = passwordCapabilityType.isReadable(); assertNotNull("No 'readable' inducation in password capability", readable); assertTrue("Password not 'readable' in password capability", readable); }
@Override public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowType shadow, ResourceType resource) { if (focus == null || shadow == null) { return null; } if (!(focus instanceof UserType)) { return null; } if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) { return null; } ProtectedStringType passwordPs = FocusTypeUtil.getPasswordValue((UserType) focus); if (passwordPs != null && passwordPs.canGetCleartext()) { return null; } CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil .getEffectiveCapability(resource, CredentialsCapabilityType.class); if (credentialsCapabilityType == null) { return null; } PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword(); if (passwordCapabilityType == null) { return null; } if (passwordCapabilityType.isEnabled() == Boolean.FALSE) { return null; } return SchemaConstants.LIFECYCLE_PROPOSED; }
@Test public void test410Capabilities() throws Exception { final String TEST_NAME = "test410Capabilities"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(TEST_NAME); // WHEN Collection<Object> capabilities = cc.fetchCapabilities(result); // THEN result.computeStatus("getCapabilities failed"); TestUtil.assertSuccess("getCapabilities failed (result)", result); assertFalse("Empty capabilities returned", capabilities.isEmpty()); CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class); assertNotNull("password capability not present", capCred.getPassword()); PagedSearchCapabilityType capPage = CapabilityUtil.getCapability(capabilities, PagedSearchCapabilityType.class); assertNotNull("paged search capability not present", capPage); }
assertNotNull("password capability not present", capCred.getPassword()); assertNotNull("password capability not found", capCred.getPassword());
assertNotNull("password capability not found", capCred.getPassword()); assertNotNull("activation capability not found", capCred.getPassword());
@Test public void test001Connection() throws Exception { final String TEST_NAME = "test001Connection"; TestUtil.displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN OperationResult testResult = provisioningService.testResource(RESOURCE_DERBY_OID, task); display("Test result",testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result).asObjectable(); display("Resource after test",resource); display("Resource after test (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML)); List<Object> nativeCapabilities = resource.getCapabilities().getNative().getAny(); CredentialsCapabilityType credentialsCapabilityType = CapabilityUtil.getCapability(nativeCapabilities, CredentialsCapabilityType.class); assertNotNull("No credentials capability", credentialsCapabilityType); PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword(); assertNotNull("No password in credentials capability", passwordCapabilityType); assertEquals("Wrong password capability ReturnedByDefault", Boolean.FALSE, passwordCapabilityType.isReturnedByDefault()); }
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class); assertNotNull("credentials capability not found",capCred); PasswordCapabilityType capPassword = capCred.getPassword(); assertNotNull("password capability not present", capPassword); assertPasswordCapability(capPassword); assertNotNull("password effective capability not found",capCred.getPassword());
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class); assertNotNull("password native capability not present", capCred.getPassword()); ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
if (cred.getPassword() == null) { PasswordCapabilityType pc = new PasswordCapabilityType(); cred.setPassword(pc); pc.setReturnedByDefault(false); } else { PasswordCapabilityType pc = cred.getPassword(); pc.setEnabled(def(pc.isEnabled(), true)); pc.setReturnedByDefault(def(pc.isReturnedByDefault(), true));
assertNotNull("password capability not found", capCred.getPassword()); assertNotNull("activation capability not found", capCred.getPassword());