Exemplo n.º 1
0
 // KrbSafe, KrbTgsReq
 public Checksum(int new_cksumType, byte[] data, EncryptionKey key, int usage)
     throws KdcErrException, KrbApErrException, KrbCryptoException {
   cksumType = new_cksumType;
   CksumType cksumEngine = CksumType.getInstance(cksumType);
   if (!cksumEngine.isSafe()) throw new KrbApErrException(Krb5.KRB_AP_ERR_INAPP_CKSUM);
   checksum = cksumEngine.calculateKeyedChecksum(data, data.length, key.getBytes(), usage);
 }
Exemplo n.º 2
0
  static Krb5InitCredential getInstance(Krb5NameElement name, Credentials delegatedCred)
      throws GSSException {

    EncryptionKey sessionKey = delegatedCred.getSessionKey();

    /*
     * all of the following data is optional in a KRB-CRED
     * messages. This check for each field.
     */

    PrincipalName cPrinc = delegatedCred.getClient();
    PrincipalName sPrinc = delegatedCred.getServer();

    KerberosPrincipal client = null;
    KerberosPrincipal server = null;

    Krb5NameElement credName = null;

    if (cPrinc != null) {
      String fullName = cPrinc.getName();
      credName = Krb5NameElement.getInstance(fullName, Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL);
      client = new KerberosPrincipal(fullName);
    }

    // XXX Compare name to credName

    if (sPrinc != null) {
      server = new KerberosPrincipal(sPrinc.getName(), KerberosPrincipal.KRB_NT_SRV_INST);
    }

    return new Krb5InitCredential(
        credName,
        delegatedCred,
        delegatedCred.getEncoded(),
        client,
        server,
        sessionKey.getBytes(),
        sessionKey.getEType(),
        delegatedCred.getFlags(),
        delegatedCred.getAuthTime(),
        delegatedCred.getStartTime(),
        delegatedCred.getEndTime(),
        delegatedCred.getRenewTill(),
        delegatedCred.getClientAddresses());
  }
Exemplo n.º 3
0
 /** Verifies the keyed checksum over the data passed in. */
 public boolean verifyKeyedChecksum(byte[] data, EncryptionKey key, int usage)
     throws KdcErrException, KrbApErrException, KrbCryptoException {
   CksumType cksumEngine = CksumType.getInstance(cksumType);
   if (!cksumEngine.isSafe()) throw new KrbApErrException(Krb5.KRB_AP_ERR_INAPP_CKSUM);
   return cksumEngine.verifyKeyedChecksum(data, data.length, key.getBytes(), checksum, usage);
 }