本文整理汇总了Java中org.ietf.jgss.MessageProp类的典型用法代码示例。如果您正苦于以下问题:Java MessageProp类的具体用法?Java MessageProp怎么用?Java MessageProp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageProp类属于org.ietf.jgss包,在下文中一共展示了MessageProp类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unwrap
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
public byte[] unwrap(byte[] t, final boolean privacy)
throws Exception {
return doAs(new Action() {
@Override
public byte[] run(Context me, byte[] input) throws Exception {
System.out.printf("unwrap %s privacy from %s: ", privacy?"with":"without", me.name);
MessageProp p1 = new MessageProp(0, privacy);
byte[] bytes;
if (usingStream) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
me.x.unwrap(new ByteArrayInputStream(input), os, p1);
bytes = os.toByteArray();
} else {
bytes = me.x.unwrap(input, 0, input.length, p1);
}
System.out.println(printProp(p1));
return bytes;
}
}, t);
}
示例2: verifyMic
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
public void verifyMic(byte[] t, final byte[] msg) throws Exception {
doAs(new Action() {
@Override
public byte[] run(Context me, byte[] input) throws Exception {
MessageProp p1 = new MessageProp(0, true);
System.out.printf("verifyMic from %s: ", me.name);
if (usingStream) {
me.x.verifyMIC(new ByteArrayInputStream(input),
new ByteArrayInputStream(msg), p1);
} else {
me.x.verifyMIC(input, 0, input.length,
msg, 0, msg.length,
p1);
}
System.out.println(printProp(p1));
return null;
}
}, t);
}
示例3: getMIC
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
public byte[] getMIC(byte[] message, int s, int l){
try{
MessageProp prop = new MessageProp(0, true);
return context.getMIC(message, s, l, prop);
}
catch(GSSException ex){
return null;
}
}
示例4: printProp
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
/**
* Returns a string description of a MessageProp object
* @param prop the object
* @return the description
*/
static public String printProp(MessageProp prop) {
StringBuffer sb = new StringBuffer();
sb.append("MessagePop: ");
sb.append("QOP="+ prop.getQOP() + ", ");
sb.append(prop.getPrivacy()?"privacy, ":"");
sb.append(prop.isDuplicateToken()?"dup, ":"");
sb.append(prop.isGapToken()?"gap, ":"");
sb.append(prop.isOldToken()?"old, ":"");
sb.append(prop.isUnseqToken()?"unseq, ":"");
if (prop.getMinorStatus() != 0) {
sb.append(prop.getMinorString()+ "(" + prop.getMinorStatus()+")");
}
return sb.toString();
}
示例5: calculateMIC
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws CIFSException
*
* @see jcifs.smb.SSPContext#calculateMIC(byte[])
*/
@Override
public byte[] calculateMIC ( byte[] data ) throws CIFSException {
try {
return this.gssContext.getMIC(data, 0, data.length, new MessageProp(false));
}
catch ( GSSException e ) {
throw new CIFSException("Failed to calculate MIC", e);
}
}
示例6: verifyMIC
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see jcifs.smb.SSPContext#verifyMIC(byte[], byte[])
*/
@Override
public void verifyMIC ( byte[] data, byte[] mic ) throws CIFSException {
try {
this.gssContext.verifyMIC(mic, 0, mic.length, data, 0, data.length, new MessageProp(false));
}
catch ( GSSException e ) {
throw new CIFSException("Failed to verify MIC", e);
}
}
示例7: encryptInternal
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Override
protected byte[] encryptInternal(final byte[] bytes) throws EncryptionCodecException {
LOGGER.trace("encryptInternal() called...");
try {
LOGGER.debug("Encrypting content with context.wrap()...");
return context.wrap(bytes, 0, bytes.length, new MessageProp(0, true));
} catch (final GSSException gsse) {
throw new EncryptionCodecException("Unable to encrypt the outgoing ACI data.", gsse);
}
}
示例8: decryptInternal
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Override
protected byte[] decryptInternal(final byte[] bytes) throws EncryptionCodecException {
LOGGER.trace("decryptInternal() called...");
try {
LOGGER.debug("Decrypting content with context.unwrap()...");
return context.unwrap(bytes, 0, bytes.length, new MessageProp(0, true));
} catch (final GSSException gsse) {
throw new EncryptionCodecException("Unable to decrypt the incoming ACI data.", gsse);
}
}
示例9: testEncryptInternal
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Test
public void testEncryptInternal() throws GSSException, EncryptionCodecException {
final GSSContext gssContext = when(spy(GSSContext.class).wrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class))).thenReturn("This is a test result...".getBytes()).getMock();
final GssEncryptionCodec codec = new GssEncryptionCodec(gssContext);
final byte[] result = codec.encryptInternal("This is a test...".getBytes());
assertThat(new String(result), is(equalTo("This is a test result...")));
verify(gssContext).wrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class));
verifyNoMoreInteractions(gssContext);
}
示例10: testEncryptInternalException
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Test(expected = EncryptionCodecException.class)
@SuppressWarnings("unchecked")
public void testEncryptInternalException() throws GSSException, EncryptionCodecException {
final GssEncryptionCodec codec = new GssEncryptionCodec(
when(spy(GSSContext.class).wrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class))).thenThrow(GSSException.class).<GSSContext>getMock()
);
codec.encryptInternal("This is a test...".getBytes());
fail("Should've thrown a GSSException...");
}
示例11: testDecryptInternal
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Test
public void testDecryptInternal() throws GSSException, EncryptionCodecException {
final GSSContext gssContext = when(spy(GSSContext.class).unwrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class))).thenReturn("This is a test...".getBytes()).getMock();
final GssEncryptionCodec codec = new GssEncryptionCodec(gssContext);
final byte[] result = codec.decryptInternal("This is a test result...".getBytes());
assertThat(new String(result), is(equalTo("This is a test...")));
verify(gssContext).unwrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class));
verifyNoMoreInteractions(gssContext);
}
示例12: testDecryptInternalException
import org.ietf.jgss.MessageProp; //导入依赖的package包/类
@Test(expected = EncryptionCodecException.class)
@SuppressWarnings("unchecked")
public void testDecryptInternalException() throws GSSException, EncryptionCodecException {
final GssEncryptionCodec codec = new GssEncryptionCodec(
when(spy(GSSContext.class).unwrap((byte[]) any(), anyInt(), anyInt(), any(MessageProp.class))).thenThrow(GSSException.class).<GSSContext>getMock()
);
codec.decryptInternal("This is a test result...".getBytes());
fail("Should've thrown a GSSException...");
}