• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Extension类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getNewExtensionValue

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private String getNewExtensionValue(ExtensionFieldEntity extensionField, Extension updatedExtension,
                                    String fieldName) {
    String newValue = updatedExtension.getField(fieldName, ExtensionFieldType.STRING);
    if (newValue != null &&
            (extensionField.getType() == ExtensionFieldType.INTEGER
                    || extensionField.getType() == ExtensionFieldType.DECIMAL)) {
        newValue = numberPadder.pad(newValue);
    }
    return newValue;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:11,代码来源:ExtensionUpdater.java


示例17: deserializeExtension

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
private Extension deserializeExtension(JsonParser jp, JsonNode rootNode, String urn) throws IOException {
    if (urn == null || urn.isEmpty()) {
        throw new IllegalStateException("The URN cannot be null or empty");
    }
    if (rootNode.getNodeType() != JsonNodeType.OBJECT) {
        throw new JsonMappingException(jp, "Extension is of wrong JSON type");
    }
    Extension.Builder extensionBuilder = new Extension.Builder(urn);
    Iterator<Map.Entry<String, JsonNode>> fieldIterator = rootNode.fields();
    while (fieldIterator.hasNext()) {
        Map.Entry<String, JsonNode> entry = fieldIterator.next();
        switch (entry.getValue().getNodeType()) {
            case BOOLEAN:
                Boolean boolValue = ExtensionFieldType.BOOLEAN.fromString(entry.getValue().asText());
                extensionBuilder.setField(entry.getKey(), boolValue);
                break;
            case STRING:
                String stringValue = ExtensionFieldType.STRING.fromString(entry.getValue().asText());
                extensionBuilder.setField(entry.getKey(), stringValue);
                break;
            case NUMBER:
                String numberValueAsString = entry.getValue().asText();
                if (numberValueAsString.contains(".")) {
                    BigDecimal decimalValue = ExtensionFieldType.DECIMAL.fromString(numberValueAsString);
                    extensionBuilder.setField(entry.getKey(), decimalValue);
                } else {
                    BigInteger integerValue = ExtensionFieldType.INTEGER.fromString(numberValueAsString);
                    extensionBuilder.setField(entry.getKey(), integerValue);
                }
                break;
            default:
                throw new IllegalArgumentException("JSON type not supported: " + entry.getValue().getNodeType());
        }
    }

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


示例18: serialize

import org.osiam.resources.scim.Extension; //导入依赖的package包/类
@Override
public void serialize(Extension value, JsonGenerator jgen, SerializerProvider provider) throws IOException {

    jgen.writeStartObject();

    Map<String, Field> fields = value.getFields();
    for (Entry<String, Field> entry : fields.entrySet()) {
        String fieldName = entry.getKey();
        ExtensionFieldType<?> fieldType = entry.getValue().getType();
        String rawFieldValue = entry.getValue().getValue();

        jgen.writeFieldName(fieldName);

        if (fieldType == ExtensionFieldType.INTEGER) {
            BigInteger valueAsBigInteger = ExtensionFieldType.INTEGER.fromString(rawFieldValue);
            jgen.writeNumber(valueAsBigInteger);
        } else if (fieldType == ExtensionFieldType.DECIMAL) {
            BigDecimal valueAsBigDecimal = ExtensionFieldType.DECIMAL.fromString(rawFieldValue);
            jgen.writeNumber(valueAsBigDecimal);
        } else if (fieldType == ExtensionFieldType.BOOLEAN) {
            Boolean valueAsBoolean = ExtensionFieldType.BOOLEAN.fromString(rawFieldValue);
            jgen.writeBoolean(valueAsBoolean);
        } else {
            jgen.writeString(rawFieldValue);
        }
    }

    jgen.writeEndObject();
}
 
开发者ID:osiam,项目名称:osiam,代码行数:30,代码来源:ExtensionSerializer.java


示例19: hasAuthServerExtension

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


示例20: 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 = extensionDao.getExtensionByUrn(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,项目名称:resource-server,代码行数:34,代码来源:ExtensionConverter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IdentityOutputFilter类代码示例发布时间:2022-05-22
下一篇:
Java DriverInternalError类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap