Examples of BerConstructed


Examples of ca.carleton.gcrc.security.ber.BerConstructed

     
      if( false == outerObj.isTypeConstructed()
       || false == (outerObj instanceof BerConstructed) ){
        throw new Exception("Object is not constructed.");
      }
      BerConstructed outer = (BerConstructed)outerObj;

      if( Token.APPLICATION_TYPE_CREATION == outer.getType() ){
        return CreationToken.decode(outer);
      } else {
        throw new Exception("Unrecognized type: "+outer.getType());
      }
     
    } catch(Exception e) {
      throw new Exception("Error while deccoding token", e);
    }
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

    BerTag tag = BerTagEncoder.decodeTag(is);
    int length = BerLengthEncoder.decodeLength(is);
   
    BerObject result = null;
    if( tag.isConstructed() ) {
      BerConstructed constructed = impl.createConstructed(tag.getTypeClass(), tag.getType());
      result = constructed;
     
      is.pushLimit(length);
     
      while(is.getCurrentLimit() > 0) {
        BerObject child = decode(is);
        constructed.add(child);
      }
     
      is.popLimit();
    } else {
      // Primitive
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

      throw new Exception("Error during encryption of token", e);
    }
   
    // Encode
    BerFactory factory = new BerImplementation();
    BerConstructed outer = factory.createConstructed(
        BerObject.TypeClass.APPLICATION
        ,Token.APPLICATION_TYPE_ENCRYPTED
        );
   
    // Context
    BerBytes berContext = factory.createOctetString();
    berContext.setValue(context);
    outer.add(berContext);
   
    // Encrypted Token
    BerBytes berEncrypted = factory.createOctetString();
    berEncrypted.setValue(encrypted);
    outer.add(berEncrypted);
   
    byte[] result = BerEncoder.encode(outer);
    return result;
  }
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

        throw new Exception("Object is not constructed.");
      }
      if( Token.APPLICATION_TYPE_ENCRYPTED != outerObj.getType() ){
        throw new Exception("Unexpected type.");
      }
      BerConstructed outer = (BerConstructed)outerObj;
     
      // Check that we have enough members
      if( outer.size() < 2 ){
        throw new Exception("Not enough components.");
      }
     
      // Get context
      BerObject contextObj = outer.get(0);
      if( false == (contextObj instanceof BerBytes) ){
        throw new Exception("Invalid context.");
      }
      byte[] context = ((BerBytes)contextObj).getValue();
     
      // Get encrypted payload
      BerObject encryptedObj = outer.get(1);
      if( false == (encryptedObj instanceof BerBytes) ){
        throw new Exception("Invalid encrypted payload.");
      }
      byte[] encryptedPayload = ((BerBytes)encryptedObj).getValue();
     
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

 
  @Override
  public byte[] encode() throws Exception {
    BerFactory factory = new BerImplementation();
   
    BerConstructed outer = factory.createConstructed(
      BerObject.TypeClass.APPLICATION
      ,Token.APPLICATION_TYPE_PASSWORD_RECOVERY
      );
   
    BerString email = factory.createUTF8String();
    email.setValue(emailAddress);
    outer.add(email);
   
    long expiryMs = expiry.getTime();
    Long expiryLong = new Long(expiryMs);
    BerInteger date = factory.createInteger();
    date.setValue( expiryLong );
    outer.add(date);

    BerString berVersion = factory.createUTF8String();
    berVersion.setValue(version);
    outer.add(berVersion);
   
    byte[] result = BerEncoder.encode(outer);
    return result;
  }
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

 
  @Override
  public byte[] encode() throws Exception {
    BerFactory factory = new BerImplementation();
   
    BerConstructed outer = factory.createConstructed(
      BerObject.TypeClass.APPLICATION
      ,Token.APPLICATION_TYPE_CREATION
      );
   
    BerString email = factory.createUTF8String();
    email.setValue(emailAddress);
    outer.add(email);
   
    long expiryMs = expiry.getTime();
    Long expiryLong = new Long(expiryMs);
    BerInteger date = factory.createInteger();
    date.setValue( expiryLong );
    outer.add(date);
   
    byte[] result = BerEncoder.encode(outer);
    return result;
  }
View Full Code Here

Examples of ca.carleton.gcrc.security.ber.BerConstructed

     
      if( false == outerObj.isTypeConstructed()
       || false == (outerObj instanceof BerConstructed) ){
        throw new Exception("Object is not constructed.");
      }
      BerConstructed outer = (BerConstructed)outerObj;

      if( Token.APPLICATION_TYPE_CREATION == outer.getType() ){
        return CreationToken.decode(outer);
       
      } else if( Token.APPLICATION_TYPE_PASSWORD_RECOVERY == outer.getType() ){
          return PasswordRecoveryToken.decode(outer);
         
      } else {
        throw new Exception("Unrecognized type: "+outer.getType());
      }
     
    } catch(Exception e) {
      throw new Exception("Error while deccoding token", e);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.