USP_GETCREATE_SSO_URLFORMATSTRING

Get SSO URL formatting string and the shared key by name and site, or create if not exist

Parameters

Parameter Parameter Type Mode Description
@urlFormatString varchar(512) INOUT
@sharedKey varchar(512) INOUT
@sso_name varchar(512) IN
@siteId int IN
@timeoutSecs int IN
@includeIP bit IN

Definition

Copy


CREATE procedure dbo.USP_GETCREATE_SSO_URLFORMATSTRING
  @urlFormatString varchar(512) output,
  @sharedKey varchar(512) output,
    @sso_name varchar(512),
    @siteId int,
    @timeoutSecs int = 86400,
    @includeIP bit = 1
as
begin

        if not exists(select * from dbo.ClientSSO where ClientSiteID = @siteId and Description = @sso_name)
        begin
            -- create a new SSO entry

            set @sharedKey = convert(varchar(512), newid())
            exec dbo.spAddUpdate_ClientSSO @id=null, @Description=@sso_name, @SharedKey=@sharedKey,
            @UserNameParameter='u', @TimeParameter='t', @MD5Parameter='m',
            @ClientSiteID=@siteId, @Delta=@timeoutSecs, @IncludeIP=@includeIP, @RequireSsl=0
        end

        begin try
            exec dbo.USP_GET_KEY_ACCESS;
            select top 1
                @urlFormatString = TimeParameter + '={0}&' + UserNameParameter + '={1}&' + MD5Parameter + '={2}',
                @sharedKey = Convert(nvarchar(512), DECRYPTBYKEY(SharedKey))
            from dbo.ClientSSO
            where ClientSiteID = @siteId and Description = @sso_name;

        close symmetric key sym_BBInfinity;
     end try
     begin catch
     exec dbo.USP_RAISE_ERROR;
         close symmetric key sym_BBInfinity;
     end catch
end