0

嗨,我需要访问托管在 https 协议中的 oam 服务器。我从服务器获得了证书和 obaccess.xml 文件以进行访问。但仍然面临一些问题。下面是我的代码

import java.util.Hashtable;
import oracle.security.am.asdk.*;

public class JAccessClient
{
  public static final String ms_resource ="//1.1.1.1:14101/rest/userprofile";               
  public static final String ms_protocol = "https";
  public static final String ms_method = "GET";
  public static final String ms_login = "admin";
  public static final String ms_passwd = "admin";
  public static final String m_configLocation = "D:\\Configfiles";

  public static void main(String argv[])
  {
      AccessClient ac = null;
      try
      {
            System.out.println("Entered Try..");
            ac = AccessClient.createDefaultInstance(m_configLocation,AccessClient.CompatibilityMode.OAM_10G);
            System.out.println("Created Default Instance..");
            ResourceRequest rrq = new ResourceRequest(ms_protocol, ms_resource,ms_method);
            System.out.println("Created Resource Request object..");

            if (rrq.isProtected())
            {
                System.out.println("Resource is protected.");
                AuthenticationScheme authnScheme = new AuthenticationScheme(rrq);
                if (authnScheme.isForm())
                {
                    System.out.println("Form Authentication Scheme.");
                    Hashtable creds = new Hashtable();
                    creds.put("userid", ms_login);
                    creds.put("password", ms_passwd);
                    UserSession session = new UserSession(rrq, creds);
                    if (session.getStatus() == UserSession.LOGGEDIN)
                    {
                        if (session.isAuthorized(rrq))
                        {
                            System.out.println("User is logged in and authorized for the"+"request at level " + session.getLevel());
                            System.out.println("User Identity:"+session.getUserIdentity());
                            System.out.println("Status: "+session.getStatus());
                            System.out.println("Start time:"+session.getStartTime());
                            System.out.println("Session Token:"+session.getSessionToken());
                            System.out.println("Last Usetime:"+session.getLastUseTime());

                        }
                        else
                        {
                            System.out.println("User is logged in but NOT authorized");
                        }
                        //user can be loggedout by calling logoff method on the session object
                    }
                    else
                    {
                        System.out.println("User is NOT logged in");
                    }
                }
                else
                {
                    System.out.println("non-Form Authentication Scheme.");
                }
            }
            else
            {
                System.out.println("Resource is NOT protected.");
            }
  }
  catch (AccessException ae)
  {
     //System.out.println("Access Exception: " + ae.getCause());
          ae.getStackTrace();
  }
  ac.shutdown();

我已将 obaccess.xml 和 cwallet.sso 放在路径 D://ConfigFiles 中。当我运行上面的代码时,我收到如下错误

Entered Try..
Jul 05, 2013 9:04:49 AM oracle.security.am.asdk.impl.Configuration setEncryptedPassword
SEVERE: Failed to perform encrypt password operation.
Jul 05, 2013 9:04:49 AM oracle.security.am.asdk.impl.Configuration setEncryptedPassword
SEVERE: 
java.lang.NumberFormatException: For input string: "9a"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at oracle.security.am.common.nap.util.ObCrypt.convert(ObCrypt.java:163)
at oracle.security.am.common.nap.util.ObCrypt.decrypt(ObCrypt.java:100)
at oracle.security.am.common.nap.util.ObCrypt.decrypt(ObCrypt.java:214)
at oracle.security.am.asdk.impl.Configuration.decrypt(Configuration.java:810)
at     oracle.security.am.asdk.impl.Configuration.decryptPassword(Configuration.java:766)
at oracle.security.am.asdk.impl.Configuration.setEncryptedPassword(Configuration.java:242)
at oracle.security.am.asdk.impl.ConfigXMLHandler.processConfig(ConfigXMLHandler.java:570)
at oracle.security.am.asdk.impl.ConfigXMLHandler.readConfigurationFromFile(ConfigXMLHandler.java:124)
at oracle.security.am.asdk.AccessClient.initialize(AccessClient.java:608)
at oracle.security.am.asdk.AccessClient.<init>(AccessClient.java:527)
at oracle.security.am.asdk.AccessClient.createDefaultInstance(AccessClient.java:234)
at JAccessClient.main(JAccessClient.java:21)

Jul 05, 2013 9:04:49 AM oracle.security.am.asdk.AccessClient initialize
SEVERE: Oracle Access SDK initialization failed. 
oracle.security.am.asdk.AccessException: OAMAGENT-02072: Failed to perform encrypt  password operation.
at oracle.security.am.asdk.impl.Configuration.setEncryptedPassword(Configuration.java:263)
at oracle.security.am.asdk.impl.ConfigXMLHandler.processConfig(ConfigXMLHandler.java:570)
at oracle.security.am.asdk.impl.ConfigXMLHandler.readConfigurationFromFile(ConfigXMLHandler.java:124)
at oracle.security.am.asdk.AccessClient.initialize(AccessClient.java:608)
at oracle.security.am.asdk.AccessClient.<init>(AccessClient.java:527)
at oracle.security.am.asdk.AccessClient.createDefaultInstance(AccessClient.java:234)
at JAccessClient.main(JAccessClient.java:21)
Caused by: java.lang.NumberFormatException: For input string: "9a"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at oracle.security.am.common.nap.util.ObCrypt.convert(ObCrypt.java:163)
at oracle.security.am.common.nap.util.ObCrypt.decrypt(ObCrypt.java:100)
at oracle.security.am.common.nap.util.ObCrypt.decrypt(ObCrypt.java:214)
at oracle.security.am.asdk.impl.Configuration.decrypt(Configuration.java:810)
at oracle.security.am.asdk.impl.Configuration.decryptPassword(Configuration.java:766)
at oracle.security.am.asdk.impl.Configuration.setEncryptedPassword(Configuration.java:242)
... 6 more

Exception in thread "main" java.lang.NullPointerException
at JAccessClient.main(JAccessClient.java:75)

我是 OAM 的新手,这就是我卡住的地方。任何有关这方面的帮助都会非常有帮助。

4

1 回答 1

0

您收到此错误是因为您尚未创建 AMClient 的实例。OAM SDK 要求您在对 SDK 执行任何其他操作(例如启动新会话)之前创建 AMCLient 实例。

于 2013-10-25T14:29:25.940 回答