直接バインディングを起動するJ2SEクライアントのアイデンティティの設定方法
次の例に示すように、JNDIルックアップのプロセス中にサーバーに対してJNDIセキュリティ資格証明を渡すことによる認証時に、ユーザー・アイデンティティを確立できます。
public static void main(String[] args) throws Exception { String operation = "process"; // This is the request message XML String ns = "http://xmlns.oracle.com/DirectBinding_jws/EchoBPEL/BPELProcess1"; String payloadXML = "<ns1:process xmlns:ns1=\"" + ns + "\">\n" + " <ns1:input>wew</ns1:input>\n" + "</ns1:process>"; String serviceAddress = "soadirect:/default/EchoBPEL!1.0/DService1"; // Specify the direct binding connection properties Map<String, Object> props = new HashMap<String, Object>(); props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); props.put(Context.PROVIDER_URL, "t3://" + hostname + ':' + portname); props.put(Context.SECURITY_PRINCIPAL,username); props.put(Context.SECURITY_CREDENTIALS, password); // Create the direct binding connection, using those context properties DirectConnectionFactory factory = JNDIDirectConnectionFactory.newInstance(); try { DirectConnection dc = factory.createConnection(serviceAddress, props); // Parse the XML request message DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(payloadXML))); // Prepare the payload for inclusion in the Message object Map<String, Element> payload = new HashMap<String, Element>(); payload.put("payload", doc.getDocumentElement()); Message<Element> request = XMLMessageFactory.getInstance().createMessage(payload); Message<Element> response = dc.request(operation, request); } finally { dc.close(); } }