本文整理匯總了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;
}
}
示例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);}
);
}
}
示例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);
}
}
}
示例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;
}
示例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());
}
示例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);
}
示例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());
}
示例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()));
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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()));
}