當前位置: 首頁>>代碼示例>>Java>>正文


Java SerializationUtils.deserialize方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.SerializationUtils.deserialize方法的典型用法代碼示例。如果您正苦於以下問題:Java SerializationUtils.deserialize方法的具體用法?Java SerializationUtils.deserialize怎麽用?Java SerializationUtils.deserialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.SerializationUtils的用法示例。


在下文中一共展示了SerializationUtils.deserialize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyServiceAttributeFilterAllAttributes

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Test
public void verifyServiceAttributeFilterAllAttributes() {
    final ReturnAllAttributeReleasePolicy policy = new ReturnAllAttributeReleasePolicy();
    final Principal p = mock(Principal.class);

    final Map<String, Object> map = new HashMap<>();
    map.put("attr1", "value1");
    map.put("attr2", "value2");
    map.put("attr3", Arrays.asList("v3", "v4"));

    when(p.getAttributes()).thenReturn(map);
    when(p.getId()).thenReturn("principalId");

    final Map<String, Object> attr = policy.getAttributes(p);
    assertEquals(attr.size(), map.size());

    final byte[] data = SerializationUtils.serialize(policy);
    final ReturnAllAttributeReleasePolicy p2 = SerializationUtils.deserialize(data);
    assertNotNull(p2);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:21,代碼來源:RegisteredServiceAttributeReleasePolicyTests.java

示例2: run

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public void run() {
    Thread.currentThread().setContextClassLoader(TaskThread.class.getClassLoader());
    executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_RUNNING).build());
    Map<String, Object> data = SerializationUtils.deserialize(taskInfo.getData().toByteArray());
    ShardingContexts shardingContexts = (ShardingContexts) data.get("shardingContext");
    @SuppressWarnings("unchecked")
    JobConfigurationContext jobConfig = new JobConfigurationContext((Map<String, String>) data.get("jobConfigContext"));
    try {
        ElasticJob elasticJob = getElasticJobInstance(jobConfig);
        final CloudJobFacade jobFacade = new CloudJobFacade(shardingContexts, jobConfig, jobEventBus);
        if (jobConfig.isTransient()) {
            JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
            executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).build());
        } else {
            new DaemonTaskScheduler(elasticJob, jobConfig, jobFacade, executorDriver, taskInfo.getTaskId()).init();
        }
        // CHECKSTYLE:OFF
    } catch (final Throwable ex) {
        // CHECKSTYLE:ON
        log.error("Elastic-Job-Cloud-Executor error", ex);
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_ERROR).setMessage(ExceptionUtil.transform(ex)).build());
        executorDriver.stop();
        throw ex;
    }
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:27,代碼來源:TaskExecutor.java

示例3: handleData

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public void handleData(NBTTagCompound data)
{
	Biome b = Biome.getBiome(data.getInteger("biomeID"));
	DimBlockPos dbp = SerializationUtils.deserialize(data.getByteArray("blockPosData"));
	if (MC.getSide() == Side.CLIENT)
	{
		VoidApi.proxy.getClientListener().addScheduledTask(() -> {
				if (VoidApi.proxy.getClientWorld().isBlockLoaded(dbp.pos))
					ChunkUtils.setBiomeAt(b, dbp.pos, VoidApi.proxy.getClientWorld());}
		);
	}
	else
	{
		WorldServer ws = DimensionManager.getWorld(dbp.dim);
		ws.addScheduledTask(() -> {
				if (ws.isBlockLoaded(dbp.pos))
					ChunkUtils.setBiomeAt(b, dbp.pos, ws);}
		);
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:VoidApi,代碼行數:22,代碼來源:HandlerBiome.java

示例4: verifyAttributeFilterMappedAttributes

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Test
public void verifyAttributeFilterMappedAttributes() {
    final ReturnMappedAttributeReleasePolicy policy = new ReturnMappedAttributeReleasePolicy();
    final Map<String, String> mappedAttr = new HashMap<>();
    mappedAttr.put("attr1", "newAttr1");
    
    policy.setAllowedAttributes(mappedAttr);
            
    final Principal p = mock(Principal.class);
    
    final Map<String, Object> map = new HashMap<>();
    map.put("attr1", "value1");
    map.put("attr2", "value2");
    map.put("attr3", Arrays.asList("v3", "v4"));
    
    when(p.getAttributes()).thenReturn(map);
    when(p.getId()).thenReturn("principalId");
    
    final Map<String, Object> attr = policy.getAttributes(p);
    assertEquals(attr.size(), 1);
    assertTrue(attr.containsKey("newAttr1"));
    
    final byte[] data = SerializationUtils.serialize(policy);
    final ReturnMappedAttributeReleasePolicy p2 = SerializationUtils.deserialize(data);
    assertNotNull(p2);
    assertEquals(p2.getAllowedAttributes(), policy.getAllowedAttributes());
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:28,代碼來源:RegisteredServiceAttributeReleasePolicyTests.java

示例5: SearchOptionEditor

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
public SearchOptionEditor(String markupId) {
	super("searchOptions", markupId, AdvancedSearchPanel.this);
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(option.getClass().getName());
	if (cookie != null) {
		try {
			byte[] bytes = Base64.decode(cookie.getValue());
			option = (SearchOption) SerializationUtils.deserialize(bytes);
		} catch (Exception e) {
			logger.debug("Error restoring search option from cookie", e);
		}
	} 
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:15,代碼來源:AdvancedSearchPanel.java

示例6: decodeAndSerializeObject

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
/**
 * Decode and serialize object.
 *
 * @param <T>  the type parameter
 * @param object the object
 * @param cipher the cipher
 * @param type the type
 * @return the t
 * @since 4.2
 */
public static <T> T decodeAndSerializeObject(final byte[] object,
                                             final CipherExecutor<byte[], byte[]> cipher,
                                             final Class<? extends Serializable> type) {
    final byte[] decoded = cipher.decode(object);
    final Object result = SerializationUtils.deserialize(decoded);
    if (!type.isAssignableFrom(result.getClass())) {
        throw new ClassCastException("Decoded object is of type " + result.getClass()
                + " when we were expecting " + type);
    }
    return (T) result;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:22,代碼來源:CompressionUtils.java

示例7: testSerialization

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Test
public void testSerialization() throws ParseException {
    final OidcCredentials credentials = new OidcCredentials(CLIENT_NAME);
    credentials.setCode(new AuthorizationCode(VALUE));
    credentials.setAccessToken(new BearerAccessToken(VALUE, 0L, Scope.parse("oidc email")));
    credentials.setRefreshToken(new RefreshToken(VALUE));
    credentials.setIdToken(JWTParser.parse(ID_TOKEN));
    byte[] result = SerializationUtils.serialize(credentials);
    final OidcCredentials credentials2 = SerializationUtils.deserialize(result);
    assertEquals(credentials.getAccessToken(), credentials2.getAccessToken());
    assertEquals(credentials.getRefreshToken(), credentials2.getRefreshToken());
    assertEquals(credentials.getIdToken().getParsedString(), credentials2.getIdToken().getParsedString());
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:14,代碼來源:OidcCredentialsTests.java

示例8: testReadWriteObjectNullAccessToken

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
/**
 * Test that serialization and deserialization of the OidcProfile work when the BearerAccessToken is null.
 */
@Test
public void testReadWriteObjectNullAccessToken() {
    OidcProfile profile = new OidcProfile();
    profile.setIdTokenString(ID_TOKEN);
    profile.setRefreshToken(new RefreshToken(REFRESH_TOKEN));
    byte[] result = SerializationUtils.serialize(profile);
    profile = SerializationUtils.deserialize(result);
    assertNull(profile.getAccessToken());
    assertEquals(profile.getIdTokenString(), ID_TOKEN);
    assertEquals(profile.getRefreshToken().getValue(), REFRESH_TOKEN);
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:15,代碼來源:OidcProfileTests.java

示例9: testReadWriteObjectNullRefreshToken

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
/**
 * Test that serialization and deserialization of the OidcProfile work when the Refresh token is null.
 */
@Test
public void testReadWriteObjectNullRefreshToken() {
    OidcProfile profile = new OidcProfile();
    profile.setAccessToken(populatedAccessToken);
    profile.setIdTokenString(ID_TOKEN);
    byte[] result = SerializationUtils.serialize(profile);
    profile = SerializationUtils.deserialize(result);
    assertNotNull("accessToken", profile.getAccessToken());
    assertNotNull("value", profile.getAccessToken().getValue());
    assertEquals(profile.getAccessToken().getLifetime(), populatedAccessToken.getLifetime());
    assertEquals(profile.getAccessToken().getScope(), populatedAccessToken.getScope());
    assertEquals(profile.getIdTokenString(), ID_TOKEN);
    assertNull(profile.getRefreshToken());
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:18,代碼來源:OidcProfileTests.java

示例10: frameworkMessage

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public void frameworkMessage(ExecutorDriver driver, byte[] data) {
    System.out.println("HumioExecutor.frameworkMessage");
    final List<TaskDetails> taskDetails = SerializationUtils.deserialize(data);

    updateElasticBeatConfig(HUMIO_FILEBEAT_YAML, taskDetails);
    updateElasticBeatConfig(HUMIO_METRICBEAT_YAML, taskDetails.stream().filter(taskDetail -> taskDetail.getContainerId() != null).collect(Collectors.toList()));
}
 
開發者ID:humio,項目名稱:dcos2humio,代碼行數:9,代碼來源:HumioExecutor.java

示例11: validateSecurityTokenInAssertion

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
private static SecurityToken validateSecurityTokenInAssertion(final Assertion assertion, final HttpServletRequest request,
                                                              final HttpServletResponse response) {
    LOGGER.debug("Validating security token in CAS assertion...");

    final AttributePrincipal principal = assertion.getPrincipal();
    if (!principal.getAttributes().containsKey(WSFederationConstants.SECURITY_TOKEN_ATTRIBUTE)) {
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
    }
    final String token = (String) principal.getAttributes().get(WSFederationConstants.SECURITY_TOKEN_ATTRIBUTE);
    final byte[] securityTokenBin = EncodingUtils.decodeBase64(token);
    return SerializationUtils.deserialize(securityTokenBin);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:13,代碼來源:WSFederationValidateRequestCallbackController.java

示例12: deserialize

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public Object deserialize(String topic, byte[] data) {
    if (data == null)
        return null;
    else
        return SerializationUtils.deserialize(data);
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:8,代碼來源:JdkMessageDeserializer.java

示例13: generateReEncryptionKey

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public ReEncryptionKey generateReEncryptionKey(byte[] keyMaterialFrom, byte[] keyMaterialTo) {
  final PrivateKey keyFrom = SerializationUtils.deserialize(keyMaterialFrom);
  final PrivateKey keyTo = SerializationUtils.deserialize(keyMaterialTo);
  return new BBS98ReEncryptionKeySpec(
      engine.rekeygen(keyFrom, keyTo));
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:8,代碼來源:BBS98BCReEncryptionKeyGenerator.java

示例14: testReadWriteObjectNullTokens

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
/**
 * Test that serialization and deserialization of the OidcProfile work when tokens are null, after a call
 * to clearSensitiveData().
 */
@Test
public void testReadWriteObjectNullTokens() {
    OidcProfile profile = new OidcProfile();
    profile.setAccessToken(populatedAccessToken);
    profile.clearSensitiveData();

    byte[] result = SerializationUtils.serialize(profile);
    profile = SerializationUtils.deserialize(result);
    assertNull(profile.getAccessToken());
    assertNull(profile.getIdTokenString());
    assertNull(profile.getRefreshToken());
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:17,代碼來源:OidcProfileTests.java

示例15: deserialize

import org.apache.commons.lang3.SerializationUtils; //導入方法依賴的package包/類
@Override
public SolrQuery deserialize(JsonParser parser, DeserializationContext context)
		throws IOException, JsonProcessingException {
	JsonNode node = parser.getCodec().readTree(parser);
	String serialization = node.get(SERIALIZATION).textValue();
	return SerializationUtils.deserialize(Base64.decodeBase64(serialization.getBytes()));
}
 
開發者ID:maenu,項目名稱:kowalski,代碼行數:8,代碼來源:SolrQueryDeserializer.java


注:本文中的org.apache.commons.lang3.SerializationUtils.deserialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。