本文整理匯總了Java中com.google.common.io.ByteSource.wrap方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteSource.wrap方法的具體用法?Java ByteSource.wrap怎麽用?Java ByteSource.wrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteSource
的用法示例。
在下文中一共展示了ByteSource.wrap方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeTicket
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
/**
* Encode ticket.
*
* @param ticket the ticket
* @return the ticket
*/
protected Ticket encodeTicket(final Ticket ticket) {
if (this.cipherExecutor == null) {
logger.trace("Ticket encryption is not enabled. Falling back to default behavior");
return ticket;
}
if (ticket == null) {
return ticket;
}
logger.info("Encoding [{}]", ticket);
final byte[] encodedTicketObject = CompressionUtils.serializeAndEncodeObject(
this.cipherExecutor, ticket);
final String encodedTicketId = encodeTicketId(ticket.getId());
final Ticket encodedTicket = new EncodedTicket(
ByteSource.wrap(encodedTicketObject), encodedTicketId);
logger.info("Created [{}]", encodedTicket);
return encodedTicket;
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:26,代碼來源:AbstractCrypticTicketRegistry.java
示例2: getGraphics
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Response<SearchResult> response = searchForId(username);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(gua.getLdap().getImageAttribute());
if (attribute != null && attribute.isBinary()) {
return ByteSource.wrap(attribute.getBinaryValue());
}
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
示例3: encodeTicket
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
/**
* Encode ticket.
*
* @param ticket the ticket
* @return the ticket
*/
protected Ticket encodeTicket(final Ticket ticket) {
if (!isCipherExecutorEnabled()) {
LOGGER.trace(MESSAGE);
return ticket;
}
if (ticket == null) {
LOGGER.debug("Ticket passed is null and cannot be encoded");
return null;
}
LOGGER.debug("Encoding ticket [{}]", ticket);
final byte[] encodedTicketObject = SerializationUtils.serializeAndEncodeObject(this.cipherExecutor, ticket);
final String encodedTicketId = encodeTicketId(ticket.getId());
final Ticket encodedTicket = new EncodedTicket(ByteSource.wrap(encodedTicketObject), encodedTicketId);
LOGGER.debug("Created encoded ticket [{}]", encodedTicket);
return encodedTicket;
}
示例4: EncryptedMapDecorator
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
/**
* Decorates a map using the provided algorithms.
* <p>Takes a salt and secretKey so that it can work with a distributed cache.
*
* @param decoratedMap the map to decorate. CANNOT be NULL.
* @param hashAlgorithm the algorithm to use for hashing. CANNOT BE NULL.
* @param salt the salt, as a String. Gets converted to bytes. CANNOT be NULL.
* @param secretKeyAlgorithm the encryption algorithm. CANNOT BE NULL.
* @param secretKey the secret to use. CANNOT be NULL.
* @throws RuntimeException if the algorithm cannot be found or the iv size cant be determined.
*/
public EncryptedMapDecorator(final Map<String, String> decoratedMap, final String hashAlgorithm, final byte[] salt,
final String secretKeyAlgorithm, final Key secretKey) {
try {
this.decoratedMap = decoratedMap;
this.key = secretKey;
this.salt = ByteSource.wrap(salt);
this.secretKeyAlgorithm = secretKeyAlgorithm;
this.messageDigest = MessageDigest.getInstance(hashAlgorithm);
this.ivSize = getIvSize();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例5: openWriter
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public Writer openWriter() throws IOException {
return new StringWriter() {
@Override
public void close() throws IOException {
// Save the writer contents as the file contents
data = ByteSource.wrap(toString().getBytes(charset));
lastModifiedMsFromEpoch = System.currentTimeMillis();
}
};
}
示例6: getGraphics
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Resource resource = resourceLoader.getResource(gua.getResource().getLocation());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(resource.getInputStream(), bos);
return ByteSource.wrap(bos.toByteArray());
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
示例7: testSerialization
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Test
public void testSerialization() throws IOException {
final QuoteFilter reference = QuoteFilter.createFromBannedRegions(
ImmutableMap.of(
Symbol.from("dummy"),
ImmutableRangeSet.<Integer>builder().add(Range.closed(4, 60)).add(Range.closed(67, 88))
.build(),
Symbol.from("dummy2"), ImmutableRangeSet.of(Range.closed(0, 20))));
final ByteArraySink sink = new ByteArraySink();
reference.saveTo(sink);
final ByteSource source = ByteSource.wrap(sink.toByteArray());
final Object restored = QuoteFilter.loadFrom(source);
assertEquals(reference, restored);
}
示例8: openOutputStream
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
public OutputStream openOutputStream() throws IOException {
return new ByteArrayOutputStream() {
@Override
public void close() throws IOException {
// Save the output stream contents as the file contents
data = ByteSource.wrap(toByteArray());
lastModifiedMsFromEpoch = System.currentTimeMillis();
}
};
}
示例9: checkSerializationOfTgtByteSource
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Test
public void checkSerializationOfTgtByteSource() throws Exception {
final ByteSource bytes = ByteSource.wrap(CompressionUtils.serializeAndEncodeObject(cipher, tgt));
final Ticket obj = CompressionUtils.decodeAndSerializeObject(bytes.read(), cipher, Ticket.class);
assertNotNull(obj);
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:7,代碼來源:TicketEncryptionDecryptionTests.java
示例10: SpnegoCredential
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
/**
* Instantiates a new SPNEGO credential.
*
* @param initToken the init token
*/
public SpnegoCredential(final byte[] initToken) {
Assert.notNull(initToken, "The initToken cannot be null.");
this.initToken = ByteSource.wrap(initToken);
this.isNtlm = isTokenNtlm(this.initToken);
}
示例11: checkSerializationOfTgtByteSource
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Test
public void checkSerializationOfTgtByteSource() throws Exception {
final ByteSource bytes = ByteSource.wrap(SerializationUtils.serializeAndEncodeObject(cipher, tgt));
final Ticket obj = SerializationUtils.decodeAndDeserializeObject(bytes.read(), cipher, Ticket.class);
assertNotNull(obj);
}
示例12: createContent
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
@Override
protected MessageContent createContent(byte[] bytes) {
return new InputStreamMessageContent(ByteSource.wrap(bytes), OptionalInt.of(bytes.length), MessageContentEncoding.UNKNOWN);
}
示例13: setNextToken
import com.google.common.io.ByteSource; //導入方法依賴的package包/類
/**
* Sets next token.
*
* @param nextToken the next token
*/
public void setNextToken(final byte[] nextToken) {
this.nextToken = ByteSource.wrap(nextToken);
}