Package org.ietf.jgss

Examples of org.ietf.jgss.MessageProp


public class MessagePropTest extends TestCase {

    public void testMessagePropCreation() {

        MessageProp msgp = new MessageProp(true);
        MessageProp msgp2 = new MessageProp(0, true);

        msgp2.setQOP(1);
        msgp2.setPrivacy(false);
        msgp2.setSupplementaryStates(false, false, false, false,
                                     0, "no status");

        if (msgp2.getQOP() != 1)
            fail("Failed to get QOP from MessageProp");
        System.out.format("%-40s %10s%n", "... testing getQOP()",
                "... passed");

        if (msgp2.getPrivacy() != false)
            fail("Failed to get Privacy from MessageProp");
        System.out.format("%-40s %10s%n", "... testing getPrivacy()",
                "... passed");

        if (msgp2.getMinorStatus() != 0
            fail("Failed to get minor status from MessageProp");
        System.out.format("%-40s %10s%n", "... testing getMinorStatus()",
                "... passed");

        if (!msgp2.getMinorString().equals("no status"))
            fail("Failed to get minor status string from MessageProp");
        System.out.format("%-40s %10s%n", "... testing getMinorString()",
                "... passed");

        if (msgp2.isDuplicateToken())
            fail("Incorrect duplicate flag set");
        System.out.format("%-40s %10s%n", "... testing isDuplicateToken()",
                "... passed");

        if (msgp2.isOldToken())
            fail("Incorrect old token flag set");
        System.out.format("%-40s %10s%n", "... testing isOldToken()",
                "... passed");

        if (msgp2.isUnseqToken())
            fail("Incorrect unseq token set");
        System.out.format("%-40s %10s%n", "... testing isUnseqToken()",
                "... passed");

        if (msgp2.isGapToken())
            fail("Incorrect gap token set");
        System.out.format("%-40s %10s%n", "... testing isGapToken()",
                "... passed");
    }
View Full Code Here


  }

  @Override
  public byte[] getMIC(byte[] message, int offset, int length) {
    try {
      return _context.getMIC(message, offset, length, new MessageProp(0, true));
    } catch(GSSException ex) {
      return null;
    }
  }
View Full Code Here

                    startupLatch.release();
                }
            } else {
                ByteBuffer buffer = packet.getBuffer();

                byte[] token = context.unwrap(buffer.array(), buffer.position(), buffer.remaining(), new MessageProp(0, true));
                UpPacket message = new UpPacket();
                message.setBuffer((ByteBuffer) ByteBuffer.allocate(token.length).put(token).flip());

                MetadataSupport.setSubject(message, clientSubject);
View Full Code Here

            for (Iterator iter = packet.getBuffers().iterator(); iter.hasNext();) {
                buffer.put((ByteBuffer) iter.next());
            }
            buffer.flip();

            byte[] token = context.wrap(buffer.array(), buffer.position(), buffer.remaining(), new MessageProp(0, true));
            PlainDownPacket reply = new PlainDownPacket();
            reply.setBuffers(Collections.singletonList(ByteBuffer.allocate(token.length).put(token).flip()));
            getDownProtocol().sendDown(reply);
        } catch (GSSException e) {
            throw new ProtocolException(e);
View Full Code Here

                    log.trace("RELEASED " + startupLatch);
                }
            } else {
                ByteBuffer buffer = packet.getBuffer();

                byte[] token = context.unwrap(buffer.array(), buffer.position(), buffer.remaining(), new MessageProp(0, true));
                UpPacket message = new UpPacket();
                message.setBuffer((ByteBuffer) ByteBuffer.allocate(token.length).put(token).flip());
                getUpProtocol().sendUp(message);
            }
        } catch (GSSException e) {
View Full Code Here

            for (Iterator iter = packet.getBuffers().iterator(); iter.hasNext();) {
                buffer.put((ByteBuffer) iter.next());
            }
            buffer.flip();

            byte[] token = context.wrap(buffer.array(), buffer.position(), buffer.remaining(), new MessageProp(0, true));
            PlainDownPacket reply = new PlainDownPacket();
            reply.setBuffers(Collections.singletonList(ByteBuffer.allocate(token.length).put(token).flip()));
            getDownProtocol().sendDown(reply);
        } catch (GSSException e) {
            throw new ProtocolException(e);
View Full Code Here

   
    /**
     * Unwrap a key
     */
    public byte[] unwrapKey(byte[] secret) throws WSSecurityException {
        MessageProp mProp = new MessageProp(0, true);
        try {
            return secContext.unwrap(secret, 0, secret.length, mProp);
        } catch (GSSException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Error in cleaning up a GSS context", e);
View Full Code Here

   
    /**
     * Wrap a key
     */
    public byte[] wrapKey(byte[] secret) throws WSSecurityException {
        MessageProp mProp = new MessageProp(0, true);
        try {
            return secContext.wrap(secret, 0, secret.length, mProp);
        } catch (GSSException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Error in cleaning up a GSS context", e);
View Full Code Here

TOP

Related Classes of org.ietf.jgss.MessageProp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.