> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/seminar/java/authservice.md).

# Auth Service

### 1、查询研讨会参会条件

#### 描述

```
查询研讨会参会条件
接口地址（仅做说明使用）：https://api.polyv.net/live/v3/channel/seminar/setting/auth/get
```

#### 调用约束

1、接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/seminar/java/limit.md)，调用常见异常，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/seminar/java/exceptionDoc/README.md)

#### 单元测试

```java
	@Test
	public void testGetAuthSetting() throws IOException, NoSuchAlgorithmException {
        SeminarGetAuthSettingRequest seminarGetAuthSettingRequest = new SeminarGetAuthSettingRequest();
        List<SeminarGetAuthSettingResponse> seminarGetAuthSettingResponse;
        try {
            String channelId = super.getChannelId();
            seminarGetAuthSettingRequest.setChannelId(channelId);
            seminarGetAuthSettingResponse = new SeminarAuthServiceImpl().getAuthSetting(seminarGetAuthSettingRequest);
            Assert.assertNotNull(seminarGetAuthSettingResponse);
            if (seminarGetAuthSettingResponse != null) {
                //to do something ......
                log.debug("测试查询研讨会参会条件成功 {}", JSON.toJSONString(seminarGetAuthSettingResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误，错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑，记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
```

#### 单元测试说明

1、请求正确，返回SeminarGetAuthSettingResponse对象，B端依据此对象处理业务逻辑；

2、请求参数校验不合格，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 输入参数 \[xxx.chat.LivexxxRequest]对象校验失败，失败字段 \[pic不能为空 / msg不能为空] ]

3、服务器处理异常，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 保利威请求返回数据错误，请求流水号：66e7ad29fd04425a84c2b2b562d2025b，错误原因： invalid signature. ]

#### 请求入参描述

| 参数名       | 必选   | 类型     | 说明  |
| --------- | ---- | ------ | --- |
| channelId | true | String | 频道号 |

#### 返回对象描述

返回对象是List\<SeminarGetAuthSettingResponse>，**SeminarGetAuthSettingResponse**具体元素内容如下：

| 参数名       | 类型      | 说明                                   |
| --------- | ------- | ------------------------------------ |
| channelId | String  | 频道号                                  |
| userId    | String  | 用户ID                                 |
| rank      | Integer | 用于实现一个频道设置两个参会条件，为1或2（1为主要条件，2为次要条件） |
| enabled   | String  | 是否开启参会条件 N：关闭 Y：开启                   |
| authType  | String  | 参会条件类型 password：密码登录 direct：独立授权     |
| roleCode  | String  | 角色 host：主持人 attendee：参会人             |
| password  | String  | 密码登录的password                        |
| directKey | String  | 独立授权key                              |
| roleName  | String  | 角色名称                                 |
| customKey | String  | 自定义授权观看的key                          |
| customUri | String  | 自定义授权观看的接口地址                         |

\ <br>

***

\ <br>

### 2、修改研讨会参会条件

#### 描述

```
修改研讨会的登录条件
接口地址（仅做说明使用）：https://api.polyv.net/live/v3/channel/seminar/setting/auth/set
```

#### 调用约束

1、接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/seminar/java/limit.md)，调用常见异常，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/seminar/java/exceptionDoc/README.md)

2、主要参会条件不能关闭，否则返回参数错误

3、相同参会条件（主要参会条件/次要参会条件），不同角色的开关、认证类型必须相同，否则返回参数错误

4、相同参会条件（主要参会条件/次要参会条件），不同角色的密码/独立授权key必须不同，否则返回参数错误

5、当认证类型是密码登录时，密码不能为空；当认证类型是独立授权时，授权key不能为空，否则返回参数错误

6、主要参会条件和次要参会条件的类型为相同时，不能够同时打开，否则返回参数错误

#### 单元测试

```java
	@Test
	public void testSetAuthSetting() throws IOException, NoSuchAlgorithmException {
        SeminarSetAuthSettingRequest seminarSetAuthSettingRequest = new SeminarSetAuthSettingRequest();
        Boolean seminarSetAuthSettingResponse;
        try {
            String channelId = super.getChannelId();
            SeminarSetAuthSettingRequest.AuthSetting authSetting1 = new SeminarSetAuthSettingRequest.AuthSetting();
            SeminarSetAuthSettingRequest.AuthSetting authSetting2 = new SeminarSetAuthSettingRequest.AuthSetting();
            authSetting1.setRank(1)
                    .setEnabled(SeminarConstant.Flag.YES.getFlag())
                    .setAuthType(SeminarConstant.SeminarAuthType.PASSWORD.getCode())
                    .setRoleCode(SeminarConstant.RoleCode.ATTENDEE.getCode())
                    .setPassword(getRandomString(6));
            authSetting2.setRank(1)
                    .setEnabled(SeminarConstant.Flag.YES.getFlag())
                    .setAuthType(SeminarConstant.SeminarAuthType.PASSWORD.getCode())
                    .setRoleCode(SeminarConstant.RoleCode.HOST.getCode())
                    .setPassword(getRandomString(6));
            seminarSetAuthSettingRequest.setChannelId(channelId)
                    .setAuthSettings(Arrays.asList(authSetting1, authSetting2));
            seminarSetAuthSettingResponse = new SeminarAuthServiceImpl().setAuthSetting(seminarSetAuthSettingRequest);
            Assert.assertTrue(seminarSetAuthSettingResponse);
            if (seminarSetAuthSettingResponse) {
                //to do something ......
                log.debug("测试修改研讨会参会条件成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误，错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑，记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
}
```

#### 单元测试说明

1、请求正确，返回Boolean对象，B端依据此对象处理业务逻辑；

2、请求参数校验不合格，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 输入参数 \[xxx.chat.LivexxxRequest]对象校验失败，失败字段 \[pic不能为空 / msg不能为空] ]

3、服务器处理异常，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 保利威请求返回数据错误，请求流水号：66e7ad29fd04425a84c2b2b562d2025b，错误原因： invalid signature. ]

#### 请求入参描述

| 参数名          | 必选    | 类型     | 说明                                                                                                                                  |
| ------------ | ----- | ------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| channelId    | false | String | 频道号，不传为全局设置                                                                                                                         |
| authSettings | true  | Array  | 观看条件设置 【详见[AuthSetting参数描述](https://git.polyv.net/help-center/document-center/-/blob/master/seminar/java/authService.md?id=polyv0)】 |

[**AuthSetting参数描述**](#/authService.md?id=polyv0)

| 参数名       | 必选    | 类型      | 说明                                       |
| --------- | ----- | ------- | ---------------------------------------- |
| rank      | true  | Integer | 主要观看条件为1，次要观看条件为2                        |
| enabled   | true  | String  | 是否开启条件观看 N：关闭 Y：开启                       |
| roleCode  | true  | String  | 角色 host：主持人 attendee：参会人                 |
| authType  | false | String  | 参会条件类型 password：密码登录 direct：独立授权         |
| password  | false | String  | 当authType为password时，密码登录的password        |
| directKey | false | String  | 当authType为direct时，设置参数，非必填，独立授权SecretKey |
| customUri | false | String  | 当authType为custom时，为自定义授权自定义URL           |
| customKey | false | String  | 当authType为custom时，为自定义授权SecretKey        |

#### 返回对象描述

修改研讨会参会条件返回实体<br>
