Java Code Examples for sun.security.krb5.EncryptionKey#getBytes()

The following examples show how to use sun.security.krb5.EncryptionKey#getBytes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Krb5Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    return new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
}
 
Example 2
Source File: Krb5Util.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    return new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
}
 
Example 3
Source File: Krb5Util.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    return new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
}
 
Example 4
Source File: Krb5Util.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    return new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
}
 
Example 5
Source File: KeyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 6
Source File: KeyImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream ois)
            throws IOException, ClassNotFoundException {
    try {
        EncryptionKey encKey = new EncryptionKey(new
                                 DerValue((byte[])ois.readObject()));
        keyType = encKey.getEType();
        keyBytes = encKey.getBytes();
    } catch (Asn1Exception ae) {
        throw new IOException(ae.getMessage());
    }
}
 
Example 7
Source File: KeyImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 8
Source File: KeyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 9
Source File: KeyImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 10
Source File: KeyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 11
Source File: Krb5Util.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    KerberosTicket kt = new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
    PrincipalName clientAlias = serviceCreds.getClientAlias();
    PrincipalName serverAlias = serviceCreds.getServerAlias();
    if (clientAlias != null) {
        KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
                .kerberosTicketSetClientAlias(kt, new KerberosPrincipal(
                        clientAlias.getName(), clientAlias.getNameType()));
    }
    if (serverAlias != null) {
        KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
                .kerberosTicketSetServerAlias(kt, new KerberosPrincipal(
                        serverAlias.getName(), serverAlias.getNameType()));
    }
    return kt;
}
 
Example 12
Source File: KeyImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void readObject(ObjectInputStream ois)
            throws IOException, ClassNotFoundException {
    try {
        EncryptionKey encKey = new EncryptionKey(new
                                 DerValue((byte[])ois.readObject()));
        keyType = encKey.getEType();
        keyBytes = encKey.getBytes();
    } catch (Asn1Exception ae) {
        throw new IOException(ae.getMessage());
    }
}
 
Example 13
Source File: KeyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 14
Source File: KeyImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 15
Source File: KeyImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 16
Source File: KeyImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a KeyImpl from a password.
 *
 * @param principal the principal from which to derive the salt
 * @param password the password that should be used to compute the
 * key.
 * @param algorithm the name for the algorithm that this key wil be
 * used for. This parameter may be null in which case "DES" will be
 * assumed.
 */
public KeyImpl(KerberosPrincipal principal,
               char[] password,
               String algorithm) {

    try {
        PrincipalName princ = new PrincipalName(principal.getName());
        EncryptionKey key =
            new EncryptionKey(password, princ.getSalt(), algorithm);
        this.keyBytes = key.getBytes();
        this.keyType = key.getEType();
    } catch (KrbException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
}
 
Example 17
Source File: KeyImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream ois)
            throws IOException, ClassNotFoundException {
    try {
        EncryptionKey encKey = new EncryptionKey(new
                                 DerValue((byte[])ois.readObject()));
        keyType = encKey.getEType();
        keyBytes = encKey.getBytes();
    } catch (Asn1Exception ae) {
        throw new IOException(ae.getMessage());
    }
}
 
Example 18
Source File: KeyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void readObject(ObjectInputStream ois)
            throws IOException, ClassNotFoundException {
    try {
        EncryptionKey encKey = new EncryptionKey(new
                                 DerValue((byte[])ois.readObject()));
        keyType = encKey.getEType();
        keyBytes = encKey.getBytes();
    } catch (Asn1Exception ae) {
        throw new IOException(ae.getMessage());
    }
}
 
Example 19
Source File: Krb5Util.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    KerberosTicket kt = new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
    PrincipalName clientAlias = serviceCreds.getClientAlias();
    PrincipalName serverAlias = serviceCreds.getServerAlias();
    if (clientAlias != null) {
        KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
                .kerberosTicketSetClientAlias(kt, new KerberosPrincipal(
                        clientAlias.getName(), clientAlias.getNameType()));
    }
    if (serverAlias != null) {
        KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
                .kerberosTicketSetServerAlias(kt, new KerberosPrincipal(
                        serverAlias.getName(), serverAlias.getNameType()));
    }
    return kt;
}
 
Example 20
Source File: KeyImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream ois)
            throws IOException, ClassNotFoundException {
    try {
        EncryptionKey encKey = new EncryptionKey(new
                                 DerValue((byte[])ois.readObject()));
        keyType = encKey.getEType();
        keyBytes = encKey.getBytes();
    } catch (Asn1Exception ae) {
        throw new IOException(ae.getMessage());
    }
}