Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/user-search
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Aug 19, 2015
2 parents 77f4dd3 + 6eb1108 commit d2e1b88
Show file tree
Hide file tree
Showing 22 changed files with 348 additions and 46 deletions.
Expand Up @@ -17,5 +17,5 @@ PageLogin.forgetPassword=Zapomenut\u00e9 heslo
PageLogin.password=Heslo
PageLogin.signIn=P\u0159ihl\u00e1sit
PageLogin.username=U\u017eivatel
page.title=P\u0159ihlsit se
page.title=P\u0159ihl\u00e1sit se
pageLogin.message.ForgetPasswordSettingsWrong=Nastaven\u00ed pro zapomenut\u00e9 heslo nen\u00ed platn\u00e9. Pro zm\u011bnu va\u0161eho hesla kontaktujte administr\u00e1tora.
Expand Up @@ -17,5 +17,5 @@ PageLogin.forgetPassword=Zapomenut\u00e9 heslo
PageLogin.password=Heslo
PageLogin.signIn=P\u0159ihl\u00e1sit
PageLogin.username=U\u017eivatel
page.title=P\u0159ihlsit se
page.title=P\u0159ihl\u00e1sit se
pageLogin.message.ForgetPasswordSettingsWrong=Nastaven\u00ed pro zapomenut\u00e9 heslo nen\u00ed platn\u00e9. Pro zm\u011bnu va\u0161eho hesla kontaktujte administr\u00e1tora.
Expand Up @@ -399,7 +399,7 @@ public <T> T unmarshall(MapXNode xnode, Class<T> beanClass) throws SchemaExcepti
}


if (Object.class.equals(paramType) && !storeAsRawType) {
if (!(xsubnode instanceof ListXNode) && Object.class.equals(paramType) && !storeAsRawType) {
throw new IllegalArgumentException("Object property (without @Raw) not supported in field "+fieldName+" in "+beanClass);
}

Expand Down
Expand Up @@ -168,8 +168,6 @@ public int hashCode() {

@Override
public String toString() {
return "ItemPathType{" +
"itemPath=" + getItemPath() +
'}';
return getItemPath().toString();
}
}
Expand Up @@ -117,8 +117,12 @@ public <IV extends PrismValue,ID extends ItemDefinition> IV getParsedValue(ItemD

public <V,ID extends ItemDefinition> V getParsedRealValue(ItemDefinition itemDefinition, ItemPath itemPath) throws SchemaException {
if (parsed == null && xnode != null){
QName itemName = ItemPath.getName(itemPath.lastNamed());
getParsedValue(itemDefinition, itemName);
if (itemDefinition == null){
return PrismUtil.getXnodeProcessor(prismContext).parseAnyValue(xnode);
} else {
QName itemName = ItemPath.getName(itemPath.lastNamed());
getParsedValue(itemDefinition, itemName);
}
}
if (parsed != null){
if (parsed instanceof PrismPropertyValue){
Expand Down
Expand Up @@ -243,6 +243,21 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="legacySchema" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Forces schema processing in "legacy" mode.
Legacy mode means that __ACCOUNT__ is translated as AccountObjectClass,
__GROUP__ as GroupObjectClass and any other as CustomXXXXXObjectClass.
Non-legacy mode does not translates object class names. They are used
in the same form as provided by the connector.
</xsd:documentation>
<xsd:appinfo>
<a:maxOccurs>1</a:maxOccurs>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:schema>

Expand Up @@ -214,6 +214,11 @@ public static String prettyPrintForReport(Object value) {
return "";
}


if (value instanceof MetadataType){
return "";
}

//special handling for byte[], some problems with jasper when printing
if (byte[].class.equals(value.getClass())){
return prettyPrintForReport((byte[]) value);
Expand Down
Expand Up @@ -143,6 +143,11 @@ public class ConnectorFactoryIcfImpl implements ConnectorFactory {
public static final QName CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_ELEMENT = new QName(NS_ICF_CONFIGURATION,
CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME);
public static final QName CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_TYPE = DOMUtil.XSD_INT;

public static final String CONNECTOR_SCHEMA_LEGACY_SCHEMA_XML_ELEMENT_NAME = "legacySchema";
public static final QName CONNECTOR_SCHEMA_LEGACY_SCHEMA_ELEMENT = new QName(NS_ICF_CONFIGURATION,
CONNECTOR_SCHEMA_LEGACY_SCHEMA_XML_ELEMENT_NAME);
public static final QName CONNECTOR_SCHEMA_LEGACY_SCHEMA_TYPE = DOMUtil.XSD_BOOLEAN;

public static final String CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME = "timeouts";
public static final QName CONNECTOR_SCHEMA_TIMEOUTS_ELEMENT = new QName(NS_ICF_CONFIGURATION,
Expand Down
Expand Up @@ -217,7 +217,7 @@ public class ConnectorInstanceIcfImpl implements ConnectorInstance {
private PrismSchema connectorSchema;
private String description;
private boolean caseIgnoreAttributeNames = false;
private boolean legacySchema = false;
private Boolean legacySchema = null;
private boolean supportsReturnDefaultAttributes = false;

public ConnectorInstanceIcfImpl(ConnectorInfo connectorInfo, ConnectorType connectorType,
Expand Down Expand Up @@ -322,7 +322,13 @@ public void configure(PrismContainerValue<?> configuration, OperationResult pare
} else {
throw new SystemException("Got unexpected exception: " + ex.getClass().getName(), ex);
}

}

PrismProperty<Boolean> legacySchemaConfigProperty = configuration.findProperty(new QName(
ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION,
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_XML_ELEMENT_NAME));
if (legacySchemaConfigProperty != null) {
legacySchema = legacySchemaConfigProperty.getRealValue();
}

}
Expand Down Expand Up @@ -355,17 +361,17 @@ public PrismSchema generateConnectorSchema() {
return null;
}

PrismSchema mpSchema = new PrismSchema(connectorType.getNamespace(), prismContext);
connectorSchema = new PrismSchema(connectorType.getNamespace(), prismContext);

// Create configuration type - the type used by the "configuration"
// element
PrismContainerDefinition<?> configurationContainerDef = mpSchema.createPropertyContainerDefinition(
PrismContainerDefinition<?> configurationContainerDef = connectorSchema.createPropertyContainerDefinition(
ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(),
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_TYPE_LOCAL_NAME);

// element with "ConfigurationPropertiesType" - the dynamic part of
// configuration schema
ComplexTypeDefinition configPropertiesTypeDef = mpSchema.createComplexTypeDefinition(new QName(
ComplexTypeDefinition configPropertiesTypeDef = connectorSchema.createComplexTypeDefinition(new QName(
connectorType.getNamespace(),
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_TYPE_LOCAL_NAME));

Expand Down Expand Up @@ -411,6 +417,9 @@ public PrismSchema generateConnectorSchema() {
configurationContainerDef.createContainerDefinition(
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT,
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_TYPE, 0, 1);
configurationContainerDef.createPropertyDefinition(
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_ELEMENT,
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_LEGACY_SCHEMA_TYPE, 0, 1);

// No need to create definition of "configuration" element.
// midPoint will look for this element, but it will be generated as part
Expand All @@ -420,10 +429,9 @@ public PrismSchema generateConnectorSchema() {
ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME,
configPropertiesTypeDef, 1, 1);

LOGGER.debug("Generated configuration schema for {}: {} definitions", this, mpSchema.getDefinitions()
LOGGER.debug("Generated configuration schema for {}: {} definitions", this, connectorSchema.getDefinitions()
.size());
connectorSchema = mpSchema;
return mpSchema;
return connectorSchema;
}

private QName icfTypeToXsdType(Class<?> type, boolean isConfidential) {
Expand Down Expand Up @@ -482,7 +490,7 @@ public void initialize(ResourceSchema resourceSchema, Collection<Object> capabil
this.capabilities = capabilities;
this.caseIgnoreAttributeNames = caseIgnoreAttributeNames;

if (resourceSchema != null) {
if (resourceSchema != null && legacySchema == null) {
legacySchema = isLegacySchema(resourceSchema);
}

Expand Down
Expand Up @@ -46,6 +46,8 @@
<icfc:enableFilteredResultsHandler>false</icfc:enableFilteredResultsHandler>
<icfc:enableAttributesToGetSearchResultsHandler>false</icfc:enableAttributesToGetSearchResultsHandler>
</icfc:resultsHandlerConfiguration>

<icfc:legacySchema>true</icfc:legacySchema>

</connectorConfiguration>
<namespace>http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-9999dddddddd</namespace>
Expand Down
Expand Up @@ -61,12 +61,17 @@
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

/**
Expand All @@ -81,6 +86,9 @@ public abstract class AbstractEDirTest extends AbstractLdapTest {
protected static final File ROLE_PIRATES_FILE = new File(TEST_DIR, "role-pirate.xml");
protected static final String ROLE_PIRATES_OID = "5dd034e8-41d2-11e5-a123-001e8c717e5b";

protected static final File ROLE_META_ORG_FILE = new File(TEST_DIR, "role-meta-org.xml");
protected static final String ROLE_META_ORG_OID = "f2ad0ace-45d7-11e5-af54-001e8c717e5b";

public static final String ATTRIBUTE_LOCKOUT_LOCKED_NAME = "lockedByIntruder";
public static final String ATTRIBUTE_LOCKOUT_RESET_TIME_NAME = "loginIntruderResetTime";
public static final String ATTRIBUTE_GROUP_MEMBERSHIP_NAME = "groupMembership";
Expand All @@ -91,6 +99,7 @@ public abstract class AbstractEDirTest extends AbstractLdapTest {
protected static final String ACCOUNT_JACK_PASSWORD = "qwe123";

private static final String GROUP_PIRATES_NAME = "pirates";
private static final String GROUP_MELEE_ISLAND_NAME = "Mêlée Island";

protected static final int NUMBER_OF_ACCOUNTS = 4;
protected static final int LOCKOUT_EXPIRATION_SECONDS = 65;
Expand All @@ -100,7 +109,8 @@ public abstract class AbstractEDirTest extends AbstractLdapTest {
protected String groupPiratesOid;
protected long jackLockoutTimestamp;
private String accountBarbossaOid;

private String orgMeleeIslandOid;
protected String groupMeleeOid;

@Override
public String getStartSystemCommand() {
Expand Down Expand Up @@ -178,6 +188,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti

// Roles
repoAddObjectFromFile(ROLE_PIRATES_FILE, RoleType.class, initResult);
repoAddObjectFromFile(ROLE_META_ORG_FILE, RoleType.class, initResult);

}

Expand All @@ -188,6 +199,7 @@ public void test000Sanity() throws Exception {
cleanupDelete(toDn(USER_BARBOSSA_USERNAME));
cleanupDelete(toDn(USER_CPTBARBOSSA_USERNAME));
cleanupDelete(toDn(USER_GUYBRUSH_USERNAME));
cleanupDelete(toGroupDn("Mêlée Island"));
}

@Test
Expand Down Expand Up @@ -609,6 +621,73 @@ public void test390ModifyUserBarbossaRename() throws Exception {

// TODO: create account with a group membership

@Test
public void test500AddOrgMeleeIsland() throws Exception {
final String TEST_NAME = "test500AddOrgMeleeIsland";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
OrgType orgType = org.asObjectable();
orgType.setName(new PolyStringType(GROUP_MELEE_ISLAND_NAME));
AssignmentType metaroleAssignment = new AssignmentType();
ObjectReferenceType metaroleRef = new ObjectReferenceType();
metaroleRef.setOid(ROLE_META_ORG_OID);
metaroleRef.setType(RoleType.COMPLEX_TYPE);
metaroleAssignment.setTargetRef(metaroleRef);
orgType.getAssignment().add(metaroleAssignment);

// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(org, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

orgMeleeIslandOid = org.getOid();
Entry entry = assertLdapGroup(GROUP_MELEE_ISLAND_NAME);

org = getObject(OrgType.class, orgMeleeIslandOid);
groupMeleeOid = getSingleLinkOid(org);
PrismObject<ShadowType> shadow = getShadowModel(groupMeleeOid);
display("Shadow (model)", shadow);
}

@Test
public void test510AssignGuybrushMeleeIsland() throws Exception {
final String TEST_NAME = "test510AssignGuybrushMeleeIsland";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// WHEN
TestUtil.displayWhen(TEST_NAME);
assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME);

PrismObject<UserType> user = getUser(USER_GUYBRUSH_OID);
String shadowOid = getSingleLinkOid(user);
PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
display("Shadow (model)", shadow);

assertEDirGroupMember(entry, GROUP_PIRATES_NAME);

IntegrationTestTools.assertAssociation(shadow, getAssociationGroupQName(), groupMeleeOid);
}

// Wait until the lockout of Jack expires, check status
@Test
public void test800JackLockoutExpires() throws Exception {
Expand Down
Expand Up @@ -352,9 +352,15 @@ public void test020Schema() throws Exception {

ResourceAttributeDefinition<String> cnDef = accountObjectClassDefinition.findAttributeDefinition("cn");
PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, -1);
assertTrue("createTimestampDef read", cnDef.canRead());
assertTrue("createTimestampDef read", cnDef.canModify());
assertTrue("createTimestampDef read", cnDef.canAdd());
assertTrue("cn read", cnDef.canRead());
assertTrue("cn read", cnDef.canModify());
assertTrue("cn read", cnDef.canAdd());

ResourceAttributeDefinition<String> oDef = accountObjectClassDefinition.findAttributeDefinition("o");
PrismAsserts.assertDefinition(oDef, new QName(MidPointConstants.NS_RI, "o"), DOMUtil.XSD_STRING, 0, -1);
assertTrue("o read", oDef.canRead());
assertTrue("o read", oDef.canModify());
assertTrue("o read", oDef.canAdd());

ResourceAttributeDefinition<Long> createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimestamp");
PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimestamp"),
Expand Down Expand Up @@ -449,6 +455,12 @@ protected Entry getLdapGroupByName(String name) throws LdapException, IOExceptio
return entry;
}

protected Entry assertLdapGroup(String cn) throws LdapException, IOException, CursorException {
Entry entry = getLdapGroupByName(cn);
assertAttribute(entry, "cn", cn);
return entry;
}

protected void assertAttribute(Entry entry, String attrName, String expectedValue) throws LdapInvalidAttributeValueException {
String dn = entry.getDn().toString();
Attribute ldapAttribute = entry.get(attrName);
Expand Down

0 comments on commit d2e1b88

Please sign in to comment.