Package abstrasy.externals

Examples of abstrasy.externals.OptAccessList


    private OptAccess[] DEFAULT_OPTIONS = new OptAccess[] { oa_key_size,
            oa_secret_key };

    public External_Blowfish() throws NoSuchAlgorithmException {
        generateKey();
        this.setOptAccessList(new OptAccessList(DEFAULT_OPTIONS));
    }
View Full Code Here


   
    private OptAccess[] DEFAULT_OPTIONS = new OptAccess[] { oa_socket_timeout, oa_Protocol, oa_Port,oa_Max_Connections,oa_Bind_IP,oa_Host,oa_IP};


    public External_Server() {
        this.setOptAccessList(new OptAccessList(DEFAULT_OPTIONS));
    }
View Full Code Here

        // le file est automatiquement marqué comme ouvert.
        file.setTcpPort(sock.getPort());
        file.setTcpHost(sock.getInetAddress().getHostName());
        file.setTcpIP(sock.getInetAddress().getHostAddress());
        file.setProtocol(protocol);
        file.setOptAccessList(new OptAccessList(file.getSOCKET_OPTIONS()));
        file.getOptAccessList().set(file.getOa_Host());
        file.getOptAccessList().set(file.getOa_IP());
        file.getOptAccessList().set(file.getOa_Port());
                                   
View Full Code Here

    /*
     * ---------------------------------------------------------------------------------
     */

    public External_Buffer() {
        this.setOptAccessList(new OptAccessList(oa_charset));
    }
View Full Code Here

    }


    public External_File() throws Exception {
        this.eol_bytes = this.eolStr.getBytes(charset);
        this.setOptAccessList(new OptAccessList(DEFAULT_OPTIONS));
    }
View Full Code Here

            throw new InterpreterException(StdErrors.extend(StdErrors.Already_used, "File already open"));
        }
        Buffer buffer = ((External_Buffer) AExtTools.getArgExternalInstance(startAt, 1, External_Buffer.class, Node.ACCESSVTYPE_MUTABLE_WRITELOCK)).getBuffer();
        setInputStream(buffer.getInputStream());
        setOutputStream(buffer.getOutputStream());
        this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
        // pas besoin de placer un hook...
        return null;
    }
View Full Code Here

            output = fileOutputStream;
        }
        else {
            throw new InterpreterException(StdErrors.extend(StdErrors.Invalid_parameter, "Mode not supported"));
        }
        this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
        /*
         * On place un hook en cas de problème ou d'oubli...
         */
        putHook();
        return null;
View Full Code Here

             *
             */
            if (protocol.equalsIgnoreCase("file") && mode != null && mode.equalsIgnoreCase("w")) {
                File f = new File(url.toURI());
                output = new FileOutputStream(f);
                this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
                this.getOptAccessList().add(oa_Protocol);
            }
            /**
             * cas de tcp://
             */
            else if (protocol.equalsIgnoreCase("tcp")) {
                tcpHost = url.getHost();
                tcpPort = url.getPort();
                if (tcpPort < 0 || tcpPort > 65535) {
                    throw new InterpreterException(StdErrors.extend(StdErrors.Out_of_range, "" + tcpPort));
                }
                //System.out.println("host:"+tcpHost); // debug
                //System.out.println("port:"+tcpPort); // debug
                socket = new Socket(tcpHost, tcpPort);
                if (readTimeOut > 0) {
                    socket.setSoTimeout(readTimeOut);
                }
                tcpIP = socket.getInetAddress().getHostAddress();
                tcpHost = socket.getInetAddress().getHostName();
                input = socket.getInputStream();
                output = socket.getOutputStream();
                this.setOptAccessList(new OptAccessList(this.getSOCKET_OPTIONS()));
                this.getOptAccessList().set(oa_Host);
                this.getOptAccessList().set(oa_IP);
                this.getOptAccessList().set(oa_Port);
            }
            /**
             * cas de ssl+tcp://
             */
            else if (protocol.equalsIgnoreCase("ssl+tcp")) {
                tcpHost = url.getHost();
                tcpPort = url.getPort();
                if (tcpPort < 0 || tcpPort > 65535) {
                    throw new InterpreterException(StdErrors.extend(StdErrors.Out_of_range, "" + tcpPort));
                }
                SocketFactory socketFactory = SSLSocketFactory.getDefault();
                socket = socketFactory.createSocket(tcpHost, tcpPort);
                if (readTimeOut > 0) {
                    socket.setSoTimeout(readTimeOut);
                }
                tcpIP = socket.getInetAddress().getHostAddress();
                tcpHost = socket.getInetAddress().getHostName();

                input = socket.getInputStream();
                output = socket.getOutputStream();

                this.setOptAccessList(new OptAccessList(this.getSOCKET_OPTIONS()));
                this.getOptAccessList().set(oa_Host);
                this.getOptAccessList().set(oa_IP);
                this.getOptAccessList().set(oa_Port);
            }
            /**
             * cas de stdout://
             */
            else if (protocol.equalsIgnoreCase("stdout")) {
                output = System.out;
                this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
                this.getOptAccessList().add(oa_Protocol);
            }
            /**
             * cas de stdout://
             */
            else if (protocol.equalsIgnoreCase("stderr")) {
                output = System.err;
                this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
                this.getOptAccessList().add(oa_Protocol);
            }
            /**
             * cas de stdin://
             */
            else if (protocol.equalsIgnoreCase("stdin")) {
                input = System.in;
                this.setOptAccessList(new OptAccessList(this.getDEFAULT_OPTIONS()));
                this.getOptAccessList().add(oa_Protocol);
            }
            /*
             * autres protocoles...
             */
            else {
                /**
                 * sinon dans les autres cas, on ouvre réellement une connexion vers l'url...
                 */
                urlConnection = url.openConnection();
                tcpHost = url.getHost();
                tcpPort = url.getPort();
                /*
                 * timeout
                 */
                if (connectTimeOut > 0) {
                    urlConnection.setConnectTimeout(connectTimeOut);
                }
                if (readTimeOut > 0) {
                    urlConnection.setReadTimeout(readTimeOut);
                }
                /*
                 * pas de cache et toujours en lecture (par défaut)...
                 */
                urlConnection.setUseCaches(false);
                urlConnection.setDoInput(true);

                /**
                 * Typiquement HTTP
                 *
                 * Remarque: HttpsURLConnection est une sous-classe de HttpURLConnection.
                 * --------  Donc le protocole http est respecté en https.
                 */
                if (urlConnection instanceof HttpURLConnection) {
                    HttpURLConnection httpCon = (HttpURLConnection) urlConnection;

                    if (props != null) {
                        // il y a des propriétés header...
                        Hash hash=props.getHash();
                        ArrayList<String> ks=hash.keys_strings();
                        for (int i = 0; i < ks.size(); i++) {
                            String header_s = ks.get(i);
                            String value_s = Node.node2VString(hash.get(header_s)).getString();
                            Interpreter.Log("   HTTP-Header: " + header_s + " : " + value_s);
                            httpCon.setRequestProperty(header_s, value_s);
                        }
                    }

                    if (mode != null && (mode.equals("POST") || mode.equals("PUT"))) {
                        // c'est la méthode POST...
                        if (mode.equals("PUT")) {
                            Interpreter.Log("   HTTP PUT: " + url.toString());
                        }
                        else {
                            Interpreter.Log("   HTTP POST: " + url.toString());
                        }
                        urlConnection.setDoOutput(true);
                        httpCon.setRequestMethod(mode);
                        output = urlConnection.getOutputStream();

                        // envoyer...
                        output.write(buffer);
                        if (isAutoflush())
                            output.flush();
                    }

                    input = urlConnection.getInputStream();

                    this.setOptAccessList(new OptAccessList(this.getSOCKET_OPTIONS()));
                    if (tcpHost != null)
                        this.getOptAccessList().set(oa_Host);
                    if (tcpPort > 0)
                        this.getOptAccessList().set(oa_Port);

                }
                /**
                 * Autres protocoles...
                 */
                else {
                    /*
                     * par défaut méthode "r"... (r)ead...
                     */
                    if (mode == null || (mode != null && mode.equalsIgnoreCase("r"))) {
                        Interpreter.Log("   " + protocol + " read : " + url.toString());
                        input = urlConnection.getInputStream();

                    }
                    /*
                     * sinon, méthode "w"... (w)rite...
                     */
                    else {
                        Interpreter.Log("   " + protocol + " write : " + url.toString());
                        output = urlConnection.getOutputStream();

                    }
                    this.setOptAccessList(new OptAccessList(this.getSOCKET_OPTIONS()));
                    if (tcpHost != null)
                        this.getOptAccessList().set(oa_Host);
                    if (tcpPort > 0)
                        this.getOptAccessList().set(oa_Port);
                }
View Full Code Here

TOP

Related Classes of abstrasy.externals.OptAccessList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.