{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.EMR.Types.KerberosAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EMR.Types.KerberosAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Attributes for Kerberos configuration when Kerberos authentication is
-- enabled using a security configuration. For more information see
-- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-kerberos.html Use Kerberos Authentication>
-- in the /Amazon EMR Management Guide/.
--
-- /See:/ 'newKerberosAttributes' smart constructor.
data KerberosAttributes = KerberosAttributes'
  { -- | The Active Directory password for @ADDomainJoinUser@.
    KerberosAttributes -> Maybe Text
aDDomainJoinPassword :: Prelude.Maybe Prelude.Text,
    -- | Required only when establishing a cross-realm trust with an Active
    -- Directory domain. A user with sufficient privileges to join resources to
    -- the domain.
    KerberosAttributes -> Maybe Text
aDDomainJoinUser :: Prelude.Maybe Prelude.Text,
    -- | Required only when establishing a cross-realm trust with a KDC in a
    -- different realm. The cross-realm principal password, which must be
    -- identical across realms.
    KerberosAttributes -> Maybe Text
crossRealmTrustPrincipalPassword :: Prelude.Maybe Prelude.Text,
    -- | The password used within the cluster for the kadmin service on the
    -- cluster-dedicated KDC, which maintains Kerberos principals, password
    -- policies, and keytabs for the cluster.
    KerberosAttributes -> Maybe Text
kdcAdminPassword :: Prelude.Maybe Prelude.Text,
    -- | The name of the Kerberos realm to which all nodes in a cluster belong.
    -- For example, @EC2.INTERNAL@.
    KerberosAttributes -> Maybe Text
realm :: Prelude.Maybe Prelude.Text
  }
  deriving (KerberosAttributes -> KerberosAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KerberosAttributes -> KerberosAttributes -> Bool
$c/= :: KerberosAttributes -> KerberosAttributes -> Bool
== :: KerberosAttributes -> KerberosAttributes -> Bool
$c== :: KerberosAttributes -> KerberosAttributes -> Bool
Prelude.Eq, ReadPrec [KerberosAttributes]
ReadPrec KerberosAttributes
Int -> ReadS KerberosAttributes
ReadS [KerberosAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KerberosAttributes]
$creadListPrec :: ReadPrec [KerberosAttributes]
readPrec :: ReadPrec KerberosAttributes
$creadPrec :: ReadPrec KerberosAttributes
readList :: ReadS [KerberosAttributes]
$creadList :: ReadS [KerberosAttributes]
readsPrec :: Int -> ReadS KerberosAttributes
$creadsPrec :: Int -> ReadS KerberosAttributes
Prelude.Read, Int -> KerberosAttributes -> ShowS
[KerberosAttributes] -> ShowS
KerberosAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KerberosAttributes] -> ShowS
$cshowList :: [KerberosAttributes] -> ShowS
show :: KerberosAttributes -> String
$cshow :: KerberosAttributes -> String
showsPrec :: Int -> KerberosAttributes -> ShowS
$cshowsPrec :: Int -> KerberosAttributes -> ShowS
Prelude.Show, forall x. Rep KerberosAttributes x -> KerberosAttributes
forall x. KerberosAttributes -> Rep KerberosAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KerberosAttributes x -> KerberosAttributes
$cfrom :: forall x. KerberosAttributes -> Rep KerberosAttributes x
Prelude.Generic)

-- |
-- Create a value of 'KerberosAttributes' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'aDDomainJoinPassword', 'kerberosAttributes_aDDomainJoinPassword' - The Active Directory password for @ADDomainJoinUser@.
--
-- 'aDDomainJoinUser', 'kerberosAttributes_aDDomainJoinUser' - Required only when establishing a cross-realm trust with an Active
-- Directory domain. A user with sufficient privileges to join resources to
-- the domain.
--
-- 'crossRealmTrustPrincipalPassword', 'kerberosAttributes_crossRealmTrustPrincipalPassword' - Required only when establishing a cross-realm trust with a KDC in a
-- different realm. The cross-realm principal password, which must be
-- identical across realms.
--
-- 'kdcAdminPassword', 'kerberosAttributes_kdcAdminPassword' - The password used within the cluster for the kadmin service on the
-- cluster-dedicated KDC, which maintains Kerberos principals, password
-- policies, and keytabs for the cluster.
--
-- 'realm', 'kerberosAttributes_realm' - The name of the Kerberos realm to which all nodes in a cluster belong.
-- For example, @EC2.INTERNAL@.
newKerberosAttributes ::
  KerberosAttributes
newKerberosAttributes :: KerberosAttributes
newKerberosAttributes =
  KerberosAttributes'
    { $sel:aDDomainJoinPassword:KerberosAttributes' :: Maybe Text
aDDomainJoinPassword =
        forall a. Maybe a
Prelude.Nothing,
      $sel:aDDomainJoinUser:KerberosAttributes' :: Maybe Text
aDDomainJoinUser = forall a. Maybe a
Prelude.Nothing,
      $sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: Maybe Text
crossRealmTrustPrincipalPassword = forall a. Maybe a
Prelude.Nothing,
      $sel:kdcAdminPassword:KerberosAttributes' :: Maybe Text
kdcAdminPassword = forall a. Maybe a
Prelude.Nothing,
      $sel:realm:KerberosAttributes' :: Maybe Text
realm = forall a. Maybe a
Prelude.Nothing
    }

-- | The Active Directory password for @ADDomainJoinUser@.
kerberosAttributes_aDDomainJoinPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_aDDomainJoinPassword :: Lens' KerberosAttributes (Maybe Text)
kerberosAttributes_aDDomainJoinPassword = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
aDDomainJoinPassword :: Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
aDDomainJoinPassword} -> Maybe Text
aDDomainJoinPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:aDDomainJoinPassword:KerberosAttributes' :: Maybe Text
aDDomainJoinPassword = Maybe Text
a} :: KerberosAttributes)

-- | Required only when establishing a cross-realm trust with an Active
-- Directory domain. A user with sufficient privileges to join resources to
-- the domain.
kerberosAttributes_aDDomainJoinUser :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_aDDomainJoinUser :: Lens' KerberosAttributes (Maybe Text)
kerberosAttributes_aDDomainJoinUser = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
aDDomainJoinUser :: Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
aDDomainJoinUser} -> Maybe Text
aDDomainJoinUser) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:aDDomainJoinUser:KerberosAttributes' :: Maybe Text
aDDomainJoinUser = Maybe Text
a} :: KerberosAttributes)

-- | Required only when establishing a cross-realm trust with a KDC in a
-- different realm. The cross-realm principal password, which must be
-- identical across realms.
kerberosAttributes_crossRealmTrustPrincipalPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_crossRealmTrustPrincipalPassword :: Lens' KerberosAttributes (Maybe Text)
kerberosAttributes_crossRealmTrustPrincipalPassword = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
crossRealmTrustPrincipalPassword} -> Maybe Text
crossRealmTrustPrincipalPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: Maybe Text
crossRealmTrustPrincipalPassword = Maybe Text
a} :: KerberosAttributes)

-- | The password used within the cluster for the kadmin service on the
-- cluster-dedicated KDC, which maintains Kerberos principals, password
-- policies, and keytabs for the cluster.
kerberosAttributes_kdcAdminPassword :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_kdcAdminPassword :: Lens' KerberosAttributes (Maybe Text)
kerberosAttributes_kdcAdminPassword = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
kdcAdminPassword :: Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
kdcAdminPassword} -> Maybe Text
kdcAdminPassword) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:kdcAdminPassword:KerberosAttributes' :: Maybe Text
kdcAdminPassword = Maybe Text
a} :: KerberosAttributes)

-- | The name of the Kerberos realm to which all nodes in a cluster belong.
-- For example, @EC2.INTERNAL@.
kerberosAttributes_realm :: Lens.Lens' KerberosAttributes (Prelude.Maybe Prelude.Text)
kerberosAttributes_realm :: Lens' KerberosAttributes (Maybe Text)
kerberosAttributes_realm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KerberosAttributes' {Maybe Text
realm :: Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
realm} -> Maybe Text
realm) (\s :: KerberosAttributes
s@KerberosAttributes' {} Maybe Text
a -> KerberosAttributes
s {$sel:realm:KerberosAttributes' :: Maybe Text
realm = Maybe Text
a} :: KerberosAttributes)

instance Data.FromJSON KerberosAttributes where
  parseJSON :: Value -> Parser KerberosAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"KerberosAttributes"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> KerberosAttributes
KerberosAttributes'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ADDomainJoinPassword")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ADDomainJoinUser")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CrossRealmTrustPrincipalPassword")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"KdcAdminPassword")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Realm")
      )

instance Prelude.Hashable KerberosAttributes where
  hashWithSalt :: Int -> KerberosAttributes -> Int
hashWithSalt Int
_salt KerberosAttributes' {Maybe Text
realm :: Maybe Text
kdcAdminPassword :: Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
aDDomainJoinUser :: Maybe Text
aDDomainJoinPassword :: Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aDDomainJoinPassword
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aDDomainJoinUser
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
crossRealmTrustPrincipalPassword
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kdcAdminPassword
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
realm

instance Prelude.NFData KerberosAttributes where
  rnf :: KerberosAttributes -> ()
rnf KerberosAttributes' {Maybe Text
realm :: Maybe Text
kdcAdminPassword :: Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
aDDomainJoinUser :: Maybe Text
aDDomainJoinPassword :: Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aDDomainJoinPassword
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aDDomainJoinUser
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
crossRealmTrustPrincipalPassword
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kdcAdminPassword
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
realm

instance Data.ToJSON KerberosAttributes where
  toJSON :: KerberosAttributes -> Value
toJSON KerberosAttributes' {Maybe Text
realm :: Maybe Text
kdcAdminPassword :: Maybe Text
crossRealmTrustPrincipalPassword :: Maybe Text
aDDomainJoinUser :: Maybe Text
aDDomainJoinPassword :: Maybe Text
$sel:realm:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:kdcAdminPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:crossRealmTrustPrincipalPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinUser:KerberosAttributes' :: KerberosAttributes -> Maybe Text
$sel:aDDomainJoinPassword:KerberosAttributes' :: KerberosAttributes -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ADDomainJoinPassword" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
aDDomainJoinPassword,
            (Key
"ADDomainJoinUser" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
aDDomainJoinUser,
            (Key
"CrossRealmTrustPrincipalPassword" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
crossRealmTrustPrincipalPassword,
            (Key
"KdcAdminPassword" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
kdcAdminPassword,
            (Key
"Realm" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
realm
          ]
      )