2023-02-19 09:25:32 +00:00
< ? php
2023-03-01 22:54:30 +00:00
namespace App\Classes\LDAP\Attribute\Schema ;
2023-02-19 09:25:32 +00:00
2023-03-01 22:54:30 +00:00
use App\Classes\LDAP\Attribute\Schema ;
2023-02-19 09:25:32 +00:00
/**
2023-03-02 07:21:53 +00:00
* Represents a Mechanisms Attribute
2023-02-19 09:25:32 +00:00
*/
2023-03-01 22:54:30 +00:00
final class Mechanisms extends Schema
2023-02-19 09:25:32 +00:00
{
public function __toString () : string
{
return $this -> values
-> transform ( function ( $item ) {
2023-03-25 12:33:27 +00:00
$format = sprintf ( '<abbr class="pb-1" title="%s"><i class="fas fa-book pe-2"></i>%s</abbr>%s<p class="mb-0">%s</p>' ,
2023-02-19 09:25:32 +00:00
$item ,
static :: get ( $item , 'title' ),
2023-03-25 12:33:27 +00:00
( $x = static :: get ( $item , 'ref' )) ? sprintf ( '<abbr class="ps-2" title="%s"><i class="fas fa-comment-dots"></i></abbr>' , $x ) : '' ,
2023-02-19 09:25:32 +00:00
static :: get ( $item , 'desc' ),
);
return $format ;
}) -> join ( '<br>' );
}
/**
* Given an SASL Mechanism name , returns a verbose description of the Mechanism .
* This function parses ldap_supported_saslmechanisms . txt and looks up the specified
* Mechanism , and returns the verbose message defined in that file .
*
* < code >
* " SCRAM-SHA-1 " => array : 3 [ ▼
* " title " => " Salted Challenge Response Authentication Mechanism (SCRAM) SHA1 "
* " ref " => " RFC 5802 "
* " desc " => " This specification describes a family of authentication mechanisms called the Salted Challenge Response Authentication Mechanism (SCRAM) which addresses the req ▶ "
* ]
* </ code >
*
* @ param string $string The SASL Mechanism ( ie , " SCRAM-SHA-1 " ) of interest .
* @ param string $key The title | ref | desc to return
* @ return string | NULL
*/
2023-03-01 22:54:30 +00:00
protected static function get ( string $string , string $key ) : ? string
2023-02-19 09:25:32 +00:00
{
2023-03-01 22:54:30 +00:00
return parent :: _get ( config_path ( 'ldap_supported_saslmechanisms.txt' ), $string , $key );
2023-02-19 09:25:32 +00:00
}
}