⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsasuserstorereader.java

📁 开源的OpenId的一个java实现
💻 JAVA
字号:
/*                                                                              * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org *                                                                              * Licensed under the Apache License, Version 2.0 (the "License");              * you may not use this file except in compliance with the License.             * You may obtain a copy of the License at                                      *                                                                              *      http://www.apache.org/licenses/LICENSE-2.0                              *                                                                              * Unless required by applicable law or agreed to in writing, software          * distributed under the License is distributed on an "AS IS" BASIS,            * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     * See the License for the specific language governing permissions and          * limitations under the License.                                               */package org.wso2.solutions.identity.users.wsas;import org.apache.axis2.AxisFault;import org.wso2.usermanager.UserManagerException;import org.wso2.usermanager.UserStoreReader;import org.wso2.wsas.admin.service.UserAdmin;import org.wso2.wsas.admin.service.util.RoleData;import org.wso2.wsas.admin.service.util.UserData;import java.util.HashMap;import java.util.Map;public class WSASUserStoreReader implements UserStoreReader {    UserAdmin admin = new UserAdmin();        public final static String PROP_USERNAME="username";    public final static String PROP_ROLES  = "roles";        /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getAllRoleNames()     */    public String[] getAllRoleNames() throws UserManagerException {        return null;    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getAllUserNames()     */    public String[] getAllUserNames() throws UserManagerException {        try {            return admin.getUsers();        } catch (AxisFault e) {            throw new UserManagerException(e.getMessage(), e);        }    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getRoleProperties(java.lang.String)     */    public Map getRoleProperties(String roleName) throws UserManagerException {        return null;    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getUserNamesWithPropertyValue(java.lang.String, java.lang.String)     */    public String[] getUserNamesWithPropertyValue(String propertyName,            String propetyValue) throws UserManagerException {        return null;    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getUserProperties(java.lang.String)     */    public Map getUserProperties(String userName) throws UserManagerException {        try {            UserData[] data = admin.getUserNames();            for (int i = 0; i < data.length; i++) {                if(data[i].getUserName().equals(userName)) {                    Map<String, String> props = new HashMap<String, String>();                    props.put(PROP_USERNAME, data[i].getUserName());                    RoleData[] roles = data[i].getRoles();                    String rolesStr = "";                    for (int j = 0; j < roles.length; j++) {                        rolesStr += roles[j].getRole();                        if(j != roles.length-1) {                            rolesStr += ",";                        }                    }                    props.put(PROP_ROLES, rolesStr);                    return props;                }            }        } catch (AxisFault e) {            throw new UserManagerException(e.getMessage(), e);        }        return new HashMap<String, String>();    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getUserPropertyNames()     */    public String[] getUserPropertyNames() throws UserManagerException {        return new String[] {PROP_USERNAME, PROP_ROLES};    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getUserRoles(java.lang.String)     */    public String[] getUserRoles(String userName) throws UserManagerException {        return null;    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#getUsersInRole(java.lang.String)     */    public String[] getUsersInRole(String roleName) throws UserManagerException {        return null;    }    /* (non-Javadoc)     * @see org.wso2.usermanager.UserStoreReader#isExistingUser(java.lang.String)     */    public boolean isExistingUser(String userName) throws UserManagerException {        try {            String[] users = admin.getUsers();            for (int i = 0; i < users.length; i++) {                if(users[i].equals(userName)) {                    return true;                }            }        } catch (AxisFault e) {            throw new UserManagerException(e.getMessage(), e);        }        return false;    }	public boolean isExistingRole(String arg0) throws UserManagerException {		// TODO Auto-generated method stub		return false;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -