📄 authserverimpl.java
字号:
} try { // Extend qos to contain security credentials ... ConnectQosServer loginQos = new ConnectQosServer(glob, qos_literal); loginQos.loadClientPlugin(null, null, loginName, passwd); // No login using the connect() method ... ConnectReturnQosServer returnQos = connectIntern(loginQos.toXml()); // Build return handle ... ServerRef ref = returnQos.getServerRef(); if (ref == null) { throw OrbInstanceFactory.convert(new org.xmlBlaster.util.XmlBlasterException(glob, ErrorCode.INTERNAL_CONNECTIONFAILURE, ME, "Can't determine server reference.")); } String xmlBlasterIOR = ref.getAddress(); org.xmlBlaster.protocol.corba.serverIdl.Server xmlBlaster = ServerHelper.narrow(orb.string_to_object(xmlBlasterIOR)); return xmlBlaster; } catch (org.xmlBlaster.util.XmlBlasterException e) { throw OrbInstanceFactory.convert(e); // transform native exception to Corba exception } } /** * Ping to check if xmlBlaster is alive. * @see org.xmlBlaster.protocol.I_XmlBlaster#ping(String) */ public String ping(String qos) { if (log.isLoggable(Level.FINER)) log.finer("Entering ping("+qos+") ..."); return authenticate.ping(this.addressServer, qos); } /** * Called by the CORBA layer. * If qos_literal transports another sessionId (e.g. from a2Blaster) * we leave this untouched. * This CORBA sessionId (transported hidden in the IOR) is used as well */ public String connect(String qos_literal) throws XmlBlasterException { try { return connectIntern(qos_literal).toXml(); } catch (org.xmlBlaster.util.XmlBlasterException e) { throw OrbInstanceFactory.convert(e); // transform native exception to Corba exception } } private ConnectReturnQosServer connectIntern(String qos_literal) throws org.xmlBlaster.util.XmlBlasterException { ConnectReturnQosServer returnQos = null; String sessionId = null; org.omg.CORBA.Object certificatedServerRef = null; try { // set up a association between the new created object reference (oid is sufficient) // and the callback object reference certificatedServerRef = xmlBlasterPOA.create_reference(ServerHelper.id()); sessionId = getSessionId(certificatedServerRef); // The bytes at IOR position 234 and 378 are increased (there must be the object_id) if (log.isLoggable(Level.FINE)) log.fine("Created sessionId="+sessionId); } catch (Exception e) { e.printStackTrace(); log.severe(e.toString()); throw new org.xmlBlaster.util.XmlBlasterException(glob, ErrorCode.INTERNAL_CONNECTIONFAILURE, ME, "connect failed: " + e.toString()); } String returnQosStr = authenticate.connect(this.addressServer, qos_literal, sessionId); returnQos = new ConnectReturnQosServer(glob, returnQosStr); if (returnQos.isReconnected()) { // How to detect outdated server IORs?? // Here we assume max one connection of type=CORBA which is probably wrong? if (log.isLoggable(Level.FINE)) log.fine("Destroying old server addresses because of reconnect"); returnQos.removeServerRef("IOR"); } org.xmlBlaster.protocol.corba.serverIdl.Server xmlBlaster = org.xmlBlaster.protocol.corba.serverIdl.ServerHelper.narrow(certificatedServerRef); String serverIOR = orb.object_to_string(xmlBlaster); returnQos.addServerRef(new ServerRef("IOR", serverIOR)); if (log.isLoggable(Level.FINEST)) log.finest("Returning from login-connect()" + returnQos.toXml()); return returnQos; } public void disconnect(String sessionId, String qos_literal) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("Entering disconnect()"); try { authenticate.disconnect(this.addressServer, sessionId, qos_literal); // throws XmlBlasterException (eg if not connected (init not called, timeout etc.) or someone else than the session owner called disconnect!) } catch (org.xmlBlaster.util.XmlBlasterException e) { throw OrbInstanceFactory.convert(e); // transform native exception to Corba exception } if (log.isLoggable(Level.FINER)) log.finer("Exiting disconnect()"); } /** * logout of a client. * @param xmlServer The handle you got from the login call */ public void logout(org.xmlBlaster.protocol.corba.serverIdl.Server xmlServer) throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("Entering logout()"); disconnect(getSessionId(xmlServer), (new DisconnectQosServer(glob)).toXml()); } /** * @param xmlServer org.xmlBlaster.protocol.corba.serverIdl.Server */ public final String getSessionId(org.omg.CORBA.Object xmlServer) throws XmlBlasterException { String sessionId = null; try { byte[] oid = xmlBlasterPOA.reference_to_id(xmlServer); sessionId = ServerImpl.convert(oid); if (log.isLoggable(Level.FINE)) log.fine("POA oid=<" + sessionId + ">"); } catch (Exception e) { log.severe("Sorry, you are unknown. No logout possible."); throw OrbInstanceFactory.convert(new org.xmlBlaster.util.XmlBlasterException(glob, ErrorCode.USER_SECURITY_AUTHENTICATION_ACCESSDENIED, ME, "Sorry, you are not known with CORBA")); } return sessionId; } /* private String addToQoS(String qos, String add) { qos = qos.substring(0, qos.lastIndexOf("</qos>")); qos += add + "\n</qos>\n"; return qos; } */ public void shutdown() { if (log.isLoggable(Level.FINE)) log.fine("shutdown has been invoked"); if (this.xmlBlasterPOA != null) { if (log.isLoggable(Level.FINE)) log.fine("shutdown has been invoked and servant is not null");// xmlBlasterPOA.deactivate_object(xmlBlasterPOA.reference_to_id(xmlBlasterServant)); // deserialize object, wait for competion /* try { this.xmlBlasterPOA.deactivate_object(xmlBlasterPOA.servant_to_id(xmlBlasterServant)); } catch (Exception ex) { log.warn(ME, "shutdown:exception occured when deactivating the servant: " + ex.toString()); shutdown:exception occured when deactivating the servant: org.omg.PortableServer.POAPackage.ServantNotActive: IDL:omg.org/PortableServer/POA/ServantNotActive:1.0 } */ try { xmlBlasterPOA.the_POAManager().deactivate(true, true); } catch (Exception ex) { log.warning("shutdown:exception occured deactivate(): " + ex.toString()); } /* try { this.xmlBlasterPOA._release(); } catch (Exception ex) { log.warn(ME, "shutdown:exception occured _release(): " + ex.toString()); shutdown:exception occured _release(): org.omg.CORBA.NO_IMPLEMENT: This is a locally constrained object. vmcid: 0x0 minor code: 0 completed: No } */ try { this.xmlBlasterPOA.destroy(true, true); } catch (Exception ex) { log.warning("shutdown:exception occured destroy(): " + ex.toString()); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -