Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.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
使用Java导出/导入SAP UME角色_Java_Sap Enterprise Portal - Fatal编程技术网

使用Java导出/导入SAP UME角色

使用Java导出/导入SAP UME角色,java,sap-enterprise-portal,Java,Sap Enterprise Portal,在NetWeaver Portal中,可以导入/导出角色。我想创建一个具有相同行为的自定义工具。如何使用JAVA代码实现这一点? 我在UME API中找不到任何类或接口来执行此操作 注意:定制工具具有许多其他功能,并充当所有JAVA系统的集中门户。利用SAP API集,尤其是 com.sap.security.api命名空间包含IUserAccountFactoryfactory的getUserAccount方法返回对象(对象数组)。它的方法完全符合您的需要 与方法一起,您可以实现角色的导出/导

在NetWeaver Portal中,可以导入/导出角色。我想创建一个具有相同行为的自定义工具。如何使用JAVA代码实现这一点? 我在UME API中找不到任何类或接口来执行此操作

注意:定制工具具有许多其他功能,并充当所有JAVA系统的集中门户。

利用SAP API集,尤其是

com.sap.security.api
命名空间包含
IUserAccountFactory
factory的getUserAccount方法返回对象(对象数组)。它的方法完全符合您的需要

与方法一起,您可以实现角色的导出/导入

您可以尝试使用以下示例序列化特定用户的角色:

import java.io.*;
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;
// getting current user
try {
IUser user = UMFactory.getAuthenticator().getLoggedInUser();

if (user == null) { throw new SecurityException("User is invalid"); }
// getting user roles
Iterator<String> roles = loggedInUser.getRoles(true);
// serializing roles
while (roles.hasNext()) {
            String roleId = roles.next();
            IRole role = UMFactory.getRoleFactory().getRole(roleId);

            FileOutputStream file = new FileOutputStream(filename); 
            ObjectOutputStream out = new ObjectOutputStream(file); 

            out.writeObject(role); 

            out.close(); 
            file.close();
            }
        } catch (Exception e) {
        logger.logError("[getAssignedRole] Error " + e.getMessage());
}
import java.io.*;
导入com.sap.security.api.IUser;
导入com.sap.security.api.UMFactory;
//获取当前用户
试一试{
IUser user=UMFactory.getAuthenticator().getLoggedInUser();
如果(user==null){抛出新的SecurityException(“用户无效”);}
//获取用户角色
迭代器角色=loggedInUser.getRoles(true);
//序列化角色
while(roles.hasNext()){
字符串roleId=roles.next();
IRole角色=UMFactory.getRoleFactory().getRole(roleId);
FileOutputStream文件=新的FileOutputStream(文件名);
ObjectOutputStream out=新的ObjectOutputStream(文件);
out.writeObject(角色);
out.close();
file.close();
}
}捕获(例外e){
logger.logError(“[getAssignedRole]Error”+e.getMessage());
}
利用SAP API集,尤其是

com.sap.security.api
命名空间包含
IUserAccountFactory
factory的getUserAccount方法返回对象(对象数组)。它的方法完全符合您的需要

与方法一起,您可以实现角色的导出/导入

您可以尝试使用以下示例序列化特定用户的角色:

import java.io.*;
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;
// getting current user
try {
IUser user = UMFactory.getAuthenticator().getLoggedInUser();

if (user == null) { throw new SecurityException("User is invalid"); }
// getting user roles
Iterator<String> roles = loggedInUser.getRoles(true);
// serializing roles
while (roles.hasNext()) {
            String roleId = roles.next();
            IRole role = UMFactory.getRoleFactory().getRole(roleId);

            FileOutputStream file = new FileOutputStream(filename); 
            ObjectOutputStream out = new ObjectOutputStream(file); 

            out.writeObject(role); 

            out.close(); 
            file.close();
            }
        } catch (Exception e) {
        logger.logError("[getAssignedRole] Error " + e.getMessage());
}
import java.io.*;
导入com.sap.security.api.IUser;
导入com.sap.security.api.UMFactory;
//获取当前用户
试一试{
IUser user=UMFactory.getAuthenticator().getLoggedInUser();
如果(user==null){抛出新的SecurityException(“用户无效”);}
//获取用户角色
迭代器角色=loggedInUser.getRoles(true);
//序列化角色
while(roles.hasNext()){
字符串roleId=roles.next();
IRole角色=UMFactory.getRoleFactory().getRole(roleId);
FileOutputStream文件=新的FileOutputStream(文件名);
ObjectOutputStream out=新的ObjectOutputStream(文件);
out.writeObject(角色);
out.close();
file.close();
}
}捕获(例外e){
logger.logError(“[getAssignedRole]Error”+e.getMessage());
}

谢谢你的回答,但是你说添加或删除角色是正确的,我想将角色导出到像portal一样的txt文件中,如果您想说我们可以编写java代码用于导出,请分享如何获取角色的关联操作以及门户中的导出工作的详细信息。
如何获取角色的关联操作
我假设没有用于接收操作的API,至少是我知道的API。没有用于获取权限操作的方法,但无法按用户获取权限。我看到导出/导入的唯一方法是序列化IRole对象,因为它实现了可序列化接口。添加示例谢谢您的回答,但您已经说过添加或删除角色是正确的,我想将角色导出为类似门户的txt文件,如果您想说我们可以编写java代码用于导出,请分享如何获取角色的关联操作以及门户中的导出工作的详细信息。
如何获取角色的关联操作
我假设没有用于接收操作的API,至少是我知道的API。没有用于获取权限操作的方法,但无法按用户获取权限。我看到导出/导入的唯一方法是序列化IRole对象,因为它实现了可序列化接口。添加的样本