WSO2 身份服务器 5.1.0 - 从 IdentityProviderMgtService 更新居民 IDP
WSO2 Identity Server 5.1.0 - Updating Resident IDP from IdentityProviderMgtService
我正在使用 IdentityProviderMgtServiceStub.updateResidentIdp()
来更新会话超时。这是我的代码。
IdentityProviderMgtServiceStub stub = new IdentityProviderMgtServiceStub("https://localhost:9443/services/IdentityProviderMgtService");
IdentityProvider idp = stub.getResidentIdP();
IdentityProviderProperty [] properties = idp.getIdpProperties();
for(IdentityProviderProperty property: properties){
if(property.getName().equals(SESSION_IDLE_TIMEOUT) && sessionTimeOut!= 0L) {
property.setValue(String.valueOf(sessionTimeOut));
}else if(property.getName().equals(REMEMBER_ME_TIMEOUT) && rememberMeTimeOut!= 0L){
property.setValue(String.valueOf(rememberMeTimeOut));
}
}
idp.setIdpProperties(properties);
stub.updateResidentIdP(idp);
但是,这会引发异常:
org.wso2.carbon.idp.mgt.IdentityProviderManagementException: Cannot find authenticator : openidconnect
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.getAuthenticatorIdentifier(IdPManagementDAO.java:2571)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateFederatedAuthenticatorConfig(IdPManagementDAO.java:385)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateFederatedAuthenticatorConfigs(IdPManagementDAO.java:348)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateIdP(IdPManagementDAO.java:1716)
at org.wso2.carbon.idp.mgt.dao.CacheBackedIdPMgtDAO.updateIdP(CacheBackedIdPMgtDAO.java:297)
at org.wso2.carbon.idp.mgt.IdentityProviderManager.updateResidentIdP(IdentityProviderManager.java:636)
at org.wso2.carbon.idp.mgt.IdentityProviderManagementService.updateResidentIdP(IdentityProviderManagementService.java:74)
如果我手动调用 idp.setFederatedAuthenticatorConfigs(null);
,这个异常就会消失。但这没有意义,因为我不需要触摸任何我没有更新的区域。我的问题是
(1) 在我的用例中调用 idp.setFederatedAuthenticatorConfigs(null);
安全吗?
(2) 是WSO2的bug吗?
请使用以下代码更新常驻身份提供者。不要直接使用取自 "stub.getResidentIdP()" 的值,因为有一些不需要发送的值。
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setEnable(true);
identityProvider.setPrimary(true);
identityProvider.setIdentityProviderName("LOCAL");
identityProvider.setHomeRealmId("localhost");
IdentityProviderProperty propertySessionIdelTimeout = new IdentityProviderProperty();
propertySessionIdelTimeout.setName(SESSION_IDLE_TIMEOUT);
propertySessionIdelTimeout.setValue(sessionTimeOut);
IdentityProviderProperty propertyRememberMeTimeout = new IdentityProviderProperty();
propertyRememberMeTimeout.setName(REMEMBER_ME_TIMEOUT);
propertyRememberMeTimeout.setValue(rememberMeTimeOut);
IdentityProviderProperty[] idpProperties = new IdentityProviderProperty[2];
idpProperties[0] = propertySessionIdelTimeout;
idpProperties[1] = propertyRememberMeTimeout;
identityProvider.setIdpProperties(idpProperties);
stub.updateResidentIdP(identityProvider);
对于 HomeRealmId,如有必要,您可以从 stub.getResidentIdP()
的结果中检索值
我正在使用 IdentityProviderMgtServiceStub.updateResidentIdp()
来更新会话超时。这是我的代码。
IdentityProviderMgtServiceStub stub = new IdentityProviderMgtServiceStub("https://localhost:9443/services/IdentityProviderMgtService");
IdentityProvider idp = stub.getResidentIdP();
IdentityProviderProperty [] properties = idp.getIdpProperties();
for(IdentityProviderProperty property: properties){
if(property.getName().equals(SESSION_IDLE_TIMEOUT) && sessionTimeOut!= 0L) {
property.setValue(String.valueOf(sessionTimeOut));
}else if(property.getName().equals(REMEMBER_ME_TIMEOUT) && rememberMeTimeOut!= 0L){
property.setValue(String.valueOf(rememberMeTimeOut));
}
}
idp.setIdpProperties(properties);
stub.updateResidentIdP(idp);
但是,这会引发异常:
org.wso2.carbon.idp.mgt.IdentityProviderManagementException: Cannot find authenticator : openidconnect
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.getAuthenticatorIdentifier(IdPManagementDAO.java:2571)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateFederatedAuthenticatorConfig(IdPManagementDAO.java:385)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateFederatedAuthenticatorConfigs(IdPManagementDAO.java:348)
at org.wso2.carbon.idp.mgt.dao.IdPManagementDAO.updateIdP(IdPManagementDAO.java:1716)
at org.wso2.carbon.idp.mgt.dao.CacheBackedIdPMgtDAO.updateIdP(CacheBackedIdPMgtDAO.java:297)
at org.wso2.carbon.idp.mgt.IdentityProviderManager.updateResidentIdP(IdentityProviderManager.java:636)
at org.wso2.carbon.idp.mgt.IdentityProviderManagementService.updateResidentIdP(IdentityProviderManagementService.java:74)
如果我手动调用 idp.setFederatedAuthenticatorConfigs(null);
,这个异常就会消失。但这没有意义,因为我不需要触摸任何我没有更新的区域。我的问题是
(1) 在我的用例中调用 idp.setFederatedAuthenticatorConfigs(null);
安全吗?
(2) 是WSO2的bug吗?
请使用以下代码更新常驻身份提供者。不要直接使用取自 "stub.getResidentIdP()" 的值,因为有一些不需要发送的值。
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setEnable(true);
identityProvider.setPrimary(true);
identityProvider.setIdentityProviderName("LOCAL");
identityProvider.setHomeRealmId("localhost");
IdentityProviderProperty propertySessionIdelTimeout = new IdentityProviderProperty();
propertySessionIdelTimeout.setName(SESSION_IDLE_TIMEOUT);
propertySessionIdelTimeout.setValue(sessionTimeOut);
IdentityProviderProperty propertyRememberMeTimeout = new IdentityProviderProperty();
propertyRememberMeTimeout.setName(REMEMBER_ME_TIMEOUT);
propertyRememberMeTimeout.setValue(rememberMeTimeOut);
IdentityProviderProperty[] idpProperties = new IdentityProviderProperty[2];
idpProperties[0] = propertySessionIdelTimeout;
idpProperties[1] = propertyRememberMeTimeout;
identityProvider.setIdpProperties(idpProperties);
stub.updateResidentIdP(identityProvider);
对于 HomeRealmId,如有必要,您可以从 stub.getResidentIdP()
的结果中检索值