Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wso2is 5.9 CustomUserStoremanager的配置问题_Wso2_Wso2is - Fatal编程技术网

wso2is 5.9 CustomUserStoremanager的配置问题

wso2is 5.9 CustomUserStoremanager的配置问题,wso2,wso2is,Wso2,Wso2is,我正在尝试获取CustomUserStoreManager, 在这里,我在下面添加了CustomStoreUserManager的代码 将test_come.xml放在userstore文件夹中,并将jar文件、mysql驱动程序和jascypt jar添加到lib文件夹中。重新启动服务器后,我无法在“添加用户商店管理器”列表的下拉列表中看到这一点 <code> <?xml version="1.0" encoding="UTF-8"?> <User

我正在尝试获取CustomUserStoreManager, 在这里,我在下面添加了CustomStoreUserManager的代码 将test_come.xml放在userstore文件夹中,并将jar文件、mysql驱动程序和jascypt jar添加到lib文件夹中。重新启动服务器后,我无法在“添加用户商店管理器”列表的下拉列表中看到这一点

<code>
    <?xml version="1.0" encoding="UTF-8"?>
    <UserStoreManager class="com.wso2.custom.usermgt.CustomUserStoreManager">
    <Property name="url">jdbc:mysql://localhost:3306/wso2</Property>
    <Property name="userName">root</Property>
    <Property encrypted="false" name="password">subhash123</Property>
    <Property name="driverName">com.mysql.jdbc.Driver</Property>
    <Property name="ReadGroups">true</Property>
    <Property name="WriteGroups">false</Property>
    <Property name="UsernameJavaRegEx">^[\S]{3,30}$</Property>
    <Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
    <Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
    <Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
    <Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
    <Property name="PasswordJavaRegExViolationErrorMsg">
     Password length should be within 5 to 30 characters</Property>
    <Property name="RolenameJavaRegEx">^[\S]{3,30}$</Property>
    <Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
    <Property name="CaseInsensitiveUsername">true</Property>
    <Property name="SCIMEnabled">false</Property>
    <Property name="IsBulkImportSupported">false</Property>
    <Property name="PasswordDigest">PLAIN_TEXT</Property>
    <Property name="StoreSaltedPassword">false</Property>
    <Property name="MultiAttributeSeparator">,</Property>
    <Property name="MaxUserNameListLength">100</Property>
    <Property name="MaxRoleNameListLength">100</Property>
    <Property name="UserRolesCacheEnabled">true</Property>
    <Property name="UserNameUniqueAcrossTenants">false</Property>
    <Property name="maxActive">50</Property>
    <Property name="maxWait">60000</Property>
    <Property name="minIdle">5</Property>
    <Property name="CountRetrieverClass">
    org.wso2.carbon.identity.user.store.count.jdbc.JDBCUserStoreCountRetriever
    </Property>
    <Property name="SelectUserSQL">SELECT * FROM CUSTOMER_DATA WHERE CUSTOMER_NAME=?</Property>
    <Property name="DomainName">test.com</Property>
    <Property name="Description"/>
    </UserStoreManager>

<code>

<code>

    public class CustomUserStoreManager extends JDBCUserStoreManager {
    private static Log log = LogFactory.getLog(CustomUserStoreManager.class);
    // This instance is used to generate the hash values
    private static StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
    // You must implement at least one constructor
    public CustomUserStoreManager(RealmConfiguration realmConfig, Map<String, Object> properties, 
    ClaimManager
    claimManager, ProfileConfigurationManager profileManager, UserRealm realm, Integer tenantId)
    throws UserStoreException {
    super(realmConfig, properties, claimManager, profileManager, realm, tenantId);
    log.info("CustomUserStoreManager initialized...");
    }
    @Override
    public boolean doAuthenticate(String userName, Object credential) throws UserStoreException {
    boolean isAuthenticated = false;
    if (userName != null && credential != null) {
    try {
    String candidatePassword = String.copyValueOf(((Secret) credential).getChars());
    Connection dbConnection = null;
    ResultSet rs = null;
    PreparedStatement prepStmt = null;
    String sql = null;
    dbConnection = this.getDBConnection();
    dbConnection.setAutoCommit(false);
    // get the SQL statement used to select user details
    sql = this.realmConfig.getUserStoreProperty("SelectUserSQL");
    System.out.println("SQL IS -->"+sql);
    if (log.isDebugEnabled()) {
    log.debug(sql);
    }

    prepStmt = dbConnection.prepareStatement(sql);
    prepStmt.setString(1, userName);
    // check whether tenant id is used
    rs = prepStmt.executeQuery();
    if (rs.next()) {
    String storedPassword = rs.getString(3);
    System.out.println("PASSWORD IS -->"+storedPassword);
    System.out.println("candidatePassword IS -->"+candidatePassword);
    // check whether password is expired or not
    if(storedPassword.equalsIgnoreCase(candidatePassword))
    isAuthenticated = true;
    }
    dbConnection.commit();
    log.info(userName + " is authenticated? " + isAuthenticated);
    } catch (SQLException exp) { 
    log.error("Error occurred while retrieving user authentication info.", exp);
    throw new UserStoreException("Authentication Failure");
    }
    }
    return isAuthenticated;
    }

    @Override
    protected String preparePassword(Object password, String saltValue) throws UserStoreException {
    if (password != null) {
    String candidatePassword = String.copyValueOf(((Secret) password).getChars());
    // ignore saltValue for the time being
    log.info("Generating hash value using jasypt...");
    return passwordEncryptor.encryptPassword(String.copyValueOf(((Secret) password).getChars()));
    } else {
    log.error("Password cannot be null");
    throw new UserStoreException("Authentication Failure");
    }
    }
    @Override
    public Date getPasswordExpirationTime(String userName) throws UserStoreException {
    return new Date();
    }
    }

<code>
<code>

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema- 
    instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.wso2.sample</groupId>
    <artifactId>CustomReadOnlyJDBCUserStoreManager</artifactId>
    <version>1.0.0</version>
    <repositories>
    <repository>
    <id>wso2-nexus</id>
    <name>WSO2 internal Repository</name>
    <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    <releases>
    <enabled>true</enabled>
    <updatePolicy>daily</updatePolicy>
    <checksumPolicy>ignore</checksumPolicy>
    </releases>
    </repository>
    </repositories>
    <dependencies>
    <dependency>
    <groupId>org.wso2.carbon</groupId>
    <artifactId>org.wso2.carbon.user.core</artifactId>
    <version>4.4.11</version>
    </dependency>
    <dependency>
    <groupId>org.wso2.carbon</groupId>
    <artifactId>org.wso2.carbon.utils</artifactId>
    <version>4.4.11</version>
    </dependency>
    <dependency>
    <groupId>org.wso2.carbon</groupId>
    <artifactId>org.wso2.carbon.user.api</artifactId>
    <version>4.4.11</version>
    </dependency>
    <dependency>
    <groupId>org.jasypt</groupId>
    <artifactId>jasypt</artifactId>
    <version>1.9.2</version>
    </dependency>
    </dependencies>

     <build>
    <plugins>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.1</version>
    <inherited>true</inherited>
    <configuration>
    <encoding>UTF-8</encoding>
    <source>1.7</source>
    <target>1.7</target>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-scr-plugin</artifactId>
    <version>1.7.2</version>
    <executions>
    <execution>
    <id>generate-scr-scrdescriptor</id>
    <goals>
    <goal>scr</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.5</version>
    <extensions>true</extensions>
    <configuration>
    <instructions>
    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
    <Bundle-Name>${project.artifactId}</Bundle-Name>
    <Private-Package>
    org.wso2.sample.user.store.manager.internal
    </Private-Package>
    <Export-Package>
    !org.wso2.sample.user.store.manager.internal,
    org.wso2.sample.user.store.manager.*,
    </Export-Package>
    <Import-Package>
    org.wso2.carbon.*,
    org.apache.commons.logging.*,
    org.osgi.framework.*,
    org.osgi.service.component.*
    </Import-Package>
    </instructions>
    </configuration>
    </plugin>
    </plugins>
    </build>
    </project>
<code>

您需要将其作为osgi服务。在pom文件中,您还必须将
元素添加为bundle,因为它是一个osgi服务。您可以在此处找到示例源代码:

您可能需要根据发布矩阵验证组件的相关依赖版本:

请遵循此示例代码了解如何将此CustomUserStoreManager注册为osgi服务


请阅读此博客以进一步了解osgi服务:

carbon控制台中是否有任何错误日志?你能把它们和问题一起添加吗?我能看到你代码中的几个问题。请使用作为样板并在代码上实现你的登录。我做了所有的工作,我编写了一个customstoreusermanager,扩展了JDBCUserStoreManager,而不是示例中的ActiveDirectoryUserStoreManager,我可以在下拉列表中看到CustomUserStoreManager,甚至修改了SelctUserSql,可以在用户列表中看到用户,并创建了一个内部角色,提供了所有权限,并为创建的角色分配了用户,之后我进行了搜索,尝试以TRELLCUS/dinuka/dinuka的身份登录,但失败了,控制台中的错误为error org.wso2.carbon.core.services.authentication.AuthenticationAdmin}-身份验证/授权用户时出现系统错误:处理事件时出错:PRE_authentication我在CustomUSerStoreManager中放置了许多Logger/sysout,但我发现它们根本没有打印,,,:(您可以使用log.info)(“一些日志。”)并打印信息日志。或者,您可以添加调试日志并启用调试日志。您可以按照以下文档操作。但是,当我与custum用户一起登录时,我看不到正在调用我的CustomUserstoreManager,,,,doAuthenticate方法调用没有发生根据日志,它显示“wso2.um\u角色表不存在。因此请检查您的userstore,该表是否存在