Examples of UAttr


Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        SyncopeUser user = userDAO.find(1L);

        USchema emailSchema = userSchemaDAO.find("email", USchema.class);
        assertNotNull(emailSchema);

        UAttr attribute = new UAttr();
        attribute.setSchema(emailSchema);
        attribute.setOwner(user);

        Exception thrown = null;
        try {
            attribute.addValue("john.doe@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
            attribute.addValue("mario.rossi@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            LOG.error("Unexpected exception", e);
            thrown = e;
        }
        assertNull("no validation exception expected here ", thrown);

        try {
            attribute.addValue("http://www.apache.org", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            thrown = e;
        }
        assertNotNull("validation exception expected here ", thrown);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        USchema gender = userSchemaDAO.find("gender", USchema.class);
        assertNotNull(gender);
        assertNotNull(gender.getType());
        assertNotNull(gender.getEnumerationValues());

        UAttr attribute = new UAttr();
        attribute.setSchema(gender);
        attribute.setOwner(user);
        user.addAttr(attribute);

        Exception thrown = null;

        try {
            attribute.addValue("A", AttributableUtil.getInstance(AttributableType.USER));
        } catch (ValidationException e) {
            thrown = e;
        }
        assertNotNull("validation exception expected here ", thrown);

        attribute.addValue("M", AttributableUtil.getInstance(AttributableType.USER));

        InvalidEntityException iee = null;
        try {
            userDAO.save(user);
        } catch (InvalidEntityException e) {
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        assertNotNull(emailSchema);

        final USchema fullnameSchema = userSchemaDAO.find("fullname", USchema.class);
        assertNotNull(fullnameSchema);

        UAttr attribute = new UAttr();
        attribute.setSchema(emailSchema);

        UAttrUniqueValue uauv = new UAttrUniqueValue();
        uauv.setAttribute(attribute);
        uauv.setSchema(fullnameSchema);
        uauv.setStringValue("a value");

        attribute.setUniqueValue(uauv);

        user.addAttr(attribute);

        InvalidEntityException iee = null;
        try {
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        final USchema obscureSchema = userSchemaDAO.find("obscure", USchema.class);
        assertNotNull(obscureSchema);
        assertNotNull(obscureSchema.getSecretKey());
        assertNotNull(obscureSchema.getCipherAlgorithm());

        UAttr attribute = new UAttr();
        attribute.setSchema(obscureSchema);
        attribute.addValue("testvalue", AttributableUtil.getInstance(AttributableType.USER));
        attribute.setOwner(user);
        user.addAttr(attribute);

        userDAO.save(user);

        UAttr obscure = user.getAttr("obscure");
        assertNotNull(obscure);
        assertEquals(1, obscure.getValues().size());
        assertEquals(Encryptor.getInstance(obscureSchema.getSecretKey()).
                encode("testvalue", obscureSchema.getCipherAlgorithm()), obscure.getValues().get(0).getStringValue());
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        final byte[] bytes = new byte[20];
        new Random().nextBytes(bytes);
        final String photoB64Value = new String(Base64.encode(bytes), SyncopeConstants.DEFAULT_ENCODING);

        UAttr attribute = new UAttr();
        attribute.setSchema(photoSchema);
        attribute.addValue(photoB64Value, AttributableUtil.getInstance(AttributableType.USER));
        attribute.setOwner(user);
        user.addAttr(attribute);

        userDAO.save(user);

        UAttr obscure = user.getAttr("photo");
        assertNotNull(obscure);
        assertEquals(1, obscure.getValues().size());
        assertTrue(Arrays.equals(bytes, obscure.getValues().get(0).getBinaryValue()));
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

        assertTrue(Arrays.equals(bytes, obscure.getValues().get(0).getBinaryValue()));
    }

    @Test
    public void delete() {
        UAttr attribute = attrDAO.find(104L, UAttr.class);
        String attrSchemaName = attribute.getSchema().getName();

        attrDAO.delete(attribute.getId(), UAttr.class);

        USchema schema = userSchemaDAO.find(attrSchemaName, USchema.class);
        assertNotNull("user attribute schema deleted when deleting values", schema);
    }
View Full Code Here

Examples of org.apache.syncope.core.persistence.beans.user.UAttr

    public <T extends AbstractAttr> T newAttr() {
        T result = null;

        switch (type) {
            case USER:
                result = (T) new UAttr();
                break;
            case ROLE:
                result = (T) new RAttr();
                break;
            case MEMBERSHIP:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.