Package net.rim.device.api.io

Examples of net.rim.device.api.io.URI


        if( this._browserField == null ) {
            return new HTTPResponseStatus( HTTPResponseStatus.SC_SERVER_ERROR, request ).getResponse();
        }
        if( request.getURL().startsWith( "http://localhost:8472/" ) ) {
            URI requestURI = URI.create( request.getURL() );
            String[] splitPath = StringUtilities.split( requestURI.getPath(), "/" );
            String featureID = "";
            for( int i = 0; i < splitPath.length - 1; i++ ) {
                if( featureID == "" ) {
                    featureID = featureID + splitPath[ i ];
                } else {
View Full Code Here


        _headers = headers;
        _featureTable = featureTable;
        _argsTable = new Hashtable();
        _postArgsTable = new Hashtable();

        URI requestURI = null;
        try {
            requestURI = URI.create( _url );
        } catch( IllegalArgumentException e ) {
            e.printStackTrace();
        } catch( MalformedURIException e ) {
            e.printStackTrace();
        }

        String[] splitPath = StringUtilities.split( URLDecoder.decode(requestURI.getPath()), "/" );
        _methodName = splitPath[ splitPath.length - 1 ];

        if( requestURI.getQuery() != null ) {
            String[] completeArgs = StringUtilities.splitURLDecoder.decode(requestURI.getQuery()), "&" );

            _args = new Object[ completeArgs.length ];
                       
            for( int i = 0; i < completeArgs.length; i++ ) {               
                int index = completeArgs[i].indexOf( "=" );
View Full Code Here

    private boolean isUriCacheable( String url, Hashtable filters ) {
        if( filters == null ) {
            return true;
        }

        URI uri = null;
        try {
            uri = URI.create( url.trim() );
        } catch( MalformedURIException mue ) {
            return false;
        }

        if( uri == null ) {
            return false;
        }

        String file = URI.getFile( uri.getPath() );
        int lastDot = file.lastIndexOf( '.' );
        if( lastDot < 0 ) {
            return false;
        } else {
            String ext = file.substring( lastDot + 1 );
View Full Code Here

     *            WidgetAccess array to loop through to find matching request.
     * @return Return true if the request should be allowed based on WebWorks' config.xml; false otherwise.
     */
    public WidgetAccess getElement( String request, WidgetAccess[] accessList ) {
        try {
            URI requestURI = URI.create( request.trim() );
            // require absolute URI's
            if( requestURI.isAbsolute() ) {

                // Initialize authority collection if it does not yet exist
                initializeAuthCollection( accessList );

                // Start with the full authority path and check if a WidgetAccess set exists for that path
                // If it does not exist, remove the first section of the authority path and try again
                String authString = getAuthorityFromString( request );
                String schemeString = getSchemeFromString( request );

                // Check for an authority string that has an existing key
                // Special case: Allow file protocol to proceed without an authority
                // Special case: Allow local protocol which is always without an authority
                // Special case: Allow data protocol which is always without an authority (let isMatch handle it)
                authString = authorityCheck( schemeString, authString );
                if( authString.equals( "" ) && !( schemeString.equals( "file" ) || schemeString.equals( "local" ) || schemeString.equals( "data" ) ) ) {
                    return null;
                }

                WidgetWebFolderAccess folderAccess;
                WidgetAccess fetchedAccess = null;

                // Retrieve WidgetAccess set for the specified authority
                folderAccess = (WidgetWebFolderAccess) _authorityCollection.get( schemeString + "://" + authString );

                // Special case: no access element was found for a file protocol request.
                // This is added since file protocol was allowed through the above check
                if( schemeString.equals( "file" ) && folderAccess == null ) {
                    return null;
                }
               
                // If no access element is found with local URI, use local access for this request
                if ( schemeString.equals( "local" ) && folderAccess == null ) {
                    return _localAccess;
                }
               
                if(folderAccess != null) {
                    fetchedAccess = folderAccess.getWidgetAccess( requestURI.getPath() + parseNull( requestURI.getQuery() ) );
                }
                if( !isMatch( fetchedAccess, requestURI ) ) {
                    fetchedAccess = folderAccess.getWidgetAccess( requestURI.getPath() + "*" );
                }

                boolean failedToFindAccess = false;
                // Make sure we've got the right one
                while( fetchedAccess == null || !isMatch( fetchedAccess, requestURI ) ) {

                    // There was an auth url that matched, but didnt match the folder structure
                    // Try the next level up
                    authString = authString.substring( authString.indexOf( '.' ) + 1 );

                    // Check for an authority string that has an existing key
                    authString = authorityCheck( schemeString, authString );
                    if( authString.equals( "" ) ) {
                        failedToFindAccess = true;
                        break;
                    }

                    // Retrieve WidgetAccess set for the specified authority
                    folderAccess = (WidgetWebFolderAccess) _authorityCollection.get( schemeString + "://" + authString );

                    // Special case: no access element was found for a file protocol request.
                    // This is added since file protocol was allowed through the above check
                    if( schemeString.equals( "file" ) && folderAccess == null ) {
                        return null;
                    }

                    fetchedAccess = folderAccess.getWidgetAccess( requestURI.getPath() + parseNull( requestURI.getQuery() ) );
                }
               
                if( !failedToFindAccess ) {
                    return fetchedAccess;
                } else if ( isMatch( _localAccess, requestURI ) ) {
View Full Code Here

            return false;
        }

        // Based on widgets 1.0 (access control)
        // http://www.w3.org/TR/2009/WD-widgets-access-20090618/#rfc3987
        URI referenceURI = access.getURI();
        boolean allowSub = access.allowSubDomain();

        // Start comparison based on widgets spec.
        // 1. Compare scheme
        if( !referenceURI.getScheme().equalsIgnoreCase( toMatchURI.getScheme() ) ) {
            return false;
        }
        // 2. Compare host - if subdoman is false, host must match exactly
        // (referenceURI MUST HAVE host specified - not null.)
        String refHost = referenceURI.getHost();
        String matchHost = toMatchURI.getHost();
        if( matchHost == null ) {
            return false;
        }
        if( !allowSub && !( refHost.equalsIgnoreCase( matchHost ) ) ) {
            return false;
        }
        // 3. Compare host - if subdomain is true, check for subdomain or match
        if( allowSub && !matchHost.toLowerCase().endsWith( "." + refHost.toLowerCase() ) && !matchHost.equalsIgnoreCase( refHost ) ) {
            return false;
        }
        // 4. Compare port
        String refPort = parseNull( referenceURI.getPort() );
        String toMatchPort = parseNull( toMatchURI.getPort() );
        if( !refPort.equals( toMatchPort ) ) {
            return false;
        }
        // 5. Compare path+query
        String refPath = referenceURI.getPath() + parseNull( referenceURI.getQuery() );
        String toMatchPath = toMatchURI.getPath() + parseNull( toMatchURI.getQuery() );
        if( refPath.endsWith( "*" ) ) {
            refPath = refPath.substring( 0, refPath.length() - 1 );
        }
        if( !toMatchPath.startsWith( refPath ) ) {
View Full Code Here

            _authorityCollection = new Hashtable();

            // Loop access elements and add them to the authority collection
            for( int i = 0; i < accessList.length; i++ ) {
                WidgetAccess currentAccess = accessList[ i ];
                URI currentURI = currentAccess.getURI();

                // Special case: local access does not go into the collection because it has no URI
                if( currentAccess.isLocal() ) {
                    _localAccess = currentAccess;
                } else {
                    WidgetWebFolderAccess folderAccess;

                    // Check the authority collection to see if the authority item we want already exists
                    if( _authorityCollection.containsKey( currentURI.getScheme() + "://" + currentURI.getAuthority() ) ) {
                        folderAccess = (WidgetWebFolderAccess) _authorityCollection.get( currentURI.getScheme() + "://"
                                + currentURI.getAuthority() );
                    } else {
                        // Create web folder access
                        folderAccess = new WidgetWebFolderAccess();
                    }

                    // Add folder path access to the authority item
                    folderAccess.addWidgetAccess( currentURI.getPath() + parseNull( currentURI.getQuery() ), currentAccess );
                    _authorityCollection.put( currentURI.getScheme() + "://" + currentURI.getAuthority(), folderAccess );

                }
            }
        }
View Full Code Here

     *            URL to parse for authority
     * @return authority URL
     */
    private String getAuthorityFromString( String url ) {
        try {
            URI uriObject = URI.create( url );
            return uriObject.getAuthority();
        } catch( MalformedURIException mue ) {
            // invalid request URI - return null
            return null;
        }
    }
View Full Code Here

     *            URL to parse for authority
     * @return scheme of the URL
     */
    private String getSchemeFromString( String url ) {
        try {
            URI uriObject = URI.create( url );
            return uriObject.getScheme();
        } catch( MalformedURIException mue ) {
            // invalid request URI - return null
            return null;
        }
    }
View Full Code Here

    public void sendNonBlocking(final String uriStr,
            final boolean releaseDestination, final ResponseCallback callback) {
        MonitoredDestinationListener responseListener;

        try {
            final URI uri = URI.create(uriStr);

            responseListener =
                    new MonitoredDestinationListener(
                            "SendNonBlocking MessageListener [id: "
                                    + _listenerId++ + "]");
View Full Code Here

    public void setNonBlockingSenderDestination(final String uriStr) {
        final MessageListener responseListener =
                new DestinationListener("Cancellation Listener", true);

        try {
            final URI uri = URI.create(uriStr);
            SenderDestination destination =
                    DestinationFactory.getSenderDestination(_context.getName(),
                            uri);
            if (destination == null) {
                // Destination not registered yet
View Full Code Here

TOP

Related Classes of net.rim.device.api.io.URI

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.