Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.thetransactioncompany.cors;

Validated resource request origin, as defined in The Web Origin Concept (RFC 6454). Supported schemes are http and https.

Vladimir Dzhuvinov
Luis Sala
Jared Ottley
EdraĆ­ Brosa
 public class ValidatedOrigin extends Origin {

The origin scheme.
 	private String scheme;

The origin host.
 	private String host;

The parsed origin port, -1 for default port.
 	private int port = -1;

Creates a new validated origin.

origin The origin to validate. Must not be null.
OriginException If the value doesn't represent a valid URI and a supported origin.
 	public ValidatedOrigin(final Origin origin)
 		throws OriginException {
 		// Parse URI value
 		URI uri;
 		try {
 			uri = new URI(origin.toString());
 		} catch (URISyntaxException e) {
 			throw new OriginException("Bad origin URI: " + e.getMessage());
 		 = uri.getScheme();
 		 = uri.getHost();
 		 = uri.getPort();
 		if ( == null)
 			throw new OriginException("Bad origin URI: Missing scheme, such as http or https");
 		// Canonicalise scheme and host
 		// Apply the IDNA toASCII algorithm [RFC3490] to /host/
 		// Finally, convert to lower case

Returns the scheme.

The scheme.
 	public String getScheme() {
 		return ;

Returns the host (name or IP address).

The host name or IP address.
 	public String getHost() {
		return ;

Returns the port number.

The port number, -1 for default port.
	public int getPort() {
		return ;

Returns the suffix which is made up of the host name / IP address and port (if a non-default port is specified).

Example: => =>

The suffix.
	public String getSuffix() {
		String s = ;
		if ( != -1)
			s = s + ":" + ;
		return s;
New to GrepCode? Check out our FAQ X