当前位置: 首页>>代码示例>>Java>>正文


Java Extension类代码示例

本文整理汇总了Java中org.osiam.resources.scim.Extension的典型用法代码示例。如果您正苦于以下问题:Java Extension类的具体用法?Java Extension怎么用?Java Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Extension类属于org.osiam.resources.scim包,在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllExtensionDefinitions

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
/**
 * Get all persisted extension definitions.
 *
 * @return A list of all {@link ExtensionDefinition} that are persisted.
 */
public List<ExtensionDefinition> getAllExtensionDefinitions() {
    List<Extension> extensions = fromEntity(repository.findAll());
    final List<ExtensionDefinition> extensionDefinitions = new ArrayList<>();

    for (Extension extension : extensions) {
        final ExtensionDefinition extensionDefinition = new ExtensionDefinition(extension.getUrn());

        for (Entry<String, Field> fieldEntry : extension.getFields().entrySet()) {
            final String field = fieldEntry.getKey();
            final ExtensionFieldType<?> type = fieldEntry.getValue().getType();

            extensionDefinition.addPair(field, type);
        }

        extensionDefinitions.add(extensionDefinition);
    }

    return extensionDefinitions;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:25,代码来源:SCIMExtensionProvisioning.java

示例2: update

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
/**
 * updates (remove, updates) the {@link ExtensionEntity}'s of the given {@link UserEntity} based on the given List
 * of Email's
 *
 * @param extensions map of {@link Extension} to be removed or updated
 * @param userEntity user who needs to be updated
 * @param attributes all {@link Extension}'s field values of the user will be removed if this Set contains an existing urn
 *                   and field name
 */
void update(Map<String, Extension> extensions, UserEntity userEntity, Set<String> attributes) {

    for (String attribute : attributes) {

        Optional<String> urn = getUrn(attribute);

        if (urn.isPresent()) {
            Optional<String> fieldName = getFieldName(attribute);

            if (fieldName.isPresent()) {
                removeExtensionFieldValue(userEntity, urn.get(), fieldName.get());
            } else {
                userEntity.removeAllExtensionFieldValues(urn.get());
            }
        }
    }

    if (extensions != null) {
        for (Entry<String, Extension> extensionEntry : extensions.entrySet()) {
            updateExtensionField(extensionEntry, userEntity);
        }
    }
}
 
开发者ID:osiam,项目名称:osiam,代码行数:33,代码来源:ExtensionUpdater.java

示例3: getAllExtensionDefinitions

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
/**
 * Get all persisted extension definitions.
 *
 * @return A list of all {@link ExtensionDefinition} that are persisted.
 */
public List<ExtensionDefinition> getAllExtensionDefinitions() {
    List<Extension> extensions = fromEntity(dao.getAllExtensions());
    final List<ExtensionDefinition> extensionDefinitions = new ArrayList<>();

    for (Extension extension : extensions) {
        final ExtensionDefinition extensionDefinition = new ExtensionDefinition(extension.getUrn());

        for (Entry<String, Field> fieldEntry : extension.getFields().entrySet()) {
            final String field = fieldEntry.getKey();
            final ExtensionFieldType<?> type = fieldEntry.getValue().getType();

            extensionDefinition.addPair(field, type);
        }

        extensionDefinitions.add(extensionDefinition);
    }

    return extensionDefinitions;
}
 
开发者ID:osiam,项目名称:resource-server,代码行数:25,代码来源:SCIMExtensionProvisioning.java

示例4: validate

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
public void validate(String urn, String fieldKey, String fieldValue) {
    final Extension extension = extensions.get(urn);
    final Field field = extension.getFields().get(fieldKey);

    try {
        field.getType().fromString(fieldValue);
    } catch (Exception e) {
        final String fieldPath = getFieldPath(urn, fieldKey);
        final String message = getMessage(field.getType(), e);
        final Object[] errorArgs = new Object[] {
                urn, fieldKey, fieldValue
        };

        bindingResult.rejectValue(fieldPath, message, errorArgs, message);
    }
}
 
开发者ID:osiam,项目名称:addon-administration,代码行数:17,代码来源:ExtensionValidator.java

示例5: enterExtensionShell

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
public Extension enterExtensionShell(String urn) throws IOException {
	final ExtensionBuilder extensionBuilder = new ExtensionBuilder(urn);

	final Shell subShell = ShellBuilder.subshell("update-extension", shell)
		.behavior()
			.disableExitCommand()
			.addHandler(extensionBuilder)
		.build();

	output.out()
		.normal("In this subshell you can create an extension. Leave this sub shell via \"commit\" to persist the changes.")
	.println();

	subShell.commandLoop();

	return extensionBuilder.build();
}
 
开发者ID:osiam,项目名称:shell,代码行数:18,代码来源:BuilderShellFactory.java

示例6: setUp

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Before
public void setUp() {
    extensionData = new HashMap<>();
    extensionData.put("gender", new Extension.Field(ExtensionFieldType.STRING, "male"));
    extensionData.put("newsletter", new Extension.Field(ExtensionFieldType.BOOLEAN, "true"));
    extensionData.put("age", new Extension.Field(ExtensionFieldType.INTEGER, "28"));
    extensionData.put("weight", new Extension.Field(ExtensionFieldType.DECIMAL, "82.7"));
    extensionData.put("birthday", new Extension.Field(ExtensionFieldType.DATE_TIME, "2008-01-23T04:56:22.000Z"));
    extensionData.put("photo", new Extension.Field(ExtensionFieldType.BINARY, "ZXhhbXBsZQ=="));
    extensionData.put("mother", new Extension.Field(ExtensionFieldType.REFERENCE, "https://example.com/Users/28"));

    extensionDataToPatch = new HashMap<>();
    extensionDataToPatch.put("gender", new Extension.Field(ExtensionFieldType.STRING, "female"));
    extensionDataToPatch.put("newsletter", new Extension.Field(ExtensionFieldType.BOOLEAN, "false"));
    extensionDataToPatch.put("age", new Extension.Field(ExtensionFieldType.INTEGER, "32"));
    extensionDataToPatch.put("weight", new Extension.Field(ExtensionFieldType.DECIMAL, "78.7"));
    extensionDataToPatch.put("birthday", new Extension.Field(ExtensionFieldType.DATE_TIME,
            "2005-01-23T04:56:22.000Z"));
    extensionDataToPatch.put("photo", new Extension.Field(ExtensionFieldType.BINARY, "Y2hhbmdlZA=="));
    extensionDataToPatch.put("mother", new Extension.Field(ExtensionFieldType.REFERENCE,
            "https://www.example.com/Users/99"));
    accessToken = OSIAM_CONNECTOR.retrieveAccessToken("marissa", "koala", Scope.ADMIN);
}
 
开发者ID:osiam,项目名称:connector4java-integration-tests,代码行数:24,代码来源:ScimExtensionIT.java

示例7: retrieving_multiple_users_with_extension_via_query_works

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Test
@DatabaseSetup("/database_seeds/ScimExtensionIT/extensions_and_multiple_users.xml")
public void retrieving_multiple_users_with_extension_via_query_works() {
    Query query = new QueryBuilder().filter("userName co \"existing\"").build();

    SCIMSearchResult<User> result = OSIAM_CONNECTOR.searchUsers(query, accessToken);

    assertThat(result.getResources().size(), is(3));
    for (User storedUser : result.getResources()) {
        assertTrue(storedUser.getSchemas().contains(URN));
        Extension storedExtension = storedUser.getExtension(URN);
        for (Map.Entry<String, Extension.Field> entry : extensionData.entrySet()) {
            String fieldName = entry.getKey();
            Extension.Field expectedField = entry.getValue();
            ExtensionFieldType<?> expectedType = expectedField.getType();
            Object expectedValue = expectedType.fromString(expectedField.getValue());
            Object actualValue = storedExtension.getField(fieldName, expectedType);

            assertEquals(expectedValue, actualValue);
        }
    }
}
 
开发者ID:osiam,项目名称:connector4java-integration-tests,代码行数:23,代码来源:ScimExtensionIT.java

示例8: replacing_a_user_with_extension_data_to_database_works

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Test
@DatabaseSetup(value = "/database_seeds/ScimExtensionIT/extensions.xml")
public void replacing_a_user_with_extension_data_to_database_works() {
    User existingUser = OSIAM_CONNECTOR.getUser(EXISTING_USER_UUID, accessToken);
    extensionData.put("gender", new Extension.Field(ExtensionFieldType.STRING, "female"));
    Extension extension = existingUser.getExtension(URN);
    Extension newExtension = new Extension.Builder(extension).setField("gender", "female").build();

    User replaceUser = new User.Builder(existingUser).addExtension(newExtension).build();

    OSIAM_CONNECTOR.replaceUser(EXISTING_USER_UUID, replaceUser, accessToken);

    User storedUser = OSIAM_CONNECTOR.getUser(EXISTING_USER_UUID, accessToken);
    Extension storedExtension = storedUser.getExtension(URN);

    assertExtensionEqualsExtensionMap(storedExtension, extensionData);
}
 
开发者ID:osiam,项目名称:connector4java-integration-tests,代码行数:18,代码来源:ScimExtensionIT.java

示例9: hasAuthServerExtension

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private boolean hasAuthServerExtension(User user) {
    if (!user.isExtensionPresent(LdapAuthentication.AUTH_EXTENSION)) {
        return false;
    }
    Extension authExtension = user.getExtension(LdapAuthentication.AUTH_EXTENSION);
    return authExtension.isFieldPresent("origin")
            && authExtension.getFieldAsString("origin").equals(LdapAuthentication.LDAP_PROVIDER);
}
 
开发者ID:osiam,项目名称:auth-server,代码行数:9,代码来源:OsiamLdapAuthenticationProvider.java

示例10: addExtensions

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private void addExtensions(User.Builder userBuilder, Set<ExtensionFieldValueEntity> extensionFieldValues) {
    Set<Extension> extensions = extensionConverter.toScim(extensionFieldValues);

    for (Extension extension : extensions) {
        userBuilder.addExtension(extension);
    }
}
 
开发者ID:osiam,项目名称:osiam,代码行数:8,代码来源:UserConverter.java

示例11: fromScim

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Override
public Set<ExtensionFieldValueEntity> fromScim(Set<Extension> extensions) {
    Set<ExtensionFieldValueEntity> result = new HashSet<>();

    for (Extension extension : checkNotNull(extensions)) {
        String urn = extension.getUrn();
        ExtensionEntity extensionEntity = extensionRepository.findByUrn(urn);

        for (ExtensionFieldEntity field : extensionEntity.getFields()) {
            if (extension.isFieldPresent(field.getName())) {

                if (Strings.isNullOrEmpty(extension.getField(field.getName(), ExtensionFieldType.STRING))) {
                    continue;
                }

                ExtensionFieldValueEntity value = new ExtensionFieldValueEntity();

                String typeCheckedStringValue = getTypeCheckedStringValue(field.getType(), field.getName(),
                        extension);

                if (field.getType() == ExtensionFieldType.INTEGER || field.getType() == ExtensionFieldType.DECIMAL) {
                    typeCheckedStringValue = numberPadder.pad(typeCheckedStringValue);
                }

                value.setValue(typeCheckedStringValue);
                value.setExtensionField(field);
                result.add(value);
            }
        }

    }
    return result;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:34,代码来源:ExtensionConverter.java

示例12: toScim

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Override
public Set<Extension> toScim(Set<ExtensionFieldValueEntity> entity) {
    Map<String, Extension.Builder> extensionMap = new HashMap<>();

    for (ExtensionFieldValueEntity fieldValueEntity : checkNotNull(entity)) {
        String urn = fieldValueEntity.getExtensionField().getExtension().getUrn();
        Extension.Builder extensionBuilder;

        if (extensionMap.containsKey(urn)) {
            extensionBuilder = extensionMap.get(urn);
        } else {
            extensionBuilder = new Extension.Builder(urn);
            extensionMap.put(urn, extensionBuilder);
        }

        ExtensionFieldType<?> type = fieldValueEntity.getExtensionField().getType();
        if (type == null) {
            // If this is ever true, something went very, very wrong.
            throw new IllegalArgumentException("The ExtensionField type can't be null");
        }
        String value = fieldValueEntity.getValue();

        if (type == ExtensionFieldType.INTEGER || type == ExtensionFieldType.DECIMAL) {
            value = numberPadder.unpad(value);
        }

        String name = fieldValueEntity.getExtensionField().getName();
        addField(extensionBuilder, type, name, value);
    }

    HashSet<Extension> extensions = new HashSet<>();
    for (Extension.Builder builder : extensionMap.values()) {
        extensions.add(builder.build());
    }

    return extensions;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:38,代码来源:ExtensionConverter.java

示例13: fromEntity

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private List<Extension> fromEntity(List<ExtensionEntity> entities) {
    List<Extension> result = new ArrayList<>();

    for (ExtensionEntity entity : entities) {
        Extension.Builder builder = new Extension.Builder(entity.getUrn());
        setField(entity, builder);

        result.add(builder.build());
    }

    return result;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:13,代码来源:SCIMExtensionProvisioning.java

示例14: setField

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private void setField(ExtensionEntity entity, Extension.Builder builder) {
    for (ExtensionFieldEntity fieldEntity : entity.getFields()) {
        switch (fieldEntity.getType().getName()) {
            case "STRING":
                builder.setField(fieldEntity.getName(), "null");
                break;
            case "INTEGER":
                builder.setField(fieldEntity.getName(), BigInteger.ZERO);
                break;
            case "DECIMAL":
                builder.setField(fieldEntity.getName(), BigDecimal.ZERO);
                break;
            case "BOOLEAN":
                builder.setField(fieldEntity.getName(), false);
                break;
            case "DATE_TIME":
                builder.setField(fieldEntity.getName(), new Date(0L));
                break;
            case "BINARY":
                builder.setField(fieldEntity.getName(), ByteBuffer.wrap(new byte[]{}));
                break;
            case "REFERENCE":
                try {
                    builder.setField(fieldEntity.getName(), new URI("http://www.osiam.org"));
                } catch (URISyntaxException e) {
                    logger.warn("Unable to contruct URI for http://www.osiam.org This should never happen!", e);
                    throw new OsiamBackendFailureException();
                }
                break;
            default:
                throw new NoSuchElementException("Type '" + fieldEntity.getType().getName() + "' does not exist");
        }
    }
}
 
开发者ID:osiam,项目名称:osiam,代码行数:35,代码来源:SCIMExtensionProvisioning.java

示例15: updateExtensionField

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private void updateExtensionField(Entry<String, Extension> extensionEntry, UserEntity userEntity) {
    String urn = extensionEntry.getKey();
    Extension updatedScimExtension = extensionEntry.getValue();
    ExtensionEntity extensionEntity = extensionRepository.findByUrn(urn);

    for (String fieldName : updatedScimExtension.getFields().keySet()) {
        ExtensionFieldEntity extensionEntitiyField;
        try {
            extensionEntitiyField = extensionEntity.getFieldForName(fieldName, true);
        } catch (NoSuchElementException e) {
            logger.warn("Update Extension failed: ", e.getMessage());
            throw e;
        }
        ExtensionFieldValueEntity extensionFieldValue = findExtensionFieldValue(extensionEntitiyField,
                userEntity);

        if (extensionFieldValue == null) {
            extensionFieldValue = new ExtensionFieldValueEntity();
        }
        String newValue = getNewExtensionValue(extensionEntitiyField, updatedScimExtension, fieldName);
        if (!Strings.isNullOrEmpty(newValue)) {
            extensionFieldValue.setValue(newValue);
            extensionFieldValue.setExtensionField(extensionEntitiyField);
            userEntity.addOrUpdateExtensionValue(extensionFieldValue);
        }
    }
}
 
开发者ID:osiam,项目名称:osiam,代码行数:28,代码来源:ExtensionUpdater.java


注:本文中的org.osiam.resources.scim.Extension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。