Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.eyrie.remctl.core;
Represents an encrypted remctl message token. This is the parent class for all remctl tokens except for the initial session establishment tokens. It holds the GSS-API context that should be used to encrypt and decrypt the token and supports a factory method to decrypt a token and then create the appropriate message token type.

We can't force a constructor signature on subclasses. I think we are looking for an AbstractFacotry for 'forcing' a standard way to build things, but for now we will just implement the constructor on all subclasses.

 public abstract class RemctlMessageToken implements RemctlToken {

Protocol version of token.
     private final byte version;

Construct a message token with the given version. This constructor should be used by child classes to initialize those fields in the token.

version The protocol version required to understand this token
RemctlException If version is out of range. The version is not checked against RemctlToken.SUPPORTED_VERSION.
     RemctlMessageToken(final int version) {
         if (version < 2 || version > 127) {
             throw new RemctlProtocolException("Invalid protocol version " + version);
         this. = (byteversion;

Encrypt the token and write it to the provided stream.

The byte[] of the encrypted token
Throws: An error occurred writing the token to the stream
org.ietf.jgss.GSSException On errors encrypting the token
     public byte[] write() throws GSSExceptionIOException {
         int length = this.length() + 2;
         ByteArrayOutputStream array = new ByteArrayOutputStream(length);
         DataOutputStream encode = new DataOutputStream(array);
         try {
             return array.toByteArray();
         } catch (IOException e) {
             // It should be impossible for writes to a ByteArrayOutputStream
             // to fail, so turn them into runtime exceptions.
             throw new RuntimeException(e);

Returns the length of the encoded token. This method is designed to be overridden by child classes of RemctlMessageToken so that the output buffer required for a token can be sized. The fields included in every token are not part of the length.

The encoded length of the token
     abstract int length();

Writes the type-specific data to DataOutputStream. This method is designed to be overridden by child classes of RemctlMessageToken so that child classes don't have to implement the rest of #write(OutputStream ).

stream Output stream to which to write the token data
Throws: On error writing to the stream
     abstract void writeData(DataOutputStream streamthrows IOException;

FIXME Do we use this? We check version in a few places. Maybe once the server is implemented

the version
     private byte getVersion() {
         return this.;


the type
    abstract RemctlMessageCode getType();

Prints the token type and version.
    public String toString() {
        return "RemctlToken: " + this.getType() + " version " + this.getVersion();
New to GrepCode? Check out our FAQ X