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


Java ByteSource.wrap方法代碼示例

本文整理匯總了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();
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:18,代碼來源:LdapUserGraphicalAuthenticationRepository.java

示例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;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:25,代碼來源:AbstractTicketRegistry.java

示例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);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:25,代碼來源:EncryptedMapDecorator.java

示例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();
		}
	};
}
 
開發者ID:MatthewTamlin,項目名稱:Avatar,代碼行數:12,代碼來源:InMemoryJavaFileObject.java

示例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();
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:14,代碼來源:StaticUserGraphicalAuthenticationRepository.java

示例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);
}
 
開發者ID:isi-nlp,項目名稱:tac-kbp-eal,代碼行數:16,代碼來源:TestQuoteFilter.java

示例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();
		}
	};
}
 
開發者ID:MatthewTamlin,項目名稱:Avatar,代碼行數:12,代碼來源:InMemoryJavaFileObject.java

示例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);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:11,代碼來源:SpnegoCredential.java

示例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);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:7,代碼來源:TicketEncryptionDecryptionTests.java

示例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);
}
 
開發者ID:HubSpot,項目名稱:NioSmtpClient,代碼行數:5,代碼來源:InputStreamMessageContentTest.java

示例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);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:9,代碼來源:SpnegoCredential.java


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