<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># --
# Kernel/GenericInterface/Operation/Session/SessionCreate.pm - GenericInterface SessionCreate operation backend
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::GenericInterface::Operation::Session::SessionCreate;

use strict;
use warnings;

use Kernel::GenericInterface::Operation::Common;
use Kernel::GenericInterface::Operation::Session::Common;
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData);

=head1 NAME

Kernel::GenericInterface::Operation::Ticket::SessionCreate - GenericInterface Session Create Operation backend

=head1 SYNOPSIS

=head1 PUBLIC INTERFACE

=over 4

=cut

=item new()

usually, you want to create an instance of this
by using Kernel::GenericInterface::Operation-&gt;new();

=cut

sub new {
    my ( $Type, %Param ) = @_;

    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for my $Needed (
        qw(DebuggerObject ConfigObject MainObject LogObject TimeObject DBObject EncodeObject WebserviceID)
        )
    {
        if ( !$Param{$Needed} ) {
            return {
                Success      =&gt; 0,
                ErrorMessage =&gt; "Got no $Needed!"
            };
        }

        $Self-&gt;{$Needed} = $Param{$Needed};
    }

    # create additional objects
    $Self-&gt;{CommonObject} = Kernel::GenericInterface::Operation::Common-&gt;new( %{$Self} );
    $Self-&gt;{SessionCommonObject}
        = Kernel::GenericInterface::Operation::Session::Common-&gt;new( %{$Self} );

    return $Self;
}

=item Run()

Retrieve a new session id value.

    my $Result = $OperationObject-&gt;Run(
        Data =&gt; {
            UserLogin         =&gt; 'Agent1',
            CustomerUserLogin =&gt; 'Customer1',       # optional, provide UserLogin or CustomerUserLogin
            Password          =&gt; 'some password',   # plain text password
        },
    );

    $Result = {
        Success      =&gt; 1,                                # 0 or 1
        ErrorMessage =&gt; '',                               # In case of an error
        Data         =&gt; {
            SessionID =&gt; $SessionID,
        },
    };

=cut

sub Run {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    if ( !IsHashRefWithData( $Param{Data} ) ) {
        return $Self-&gt;{CommonObject}-&gt;ReturnError(
            ErrorCode    =&gt; 'SessionCreate.MissingParameter',
            ErrorMessage =&gt; "SessionCreate: The request is empty!",
        );
    }

    for my $Needed (qw( Password )) {
        if ( !$Param{Data}-&gt;{$Needed} ) {
            return $Self-&gt;{CommonObject}-&gt;ReturnError(
                ErrorCode    =&gt; 'SessionCreate.MissingParameter',
                ErrorMessage =&gt; "SessionCreate: $Needed parameter is missing!",
            );
        }
    }

    my $SessionID = $Self-&gt;{SessionCommonObject}-&gt;CreateSessionID(
        %Param,
    );

    if ( !$SessionID ) {
        return $Self-&gt;{CommonObject}-&gt;ReturnError(
            ErrorCode    =&gt; 'SessionCreate.AuthFail',
            ErrorMessage =&gt; "SessionCreate: Authorization failing!",
        );
    }

    return {
        Success =&gt; 1,
        Data    =&gt; {
            SessionID =&gt; $SessionID,
        },
    };
}

1;

=back

=head1 TERMS AND CONDITIONS

This software is part of the OTRS project (L&lt;http://otrs.org/&gt;).

This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L&lt;http://www.gnu.org/licenses/agpl.txt&gt;.

=cut
</pre></body></html>